<!ELEMENT page (other*|form|other*)>

will ONLY validate examples 3 & 4.

<!ELEMENT page (other*,form,other*)>

is what you probably meant but it will NOT validate examples 2 and 3
(no required form elements). By the way,

<!ELEMENT page (other*|form?|other*)>

will not work either but 

<!ELEMENT page (other*,form?,other*)>

will.  I'm sure that's what E. de Haan meant in the first place.


At any rate, the modified E. model is definitely non-deterministic.
Given an initial other element (or series of other elements), it is
not possible for the parser to determine which one(s) you are
referring to without looking to see if a form element exists.

It gets REALLY interesting when you start listing all of the
possible ways you could interpret this document:

<page>
        <other>A</other>
        <other>Z</other>
</page>

For example:

1) the first other element (A) and the second other element (Z) are part
of a single group represented by the first other* in the first definition
of page.

2) A is a member of the first other* and Z is a member of the second other*.

3) A and Z are both members of the second other*.


Sadly, this is just the nature of XML DTDs.  This is the only way to
represent the content model in question but according to the spec., it is
the wrong way!

However, if you read the spec. closely, you will notice that although "it
is required that content models in element type declarations be
deterministic" (Extensible Markup Language (XML) 1.0 (Second Edition),
Appendix E), it is NOT required that a parser report non-deterministic
models as an error.

Could it be that someone from the original design group actually realized
that DTDs were NOT going to be able to represent this scenario?  Perhaps
by "ignoring" the problem, they could allow parser writers to pick up the
slack?

NOTE: Xerces-J handles <!ELEMENT page (other*,form?,other*)> just fine.


-----Original Message-----
From: Hilary Bannister [mailto:[EMAIL PROTECTED]
Sent: Monday, April 02, 2001 6:20 PM
To: xerces user group
Subject: Re: Need help with DTD


Will this work as the solution:

<!ELEMENT page (other*|form?|other*)>

as it is non-deterministic and I am led to believe that every content model
must
be deterministic.  Am I wrong?

 <!ELEMENT page (other*|form|other*)>

is deterministic because the form is required so you know which set the
"other" instances belong to.  The above optional version cannot determine
which set the "other" instances belong to if the form is missing.



----- Original Message -----
From: E. de Haan <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: 01 April 2001 11:42
Subject: Re: Need help with DTD


> ----- Original Message -----
> From: "callista" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Monday, April 02, 2001 9:53 AM
> Subject: Need help with DTD
>
> > Hi, I'm having problem creating a DTD to do what I need it to do.
> >
> > Here's what I need.
> > Page element can have one/zero form element or zero/many other element.
> >
> > Examples:
> > One:
> > <page>
> >   <other></other>
> >   <other></other>
> >   <form></form>
> >   <other></other>
> > </page>
> >
> > Two:
> > <page></page>
> >
> > Three:
> > <page>
> >   <other></other>
> >   <other></other>
> > </page>
> >
> > Four:
> > <page>
> >   <form></form>
> > </page>
> >
> > All the above should be valid. As long as there is more than one <form>
> > tag, it's invalid.
> > i.e: <page>
> >        <form></form>
> >        <form></form>
> >      </page>
> > Should generate a ParseError. If possible, I would like the example
below
> > to generate an error as well.
> > <page>
> >   <other>
> >     <form></form>
> >   </other>
> >   <form></form>
> > </page>
> >
> > I was going along the line of <!ELEMENT page (form?|other*)> but only
> > examples 2 - 3 will be valid and not example 1. If I write it as
<!ELEMENT
> > page (form?|other*)*>, it's valid for examples 1-4 but it is also valid
> for
> > the invalid multiple <form> tag example.
> >
> > Can anyone help?  Callista
> > ---------------------------------------------------------------------
>
> In my opinion example 1 should be invalid,
>
> <!ELEMENT page (form?|other*)>
>
> but you can achieve what you want using:
>
> <!ELEMENT page (other*|form?|other*)>
>
> i think you missed this for exactly the reason
> i think it should not be used.
>
> Eric.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





======================= Confidentiality Statement ======================= 
The information contained in this message and any attachments is 
intended only for the use of the individual or entity to which it is 
addressed, and may contain information that is PRIVILEGED, CONFIDENTIAL 
and exempt from disclosure under applicable law.  If you have received 
this message in error, you are prohibited from copying, distributing, or 
using the information.  Please contact the sender immediately by return 
e-mail and delete the original message from your system. 
===================== End Confidentiality Statement =====================  



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to