Re: [xsl] recursive node checking

Subject: Re: [xsl] recursive node checking
From: David Carlisle <davidc@xxxxxxxxx>
Date: Mon, 20 Feb 2006 17:01:33 GMT
> but it only seems to check the first 'd' node,

  d/d1 selects a node set of all the d1 children, but if you use a node
set in a string context then (in XSLT1) it uses the string value of the
first node in document order, and silently discards the other nodes. (In
XSLT2 it's an error, unless backwards compatibility is enabled)

starts-with requires two strings as arguments so in
starts-with(d/d1, $letter)
the first argument is the string value of the first node
selected by d/d1.
You need to arrange that the node set pased to starts-with has at most
one node, so something like

select="/root/a[d/d1[starts-with(., $letter)]]" 
selects all a elements that have a d1 grandchild that starts with

Note its a bit confusing to call the top level element root in an xpath
context, as the root node is the parent of that element not the element


This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:

Current Thread