- From: Christopher Milton <cmiltonperl@yahoo.com>
- Date: Mon, 23 Aug 2004 08:16:38 -0700 (PDT)
- To: xmlschema-dev@w3.org
I think a novice-friendly explanation of why ordering is preferred would be good, especially for folks who have to deal with existing unordered data sets and systems. Such novices may be expected to justify enforcing ordering on the data. --- Mik Lernout <mik@futurestreet.org> wrote: > Just a little sideremark... > > We shouldn't be offering these kind of solutions to novices in XMLSchema > or people who are in the process of (re)defining their schemas. > > There is a very good reason why ordering is preferred to non-ordering > and it is the "XML Schema"-way to do things. > All of the solutions offered here are overcomplicating implementations > and confusing users, pushing them to other validation technologies or > wrecking the validation performance. > > XMLSchema can be clean and simple and that's how we should guide > potential users... > > What do you people think? > > Mik > > > > Michael Kay wrote: > > >>This is the most frequent of FAQs. It can't be done in XML Schema. > >> > >> > > > >Actually, I think someone did discover a way of doing it. You can use a > >choice as in (2) below, and then use a uniqueness constraint to ensure there > >is only one father and only one mother. Under the element declaration for > >family, you add: > > > ><xs:unique name="one-father"> > > <xs:selector xpath="."/> > > <xs:field xpath="father"/> > ></xs:unique> > > > >This will cause a validation error if a the xs:field expression selects more > >than one node, that is, if a family has more than one father. > > > >Michael Kay > >Saxonica Limited > >www.saxonica.com > > > > > > > >>Your options are: > >> > >>1. Constrain the order as in your current schema, and use a simple > >>transformation to transform the any-order documents into the > >>constrained-order documents, which you can then validate. > >> > >>2. Use a content model with no constraints on occurrence, as in: > >> > >> <xs:choice minOccurs="0" maxOccurs="unbounded"> > >> <xs:element ref="father" /> > >> <xs:element ref="mother" /> > >> <xs:element ref="son" /> > >> <xs:element ref="daughter" /> > >> <xs:element ref="pet" /> > >> </xs:choice> > >> > >>and add supplementary Schematron rules to constrain the occurrence of > >>each of the elements. The Schematron rules can be processed in a > >>separate step. > >> > >>3. Switch to using RELAX NG, where you can do: > >> > >> <interleave> > >> <optional><ref name="father" /></optional> > >> <optional><ref name="mother" /></optional> > >> <zeroOrMore><ref name="son" /></zeroOrMore> > >> <zeroOrMore><ref name="daughter" /></zeroOrMore> > >> <zeroOrMore><ref name="pet" /></zeroOrMore> > >> </interleave> > >> > >>or, in compact syntax: > >> > >> father? & mother? & son* & daughter* & pet* > >> > >>Cheers, > >> > >>Jeni > >> > >>--- > >>Jeni Tennison > >>http://www.jenitennison.com/ > >> > >> > >> > >> > >> > > > > > > > > > > > ===== Christopher Milton <==||==> cmiltonperl@yahoo.com "What appears to be coming at you is coming from you." --Jack Flanders (Meatball Fulton, ZBS) There's an evil monkey in my closet.
Received on Monday, 23 August 2004 15:16:39 UTC