[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Constrain the Number of Occurrences of Elements in your XM


Re:  Constrain the Number of Occurrences of Elements in your XM

Roger L. Costello wrote:

> Below I have jotted down a few thoughts regarding XML Schemas which permit
> an unbounded number of occurrences.  Namely, I recommend against using
> maxOccurs="unbounded" in an XML Schema.  I am interested in hearing your
> thoughts on this.

My thoughts lead to the exact opposite conclusion:
you should never use anything *except* maxOccurs="unbounded"
(or maxOccurs="1") in a schema.

With very few exceptions, any attempt to devise a suitable
upper bound for any 'maxOccurs' value is bound to involve
wild-ass-guessery.  How many paragraphs should one allow
in an HTML document?  You can take this from a business logic
standpoint ("what's the longest web page anyone is ever
going to want to produce"), or a processing standpoint
(how many <p> elements can Mozilla cope with?  What about
MSIE?  Does your answer change depending on how old the
user's computer is?), but you'll never be able to come up
with a satisfactory number.  Whatever number you choose
will either be too large as a meaningful resource constraint,
or it will be too small for some existing or future document.

What you advocate is reminiscent of the QUANTITY and CAPACITY
sections of the SGML declaration.  These were a perpetual annnoyance
(the SGML declaration was the first thing that got dumped
when XML was being designed), and as far as I know they
never did anybody any good (i.e., they were never an accurate
indication of how large a document any particular application
could actually handle).


> Recap
> 1.	Don't use maxOccurs="unbounded"
> 2.	Don't use recursive constructions
> 3.	Set maxOccurs to a number no larger than the amount of resources you
> have available

I'd argue the exact opposite, mostly because (3) is in
practice impossible to answer, and rarely worth even trying
to answer in the first place.

There are only three sensible cardinalities: zero, one, and many.
There are only four sensible cardinality constraints: mandatory,
optional, mandatory+repeatable and mandatory+optional.
(Corrolary: "?", "+", and "*" operators as found in DTDs and Relax NG
are far more appropriate than WXS' separate minOccurs= and maxOccurs=
attributes.)



--Joe English

  jenglish@f...

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.