[standards-jig] sequence vs. choice

David Waite mass at akuma.org
Wed Feb 6 23:22:20 UTC 2002


Hmm, if this is informational, we shouldn't go changing things now by 
saying that elements have to occur in a particular order :-)
1. elements within message/presence/iq can happen in any order
2. there may be rules about how many body/subject/etc tags you can have
3. there may be rules about XML contained within a body/subject/etc tag 
(only CDATA, no mixed data)

-David Waite

Peter Saint-Andre wrote:

>As I'm working on the schemas for the RFC, I'm wondering how we want to
>codify some of the XML. I think in the past we have not enforced sequence
>in the elements that are included within a <message/>, <presence/>, or
><iq/> chunk, nor (necessarily) the number of allowable instances of child
>elements. So for instance the following two chunks are both valid as far
>as I can see:
>
><presence 
>    from='maineboy66 at jabber.org/Gabber'
>    to='stpeter at jabber.org'>
>  <status>Automatically away due to being idle</status>
>  <show>xa</show>
>  <x xmlns='jabber:x:signed'>signedstatushere</x>
>  <x xmlns='gabber:x:music:info'>
>    <title>Awaken.mp3</title>
>    <state>playing</state>
>  </x>
></presence>
>
><presence
>    from='maineboy66 at jabber.org/Gabber'
>    to='stpeter at jabber.org'>
>  <x xmlns='gabber:x:music:info'>
>    <title>Awaken.mp3</title>
>    <state>playing</state>
>  </x>
>  <status>Automatically away due to being idle</status>
>  <x xmlns='jabber:x:signed'>signedstatushere</x>
>  <show>xa</show>
></presence>
>
>Do we want to enforce any given sequence of elements? Personally I would
>prefer that. The resulting schema snippet would look something like this:
>
>      <xsd:sequence>
>        <xsd:element ref='status' minOccurs='0' maxOccurs='1'/>
>        <xsd:element ref='priority' minOccurs='0' maxOccurs='1'/>
>        <xsd:element ref='show' minOccurs='0' maxOccurs='1'/>
>        <xsd:any namespace='##any' minOccurs='0' maxOccurs='unbounded'/>
>        <xsd:element ref='error' minOccurs='0' maxOccurs='1'/>
>      </xsd:sequence>
>
>(since <error/> elements seem to go at the end in current implementations)
>
>A similar snippet for <message/> would be:
>
>      <xsd:sequence>
>        <xsd:element ref='thread' minOccurs='0' maxOccurs='1'/>
>        <xsd:element ref='subject' minOccurs='0' maxOccurs='1'/>
>        <xsd:element ref='body' minOccurs='0' maxOccurs='1'/>
>        <xsd:any namespace='##any' minOccurs='0' maxOccurs='unbounded'/>
>        <xsd:element ref='error' minOccurs='0' maxOccurs='1'/>
>      </xsd:sequence>
>
>And for IQ:
>
>     <xsd:sequence>
>       <xsd:any namespace='##any' minOccurs='0' maxOccurs='unbounded'/>
>       <xsd:element ref='error' minOccurs='0' maxOccurs='1'/>
>     </xsd:sequence>
>
>However, right now sequence is not enforced in any way, so this would mean
>some current implementations would not comply with above snippets. (!)
>
>We could also stick with no enforced sequences, as so:
>
>     <xsd:choice minOccurs='0' maxOccurs='1'>
>       <xsd:element ref='body' />
>       <xsd:element ref='subject' />
>       <xsd:element ref='thread' />
>       <xsd:any namespace='##any' />
>       <xsd:element ref='error' />
>     </xsd:choice>
>
>XML schemas question: can do the following to override the maxOccurs on
>the <xsd:choice/> element?
>
>     <xsd:choice minOccurs='0' maxOccurs='1'>
>       <xsd:element ref='body' />
>       <xsd:element ref='subject' />
>       <xsd:element ref='thread' />
>       <xsd:any namespace='##any' minOccurs='0' maxOccurs='unbounded' />
>       <xsd:element ref='error' />
>     </xsd:choice>
>
>Let the flames begin.
>
>Peter
>
>--
>Peter Saint-Andre
>email+jabber: stpeter at jabber.org
>web: http://www.saint-andre.com/
>
>_______________________________________________
>Standards-JIG mailing list
>Standards-JIG at jabber.org
>http://mailman.jabber.org/listinfo/standards-jig
>




More information about the Standards mailing list