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.
`. Element `
` may contain either element ``, or elements `` and ``. We can specify this, it just won't be contextual (ie, dependant of `
– Sandy Gifford Apr 18 '13 at 18:48`'s parent). `<!ELEMENT p (a | (b, c))>`. PCDATA has to be used as mixed content or all by itself; it can't be an either/or situation, unfortunately.