Microsoft KB Archive/313371

= BUG: MSXML: NMTOKEN Values with Multiple Colon Characters Are Treated as XML Names =

Article ID: 313371

Article Last Modified on 1/3/2002

-

APPLIES TO


 * Microsoft XML Parser 2.0
 * Microsoft XML Parser 2.5
 * Microsoft XML Parser 2.6
 * Microsoft XML Core Services 4.0
 * Microsoft XML Parser 3.0 Service Pack 1
 * Microsoft XML Parser 3.0 Service Pack 2
 * Microsoft XML Core Services 4.0

-



This article was previously published under Q313371



SYMPTOMS
When you use NMTOKEN values that contain multiple colon characters in an XML document, the values may be treated as XML names when the MSXML parser validates the document, and you may receive the following validation error message:

Multiple colons are not allowed in a name.



RESOLUTION
To work around this problem, do either of the following:
 * Set the validateOnParse property of the DOM object to False before you load the XML document.
 * Change the type of the attribute to CDATA. Note that this permits the attribute to contain characters that are not NameChar characters.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



MORE INFORMATION
The following extract from the World Wide Web Consortium (W3C) XML Language specifications specifies the valid characters that can constitute an NMTOKEN value, and indicates that an NMTOKEN value can contain multiple occurrences of the colon character: NameChar   ::=    Letter | Digit | '.' | '-' | '_' | ':' | CombiningChar | Extender Nmtoken   ::=    (NameChar)+

Steps to Reproduce Behavior
NOTE: This sample uses the MSXML 4.0 parser.   In Notepad, create an XML document named Employees.xml that contains the following XML in the root folder of drive C: 

<!DOCTYPE Employees [

<!ELEMENT Employees (Employee+)> <!ELEMENT Employee EMPTY> <!ATTLIST Employee id ID #REQUIRED first_name CDATA #REQUIRED last_name CDATA #REQUIRED profession CDATA #REQUIRED DateOfJoining NMTOKEN #REQUIRED >

]>

    In Visual Basic, create a new Standard EXE project. Form1 is created by default. Add a project reference to Microsoft XML, version 4.0. If you have not installed MSXML 4.0, add a reference to the latest version of the MSXML parser that is installed on your computer. Drag a command button onto Form1.</li>  Paste the following code in the Click event procedure of the command button. Change the PROGID for the DOMDocument object if you are referencing an earlier version of MSXML in the project: Dim doc As MSXML2.DOMDocument40 Set doc = New MSXML2.DOMDocument40

doc.Load &quot;c:\Employees.xml&quot; If doc.parseError.errorCode <> 0 Then MsgBox doc.parseError.reason End If                   </li> Save and run the project.</li> Click the command button when the form is displayed to parse and validate the XML document that you just created.</li></ol>

<div class="references_section">