[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: DTD vs XSD: No Duplicate Types in (Mixed) Content Models
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] |
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|