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=11604>.
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=11604

EXSLT implementations of set:leading and set:trailing are off by one element

           Summary: EXSLT implementations of set:leading and set:trailing
                    are off by one element
           Product: XalanJ2
           Version: 2.4Dx
          Platform: PC
               URL: http://exslt.org/set/functions/leading/index.html
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: org.apache.xalan.lib
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


"The set:leading function returns the nodes in the node set passed as the first
argument that precede, in document order, the first node in the node set passed
as the second argument."

I read this as, the first node of the second set should *not* be included in the
result. A similar arguments holds for set:trailing.

XML source:

<doc>
   <a />
   <b />
   <c />
   <d />
   <e />
   <f />
   <g />
   <h />
</doc>

Stylesheet:

<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
        xmlns:set="http://exslt.org/sets";

<xsl:output indent="yes"/>      

<xsl:template match="doc">
<xsl:element name="out">
<xsl:element name="lead">
<xsl:attribute name="n">
<xsl:value-of select="count(set:leading(*, d))" />
</xsl:attribute>
<xsl:copy-of select="set:leading(*, d)" />
</xsl:element>
<xsl:element name="trail">
<xsl:attribute name="n">
<xsl:value-of select="count(set:trailing(*, d))" />
</xsl:attribute>
<xsl:copy-of select="set:trailing(*, d)" />
</xsl:element>
</xsl:element>
</xsl:template>

</xsl:stylesheet>

Output:

<?xml version="1.0" encoding="UTF-8"?>
<out xmlns:xalan="http://xml.apache.org/xalan"; xmlns:set="http://exslt.org/sets";>
<wildcard n="8">
<a/>
<b/>
<c/>
<d/>
<e/>
<f/>
<g/>
<h/>
</wildcard>
<d-set n="1">
<d/>
</d-set>
<diff n="7">
<a/>
<b/>
<c/>
<e/>
<f/>
<g/>
<h/>
</diff>
<lead n="4">
<a/>
<b/>
<c/>
<d/>
</lead>
<trail n="5">
<d/>
<e/>
<f/>
<g/>
<h/>
</trail>
</out>

Expected output:
<?xml version="1.0" encoding="UTF-8"?>
<out xmlns:xalan="http://xml.apache.org/xalan"; xmlns:set="http://exslt.org/sets";>
<lead n="3">
<a/>
<b/>
<c/>
</lead>
<trail n="4">
<e/>
<f/>
<g/>
<h/>
</trail>
</out>

Reply via email to