Re: Relax, TRex?

From: Richard Knapp (gyp_caver@yahoo.com)
Date: Wed Mar 14 2001 - 04:25:31 CET


>> As my test DTD develops, I'm finding there are some capabilities missing in the
>>DTD spec which might cause problems when using it.

>It would be useful if you listed the problems for people to attempt to provide answers
>for/ query relevance of

If I understand what you are asking, it is this. Within a list of elements, you have two options: specify the order
so you can ensure the correct number of child elements or not specify the order but not have control over the
number of children. For example, Element Base consists of the children First, Second, Third, and Fourth. The
following requirement apply:

- First must appear;
- Second may appear zero or one time;
- Third may appear zero or one time;
- Fourth may appear zero or one time;
- Order is not important.

(FWIW I asked this same question on xml-dev if you want to see the responses I got there (groups.
yahoo.com).

So a shot at the DTD looks like:

<!ELEMENT Base (First, Second?, Third?, Fourth?)>

which is the first case: order defined to control the number of children. Or you could do

<!ELEMENT Base (First, (Second | Third | Fourth)*)>

which is part of the second: order not enforced but no control on the number of children.

This pattern appears for the shot data mainly (other places too but most annoyingly in the shot) when you try
to allow flexible data order. For instance, if the shot is defined as

<!ELEMENT Shot (Station, Station, Azimuth, Distance, Inclination)>

there is really no reason the second station must occur after the first. So it could be:

<!ELEMENT Shot (Station, Station?, Azimuth, Distance, Inclination, Station?)>

however the control over the children is starting to slip. If could be as loose as:

<!ELEMENT Shot (Station (Station | Azimuth | Distance | Inclination)+>

but now someone could enter any number of stations (bad), azimuth, inclination readings (okay) or distances
(hmmmm...).

To a point, I'm leaning a little more in favor of a semi imposed order since I have also included a Format
element to control the display of the elements (in a special editor, not something like Xeena or XMLSpy).

Unfortunately, the designers of XML and DTDs (and it appears XMLSchema) did not include the "&" that
SGML supported for just this purpose.

Anyway, that's probably enough for now but that is the gist of what I'm running up against.

>Don't know about that but XEENA will produce a (first-cut) XML Schema corresponding to a DTD.
>Also, did you know that SAXON has a utility to produce a DTD corresponding to an XML file that you give
it?

Assuming, of course, you provide a valid XML document... Catch 22? I haven't tried converting the DTD to a
Schema yet. Thanks for lettiing me know tho'.

        - Richard Knapp

_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com



This archive was generated by hypermail 2b30 : Mon Apr 02 2001 - 18:00:01 CEST