Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: elements with different occurance limits

From: "C. M. Sperberg-McQueen" <cmsmcq@---.--->
To: John Didion <johndidion@-----.--->
Date: 9/24/2006 1:55:00 PM

On 19 Sep 2006, at 10:37 , John Didion wrote:

>
> I have a complex type...let's call it Foo. Foo
> potentially has five child elements:...
> My first instinct was to write this as an all:
>
> ...
> But of cource, all doesn't allow any element to appear
> more than once. I also tried writing this as a big
> choice block, with sequences for each of the possible
> ways these elements could be ordered, but the parser
> complained about potential ambiguity.
>
> Here is the element definition from the DTD that I'm
> trying to convert to XSD: ...
>

The simplest thing, if exact compatibility wtih the DTD is not
required, is to impose an order and write the equivalent of

   (A, B, ((C+, D*, E*) | (D+, E*) | E+))

If the sequence of elements has no significance, there can't
really be much argument against fixing an order.

Exact compatibility with the DTD shouldn't really be required,
since the content model you give is not legal in XML or SGML
DTDs: it violates the determinism rules.

But if you really need elements A-E, with occurrence requirements
as you describe, in any order, then a simple approach is to fix
the content model by left-factoring it to make it deterministic;
the result would be both an improved (legal) DTD and a legal
schema.  You'll end up with a large but deterministic content
model.

     (
       (A, (
             (B, (C | D | E)+ )
             |
             ( (C | D | E)+, B, (C | D | E)* )
           )
       )
       |
       (B, (
             (A, (C | D | E)+ )
             |
             ( (C | D | E)+, A, (C | D | E)* )
           )
       )
       |
       ((C | D | E)+, (
             (A, (C | D | E)*, B, (C | D | E)*)
             |
             (B, (C | D | E)*, A, (C | D | E)*)
            )
       )
     )

I've indented to make the pattern easier to see: first the
possible orders with A first, then with B first, then with C or D
or E first.  Translate this (rather than the illegal content model
you show in DTD notation) into XML Schema notation, and
you should have what you need.

A third possibility is to encourage the XML Schema working group
to make 'all' a first-class interleave operator, so that the all-group
that was your first instinct is supported.  You can do that
by sending mail to www-xml-schema-comments@w... or by filing
comments on XML Schema 1.1 in http://www.w3.org/Bugs/Public

I hope this helps.

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


From skits@m... Mon Sep 25 18:37:03 2006
Received: from maggie.w3.org ([193.51.208.68])
	by frink.w3


transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent