Simple question about xml schema

L

Lian Liming

Hi all,

I want to write a schema for the following example xml file:

<Items>
<ItemA>hehe</ItemB>
<ItemB>haha</ItemB>
</Items>

So far as my knowledge about xml schema, I can write the following
schema:

<element name="Items">
<complexType>
<sequence>
<element name="ItemA" type="string"/>
<element name="ItemB" type="string"/>
</sequence>
</complexType>
</element>

The problem is that, in this definition, the order of ItemA and
ItemB is fixed. If I want to make the order make no sense, in another
words, ItemB is allowed to appear before ItemA, how can I define the
schema?

This seems a simple question, but I really get confused. Thanks
for suggestion.
 
H

Henry S. Thompson

I want to write a schema for the following example xml file:
<Items>
<ItemA>hehe</ItemB>
<ItemB>haha</ItemB>
</Items>
<sequence>
<element name="ItemA" type="string"/>
<element name="ItemB" type="string"/>
</sequence>

The problem is that, in this definition, the order of ItemA and
ItemB is fixed. If I want to make the order make no sense, in another
words, ItemB is allowed to appear before ItemA, how can I define the
schema?

Use <all> instead of <sequence>.

See the W3C XML Schema Primer [1].

ht

[1] http://www.w3.org/TR/xmlschema-0/#groups
--
Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
Half-time member of W3C Team
2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
Fax: (44) 131 650-4587, e-mail: (e-mail address removed)
URL: http://www.ltg.ed.ac.uk/~ht/
[mail really from me _always_ has this .sig -- mail without it is forged spam]
 

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
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top