This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

XPath query to recurse up the tree


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]