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

Re: How can I get the XPATH of the current node ?

Subject: Re: How can I get the XPATH of the current node ?
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Thu, 10 Oct 2002 13:50:58 -0700 (PDT)
get xpath from node
--- Louis Meigret  wrote:
 
> First of all, thanks a lot to Jörg for pointing me to the Muenchian
> method.Relentlessly learning.
> 
> I have another question : I would like to get the Xpath value of the
> current node. I am done some homework and tried this method suggested
> by Jeni Tennison : 
> 
> « To get an XPath that's guaranteed to be unique, you need to use the
> index of the element within its parent rather than its
> attributevalues.
> An easy way is to use recursion with the ancestor-or-self axis:
> 
>   <xsl:for-each select="ancestor-or-self::*">
>     <xsl:text />/<xsl:value-of select="name()" />
>     <xsl:text />[<xsl:number />]<xsl:text />
>   </xsl:for-each>
> 
> Cheers,
> 
> Jeni »
> 
> Unfortunately, this does not print any number between the square
> brackets (with Xalan). I thought of adding value="position()", but
> this
> would be the position within this context (the for-each), not very
> useful.
> 
> Any suggestion to solve what would be useful debugging information
> (in
> my case) ?
> 
> Thanks
> 
> Louis

Hi Louis,

Do have a look at:

http://www.topxml.com/code/default.asp?p=3&id=v20010323001030

or at:

http://www.dpawson.co.uk/xsl/sect2/N6077.html#d177e20

This is a more complete solution, which will generate the XPath
expression not only for an element but for any type of node -- text,
PI, comment, root, attribute and namespace.

Also, positional predicates are not used when they are not necessary,
which results in a more compact and readable XPath expression




=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL

__________________________________________________
Do you Yahoo!?
Faith Hill - Exclusive Performances, Videos & More
http://faith.yahoo.com

 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.