[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

  • From: "G. Ken Holman" <gkholman@CraneSoftwrights.com>
  • To: xml-dev@lists.xml.org,xmlschema-dev-request@w...
  • Date: Mon, 31 Jan 2011 08:36:09 -0500

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!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.