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

Re: XPath problem with getting all ancestors

Subject: Re: XPath problem with getting all ancestors
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Fri, 23 Oct 2009 14:13:28 +0200
Re:  XPath problem with getting all ancestors
Jostein Austvik Jacobsen wrote:

	<xsl:template match="article">
		<xsl:variable name="v1">
			<xsl:copy-of select="content/node()"/>
		</xsl:variable>

So v1 now is a temporary document containg a deep copy of the child nodes of the content element(s). With your sample document the contents is then


                       <para>
                               <note id="1">text</note>
                       </para>


	<xsl:template match="note">
		The note at /article/content/para/note reads:
		ancestors="<xsl:value-of select="count(ancestor::*)"/>"
		preceding="<xsl:value-of select="count(preceding::*)"/>"
		contentNum="<xsl:value-of select="count(preceding::content)"/>"
		numberTest="<xsl:number level="any" count="content"/>"
	</xsl:template>

and that way the template for 'note' elements outputs


		The note at /article/content/para/note reads:
		ancestors="1"
		preceding="0"
		contentNum="0"
		numberTest=""

So the template is applied to a copy of the original para element.


--

	Martin Honnen
	http://msmvps.com/blogs/martin_honnen/

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.