2

Validate Online: http://xmlvalidator.new-studio.org

XML Document (also displayed below)

Question 1

Why the following 6 Errors shows?

  1. Line 29 Column 18 : Attribute value "1" of type ID must be a name.
  2. Line 34 Column 22 : Attribute "type" must be declared for element type "dob".
  3. Line 39 Column 26 : Attribute "type" must be declared for element type "address".
  4. Line 49 Column 18 : Attribute value "2" of type ID must be a name.
  5. Line 54 Column 22 : Attribute "type" must be declared for element type "dob".
  6. 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>
Community
  • 1
  • 1
abhisekp
  • 4,648
  • 2
  • 30
  • 37
  • https://stackoverflow.com/questions/25256989/attribute-value-001-of-type-id-must-be-an-ncname-when-namespaces-are-enabled?noredirect=1&lq=1 – Sai Sanjay Nagarur Feb 06 '20 at 07:28

1 Answers1

4
Line 29 Column 18 : Attribute value "1" of type ID must be a name.
Line 49 Column 18 : Attribute value "2" of type ID must be a name.

The value of an attribute of type ID cannot start with a digit. It must match the Name production in the XML specification, which rules out initial digits.


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".

You haven't declared a type attribute for the dob and address elements.


<!ELEMENT persona (#PCDATA|(name,dob?,address*))>

This (commented out in your DTD above) is an illegal declaration. The following would be OK (but may not be what you want):

<!ELEMENT persona (#PCDATA|name|dob|address)*>

For information on the constraints regarding "mixed content", see

mzjn
  • 48,958
  • 13
  • 128
  • 248