Hi Daniel,

I tried your xsl, but I got the same result using either JDK 8 or a recent JDK 9 (jdk9dev) build:

<?xml version="1.0" encoding="UTF-8"?><root xmlns="ns1"><test xmlns="ns2"><b><c/></b></test><test><b xmlns="ns2"><c/></b></test><test><b><c/></b></test><test><b><c/></b></test><test><b><c/></b></test><test/></root>

For the issue with regard to empty namespace, please open a bug and let's fix it.

Thanks,
Joe

On 7/26/16, 10:32 AM, Daniel Fuchs wrote:
Hi Christoph,

I was at first a bit suspicious of your proposed patch, but
I applied it and played with it and could not fault it.
Now I tend to believe this is the correct thing to do (though
that's not my area of expertise).

I tried it with a bit more elaborate content in the "transform"
template:

------------------------------ XSL ----------------------------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">
<xsl:template match="/">
<root xmlns="ns1">
<xsl:call-template name="transform"/>
</root>
</xsl:template>
<xsl:template name="transform">
<test xmlns="ns2"><b xmlns="ns2"><c xmlns=""></c></b></test>
<test xmlns="ns1"><b xmlns="ns2"><c xmlns=""></c></b></test>
<test><b><c xmlns=""></c></b></test>
<test xmlns=""><b><c xmlns=""></c></b></test>
<test xmlns="ns1"><b><c xmlns=""></c></b></test>
<test xmlns=""/>
</xsl:template>
</xsl:stylesheet>
---------------------------------------------------------------

and that gave me the content I expected (ignoring the double
xmlns declaration which seems to be another bug):


-- Formatted result with your patch (newlines added manually) --
<?xml version="1.0" encoding="UTF-8"?>
<root xmlns="ns1" xmlns="ns1">
<test xmlns="ns2" xmlns="ns2"><b><c xmlns="" xmlns=""></c></b></test>
<test><b xmlns="ns2" xmlns="ns2"><c xmlns="" xmlns=""></c></b></test>
<test xmlns="" xmlns=""><b><c></c></b></test>
<test xmlns="" xmlns=""><b><c></c></b></test>
<test><b><c xmlns="" xmlns=""></c></b></test>
<test xmlns="" xmlns=""></test>
</root>
---------------------------------------------------------------

This seems a more correct result than what the JDK currently does:

------------------ Current JDK 9/dev ---------------------------
<?xml version="1.0" encoding="UTF-8"?>
<root xmlns="ns1" xmlns="ns1">
<test xmlns="ns2" xmlns="ns2"><b><c></c></b></test>
<test><b xmlns="ns2" xmlns="ns2"><c></c></b></test>
<test><b><c></c></b></test>
<test><b><c></c></b></test>
<test><b><c></c></b></test>
<test></test>
</root>
---------------------------------------------------------------

where the empty default namespace declaration always disappears,
even at line 4 in the element <c>!

Hope this helps,

-- daniel

On 22/07/16 11:38, Langer, Christoph wrote:
Hi,

I have a customer reporting the following phenomena which I believe is an issue.

Consider the following xsl:

---------------------XSL---------------------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">
<xsl:template match="/">
<root xmlns="ns1">
<xsl:call-template name="transform"/>
</root>
</xsl:template>
<xsl:template name="transform">
<test xmlns=""/>
</xsl:template>
</xsl:stylesheet>
---------------------End of XSL---------------------


This is the XML snippet where the XSL gets applied (just a dummy):
<?xml version="1.0" encoding="UTF-8"?><aaa></aaa>

The result with the current XSLTC is:
<?xml version="1.0" encoding="UTF-8"?><root xmlns="ns1"><test/></root>
But this would not undeclare the default namespace "ns1" from the element named "root" for the element named "test" which was the intention of the xsl. So I believe it should be: <?xml version="1.0" encoding="UTF-8"?><root xmlns="ns1"><test xmlns=""/></root>

Looking at the coding I came up with the following: http://cr.openjdk.java.net/~clanger/webrevs/xsltc-namespaceissue/ With that, XSLTC would also emit the namespace attribute for an empty namespace. It works for my example but I'm not sure if it is the right thing to do or if it breaks things at other places and violates specs elsewhere.

Comparing with the Apache Xalan, I can see that the Apache XSLTC matches the JDK XSLTC behavior to suppress the namespace declaration but the interpretative transformer (org.apache.xalan.processor.TransformerFactoryImpl) would emit the namespace attribute.

Please give me some comments before I open a Bug...

Thanks a lot in advance
Christoph


Reply via email to