This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Calling position() on a parent element
- From: "Michael Kay" <michael dot h dot kay at ntlworld dot com>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Wed, 8 May 2002 17:02:48 +0100
- Subject: RE: [xsl] Calling position() on a parent element
- Reply-to: xsl-list at lists dot mulberrytech dot com
Try count(../preceding-sibling::*)
Michael Kay
Software AG
home: Michael.H.Kay@ntlworld.com
work: Michael.Kay@softwareag.com
> -----Original Message-----
> From: owner-xsl-list@lists.mulberrytech.com
> [mailto:owner-xsl-list@lists.mulberrytech.com]On Behalf Of
> Graham Ashton
> Sent: 08 May 2002 15:33
> To: xsl-list
> Subject: [xsl] 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