[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: concat all items in a sequence

Subject: Re: concat all items in a sequence
From: andrew welch <andrew.j.welch@xxxxxxxxx>
Date: Wed, 31 Aug 2005 13:54:52 +0100
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?)

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.