RE: mixing orderer and unordered elements

Robin La Fontaine writes:

>> It is a real shame that XML Schema has no 
>> way to indicate whether order is important 
>> or not. Choice does not tell you that.

In my opinion, the issue is more subtle than you might be implying.  First 
of all, the order of XML elements is by definition significant in an XML 
Infoset.  Schema can do nothing to change that.  What schema can say is 
that documents  <A/><B/> and documents with <B/><A/> are both valid, but 
it is in either case appropriate for an application to derive information 
from the order in which these elements appear (a non-normative proposal 
has been kicking around for an annotation that would signal that you did 
not care after all -- if you're a W3C member, look around in the archives 
for the issue labeled LC-200, which was our last call issue #200).

Also, as has been noted several times, if we allowed:

        <sequence>
                <element ref="a"/>
                <element ref="b"/>
                <all>
                        <element ref="c"/>
                        <element ref="d"/>
                </all>
        </sequence>

then you either need a different sort of parser than almost all 
implementations use (Deterministic Finite State Automata) or you have a 
combinatorial explosion in the number of states.  The limited form of 
"all" that we do support can easily be implemented with the same sort of 
parsing machinery that is used for attributes -- that's part of why we 
have the limits we do.

RELAX-NG is indeed a completely different class of language, requiring a 
quite different (but very nice) approach to parsing.  Though it's not my 
area of expertise, my impression that it is ultimately in the general case 
a non-deterministic parse that could in principle have rather high 
performance costs.  Obviously, Murata-san & friends have engineered it to 
give practical performance in many cases of interest.    There are also 
some subtleties as to what sort of typing information a non-deterministic 
parse can provide to a query system (along with an interesting debate over 
whether such typing information is important and valuable, or a mistake in 
the first place.  There are well held opinions by smart people on both 
sides of that question, as far as I can tell.)

Anyway:  my point is that the tradeoffs are at best subtle.  This is not 
something the Schema WG just skipped because we were too lazy to provide 
the function.  It was a more-or-less conscious tradeoff made given the 
options available in the design space.  Of course, I speak for myself and 
not the schemas workgroup.

------------------------------------------------------------------
Noah Mendelsohn                              Voice: 1-617-693-4036
IBM Corporation                                Fax: 1-617-693-8676
One Rogers Street
Cambridge, MA 02142
------------------------------------------------------------------







Robin La Fontaine <robin@monsell.co.uk>
Sent by: xmlschema-dev-request@w3.org
06/12/2002 11:20 AM

 
        To:     Mark Feblowitz <mfeblowitz@frictionless.com>, "'Torsten Curdt'" 
<tcurdt@dff.st>, xmlschema-dev@w3.org
        cc:     (bcc: Noah Mendelsohn/Cambridge/IBM)
        Subject:        RE: mixing orderer and unordered elements



In this type of situation I have found it is better to introduce a 
wrapper element to make it absolutely clear and avoid the complex 
structure. An extra element is cheap compared to having errors, and 
it is usually much easier to process with XSL, for example. It also 
makes it easier to compare the files and find changes (which is our 
business!).

It is a real shame that XML Schema has no way to indicate whether 
order is important or not. Choice does not tell you that.

Robin

At 9:52 am -0400 12/6/02, Mark Feblowitz wrote:
>Ah - I wondered about that. Then you'd have to go with something more 
like
>
><xs:element name="Root">
>                                <xs:complexType>
>                                                <xs:sequence>
> <xs:element name="Seq1"/>
> <xs:element name="Seq2"/>
> <xs:choice>
>  <xs:sequence>
>                <xs:element
>name="Unordered1" minOccurs="0" maxOccurs="unbounded"/>
>                <xs:element
>name="Unordered2" minOccurs="0" maxOccurs="unbounded"/>
>  </xs:sequence>
>  <xs:sequence>
>                <xs:element
>name="Unordered2" minOccurs="0" maxOccurs="unbounded"/>
>                <xs:element
>name="Unordered1" minOccurs="0" maxOccurs="unbounded"/>
>  </xs:sequence>
> </xs:choice>
>                                                </xs:sequence>
>                                </xs:complexType>
>                </xs:element>
>
>Any number of Unordered1's followed by any number of Unordered2's, or
>Any number of Unordered2's followed by any number of Unordered1's
>
>Does that sound more like it?
>
>Mark Feblowitz 
>XML Architect
>        [t]   617.715.7231 
>        [f]   617.495.0188
>Frictionless Commerce Incorporated
>        [e]  mfeblowitz@frictionless.com
>        [w] http://www.frictionless.com
>        [m] 400 Technology Square, 9th Floor
>              Cambridge, MA 02139
>Open Applications Group Incorporated
>        [e]  mfeblowitz@openapplications.org
>        [w] http://www.openapplications.org
>
>  -----Original Message-----
>From:           Torsten Curdt [mailto:tcurdt@dff.st]
>Sent:           Wednesday, June 12, 2002 3:58 AM
>To:             Mark Feblowitz; xmlschema-dev@w3.org
>Subject:                Re: mixing orderer and unordered elements
>
>Hi, Mark,
>
>thanks for the suggestion but
>
>On Tuesday 11 June 2002 17:14, Mark Feblowitz wrote:
>>  How about:
>>
>>               <xs:element name="Root">
>>                               <xs:complexType>
>>                                               <xs:sequence>
>> <xs:element name="Seq1"/>
>> <xs:element name="Seq2"/>
>> <xs:sequence>
>>  <xs:choice maxOccurs="unbounded">
>>               <xs:element
>>  name="Unordered1"/>
>>               <xs:element
>>  name="Unordered2"/>
>>  </xs:choice>
>> </xs:sequence>
>>                                               </xs:sequence>
>>                               </xs:complexType>
>>               </xs:element>
>
>wouldn't that also allow:
>
>   <Root>
>      <Seq1/>
>      <Seq2/>
>      <Unordered2/>
>      <Unordered1/>
>      <Unordered2/>
>   </Root>
>
>which is not what I want...
>--
>Torsten


-- 
-- -----------------------------------------------------------------
Robin La Fontaine, Director, Monsell EDM Ltd
DeltaXML: "Change control for XML in XML"
Tel: +44 1684 592 144 Fax: +44 1684 594 504
Email: robin.lafontaine@deltaxml.com      http://www.deltaxml.com

Received on Wednesday, 12 June 2002 10:56:16 UTC