Need to make a dtd for this xml code. There seems to be errors that come up, tryed it on w3 xml validator and it gives an error message.

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE Timetable [
<!ELEMENT Timetable (week, timecode)>
<!ELEMENT week (day)>
<!ELEMENT timecode (time)>
<!ELEMENT time (#PCDATA)>
<!ELEMENT day (#PCDATA)>
<!ATTLIST day id CDATA #IMPLIED>
<!ATTLIST time id CDATA #IMPLIED>
]>

<Timetable>
<week>
<day id="mo">Monday</day>
<day id="tu">Tuesday</day>
<day id="we">Wednesday</day>
<day id="th">Thursday</day>
<day id="fr">Friday</day>
<day id="sa">Saturday</day>
<day id="su">Sunday</day>
</week>
<timecode>
<time id="9">09.00</time>
<time id="10">10.00</time>
<time id="11">11.00</time>
<time id="12">12.00</time>
<time id="1">1.00</time>
<time id="2">2.00</time>
<time id="3">3.00</time>
<time id="4">4.00</time>
</timecode>
</Timetable>

I wanted a tree structure which shows timetable> week > day > time
but couldn't get it work. If its possible to do this then be much appreciated.

http://www.xmlfiles.com/dtd/dtd_elements.asp
you use this

Declaring only one occurrence of the same element

one or more use this

Declaring minimum one occurrence of the same element

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE Timetable [
<!ELEMENT Timetable (week,timecode)>
<!ELEMENT week (day+)>
<!ELEMENT timecode (time+)>
<!ELEMENT time (#PCDATA)>
<!ELEMENT day (#PCDATA)>
<!ATTLIST day 
	id CDATA #IMPLIED >
<!ATTLIST time 
	id CDATA #IMPLIED >
]>
<Timetable>
	<week>
		<day id="mo">Monday</day>
		<day id="tu">Tuesday</day>
		<day id="we">Wednesday</day>
		<day id="th">Thursday</day>
		<day id="fr">Friday</day>
		<day id="sa">Saturday</day>
		<day id="su">Sunday</day>
	</week>
	<timecode>
		<time id="9">09.00</time>
		<time id="10">10.00</time>
		<time id="11">11.00</time>
		<time id="12">12.00</time>
		<time id="1">1.00</time>
		<time id="2">2.00</time>
		<time id="3">3.00</time>
		<time id="4">4.00</time>
	</timecode>
</Timetable>

Hi thanks for the tips it worked. I was wondering if you could or anyone else help with something else related to what was displayed previously. What I want to do is how can i relate the code to incorporate a namespace. I am able to do namespace by itself with the xml file but not with a dtd, how can i incorporte both to work together.

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE Timetable [
<!ELEMENT Timetable (week,timecode)>
<!ELEMENT week (day+)>
<!ELEMENT timecode (time+)>
<!ELEMENT time (#PCDATA)>
<!ELEMENT day (#PCDATA)>
<!ATTLIST day 
                id CDATA #IMPLIED >
<!ATTLIST time 
	id CDATA #IMPLIED >
]>
<xp:Timetable xmlns:xp="http://www.xp.com">
	<xp:week>
		<xp.day id="mo">Monday</xp.day>
		<xp.day id="tu">Tuesday</xp.day>
		<xp.day id="we">Wednesday</xp.day>
		<xp.day id="th">Thursday</xp.day>
		<xp.day id="fr">Friday</xp.day>
		<xp.day id="sa">Saturday</xp.day>
		<xp.day id="su">Sunday</xp.day>
	</xp:week>
	<xp:timecode>
		<xp.time id="9">09.00</xp.time>
		<xp.time id="10">10.00</xp.time>
		<xp.time id="11">11.00</xp.time>
		<xp.time id="12">12.00</xp.time>
		<xp.time id="1">1.00</xp.time>
		<xp.time id="2">2.00</xp.time>
		<xp.time id="3">3.00</xp.time>
		<time id="4">4.00</time>
	<xp:timecode>
</xp:Timetable>

All tags with namespace must be defined namespace in the DTD

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE xp:Timetable [
<!ELEMENT xp:Timetable (xp:week,xp:timecode)>
<!ATTLIST xp:Timetable
	xmlns:xp CDATA #FIXED "http://www.xp.com" >
<!ELEMENT xp:week (xp:day)+>
<!ELEMENT xp:timecode (xp:time)+>
<!ELEMENT xp:time (#PCDATA)>
<!ELEMENT xp:day (#PCDATA)>
<!ATTLIST xp:day 
	id CDATA #IMPLIED >
<!ATTLIST xp:time 
	id CDATA #IMPLIED >
]>
<xp:Timetable xmlns:xp="http://www.xp.com">
	<xp:week>
		<xp:day id="mo">Monday</xp:day>
		<xp:day id="tu">Tuesday</xp:day>
		<xp:day id="we">Wednesday</xp:day>
		<xp:day id="th">Thursday</xp:day>
		<xp:day id="fr">Friday</xp:day>
		<xp:day id="sa">Saturday</xp:day>
		<xp:day id="su">Sunday</xp:day>
	</xp:week>
	<xp:timecode>
		<xp:time id="9">09.00</xp:time>
		<xp:time id="10">10.00</xp:time>
		<xp:time id="11">11.00</xp:time>
		<xp:time id="12">12.00</xp:time>
		<xp:time id="1">1.00</xp:time>
		<xp:time id="2">2.00</xp:time>
		<xp:time id="3">3.00</xp:time>
		<xp:time id="4">4.00</xp:time>
	</xp:timecode>
</xp:Timetable>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.