XQuery: How to retrieve Sequence of atomic values?

D

Daniel Poetzinger

Hello List

Sorry if this question is too simple or unreleated, but I didn't found
an answer yet:

How is it possible to handle an element:
<test>1 2 3 4</test>
as sequence of atomic types (xs:integer) in an XQuery?
A cast to xs:integer* is not possible I think...

Thanks for Help

Daniel P.
 
M

Martin Honnen

Daniel Poetzinger wrote:

How is it possible to handle an element:
<test>1 2 3 4</test>
as sequence of atomic types (xs:integer) in an XQuery?
A cast to xs:integer* is not possible I think...

You can tokenize the element content to a sequence of strings e.g.
tokenize(test, "\s+")
Documentation of the function is here
<http://www.w3.org/TR/xquery-operators/#func-tokenize>

Then doing a cast on any string in that sequence should do e.g.
for $s in tokenize(test, "\s+") return xs:integer($s)

That should do in XPath 2.0 and hopefully in XQuery 1.0 as those share
the data moel, functions and most expressions. But I haven't tried with
an XQuery processor.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,001
Messages
2,570,255
Members
46,852
Latest member
CarlaDowle

Latest Threads

Top