[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Calling position() on a parent element
Try count(../preceding-sibling::*) Michael Kay Software AG home: Michael.H.Kay@xxxxxxxxxxxx work: Michael.Kay@xxxxxxxxxxxxxx > -----Original Message----- > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of > Graham Ashton > Sent: 08 May 2002 15:33 > To: xsl-list > Subject: Calling position() on a parent element > > > Hi. > > I'm trying to convert this simple markup (which looks like HTML, but > isn't): > > <tr> > <td> > <label>Hello World!</label> > </td> > <td> > <label>Foo</label> > </td> > </tr> > > into something akin to this: > > <label> > <text>Hello World!</text> > <left_attach>0</left_attach> > </label> > <label> > <text>Foo</text> > <left_attach>1</left_attach> > </label> > > The <left_attach> elements in the output tell the label or the button > which table cell they should appear in. I'm having real > trouble getting > hold of the values for <left_attach> from my source input, as I can't > determine the position of the <td> element that a <label> belongs to, > from the context of a <label>'s template. > > This is close to what I'd like to be able to do: > > <xsl:template match="td/label"> > <label> > <text><xsl:value-of select="."/></text> > <left_attach><xsl:value-of > select="position(parent)"/></left_attach> > </label> > </xsl:template> > > Obviously, the "position(parent)" part is wrong (it just illustrates > what I'd like to do). > > Is there a way for the template that handles <label> elements to > determine the position of <td> elements, within the <tr>? > > I'm using the latest libxslt. Thanks. > > -- > Graham Ashton > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > 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
|