How to use the same element name for different purposes ( in XML and DTD ) ?
- by BugKiller
Hi,
I Want to create a DTD schema for this xml document:
<root>
<student>
<name>
<firstname>S1</firstname>
<lastname>S2</lastname>
</name>
</student>
<course>
<name>CS101</name>
</course>
</root>
as you can see , the element name in the course contains plain text ,but the element name in the student is complex type ( first-name, last-name ). The following is the DTD:
<!ELEMENT root (course|student)*>
<!ELEMENT student (name)>
<!ELEMENT name (lastname|firstname)>
<!ELEMENT firstname (#PCDATA)>
<!ELEMENT lastname (#PCDATA)>
<!ELEMENT course (name)>
When I want to validate it , I get an error because the course's name has different structure then the student's name .
My Question:
how can I make a work-around solution for this situation without changing the name of element name using DTD not xml schema .
Thanks.