Re: JAXP: XSLTC transformer swallows empty namespace declaration which is necessary to undeclare default namespace
Hi Daniel, I tried your xsl, but I got the same result using either JDK 8 or a recent JDK 9 (jdk9dev) build: xmlns="ns2">xmlns="ns2"> 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 http://www.w3.org/1999/XSL/Transform"; version="1.0"> --- 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) -- --- This seems a more correct result than what the JDK currently does: -- Current JDK 9/dev --- --- where the empty default namespace declaration always disappears, even at line 4 in the element ! 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- http://www.w3.org/1999/XSL/Transform"; version="1.0"> -End of XSL- This is the XML snippet where the XSL gets applied (just a dummy): The result with the current XSLTC is: 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: xmlns=""/> 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
Re: JAXP: XSLTC transformer swallows empty namespace declaration which is necessary to undeclare default namespace
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 http://www.w3.org/1999/XSL/Transform"; version="1.0"> name="transform"/> xmlns=""> xmlns=""> --- 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) -- --- This seems a more correct result than what the JDK currently does: -- Current JDK 9/dev --- --- where the empty default namespace declaration always disappears, even at line 4 in the element ! 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- http://www.w3.org/1999/XSL/Transform"; version="1.0"> -End of XSL- This is the XML snippet where the XSL gets applied (just a dummy): The result with the current XSLTC is: 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: 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
Re: JAXP: XSLTC transformer swallows empty namespace declaration which is necessary to undeclare default namespace
On 26/07/16 14:53, Langer, Christoph wrote: you mean with my webrev built in or with the current jdk9 dev? ... and with your patch applied I see this: xmlns="ns1"> cheers, -- daniel
Re: JAXP: XSLTC transformer swallows empty namespace declaration which is necessary to undeclare default namespace
Hi Christoph, On 26/07/16 14:53, Langer, Christoph wrote: Hi Daniel, you mean with my webrev built in or with the current jdk9 dev? With the current jdk9 dev - sorry if that was unclear. cheers, -- daniel public static void main(String[] args) throws XMLStreamException, TransformerConfigurationException, TransformerException { TransformerFactory trans = TransformerFactory.newInstance(); XMLInputFactory input = XMLInputFactory.newFactory(); XMLOutputFactory output = XMLOutputFactory.newFactory(); XMLEventReader reader = input.createXMLEventReader(XSLTTest.class.getResourceAsStream("test.xsl")); StAXSource source = new StAXSource(reader); Templates temp = trans.newTemplates(source); StAXResult result = new StAXResult(output.createXMLEventWriter(System.out)); temp.newTransformer().transform( new StAXSource(input.createXMLEventReader(XSLTTest.class.getResourceAsStream("test.xml"))), result); } Best Christoph
Re: JAXP: XSLTC transformer swallows empty namespace declaration which is necessary to undeclare default namespace
Hi Christoph, Joe, Actually what I see with the latest dev version of JDK 9 (eng. build built a few minutes ago) is this: xmlns="ns1"> Notice that xmlns="ns1" appears twice in the root element. So maybe there's more than one bug here :-( cheers, -- daniel On 26/07/16 12:56, Langer, Christoph wrote: Hi Joe, thanks for looking at this. Here is my comments: I'm not sure why empty namespace was explicitly excluded. But for the 2nd part, the developer was clear with a note on the intention. You may want to try removing the condition statement that excluded the empty namespace, but keep the 2nd part as is, and then run the tests to see if there's any issue or a reason why it was excluded. You are right, the comment for the second part is quite explicit. However, the method declaresDefaultNS() of XslElement always returns false and the comment to it says: "This method is now deprecated. The new implemation of this class never declares the default NS". As I didn't find any other class in the hierarchy overwriting this method, I decided to remove it and to cleanup code. Are you ok with that or is it illegal here? On another thought, if the following workaround works for you, we may as well leave the current implementation as is: try replacing in the above, with " This might work, however, the customer wants to change his current XML toolkit to the JDK one and expects his existing XML/XSL code to work as is. So that's no option. I'll go open a bug for that now and prepare a real review. Best regards Christoph
RE: JAXP: XSLTC transformer swallows empty namespace declaration which is necessary to undeclare default namespace
Hi Daniel, you mean with my webrev built in or with the current jdk9 dev? Best Christoph > -Original Message- > From: Daniel Fuchs [mailto:daniel.fu...@oracle.com] > Sent: Dienstag, 26. Juli 2016 15:47 > To: Langer, Christoph ; huizhe wang > > Cc: core-libs-dev@openjdk.java.net > Subject: Re: JAXP: XSLTC transformer swallows empty namespace declaration > which is necessary to undeclare default namespace > > Hi Christoph, Joe, > > Actually what I see with the latest dev version of > JDK 9 (eng. build built a few minutes ago) is this: > > xmlns="ns1"> > > Notice that xmlns="ns1" appears twice in the root element. > > So maybe there's more than one bug here :-( > > cheers, > > -- daniel > > On 26/07/16 12:56, Langer, Christoph wrote: > > Hi Joe, > > > > thanks for looking at this. > > > > Here is my comments: > >> I'm not sure why empty namespace was explicitly excluded. But for the > >> 2nd part, the developer was clear with a note on the intention. You may > >> want to try removing the condition statement that excluded the empty > >> namespace, but keep the 2nd part as is, and then run the tests to see if > >> there's any issue or a reason why it was excluded. > > > > You are right, the comment for the second part is quite explicit. However, > > the > method declaresDefaultNS() of XslElement always returns false and the > comment to it says: "This method is now deprecated. The new implemation of > this class never declares the default NS". As I didn't find any other class > in the > hierarchy overwriting this method, I decided to remove it and to cleanup code. > Are you ok with that or is it illegal here? > > > > > >> On another thought, if the following workaround works for you, we may as > >> well leave the current implementation as is: > >> try replacing in the above, with >> name=\"test\" namespace=\"\" />" > > > > This might work, however, the customer wants to change his current XML > toolkit to the JDK one and expects his existing XML/XSL code to work as is. So > that's no option. > > > > I'll go open a bug for that now and prepare a real review. > > > > Best regards > > Christoph > >
RE: JAXP: XSLTC transformer swallows empty namespace declaration which is necessary to undeclare default namespace
Hi Joe, thanks for looking at this. Here is my comments: > I'm not sure why empty namespace was explicitly excluded. But for the > 2nd part, the developer was clear with a note on the intention. You may > want to try removing the condition statement that excluded the empty > namespace, but keep the 2nd part as is, and then run the tests to see if > there's any issue or a reason why it was excluded. You are right, the comment for the second part is quite explicit. However, the method declaresDefaultNS() of XslElement always returns false and the comment to it says: "This method is now deprecated. The new implemation of this class never declares the default NS". As I didn't find any other class in the hierarchy overwriting this method, I decided to remove it and to cleanup code. Are you ok with that or is it illegal here? > On another thought, if the following workaround works for you, we may as > well leave the current implementation as is: > try replacing in the above, with name=\"test\" namespace=\"\" />" This might work, however, the customer wants to change his current XML toolkit to the JDK one and expects his existing XML/XSL code to work as is. So that's no option. I'll go open a bug for that now and prepare a real review. Best regards Christoph
Re: JAXP: XSLTC transformer swallows empty namespace declaration which is necessary to undeclare default namespace
On 7/22/2016 3:38 AM, Langer, Christoph wrote: Hi, I have a customer reporting the following phenomena which I believe is an issue. Consider the following xsl: -XSL- http://www.w3.org/1999/XSL/Transform"; version="1.0"> -End of XSL- This is the XML snippet where the XSL gets applied (just a dummy): The result with the current XSLTC is: 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: 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. I'm not sure why empty namespace was explicitly excluded. But for the 2nd part, the developer was clear with a note on the intention. You may want to try removing the condition statement that excluded the empty namespace, but keep the 2nd part as is, and then run the tests to see if there's any issue or a reason why it was excluded. 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. Ok, the interpretative may be correct. On another thought, if the following workaround works for you, we may as well leave the current implementation as is: try replacing in the above, with name=\"test\" namespace=\"\" />" Thanks, Joe Please give me some comments before I open a Bug... Thanks a lot in advance Christoph