[xquery-talk] How to retrieve Sequence of atomic values?

Torsten Grust grust at in.tum.de
Mon Feb 20 15:47:54 PST 2006

On 2/20/06 3:42 PM, Daniel Pötzinger wrote with possible deletions:
> [...]
> How is it possible to handle an element:
> <test>1 2 3 4</test>
> as sequence of atomic types (xs:integer) in an XQuery?

You'll need a schema description for your element and then, in your 
query, validate accordingly.  The schema could contain a global element 
declaration like:

    <xs:element name="test">
      <xs:list itemType="xs:integer"/>

Your query would import this schema and then validate:

    import schema ... ;
    let $e := fn:data(validate { <test>1 2 3 4</test> })
    return $e

The type of $e will be xs:integer* and $e[2] will evaluate to 2, for 

   | Prof. Dr. Torsten Grust                         grust at in.tum.de |
   |                                 http://www-db.in.tum.de/~grust/ |
   |     Database Systems - Technische Universität München (Germany) |

More information about the talk mailing list