Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

NMTOKEN vs ID

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If attribute type declared as NMTOKEN or ID what values can both of them accept. In other words what is the difference between NMTOKEN and ID.
'12345-09' is a valid NMTOKEN but not valid ID. Because ID has to be XML name. Isn't this true with NMTOKEN ?
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note '12345-09' is not a valid XML name as the first character is a number (Name1 character restriction)
ID type attributes must fully comply to XML Name restrictions whereas Nametokens comply to all ex cept the Name1 char restriction for XML Names.
 
Nitin Gogia
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Karthik:
I did not get you when u say "NMTOKEN comply to all" except Name1 char restriction. Does it mean that NMTOKEN has to be in XML name syntax except that the 1st character can be a number, dot, hyphen etc.
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Nitin,
The syntax of XML1.0 is expressed in EBNF to avoid ambiguity and confusion. The production for Name and Nmtoken are the following:
[4] NameChar ::= Letter | Digit | '.' | '-' | '_' | ':' | CombiningChar | Extender
[5] Name ::= (Letter | '_' | ':') (NameChar)*
[7] Nmtoken ::= (NameChar)+
The EBNF notation is quite easy to learn. If you are not familiar with EBNF, I highly recommend that you read Section 6 of the XML specification which contain an EBNF primer.
Once you understand the EBNF notation, the grammar of XML1.0 becomes clear. Other specs like XPath are also expressed in EBNF. I always start my XML classes my explaining EBNF. My experience is that it works very well.

----------
Joel Amoussou
XML Instructor
IBM XML Certification Practice Test
http://www.xmlmentor.net/xmlexamsim.htm
 
Just the other day, I was thinking ... about this tiny ad:
ScroogeXHTML 8.7 - RTF to HTML5 and XHTML converter
https://coderanch.com/t/730700/ScroogeXHTML-RTF-HTML-XHTML-converter
    Bookmark Topic Watch Topic
  • New Topic