• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what is NMTOKEN

 
Rahul Mahindrakar
Ranch Hand
Posts: 1869
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I would like to know what is NMTOKEN as given by the XML 1.0 specification.
 
Mapraputa Is
Leverager of our synergies
Sheriff
Posts: 10065
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
as given by the XML 1.0 specification NMTOKEN is
[7] Nmtoken ::= (NameChar)+
Where NameChar is defined as
NameChar ::= Letter | Digit | '.' | '-' | '_' | ':' | CombiningChar | Extender
"letter, " "digit" et al are references to corresponding Unicode definitions, I suppose. So basically "NMTOKEN" consists of letters, digits, and . - _ : characters.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
NMTOKEN's are used to describe attribute type declarations.
I quote Norman Walsh from his article "A Technical Introduction to XML ":
"Name token attributes are a restricted form of string attribute. In general, an NMTOKEN attribute must consist of a single word [Section 1.5, production 7], but there are no additional constraints on the word, it doesn't have to match another attribute or declaration."
Vinayak
 
Karthik Guru
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
as indicated , you w'd want to consider NMTOKEN as against PCDATA when you are sure that the attribute value needs to be a single word and not many words.
<person age="10"/>
if age is declared as type CDATA, it can take any value. But when declared as NMTOKEN you can atleast be sure that it can't be "hello world". But it can be "hello" for sure.
But then if you are lookign for strong data typing, you w'd probably go for schemas.
Am not aware of any other advantages of NMTOKEN
Others can probably comment on that.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic