Reputation: 341
I'm a new for XML and learning my first course right now.
What I have got the error is: when I validate my XML file it shows:
markup declaration expected
My XML and Internal DTD:
<?xml version="1.0" standalone="yes"?>
<!-- This is Internal DTD-->
<!DOCTYPE employee[
<!DOCTYPE head (title)>
<!DOCTYPE title EMPTY>
<!ELEMENT employee (body,details)+>
<!ELEMENT details (name, address, d_o_birth, d_o_join, phone, desig, dept, e_mail*)>
<!ELEMENT name EMPTY>
<!ATTLIST name gender (male | female) #REQUIRED>
<!ELEMENT address EMPTY>
<!ELEMENT d_o_birth EMPTY>
<!ELEMENT d_o_join EMPTY>
<!ELEMENT phone (resi,mobile)>
<!ELEMENT resi EMPTY>
<!ELEMENT mobile EMPTY>
<!ELEMENT desig EMPTY>
<!ELEMENT dept EMPTY>
<!ELEMENT e_mail (#PCDATA)>
]>
<employee>
<head>
<title>Employee Details</title>
</head>
<body>
<details>
<name>Name: Ismail Kedir
Gender: Male</name>
<address>: Jima, Kochi</address>
<d_o_birth>: 27/9/1976</d_o_birth>
<d_o_join>: 03/10/2005</d_o_join>
<phone>
<resi>: 2352</resi>
<mobile>: +251910178976</mobile>
</phone>
<desig>: Teacher</desig>
<dept>: JIT</dept>
<e_mail>Email: [email protected]</e_mail>
</details>
</body>
</employee>
Upvotes: 1
Views: 4343
Reputation: 52888
You're getting that error because you have DOCTYPE
declarations inside of your internal subset (between the [
and ]
). They should be ELEMENT
declarations (for the head
and title
elements).
However, that error is just the tip of the iceberg. I also noticed the following issues (there might be more):
details
is in the content model for employee
, but should be in the content model for body
.body
needs to be declared.#PCDATA
instead of EMPTY
: name
, title
, address
, d_o_birth
, d_o_join
, resi
, mobile
, desig
and dept
.gender="male"
should be added to name
in the instance (XML data itself).title
should be #PCDATA
instead of EMPTY
.#PCDATA
. You shouldn't need all of the labels (like Gender:
, Name:
, Email:
and the other extraneous :
). That seems to me more like presentation that would be handled by whatever system is consuming the XML.Here's a valid version that should get you started. (I did not do any data cleanup.)
<?xml version="1.0" standalone="yes"?>
<!-- This is Internal DTD-->
<!DOCTYPE employee [
<!ELEMENT head (title)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT employee (head,body)>
<!ELEMENT body (details)>
<!ELEMENT details (name, address, d_o_birth, d_o_join, phone, desig, dept, e_mail*)>
<!ELEMENT name (#PCDATA)>
<!ATTLIST name gender (male | female) #REQUIRED>
<!ELEMENT address (#PCDATA)>
<!ELEMENT d_o_birth (#PCDATA)>
<!ELEMENT d_o_join (#PCDATA)>
<!ELEMENT phone (resi,mobile)>
<!ELEMENT resi (#PCDATA)>
<!ELEMENT mobile (#PCDATA)>
<!ELEMENT desig (#PCDATA)>
<!ELEMENT dept (#PCDATA)>
<!ELEMENT e_mail (#PCDATA)>
]>
<employee>
<head>
<title>Employee Details</title>
</head>
<body>
<details>
<name gender="male">Name: Ismail Kedir
Gender: Male</name>
<address>: Jima, Kochi</address>
<d_o_birth>: 27/9/1976</d_o_birth>
<d_o_join>: 03/10/2005</d_o_join>
<phone>
<resi>: 2352</resi>
<mobile>: +251910178976</mobile>
</phone>
<desig>: Teacher</desig>
<dept>: JIT</dept>
<e_mail>Email: [email protected]</e_mail>
</details>
</body>
</employee>
Upvotes: 3