Mixing ordered and unordered elements

Y

yann

Hi,

I try to write a schema to validate this :

<F>
<L/>
<A/>
<B/>
<C/>
</F>

where
- L has to be present once and only once and at first place
- each of A,B,C have to be present once and only once but
not ordered ( ABC, BAC, CAB, ...)

Thank you for your help

Yann
 
C

C. M. Sperberg-McQueen

yann said:
Hi,

I try to write a schema to validate this :

<F>
<L/><A/><B/><C/>
</F>

where
- L has to be present once and only once and at first place
- each of A,B,C have to be present once and only once but
not ordered ( ABC, BAC, CAB, ...)

In XML DTD notation, what you are asking for is

(L, ( (A, ((B,C) | (C, B)))
| (B, ((A,C) | (C, A)))
| (C, ((A,B) | (B, A)))))

This has a straightforward translation into any schema language
you might wish to use.

SGML DTDs allow you to write

(L, (A & B & C))

which is shorter and means the same thing.

There are a couple of reasons to think twice before you do this,
however, in addition to the fact that working out all possible
sequences is boring.

First, the content model you describe makes sense only when the
order of A, B, and C conveys significant information. If the
order conveys no information, then you might as well fix it:

(L, A, B, C)

Second, it seems odd that the ordering constraints among
siblings should change in mid-stream. Abstractly, it
looks as if your content model falls into two pieces:
the L, and then the A-B-C sequence. It might make sense
to model that fact directly. In SGML notation:

<!ELEMENT container (L, ABCseq) >
<!ELEMENT ABCseq (A & B & C) >

In this case, the definition of ABCseq can easily be translated
into an XML Schema all-group.

--C. M. Sperberg-McQueen
World Wide Web Consortium
 

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,251
Members
46,851
Latest member
CristineKo

Latest Threads

Top