This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: XPath query to recurse up the tree
- To: xsl-list at mulberrytech dot com
- Subject: Re: XPath query to recurse up the tree
- From: Miloslav Nic <nicmila at idoox dot com>
- Date: Thu, 17 Aug 2000 16:45:47 +0200
- References: <7BCEE20FF96A2E42BFE189F44E12FEC7033EFA@zeus.Choosee.com>
- Reply-To: xsl-list at mulberrytech dot com
use axes:
http://www.zvon.org/xxl/XSLTreference/Output/index.html
http://www.zvon.org/xxl/XPathTutorial/General/examples.html
http://www.zvon.org/cgi-bin/xlab/bin/xpathAxes.py
Ian Sutton wrote:
>
> Am I missing something, or is the current definition of XPath queries (or
> whatever the current name is) limited to recursion down the tree?
> As an example, consider an XML document representing a file system with
> <directory> nodes which can contain either <file> nodes or further
> <directory> nodes. (Case I have is actually nothing to do with filesystems
> but this seems the simplest way to represent the issue.)
>
> Given a current context of a directory, I could find all child file nodes
> recursively with
>
> <xsl:apply-templates select=".//file" />
>
> and a corresponding template rule.
>
> I have a case where my <directory> nodes have certain additional attributes
> (lets say optional TYPE=something) and I wish to find the first parent which
> has say TYPE=X. Is there any way to do this?
>
> I kind of half guess it may be possible to do something like a recursive
> call with an apply templates select=".." mode="myUpwardRecursion" and write
> a specific template match rule which tests the attribute and either returns
> or recurses up, but this seems fairly painful if indeed it would work at
> all.
>
> Any answers/ideas gratefuly received ;->
>
> Ian
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
--
******************************************
<firstName> Miloslav </firstName>
<surname> Nic </surname>
<mail> nicmila@idoox.com </mail>
<support> http://www.zvon.org </support>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list