|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: outputting the "position()" of parent
Justin Friedl wrote:
>
> How do I output the posistion of the parent. I can output the position of
> the current node like this:
> <xsl:value-of select="position()"/>
>
> So I thought I could do this:
> <xsl:value-of select="../position()"/>
> but it doesn't work.... any suggestions?
>
David Carlisle (whom I trust is home by now!) came up with the solution
to this:
xml:
<?xml version="1.0"?>
<root>
<a></a>
<a></a>
<a></a>
<a></a>
<a><b/></a>
<a></a>
<a></a>
</root>
xsl:
<?xml version="1.0"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="b">
<result>
<xsl:text>b's parent is in position </xsl:text>
<xsl:value-of select="count(../preceding-sibling::*)+1" />
</result>
</xsl:template>
</xsl:stylesheet>
result (saxon):
<?xml version="1.0" encoding="utf-8" ?><result>b's parent is in
position 5</result>
Francis.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








