Issue Details (XML | Word | Printable)

Key: XALANJ-1959
Type: Bug Bug
Status: Open Open
Priority: Major Major
Assignee: Unassigned
Reporter: elharo
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
XalanJ2

Failure to copy namespace nodes

Created: 20/Sep/04 07:33 PM   Updated: 29/Nov/08 04:57 PM
Return to search
Component/s: parse-or-compile, Xalan-interpretive
Affects Version/s: 2.6
Fix Version/s: None
Security Level: No security risk; visible to anyone (Ordinary problems in Xalan projects. Anybody can view the issue.)

Time Tracking:
Not Specified

File Attachments:
  Size
Java Source File Licensed for inclusion in ASF works ElemCopyOf.java 2008-11-28 05:38 AM Mukul Gandhi 8 kB
Text File Licensed for inclusion in ASF works XALANJ-1959.patch 2008-11-29 04:57 PM Mukul Gandhi 0.2 kB
Issue Links:
Duplicate
 


 Description  « Hide
Another OASIS test suite discrepancy. This time libxslt agrres with Xalan, but on reflection I think the test case is correct and Xalan and libxslt are wrong.

The test case is:

xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <!-- Purpose: Test case for bug 70935 -->

    <xsl:output method="xml" encoding="UTF-8" omit-xml-declaration="yes" indent="yes"/>

    <xsl:template match="/">
        <test><xsl:copy-of select="document('')/xsl:stylesheet/namespace::xsl"/></test>
    </xsl:template>

</xsl:stylesheet>


The expected output is:

<test xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
</test>


The actual output is

<test>
</test>

The namespace node has not been copied.

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
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.

David Marston added a comment - 20/Sep/04 08:00 PM
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.

elharo added a comment - 20/Sep/04 08:06 PM
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.

Brian Minchau added a comment - 20/Oct/04 04:51 PM
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.

-------------------------------------

Mukul Gandhi added a comment - 28/Nov/08 05:38 AM
It seems this bug (I also submitted a similar bug, XALANJ-2305) has been open for quite some time, and quite a number of people want this feature.

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

Henry Zongaro added a comment - 29/Nov/08 01:14 PM
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

Mukul Gandhi added a comment - 29/Nov/08 04:57 PM
Hello,
   attaching a patch file in unified diff format, for this fix.

Regards,
Mukul