[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: concat all items in a sequence
> contains(string-join(elem, ''), val) > > or (depending on what you want to do if val is a substring of the > concatenation but not of any value, you may want > > > true()=elem/contains(./val) I was doing it within a predicate - an example is something like: <root> <node> <text>abc</text> </node> <node> <text>def1</text> <text>def2</text> </node> <node> <text>ghi</text> </node> </root> I wanted to find the position of a <node> based on the value within <text>, so: <xsl:value-of select="count(.|/root/node[contains(text, 'def')]/preceding-sibling::node)"/> This complains because one <node> contains two <text> elements, so from the responses I've had I think the choices are: [contains(string-join(text, ''), 'def')] and [some $x in text satisfies contains($x, 'def')] As I want to check each value individually the latter suggestion from Jarno is the one I'm using (plus its always nice to use 'some' and 'satisfies'). Also, string-join(text, '') with the empty quotes feels like a bit of an abuse of the function - why wasn't there a single argument version for this purpose? Regarding true()=elem/contains(...) it's also really good using the slash operator :) but I can't see how to squeeze it in here... (why the true()= part david?)
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|