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

Re: How to get XPath in a XSLT shylesheet

  • From: Rick Jelliffe <rjelliffe@a...>
  • To: ">"@modelo.allette.com.au, xml-dev@l...
  • Date: Tue, 09 Jan 2007 18:24:59 +1100

full path name xpath
Long JingJun wrote:
> Hi all,
>
> My original target is to get the XPath to identify the location of an element in the XML output (as location attribute for an example). So that I can find the original place in the source file when I go through the generated XML output. What I mean full XPath is like this: /document/chapter[2]/section[3]/subject[1]/para[2]
>   
Heres the code we use in Schematron (I think from David Carlisle 
originally?)

   		<xsl:template match="*|@*" mode="get-full-path">

			<xsl:apply-templates select="parent::*" mode="get-full-path"/>
			<xsl:text>/</xsl:text>
			<xsl:if test="count(. | ../@*) = count(../@*)">@</xsl:if>
			<xsl:value-of select="name()"/>
			<xsl:text>[</xsl:text>
	  		<xsl:value-of select="1+count(preceding-sibling::*[name()=name(current())])"/>
	  		<xsl:text>]</xsl:text>
       	 	</xsl:template>


(XSLT question are better dealt with on the mulberry XSLT list.)

Cheers
Rick Jelliffe


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


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
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

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.