henry human wrote:
Here is the sample.
You still don't show the associated output. I guess your problem is
like the following. From:
<root>
<e type="author" id="a1"/>
<e type="author" id="a2"/>
<e type="author" id="a3"/>
<e type="section" id="s1"/>
<e type="section" id="s1"/>
</root>
you want to walk through the first two e[(_at_)type eq 'author'] (because
there are two e[(_at_)type ew 'section']). You can try the following:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
<xsl:output indent="yes"/>
<xsl:template match="/">
<results>
<xsl:variable name="count" select="
count(root/e[(_at_)type eq 'section'])"/>
<xsl:apply-templates select="
root/e[(_at_)type eq 'author'][position() le $count]"/>
</results>
</xsl:template>
<xsl:template match="e">
<xsl:element name="{ @id }"/>
</xsl:template>
</xsl:stylesheet>
The output is:
$ saxon hhuman.xml hhuman.xsl
<?xml version="1.0" encoding="UTF-8"?>
<results>
<a1/>
<a2/>
</results>
If the e elements are not all child of the same parent element, use
parenthesis, in order to have the correct position(), like for instance
in:
(root//e[(_at_)type eq 'author'])[position() le $count]
Regards,
--drkm
_____________________________________________________________________________
Envoyez avec Yahoo! Mail. Une boite mail plus intelligente http://mail.yahoo.fr
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--