Altova Mailing List Archives


Re: DTD for Newbie

From: Peter Flynn <peter.nosp@-.--------.-->
To: NULL
Date: 11/17/2005 10:38:00 PM
boaz wrote:

> Hi,
> 
> Couple posts below, I asked if anyone would recommend any book for
> newbie. Priscilla suggested his book but it was 4 years old.

Actually that probably makes very little difference for a beginner.
With a few very minor technical details, the XML that was defined
in 1996 is the XML we use today, so any decent book on XML post-1996
is likely to be perfectly usable.

> So, instead, I bought the 2004 _Beginning XML_ and the 2001 _XML
> Weekend Crash Course_.
> 
> I have been reading the Crash Course but something is not clear to me.
> Would you guys help me please?
> Thanks!
> 
> This is a DTD from page 105:
> 
> <!ELEMENT family (father, mother, offspring?)>
> <!ELEMENT father (#PCDATA | surname)*>
> .
> .
> .
> <!ELEMENT surname (#PCDATA)>
> 
> It says that the family tag 

Element, not tag. See http://xml.silmaril.ie/authors/makeup/

> requires <father> and <mother>. 

And, optionally, one offspring element.

> It is not clear to me what the second line wants.
> Isn't the second line says that <father> is optional or can be empty?

No, father is made compulsory by its inclusion in the content model
for family, because it is not qualified by a ? or *.

The father element can contain any mix of plain text and surname
elements, eg <father>Thomas George Arthur 
<surname>Williams</surname></father>. This is a rather odd way to 
define it, but that's a data-modelling problem, not an XML one.
The oddity is that the * means "any number of", so a surname element
is not compulsory, and it could occur more than once, or not at all,
so <father/> and <father>Fred</father> are both correct, so is 
<father>Ranulph <surname>Twistleton</surname> <surname>Wykeham</surname> 
<surname>Fiennes</surname></father> :-)

> It is not clear to me becasue the first line says that <father> is
> "phyically" required but the second line says that <father> is...
> huh... "logically" optional.

No. The second line says the *content* of father is optional.
The father element must be present but it may be empty.

> i.e.:
> You still need the <father> tag but it can be empty.

Correct.

> <family>
> <father></father>
> <mother>my_mother</mother>
> <offspring>child1</offspring>
> </family>

It should be <!ELEMENT family (father, mother, offspring*)> if you
want to allow parents to have more than one child.

You're doing well, keep going :-)

///Peter
-- 
XML FAQ: http://xml.silmaril.ie/

Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.