[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Getting the XPath of a node

Subject: Re: Getting the XPath of a node
From: Mike Brown <mike@xxxxxxxx>
Date: Wed, 4 Sep 2002 03:22:29 -0600 (MDT)
xpath current node name
Dennis wrote:
> 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@xxxxxxxxxxxx</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???

  <xsl:for-each select="ancestor::*">
    <xsl:value-of select="concat('/',name())"/>
  </xsl:for-each>
  <xsl:value-of select="concat('/',name())"/>

If the current node is an attribute, change that last '/' to '/@'

   - Mike
____________________________________________________________________________
  mike j. brown                   |  xml/xslt: http://skew.org/xml/
  denver/boulder, colorado, usa   |  resume: http://skew.org/~mike/resume/

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.