- From: Michael Kay <mike@saxonica.com>
- Date: Thu, 30 Oct 2008 22:10:52 -0000
- To: <Jeffrey.Kramer@dds.net>, <xmlschema-dev@w3.org>
- Message-ID: <802A53DF48434C3F8F4DCAC12E6C5DE9@Sealion>
If you had maxOccurs="1", you would be limited to a single element, which
must be a foo or a bar. But with maxOccurs="unbounded", you can have any
number of elements, each of which must be either a foo or a bar. If you
moved the maxOccurs to the xs:element elements, then you would be allowed
any number of elements so long as they are all foo elements, or all bar
elements, but not a mixture.
If you're familiar with BNF grammars, what you have written is
(foo | bar)*
whereas it seems you might want
(foo* | bar*)
Michael Kay
_____
From: xmlschema-dev-request@w3.org [mailto:xmlschema-dev-request@w3.org] On
Behalf Of Jeffrey.Kramer@dds.net
Sent: 30 October 2008 18:45
To: xmlschema-dev@w3.org
Subject: inquiry into the <choice> element behavior
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:11:34 UTC