|
[
Permlink
| « Hide
]
David Bertoni added a comment - 20/Sep/04 07:41 PM
Xalan-C, Saxon 6.5.2, and MSXSL all produce the OASIS expected output.
Perhaps this behavior is an attempt to obey the second paragraph of
Section 7.1.1? I would think that an explicit copy should go through regardless of what the namespace URI is, except for the XML URI. I think the paragraph in 7.1.1 just means that the literal result element shoudln't pick up a declaration of the XSLT namespace from xmlns:xxsl declaration in the stylesheet. I don;t think it means an explicit insertion of that namespace using xsl:copy-of should be ignored.
Section 7.1.1 says that the created node in the result tree will have the attribute nodes that were present on the element node in the stylesheet, other than attributes with names in the XSLT namespace.
After that initial statement it would seem to me that things can be added to that created node in the result tree, in particular more namespace nodes can be added with copy-of. Section 11.3 (copy-of) says that when the result of evaluating the select expression is a node-set (which it is here, a set of namespace nodes), that the nodes are copied to the result tree. I don't see any caveat in 11.3 about the URI "http://www.w3.org/1999/XSL/Transform". So it would seem that although with the initial creation that the XSLT namespace is not copied into the result tree, the copy-of should copy the namespace node declaring the XSLT namespace with the given prefix. ------------------------------------------------- After some experimentation (thanks to Henry Zongaro's input) here is another stylesheet to consider: <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:abc="ABC"> <xsl:output method="xml" encoding="UTF-8" omit-xml-declaration="yes" indent="yes"/> <xsl:template match="/"> <test1> <xsl:copy-of select="document('')/xsl:stylesheet/namespace::*"/> </test1> <test2> <xsl:copy-of select="document('')/xsl:stylesheet/namespace::abc"/> </test2> <xsl:element name="test3"> <xsl:copy-of select="document('')/xsl:stylesheet/namespace::*"/> </xsl:element> </xsl:template> </xsl:stylesheet> ----------------------------------------- Xalan-J interpretive produces this output: <test1 xmlns:abc="ABC"/> <test2 xmlns:abc="ABC"/> <test3/> Not only is <test1> missing xsl, and <test3> is missing both xsl and abc. ----------------------------------------- XSLTC produces different, and what I think is the correct output: <test1 xmlns:abc="ABC" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/> <test2 xmlns:abc="ABC"/> <test3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:abc="ABC"/> -------------------------------------------- Modifying the stylesheet to this (and extra <doc> around the test elements): <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:abc="ABC"> <xsl:output method="xml" encoding="UTF-8" omit-xml-declaration="yes" indent="yes"/> <xsl:template match="/"> <doc> <test1> <xsl:copy-of select="document('')/xsl:stylesheet/namespace::*"/> </test1> <test2> <xsl:copy-of select="document('')/xsl:stylesheet/namespace::abc"/> </test2> <xsl:element name="test3"> <xsl:copy-of select="document('')/xsl:stylesheet/namespace::*"/> </xsl:element> </doc> </xsl:template> </xsl:stylesheet> ------------------------------------- With the extra <doc> Xalan-J produces: <doc xmlns:abc="ABC"> <test1/> <test2/> <test3/> </doc> So namespace nodes for abc exist on all of test1, test2, test3 (inherited from the parent <doc>), but xsl is missing from test1 and test3. ------------------------------------ XSLTC produces: <doc xmlns:abc="ABC"> <test1 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/> <test2/> <test3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/> </doc> Since test1, test2 and test3 inherit namespace mappings from their ancestors (only abc here)in the output XML document, test1, test2, and test3 do have all the appropriate namespace nodes. ------------------------------------- It seems this bug (I also submitted a similar bug,
I was able to fix this problem in Xalan-J today. Please find attached the patch. I have tested the patch, and it seems to work fine. Regards, Mukul Hi, Mukul. Thanks very much for submitting the fix. I'll try to review your patch in the coming week, but in the meanwhile may I ask you to attach a patch file (in unified diff format) in addition to the modified file? That will be helpful for anybody who would like to apply the patch to an older snapshot of the source code.
Thanks, Henry Hello,
attaching a patch file in unified diff format, for this fix. Regards, Mukul |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||