dtd newbie

L

Larry

Hi all,

I'm quite a XML/XSL/DTD newbie, is this DOCTYPE correct? thanks

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="stile.xsl"?>
<!DOCTYPE catalog
[
<!ELEMENT catalog (cd+)>
<!ELEMENT cd (title,artist,country,company,price,year)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT artist (#PCDATA)>
<!ELEMENT country (#PCDATA)>
<!ELEMENT company (#PCDATA)>
<!ELEMENT price (#PCDATA)>
<!ELEMENT year (#PCDATA)>
]>

<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
<cd>
<title>Hide your heart</title>
<artist>Bonnie Tyler</artist>
<country>UK</country>
<company>CBS Records</company>
<price>9.90</price>
<year>1988</year>
</cd>
</catalog>
 
M

Martin Honnen

Larry wrote:

I'm quite a XML/XSL/DTD newbie, is this DOCTYPE correct? thanks

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="stile.xsl"?>
<!DOCTYPE catalog
[
<!ELEMENT catalog (cd+)>
<!ELEMENT cd (title,artist,country,company,price,year)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT artist (#PCDATA)>
<!ELEMENT country (#PCDATA)>
<!ELEMENT company (#PCDATA)>
<!ELEMENT price (#PCDATA)>
<!ELEMENT year (#PCDATA)>
]>

<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>

Technically the DTD you have written is fine for the XML instance
document, the DTD is syntatically correct and its semantics models the
structure of the XML instance.

As for modelling a CD list however there might be more complex
scenarios, what happends if there is a CD done by multiple artists for
instance. And what currency is the price value for?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top