Jazztronik
Programmer
Hi, I'm new to XML, and I have to do an exercise which simulates values related to the state of a traffic light.
This is the DTD I wrote:
<?xml version"1.0" encoding="utf-8"?>
<!DOCTYPE trafficLights[
<!ELEMENT trafficLights (trafficLight+)>
<!ELEMENT trafficLight (#PCDATA)>
<!ATTLIST trafficLight State (red | yellow | green) "green">
]>
And here's an example I made which matches the DTD:
<trafficLights>
<trafficLight State="red">1</trafficLight>
<trafficLight State="yellow">2</trafficLight>
<trafficLight State="red">3</trafficLight>
<trafficLight State="green">4</trafficLight>
<trafficLight State="green">5</trafficLight>
</trafficLights>
Well, I guess it's written correctly, but what I actually want to know is if there's another better way to perform this exercise. For instance, is it better to identify each traffic light with numbers between tags like I made? or by using an attribute?
Any help would be really appreciated!
This is the DTD I wrote:
<?xml version"1.0" encoding="utf-8"?>
<!DOCTYPE trafficLights[
<!ELEMENT trafficLights (trafficLight+)>
<!ELEMENT trafficLight (#PCDATA)>
<!ATTLIST trafficLight State (red | yellow | green) "green">
]>
And here's an example I made which matches the DTD:
<trafficLights>
<trafficLight State="red">1</trafficLight>
<trafficLight State="yellow">2</trafficLight>
<trafficLight State="red">3</trafficLight>
<trafficLight State="green">4</trafficLight>
<trafficLight State="green">5</trafficLight>
</trafficLights>
Well, I guess it's written correctly, but what I actually want to know is if there's another better way to perform this exercise. For instance, is it better to identify each traffic light with numbers between tags like I made? or by using an attribute?
Any help would be really appreciated!