Subject: RE: [xsl] recursive node checking From: "Andrew Smith" <andrew.smith@xxxxxxxxxxxxx> Date: Tue, 21 Feb 2006 09:28:22 -0000 |
Thanks for this, it worked a treat, I'm getting what I wanted now. Thanks a lot again :-) Andy -----Original Message----- From: Michael Kay [mailto:mike@xxxxxxxxxxxx] Sent: 20 February 2006 17:13 To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: RE: [xsl] recursive node checking starts-with() expects a string as its argument; if you give it a node-set containing more than one node, XPath 1.0 will take the string value of the first node (XPath 2.0 will throw an error). Write select="/root/a[d[starts-with(d1, $letter)]]" /> Michael Kay http://www.saxonica.com/ -----Original Message----- From: David Carlisle [mailto:davidc@xxxxxxxxx] Sent: 20 February 2006 17:02 To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: [xsl] recursive node checking > 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 $letter. 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 itself. David ________________________________________________________________________ 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: http://www.star.net.uk ________________________________________________________________________
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] recursive node checking, Michael Kay | Thread | [xsl] Implementing an Blogger-style, publicreg |
RE: [xsl] problem in xsl:value-of, Michael Kay | Date | Re: [xsl] Slower performance of com, andrew welch |
Month |