471,355 Members | 1,626 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,355 software developers and data experts.

Mixing ordered and unordered elements

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

Aug 19 '05 #1
1 1238
"yann" <yd*****@gmail.com> writes:
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
Aug 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Stephen Miller | last post: by
33 posts views Thread by Jim Cobban | last post: by
210 posts views Thread by Christoph Zwerschke | last post: by
41 posts views Thread by Rene Nyffenegger | last post: by
1 post views Thread by shapper | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.