Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Attribute value "001" of type ID must be an NCName when namespaces are enabled

Tags:

xml

dtd

So i'm creating a xml file with my own DTD.

The simplified XML is as follows:

<!DOCTYPE catalog [
<!ELEMENT catalog (product+)>
<!ELEMENT product (title?, price, creation_date?, weight?, color, description?)>
<!ELEMENT creation_date (day, month, year)>

<!ATTLIST product category (art|dinner_set|ovenware) "art">
<!ATTLIST product id ID #REQUIRED>

<!ELEMENT id (#PCDATA)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT price (#PCDATA)>
<!ELEMENT day (#PCDATA)>
<!ELEMENT month (#PCDATA)>
<!ELEMENT year (#PCDATA)>
<!ELEMENT weight (#PCDATA)>
<!ELEMENT color (#PCDATA)>
<!ELEMENT description (#PCDATA)>
]>

<?xml-stylesheet type="text/xsl" href="test.xsl"?>
<catalog>
    <product category="art" id="001">
        <title>1Blue Sculpture</title>
        <price>$2000</price>
        <creation_date>
            <day>11</day>
            <month>08</month>
            <year>2014</year>
        </creation_date>
        <weight>257g</weight>
        <color>Green</color>
        <description>A beutiful Green Sculpture</description>
    </product>

When i try and run it through a XML Validater i get an error "Attribute value "001" of type ID must be an NCName when namespaces are enabled." for each of the id attributes.

I've mucked around with it for awhile and it seems to not allow numerals, letters are fine and it passes without any problems, but as soon as you set id="(any numbers)" it gives me the error.

Im a complete XML NOOB, so i'm guessing its something simple, i searched around but couldnt find anything definitive that was easy to do/undertsand.

like image 668
Joel Avatar asked Aug 12 '14 05:08

Joel


2 Answers

Yes, the problem is the attribute value 001. Attribute values of type ID must match the Name production of the XML grammar, which means that digits (and some other characters) are disallowed as initial characters.

Attribute values such as x001 or id_001 are OK.

References:

  • http://www.w3.org/TR/xml/#sec-attribute-types
  • http://www.w3.org/TR/xml/#sec-common-syn
like image 97
mzjn Avatar answered Sep 28 '22 07:09

mzjn


Add NCName to your Attlist element like this :

!ATTLIST complexe code ID NCName #REQUIRED 
like image 26
Mahdi Elhajuojy Avatar answered Sep 28 '22 06:09

Mahdi Elhajuojy