[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]
Re: [xml-dev] DTD vs XSD: No Duplicate Types in (Mixed) Content Models
- From: "G. Ken Holman" <gkholman@CraneSoftwrights.com>
- To: xml-dev@lists.xml.org,xmlschema-dev-request@w3.org
- Date: Mon, 31 Jan 2011 08:36:09 -0500
At 2011-01-31 13:56 +0100, Maik Stührenberg wrote:
>One of my students asked me if it wouldn't be
>easy to simulate XML Schema's minOccurs and
>maxOccurs by repeating the same element type
>(element name) in the content model of its parent element, e.g.:
>
><!ELEMENT a (b, b, b)>
><!ELEMENT b EMPTY>
...
>All three solutions were tolerated by the
>parsers I've tried. For simulating
>minOccurs="3", maxOccurs="5" one could use the following DTD solution:
>
><!ELEMENT a (b, b, b, b?, b?)>
><!ELEMENT b EMPTY>
>
>To my suprise, I had no problems with the parsers I've tried.
That surprises me as well, for the very reason you cited:
>The interesting case is, if I have exact four
>occurrences of the element b in an instance,
>resulting that my parser cannot know which b in the model is being matched.
Exactly.
>Was this behaviour expected?
Yes, I believe so, because of the ambiguous particles ... which way to go.
But have you tried, for minOccurs="3" and
maxOccurs="5" the W3C Schema equivalent of the following:
<!ELEMENT a (b, b, b, (b, b?)?)>
That combination is not ambiguous but gives you
what you want. There is no doubt which of the
<b> elements is being encountered.
I hope this helps.
. . . . . . . . Ken
--
Contact us for world-wide XML consulting & instructor-led training
Crane Softwrights Ltd. http://www.CraneSoftwrights.com/x/
G. Ken Holman mailto:gkholman@CraneSoftwrights.com
Legal business disclaimers: http://www.CraneSoftwrights.com/legal
[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]