Subject: Re: outputting the "position()" of parent From: Francis Norton <francis@xxxxxxxxxxx> Date: Wed, 07 Jun 2000 23:02:47 +0100 |
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: outputting the "position()" of , David Carlisle | Thread | Re: outputting the "position()" of , David Carlisle |
Flat -> hierarchy., Paul Tchistopolskii | Date | multilanguage support easily or inc, juggy |
Month |