This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Autogenerating XPath from XML?
- From: "Kenji Hollis" <kenji at ptdmicro dot com>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Sun, 29 Sep 2002 12:45:40 -0700
- Subject: RE: [xsl] Autogenerating XPath from XML?
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hmmmm, this doesn't actually work, because I'm not using a stylesheet to
create the output. This is being done via a Java program. I need a way to
do this programatically using Java...
-- Kenji
-----Original Message-----
From: owner-xsl-list@lists.mulberrytech.com
[mailto:owner-xsl-list@lists.mulberrytech.com]On Behalf Of Jeni Tennison
Sent: Sunday, September 29, 2002 12:24 PM
To: Kenji Hollis
Cc: XSL-List@lists.mulberrytech.com
Subject: Re: [xsl] Autogenerating XPath from XML?
Hi Kenji,
> I'm looking for a way to programatically create a list of XPaths
> based on a given XML document. I can easily create an XPath that
> will sort of work with a standard XML document that doesn't have
> multiple items of the same name.
The easiest thing to do is to use xsl:number to number the elements
amongst their siblings. Try iterating over the elements as follows to
create the path to the current element:
<xsl:for-each select="ancestor-or-self::*">
<xsl:text />/<xsl:value-of select="name()" />
<xsl:text />[<xsl:number />]<xsl:text />
</xsl:for-each>
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list