Please keep in mind that Mik is correct that using "all" places a burden on your processor. As you point out, it's not suitable for your specific case in XML Schema 1.0.
The rule for applying all (and indeed for placing that kind of processing burden on your processor is to consider the following: "Use xs:sequence under either of the following two conditions: 1) when you want the child elements to be in a specific order or 2) when you don't really care about the order." Note that this is really your case #2, and you should consider using xs:sequence. This begs the question of when to use "all". "Use xs:all >only< if the document order of element children may vary, and that order has significance." In other words, if the order doesn't matter to your applications, use xs:sequence. If the order carries information (like who got here first, who's most important, fattest, etc.) then it's ok to use xs:all. One other option you have is to put your collection of stuff (sons, pets, daughters, parents) into its very own namespace. This requires creating two schemas, one for your family members: <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:family-ns"> <xs:element name="father" type="xs:string"/> <xs:element name="mother" type="xs:string"/> <xs:element name="son" type="xs:string"/> <xs:element name="daughter" type="xs:string"/> <xs:element name="pet" type="xs:string"/> </xs:schema> and one to reference it (note the xs:import): <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fm="urn:family-ns"> <xs:import namespace="urn:family-ns" schemaLocation="family-members.xsd"/> <xs:element name="family"> <xs:complexType> <xs:sequence> <xs:any namespace="urn:family-ns" minOccurs="0" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> Now, the following instance document will validate: <?xml version="1.0"?> <family xmlns:fm="urn:family-ns"> <fm:father>Jack</fm:father> <fm:mother>Jill</fm:mother> <fm:son>Billy</fm:son> <fm:son>Joey</fm:son> <fm:daughter>Jane</fm:daughter> <fm:pet>Fido</fm:pet> <fm:son>Frank</fm:son> </family> Personally, I don't think that your current application warrants this treatment, but then you might have uses for your document that I don't know about. At any rate, others might find this technique useful. Best regards, David Ezell -----Original Message----- From: Mik Lernout [mailto:[EMAIL PROTECTED] Sent: Monday, August 23, 2004 8:37 AM To: [EMAIL PROTECTED] Subject: Re: XML Schema Oops, didn't see those *occurs :-) I am afraid you are stuck , either you choose for an ordered / deep definition of a complex type, or a list of optional / required elements. There is no intermediate option in XML Schema... Mik Asleson, Ryan wrote: >Thanks for the tip -- I'll ask on the w3.org list. I can't change "sequence" >to "all" because then minOccurs and maxOccurs for the child elements >(father, mother, etc.) must be 0 or 1 when using "all", and I need them to >occur more than just once. > > >-----Original Message----- >From: Mik Lernout [mailto:[EMAIL PROTECTED] >Sent: Monday, August 23, 2004 7:27 AM >To: [EMAIL PROTECTED] >Subject: Re: XML Schema > > >Hey, > >The mailing list your question should be directed to is the >xmlschema-dev mailing list at www.w3.org. >The fact that the order is validated has to do with the sequence you >have defined in your schema, if you change 'sequence' to 'all' you will >achieve what you want. >I should add though that there is a real tendency for schema's to use >fixed-order as much as possible: it eases development against the schema >and allows highly optimized validation techiniques... > >Hope that helps, > >Mik > > >Asleson, Ryan wrote: > > > >>Hello, >> >>My apologies if this isn't the correct place to ask this question, but I >>didn't know where else to go. >> >>Suppose I have a simple XML document that looks like this: >> >><?xml version="1.0"?> >><family> >> <father>Jack</father> >> <mother>Jill</mother> >> <son>Billy</son> >> <son>Joey</son> >> <daughter>Jane</daughter> >> <pet>Fido</pet> >></family> >> >> >>The above XML is successfully validated by the schema shown below: >> >> >><?xml version="1.0"?> >><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> >> >> <xs:element name="father" type="xs:string"/> >> <xs:element name="mother" type="xs:string"/> >> <xs:element name="son" type="xs:string"/> >> <xs:element name="daughter" type="xs:string"/> >> <xs:element name="pet" type="xs:string"/> >> >> <xs:element name="family"> >> <xs:complexType> >> <xs:sequence> >> <xs:element ref="father" minOccurs="0"/> >> <xs:element ref="mother" minOccurs="0"/> >> <xs:element ref="son" minOccurs="0" maxOccurs="unbounded"/> >> <xs:element ref="daughter" minOccurs="0" >>maxOccurs="unbounded"/> >> <xs:element ref="pet" minOccurs="0" maxOccurs="unbounded"/> >> </xs:sequence> >> </xs:complexType> >> </xs:element> >></xs:schema> >> >> >>However, if the XML document is changed so that the "pet" element occurs >>before the "daughter" element, a validation error is thrown. The error >>states that all instances of "pet" must occur after any instances of >>"daughter." >> >>This is the problem. I don't want the order of child elements within the >>"family" element to matter, or be validated. I don't care what order the >>father, mother, son, daughter, and pet tags are in, nor do I want to >>validate the order. >> >>How can I specify this in the XML schema? According to the documentation >>I've seen, the complexType tag must use an occurrence indicator of all, >>choice, or sequence. All might work, since order doesn't matter, but >>apparently it specifies that each child element can occur once and only >> >> >once > > >>once, which doesn't work. Choice doesn't work because only one of the >>elements can appear. Sequence might work because it allows me to specify >>multiple occurrences of child elements, but it enforces the order of the >>child elements, which I don't want. >> >>How can I specify this complex type in the XML schema? I'm sure it can be >>done, I'm just not sure how. >> >>Thank you very much!! >> >> >> >>This e-mail message is being sent solely for use by the intended >> >> >recipient(s) and may contain confidential information. Any unauthorized >review, use, disclosure or distribution is prohibited. If you are not the >intended recipient, please contact the sender by phone or reply by e-mail, >delete the original message and destroy all copies. Thank you. > > >>--------------------------------------------------------------------- >>To unsubscribe, e-mail: [EMAIL PROTECTED] >>For additional commands, e-mail: [EMAIL PROTECTED] >> >> >> >> >> > > >--------------------------------------------------------------------- >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] > >This e-mail message is being sent solely for use by the intended recipient(s) >and may contain confidential information. Any unauthorized review, use, >disclosure or distribution is prohibited. If you are not the intended >recipient, please contact the sender by phone or reply by e-mail, delete the >original message and destroy all copies. Thank you. > >--------------------------------------------------------------------- >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] > > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]