Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NMTOKENS ...

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
As per the definitions,
NMTOKEN type can contain (XML Name) only letters, digits and point [ . ] , hyphen [ - ], underline [ _ ] and colon [ : ] .
NMTOKENS can contain the same characters as NMTOKEN plus whitespaces

This is a valid document. WHY? Why 3.4 is considered as a valid NMTOKEN ? Please explain.
*************************************
<?xml version="1.0" ?>
<!DOCTYPE attributes [
<!ELEMENT attributes (#PCDATA)>
<!ATTLIST attributes
aaa CDATA #IMPLIED
bbb NMTOKEN #REQUIRED
ccc NMTOKENS #REQUIRED>

]>
<attributes aaa="#d1" bbb="a1:12" ccc=" 3.4 div -4"/>
*************************************
 
tony franz
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you think 3.4 is NOT a valid NMTOKEN?
A NMTOKEN does not have to be a legal XML name -
that is, the usual restrictions on the first character do not apply. The first character can be a number.
Tony.
 
Ronak Patel
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i think u see first character rule for valid xml name.This rule is omited in NMTOKEN and NMTOKENS.
cheers.
 
Deepti Dixit
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
XMLSpy says 'Invalid values for datatype NMTokens' in attribute ccc !
 
Tony Yan
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tested with sun xml-pack. It is a valid. The reason is:
DTD W3C
-----------------------------------------------
[4] NameChar ::= Letter | Digit | '.' | '-' | '_' | ':' | CombiningChar | Extender
[5] Name ::= (Letter | '_' | ':') (NameChar)*
[6] Names ::= Name (S Name)*
[7] Nmtoken ::= (NameChar)+
[8] Nmtokens ::= Nmtoken (S Nmtoken)*
------------------------------------------------

In short, NMTOKEN belongs to NameChar, NOT Name. NameChar can be anything in item [4]. Since Nmtoken is a combinatinon of NameChar, it can start with any NameChar, including Digit, etc.
 
Dan Drillich
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Deepti,
It's the space that made the document invalid.
Here is a valid version -

Cheers,
Dan
 
Dan Drillich
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It was XML Spy 4.4 that complained.
On the other hand, http://www.stg.brown.edu/cgi-bin/xmlvalid/xmlvalid.pl has no problem with it.
Cheers,
Dan
 
Dan Drillich
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The sax.Counter program also considers this xml to be valid.
Cheers,
Dan
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic