Discussion:
X query question
(too old to reply)
Daniel Cullender
2005-01-03 14:20:46 UTC
Permalink
Hi all,

Happy new year!!!

I am trying to achieve the following via xquery:

I have an xml :

<ns1:EmailAddress>
<ns1:To>Hello1</ns1:To>
<ns1:CC>Hello2</ns1:CC>
<ns1:CC>Hello3</ns1:CC>
<ns1:CC>Hello4</ns1:CC>
</ns1:EmailAddress>

which needs to be translated into a string like:

"Hello1, Hello2, Hello3, Hello4".

(PS - we could any number of occurances of CC)

I can only do this using hardcoded values which is not very usefull.

Any help would be greatly appreciated :)

Thanks!
Michael Reiche
2005-01-14 18:25:52 UTC
Permalink
declare namespace ns1="ns1";

let $email:=<ns1:EmailAddress>
<ns1:To>Hello1</ns1:To>
<ns1:CC>Hello2</ns1:CC>
<ns1:CC>Hello3</ns1:CC>
<ns1:CC>Hello4</ns1:CC>
</ns1:EmailAddress>

return
<result>
{
data($email/ns1:*[1])
,
for $addr in subsequence($email/ns1:*,2, count($email/ns1:*) - 1 )
return
( "," , data($addr) )
}
</result

Loading...