Validate Online: http://xmlvalidator.new-studio.org
XML Document (also displayed below)
Question 1
Why the following 6 Errors shows?
- Line 29 Column 18 : Attribute value "1" of type ID must be a name.
- Line 34 Column 22 : Attribute "type" must be declared for element type "dob".
- Line 39 Column 26 : Attribute "type" must be declared for element type "address".
- Line 49 Column 18 : Attribute value "2" of type ID must be a name.
- Line 54 Column 22 : Attribute "type" must be declared for element type "dob".
- Line 59 Column 27 : Attribute "type" must be declared for element type "address".
Question 2
When I uncomment the following line no. 4
<!ELEMENT persona (name,dob?,address*) >
AND comment the following line no. 5
<!ELEMENT name (first_name,last_name) >
Why the following error shows?
- Line 4 Column 28 : An element type is required in the declaration of element type "persona".
The XML Document with embedded DTD
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE personality [
<!ELEMENT personality (persona*) >
<!-- <!ELEMENT persona (#PCDATA|(name,dob?,address*))> -->
<!ELEMENT persona (name,dob?,address*) >
<!ELEMENT name (first_name,last_name) >
<!ELEMENT first_name (#PCDATA) >
<!ELEMENT last_name (#PCDATA) >
<!ELEMENT dob (date+,month+,year+) >
<!ELEMENT date (#PCDATA) >
<!ELEMENT month (#PCDATA) >
<!ELEMENT year (#PCDATA) >
<!ELEMENT address (building,street,city,state,country,country_code) >
<!ELEMENT building (#PCDATA) >
<!ELEMENT street (#PCDATA) >
<!ELEMENT city (#PCDATA) >
<!ELEMENT state (#PCDATA) >
<!ELEMENT country (#PCDATA) >
<!ELEMENT country_code (#PCDATA) >
<!ATTLIST persona id ID #REQUIRED >
<!ATTLIST name type (string|number) "string" >
]>
<?xml-stylesheet type="text/css" href="xmlstyle.css" ?>
<personality>
<persona id="1">
<name type="string">
<first_name>Abhisek</first_name>
<last_name>Pattnaik</last_name>
</name>
<dob type="number">
<date>29</date>
<month>8</month>
<year>1990</year>
</dob>
<address type="string">
<building>Plot-471</building>
<street>Sahid Nagar</street>
<city>Bhubaneswar</city>
<state>Odisha</state>
<country>India</country>
<country_code>91</country_code>
</address>
</persona>
<persona id="2">
<name type="string">
<first_name>Anindita</first_name>
<last_name>Patnaik</last_name>
</name>
<dob type="number">
<date>5</date>
<month>12</month>
<year>1996</year>
</dob>
<address type="string">
<building>Plot-471</building>
<street>Sahid Nagar</street>
<city>Bhubaneswar</city>
<state>Odisha</state>
<country>India</country>
<country_code>91</country_code>
</address>
</persona>
</personality>