Subject: Re2: how to get new position() of a node in a sorted result tree ANDdocument function and counting
From: David_Marston@xxxxxxxxx
Date: Wed, 1 Aug 2001 18:41:23 -0400
|
Rolling together Michael Kay's and Wendell Piez's answers on their
respective threads, plus using a technique favored here at Lotus, we
have a dual solution that uses no extension functions. This can be
accomplished if one of the XML documents can contain a list of all the
XML files to be read in:
<?xml version="1.0" ?>
<files>
<a>idkey49a.xml</a>
<a>idkey49b.xml</a>
<a>idkey49c.xml</a>
<a>idkey49d.xml</a>
</files>
As long as <a> nodes are not used for any other purpose, then
document(a)//b will be a single node-set, not an RTF, containing all
the <b> nodes from all four files. Then, you can set up iteration over
the whole set, and sort it:
<xsl:apply-templates select="document(a)//b">
<xsl:sort select="."/>
</xsl:apply-templates>
And in the next template, the position() function will return what you
wanted, a contiguous numbering of all the <b> elements from all files:
<xsl:template match="b">
<xsl:value-of select="position()"/><xsl:text>. </xsl:text>
<xsl:value-of select="."/><xsl:text> </xsl:text>
</xsl:template>
Embellish the above as necessary.
.................David Marston
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|