How to use the same element name for different purposes ( in XML and DTD ) ?
Posted
by BugKiller
on Stack Overflow
See other posts from Stack Overflow
or by BugKiller
Published on 2010-05-30T02:19:38Z
Indexed on
2010/05/30
3:22 UTC
Read the original article
Hit count: 270
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.
© Stack Overflow or respective owner