Hi, I would like to know what is NMTOKEN as given by the XML 1.0 specification.
Mapraputa Is
Leverager of our synergies
Sheriff
Joined: Aug 26, 2000
Posts: 10065
posted
0
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
Joined: Nov 22, 2008
Posts: 18944
posted
0
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
Joined: Mar 06, 2001
Posts: 1209
posted
0
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.