xsl-list
[Top] [All Lists]

RE: Getting the XPath of a node

2002-09-04 04:27:58
<xsl:for-each select="ancestor-or-self::*">
<xsl:value-of select="concat(
   '/',
   name(.),
   '[',
   count(preceding-sibling::*[name(.)=name(current())])-1,
   ']')"/>
</xsl:for-each>

(Saxon has a saxon:path extension function)

Michael Kay
Software AG
home: Michael(_dot_)H(_dot_)Kay(_at_)ntlworld(_dot_)com
work: Michael(_dot_)Kay(_at_)softwareag(_dot_)com 
   

-----Original Message-----
From: owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com 
[mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com] On Behalf Of 
Dennis
Sent: 04 September 2002 10:03
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)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(_at_)netscape(_dot_)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



<Prev in Thread] Current Thread [Next in Thread>