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

Re: Specify/determine element's "logical" parent

Subject: Re: Specify/determine element's "logical" parent
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Thu, 23 Sep 2004 20:29:59 +0100
xpath determine element name
Hi John,

Is this possible and/or a bad idea?  I read that XPath statements
cannot be dynamic, so I imagine I have to use parentid attributes
rather than parentpath, then somehow map the ID to an actual node;
does that make sense? I also see the potential for infinite
recursion; any suggestions on that topic would be appreciated.

It would certainly be easiest to use the parentid attribute. To do that, all you have to do is set up a key that indexes the <item> elements based on their id attribute:


<xsl:key name="items" match="item" use="@id" />

and to get the parent of a particular item, use the key() function with the parentid attribute:

key('items', @parentid)

Parsing XPath using XSLT is possible but difficult. You're probably best off using an extension dyn:evaluate() function to do so. If you're using a small subset of XPath then you can alternatively use recursive templates to step through the path and parse it as you go. See my reply in the thread "generate-id for identical elements" for an example of how that might be done.

I'm not sure where the infinite recursion might occur, unless you want to get the parent of the parent once you find it?

Cheers,

Jeni
--
Jeni Tennison
http://www.jenitennison.com

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.