dtd help

James Robertson jwrober at linuxfromscratch.org
Tue Nov 4 08:27:31 PST 2003

Jamie Bennett wrote:

> Wow, lots of questions.
> James Robertson wrote on 04 November 2003 03:49
>>I am by no means an XML expert.  Can someone provide a quick intro to 
>>the DTD for me?  Here are my direct questions:
> --------------------------------------------------------------------------
>>1.  The entity 'ops' contains the elements: configure, copy, download, 
>>execute, link, make, mkdir, move, ownership, package, patch, 
>>permissions, remove, search_replace, stage, textdump, and unpack.  This 
>>entity is used in the elements alfs and stage. Do these 'ops' elements 
>>have some special level or purpose over other entities?  If so, I want 
>>to denote this in the syntax doc.
> Just means that alfs and stage can contain any number of the other elements,
> in no particular order.

Ok, that makes sense.
> --------------------------------------------------------------------------
>>2. What is the significance of a "*" in an element declaration.  e.g.
>><!ELEMENT alfs           ((%ops;)*)>
> '*' means an optional or repeatable occurrence %ops;
> --------------------------------------------------------------------------
>>What about a "?" e.g.
>><!ELEMENT download       (file, url*, destination, digest?)>
> '?' means that in this case digest is optional.

So in this case '*' means that url is optional (and if used) repeatable?
> --------------------------------------------------------------------------
>>WHat about a "+" e.g.
>><!ELEMENT copy           (option*, source+, destination)>
> '+' indicates a required and repeatable occurrence of, in this case, source.
> --------------------------------------------------------------------------
>>3. What is an ATTLIST?
> An ATTLIST is a attribute list. For example, the attributes of the following
> are name and age :-
> 	<person>
> 		<details name="Jamie Bennett" age="25">
> 			Overworked and Underpaid
Aren't we all :-)
> 		</details>
> 	</person>
> Attributes can contain strings (CDATA), tokenized attributes, indicated by
> declared tokens or enumerated attributes indicated by a choice of valid
> values.

What would the DTD of this example look like for comparison?  What would 
a tokenized attribute or a list of valid choices look like?
> --------------------------------------------------------------------------
>>4. Inside ATTLIST's we have CDATA and PCDATA entries.  CDATA seems to be 
>>able to have different stuff behind it.  What does #IMPLIED, #FIXED, 
>>#REQUIRED?  I think I know, but an official response would be good. 
>>What is PCDATA?
> These are just as they sound :-
> 	#IMPLIED = The attribute is optional.

But then, what is "impied" about it?  for example

<!ATTLIST alfs
           base           CDATA #IMPLIED
           version        CDATA #FIXED "3.1">

base is CDATA #IMPLIED. Does this mean it picks up base from a use 
elsewhere?  or this a function of how nALFS parses the profile against 
the DTD?  I see here a good example of the use of #FIXED.  This is 
pretty simple.

> 	#FIXED   = Provides a constant that the attribute must contain.
>                  If it doesn't then the document is invalid.
> 	#REQUIRED = The attribute must be provided.
> PCDATA is processed CDATA. CDATA is just a string that the parser does not
> attempt to resolve i.e. 
> 	<!ENTITY	name	"Jamie Bennett">
> 	<message output="Hello my name is &name;" />
> is interpreted just as above if the output attribute is CDATA. If it is
> PCDATA then the &name; will be resolved to Jamie Bennett.
> --------------------------------------------------------------------------
>>5. If a given element (a) contains in its definition other elements 
>>(like copy above), does that mean when you use that element (a) you have 
>>to have all the other elements in the profile?  e.g. you have to do:
>>	<option>...</option>
>>	<source>...</source>
>>	<destination>...</destination>
>>in a profile and if you don't, you'll produce an XML error?
> Only if the elements are required. In this case the dtd says
> <!ELEMENT copy           (option*, source+, destination)>
> The option* means that this is optional, the source+ means that
> this is required and the destination has no trailing symbol so 
> it can be omitted.

OK just to make sure I am on the same page.

'*' after an entity item (is that correct?) in an element definition 
means "optional and if used repeatable".

'+' after and entitiy item in an element definition means "required and 

'?' after and entitiy item in an element definition means "completely 
optional, does not have to be used at all"

and nothing after and entitiy item in an element definition means 
"completely optional, does not have to be used at all"  (this seems to 
be the same as '?')

CDATA is a string variable to be added to an ATTLIST

CDATA #IMLIED means that that attlist element does not have to be used.

CDATA #FIXED means that the attlist element does not have to be used 
becasue it is already defined.

CDATA #REQUIRED means that the attlist element has to be used.

PCDATA is processed CDATA and takes it's information/rules from the 
CDATA defintion by element.

> Hope that helps,
> Jamie

It did, thanks Jamie.

James Robertson -- jwrober at linuxfromscratch dot org
Reg. Linux User -- #160424 -- http://counter.li.org
Reg. LFS User   -- #6981   -- http://www.linuxfromscratch.org
LFS Bugzilla Maintainer    -- http://{blfs-}bugs.linuxfromscratch.org

More information about the alfs-discuss mailing list