W3C home > Mailing lists > Public > www-ql@w3.org > October to December 2002

Things that one can define with XML schema but cannot query with XQuery?

From: Marko Smiljanic <markosm@cs.utwente.nl>
Date: Wed, 30 Oct 2002 11:17:11 +0100
To: <www-ql@w3.org>
Message-ID: <FLEIJNHGLMNINLGGKCJICECHCFAA.markosm@cs.utwente.nl>

This is a question about XML Schema and XQuery
<!-- Excuse me if this was already discussed, I had no time to carefully
read the whole history of this mailing list -->

Lets take the part of some XML schema definition:

<xs:element name="root">
        <xs:sequence maxOccurs="5">
            <xs:element name="A"/>
            <xs:element name="B" minOccurs="0"/>

It defines that <root> can "contain" from 1 up to 5 sequences of two
elements <A/> and <B/>.  <B> does not have to exist.

E.g. an XML instance confirming to XML schema above:


    <!-- non existing element B -->


We can assume that the XML schema designer had a specific semantics in mind
when he specified that a sequence <A/><B/> should repeat it self. E.g. <A/>
can be the name of a man and <B/> can be his address. We thus have from 1 to
5 pairs of person name / person address (where address does not have to be
Note that each single person is represented by one sequence. I can say that
sequence has a clear semantics i.e. 1 sequence = 1 person. (and each person
has a name and an address)

My questions are:

a) How can we specify a query in XQuery language saying that I'm interested
in 2nd persons address (i.e. <B>). (The answer should be empty for the
example above).

b) This is similar to the problem in a): is there any way that that I can
count the number of A,B sequences in an instance XML document (using
XQuery). (The example above has 3 sequences).

If the answers to those questions are negative, then there is a conflict
between XML Schema and XQuery. Sequence, all and choice are structures that
can be define in XML Schema, but are not visible in XML instance and might
not be accessible with XQuery. XML parser can surely count them, but can the
XQuery do the same.

If the answers are positive than thank you for saving me several hours
(days) of work in tackling the details of XQuery usage.

Marko Smiljanic

Research assistant, Database Technology
Department of Computer Science, University of Twente
P.O. Box 217, 7500 AE Enschede, The Netherlands
Phone +31 53 4894520, Fax +31 53 4892927
E-mail: markosm@cs.utwente.nl
WWW: www.cs.utwente.nl/~markosm
Received on Thursday, 31 October 2002 05:17:14 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:17:15 UTC