W3C home > Mailing lists > Public > xmlschema-dev@w3.org > October 2008

inquiry into the <choice> element behavior

From: <Jeffrey.Kramer@dds.net>
Date: Thu, 30 Oct 2008 14:45:28 -0400
To: xmlschema-dev@w3.org
Message-ID: <OFBB96C594.7F1F5F03-ON852574F2.0066A4DF-852574F2.00670A4D@donovandata.com>
We were hoping to get a definitive answer on how the <choice> element is 
supposed to behave. 

We observed kind of a counter intuitive result of choice in a test.  i.e., 
we'd think it was going to be mutually exclusive across it's elements, 
although when we provided >1 types it actually spit out both ( see below )

i.e., 

providing
....
        <foo>1</foo>
        <foo>2</foo>
        <bar>3</bar>
...
to 
..
         <xs:choice  maxOccurs="unbounded">
            <xs:element name="foo" type="xs:string" />
            <xs:element name="bar" type="xs:string" />
       </xs:choice>

yields:
 
2008-10-30 11:55:17,726 main DEBUG xml.UnmarshalHandler - #startElement: 
foo
2008-10-30 11:55:17,726 main DEBUG xml.UnmarshalHandler - #characters: 1
2008-10-30 11:55:17,726 main DEBUG xml.UnmarshalHandler - #endElement: foo
 
2008-10-30 11:55:17,726 main DEBUG xml.UnmarshalHandler - #startElement: 
foo
2008-10-30 11:55:17,726 main DEBUG xml.UnmarshalHandler - #characters: 2
2008-10-30 11:55:17,726 main DEBUG xml.UnmarshalHandler - #endElement: foo
 
2008-10-30 11:55:17,726 main DEBUG xml.UnmarshalHandler - #startElement: 
bar
2008-10-30 11:55:17,726 main DEBUG xml.UnmarshalHandler - #characters: 3
2008-10-30 11:55:17,726 main DEBUG xml.UnmarshalHandler - #endElement: bar


We were kind of thinking the choice would somehow be limited to only one 
of nested elements.  Perhaps we're misusing the maxOccurs?   Any insights 
greatly appreciated.  Thanks in advance. 

- Jeff
Received on Thursday, 30 October 2008 22:00:19 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:15:08 GMT