This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Apostrification -- Re: Generating XPath expressions
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: RE: [xsl] Apostrification -- Re: Generating XPath expressions
- From: "Charlie McCay" <Charlie at RamseySystems dot co dot uk>
- Date: Thu, 5 Apr 2001 14:21:39 +0100
- Reply-To: xsl-list at lists dot mulberrytech dot com
Richard
The following from Francis Norton may be what you are looking for -- I
couldn't find it in the archive -- hence the re-copy to the list
All the best
Charlie
Charlie McCay, charlie@RamseySystems.co.uk
> I'm trying to produce which is som debugging
> message that generates and X-Path to the problem
>
> From: Francis Norton [mailto:francis@redrice.com]
> Sent: 12 December 2000 14:17
> Subject: Re: Generating XPath expressions
>
>
> Try this ...
>
> <xsl:template name="mypath">
> <xsl:for-each select="(ancestor-or-self::*|@*)">
> <xsl:choose>
> <xsl:when test=". = /"/>
> <xsl:otherwise>/<xsl:value-of select=
> "concat(name(.), '[',
> count(preceding-sibling::*[name(current()) =
> name(.)]) + 1, ']')"
> />
> </xsl:otherwise>
> </xsl:choose>
> </xsl:for-each>
> </xsl:template>
>
> ... for an elements-only solution in XSLT, that generates
> "/a[1]/b[3]/c[1]" style xpath for any given context node.
>
> Francis.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list