LISTSERV mailing list manager LISTSERV 15.5

Help for XML-L Archives

XML-L Archives

XML-L Archives


Next Message | Previous Message
Next in Topic | Previous in Topic
Next by Same Author | Previous by Same Author
Chronologically | Most Recent First
Proportional Font | Monospaced Font


Join or Leave XML-L
Reply | Post New Message
Search Archives

Subject: Re: 'choice' element in scemas
From: "G. Ken Holman" <[log in to unmask]>
Reply-To:General discussion of Extensible Markup Language <[log in to unmask]>
Date:Fri, 5 Dec 2003 08:00:09 -0500

text/plain (49 lines)

At 2003-12-04 23:23 +0000, Neil Evans wrote:
>I'm new to XML, and I'm a bit confused as to the use of the 'choice' element
>within a schema. I understand that it details a list of child elements, and
>will allow one of those child elements to be used, and no more than one.


>But, is it valid to add a 'MinOccurs=0' attribute to each child element,
>therefore allowing none of the child elements to be used?

Yes.  By doing so the designer has allowed that no children will
successfully satisfy the content model constraints.  Personally I don't
ever do this because it is ambiguous ... when I want no children allowed
for a choice I typically make the choice optional and each of the children
mandatory, as that (to me) more accurately reflects the semantics I want: I
usually want the choice optional, but when the user does choose to include
the choice I don't want them to then be able to choose nothing.  What would
this mean to a processing application?

This question has been around since the early days of SGML because one can
do this with DTDs.

>I have seen this
>in a schema that has been defined for my latest project at work, and I'm not
>sure if this is valid.

It is not incorrect, but whether it accurately reflects the desired
information modeling choice being presented as a constraint on the
structure of an instance can only be answered by the people who know your
information best.

I hope this helps.

......................... Ken

Next public European delivery:  3-day XSLT/2-day XSL-FO 2004-01-??
Instructor-led on-site corporate, government & user group training
for XSLT and XSL-FO world-wide:  please contact us for the details

G. Ken Holman                 mailto:[log in to unmask]
Crane Softwrights Ltd.
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
ISBN 0-13-065196-6                       Definitive XSLT and XPath
ISBN 0-13-140374-5                               Definitive XSL-FO
ISBN 1-894049-08-X   Practical Transformation Using XSLT and XPath
ISBN 1-894049-11-X               Practical Formatting Using XSL-FO
Member of the XML Guild of Practitioners:
Male Breast Cancer Awareness

Back to: Top of Message | Previous Page | Main XML-L Page



CataList Email List Search Powered by the LISTSERV Email List Manager