Re: Rationale for restricted uses of "all"

Hi Dave,

> The <all> group usage is so limited already that it has become
> almost useless... yet I really would like more flexible
> functionality when mapping to/from object-oriented structures that
> have unordered content. The <interleave> content model in RelaxNG
> appears to have come pretty close to what I'm looking for.
>
> I would hope that <all> could be extended with <all>, as in this
> example, so that it retains some usefulness.

It might be that it can be. I think we need someone else from the XML
Schema WG to clear it up for us.

The other thing that could be possible is to derive by restriction
rather than extension. If you start with a type that optionally allows
all the elements that you might want to have:

<xs:complexType name="all">
  <xs:all>
    <xs:element name="Child1" minOccurs="0" />
    <xs:element name="Child2" minOccurs="0" />
  </xs:all>
</xs:complexType>

Then derive the other types by restriction from it:

<xs:complexType name="A">
  <xs:all>
    <xs:element name="Child1" />
  </xs:all>
</xs:complexType>

<xs:complexType name="B">
  <xs:all>
    <xs:element name="Child1" />
    <xs:element name="Child2" />
  </xs:all>
</xs:complexType>

Yes, I know it's less than ideal.

But then I've never understood the requirement to not impose order
where there is chaos :) If the order of an object's properties doesn't
matter, then imposing an order on them for purposes of serialization
within an XML document isn't going to matter either. Just decide on an
order and you can use XML Schema to your heart's content!

Or, as Eric just suggested, write your XML documents with whatever
ordering you want, and then use a transformation to map them on to the
strict ordering that's acceptable to an XML Schema schema.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

Received on Friday, 9 November 2001 13:02:27 UTC