You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by bu...@apache.org on 2002/07/24 09:50:06 UTC

DO NOT REPLY [Bug 11118] New: - XSLTC: Incorrect order of nodes for generate-id on preceding:: axis node-set

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11118>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11118

XSLTC: Incorrect order of nodes for generate-id on preceding:: axis node-set

           Summary: XSLTC: Incorrect order of nodes for generate-id on
                    preceding:: axis node-set
           Product: XalanJ2
           Version: CurrentCVS
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: org.apache.xalan.xsltc
        AssignedTo: xalan-dev@xml.apache.org
        ReportedBy: erik@bruchez.org


I ran the following test:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/root">
        <root>
            <xsl:for-each select="header">
                <xsl:variable name="header-id" select="generate-id()"/>
                <section>
                    <xsl:copy-of
select="following::para[generate-id(preceding::header[1]) = $header-id]"/>
                </section>
            </xsl:for-each>
        </root>
    </xsl:template>
</xsl:stylesheet>

On the following input:

<root>
    <header/>
    <para val="1"/>
    <para val="2"/>
    <para val="3"/>
    <header/>
    <para val="4"/>
</root>

I correctly get the following result:

<root>
    <section>
        <para val="1"/>
        <para val="2"/>
        <para val="3"/>
    </section>
    <section>
        <para val="4"/>
    </section>
</root>

Now, if I replace preceding::header[1] by preceding::header, I get the same
result, but I get a different result with Xalan:

<root>
    <section>
        <para val="1"/>
        <para val="2"/>
        <para val="3"/>
        <para val="4"/>
    </section>
    <section/>
</root>

In this case, Xalan is correct and XSLTC incorrect. In the second iteration of
the loop, preceding::header returns a node-set containing two header elements.
According to the XSLT 1.0 spec, gererate-id() should use the first node in
*document order*, thus generate an id for the first header element in the
document. XSLTC appears to use reverse document order.