80887

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

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.

Answer1:

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:

Recommend

  • XML validation against DTD
  • Circular dependency resolution with bison generated file
  • Why is this Haxe try-catch block still crashing, when using Release mode for C++ target
  • how to create pretty urls
  • XML file with DTD displays fine in web browser after invalid change
  • finding maximum depth of chapter
  • Duplicate Element x number of times with XSLT
  • NetBeans doesn't see style.css [duplicate]
  • how to display   in Mozilla using XSL.
  • How to add regEx in angular filter
  • Basic defensive programming [duplicate]
  • XSLT foreach repeating nodes to flat
  • Does Mobilefirst provide a provision to access web services directly?
  • Adjust width of select element according to selected option's width
  • Jquery UI tool tip close icon
  • Pass value from viewmodel to script in zk
  • Using $this when not in object context
  • Sails.js/waterline: Executing waterline queries in toJSON function of a model?
  • java.lang.NoClassDefFoundError: com.parse.Parse$Configuration$Builder on below Lollipop versions
  • Deselecting radio buttons while keeping the View Model in synch
  • Getting last autonumber in access
  • Counter field in MS Access, how to generate?
  • Incrementing object id automatically JS constructor (static method and variable)
  • How to check if every primary key value is being referenced as foreign key in another table
  • MySQL WHERE-condition in procedure ignored
  • Can I have the cursor start on a particular column by default in jqgrid's edit mode?
  • jquery mobile loadPage not working
  • Web-crawler for facebook in python
  • How to delete a row from a dynamic generate table using jquery?
  • json Serialization in asp
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • Codeigniter doesn't let me update entry, because some fields must be unique
  • trying to dynamically update Highchart column chart but series undefined
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • How do I configure my settings file to work with unit tests?
  • How to stop GridView from loading again when I press back button?
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • Does armcc optimizes non-volatile variables with -O0?
  • Binding checkboxes to object values in AngularJs
  • java string with new operator and a literal