This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Getting the XPath of a node
- From: Dennis <maillistboxes at yahoo dot com>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Thu, 5 Sep 2002 04:47:53 -0700 (PDT)
- Subject: RE: [xsl] Getting the XPath of a node
- Reply-to: xsl-list at lists dot mulberrytech dot com
Thanks to All the guys, who gave time to this.
-Dennis
--- "Macaulay,Malcolm (US)"
<Malcolm.Macaulay2@cnare.com> wrote:
> Hi Dennis
>
> I know you've have had plenty of replies on this
> one, but I just have to send you my 'generateXPath'
> named template. It work well and is in production on
> my current project (not wanting to suggest that any
> of the other replies would not work). Also I like it
> :-)
>
> <xsl:template name="generateXPath">
> <xsl:for-each select="ancestor::*">/<xsl:value-of
>
select="name()"/>[<xsl:number/>]</xsl:for-each>/<xsl:value-of
> select="name()"/>[<xsl:number/>]</xsl:template>
>
> Call this template at the context where you want the
> unique XPath inserted into the output.
>
> Note: keep this template all on one line (i.e. no
> whitespace or nice indenting) - I use the generated
> XPath in a javascript function - whitespace in the
> template = gaps in the generate XPath = stuffed up
> the javascript function.
>
> Hope that helps.
>
> cheers
>
> Malcolm
>
>
> -----Original Message-----
> From: Dennis [mailto:maillistboxes@yahoo.com]
> Sent: Wednesday, September 04, 2002 4:03 AM
> To: xsl-list@lists.mulberrytech.com
> Subject: [xsl] Getting the XPath of a node
>
>
> Hi All,
>
> Is there any way to get the XPath of a particular
> element and attribute in match template???
>
> Say if I have following XML:
> <Person id="12345">
> <Name>Dennis</Name>
> <Company>Netscape</Company>
> <Address>Mountain View</Address>
> <Email>dennis@netscape.com</Email>
> </Person>
>
> ----The XSL to print XPath---
> <xsl:template match="Company">
> //Print the XPath of Company as /Person/Company
> </xsl:template>
> More templates corresponding to each element.
>
> How do I do this...any thoughts???
>
> Thanks
> Dennis
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Finance - Get real-time stock quotes
> http://finance.yahoo.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
>
__________________________________________________
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
http://finance.yahoo.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list