BUG: MSXML: NMTOKEN Values with Multiple Colon (:) Characters Are Treated as XML Names (313371)



The information in this article applies to:

  • Microsoft XML 2.0
  • Microsoft XML 2.5
  • Microsoft XML 2.6
  • Microsoft XML 3.0
  • Microsoft XML 3.0 SP1
  • Microsoft XML 3.0 SP2
  • Microsoft XML 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.
  1. In Notepad, create an XML document named Employees.xml that contains the following XML in the root folder of drive C:
    <?xml version="1.0"?>
    
    <!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     
    >
    
    ]>
    
    <Employees>
      <Employee id="_1" first_name="Jim" last_name="Stanton" profession="Software Engineer" DateOfJoining="8-20-199911:50:55"/>
    </Employees>
    					
  2. In Visual Basic, create a new Standard EXE project. Form1 is created by default.
  3. 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.
  4. Drag a command button onto Form1.
  5. 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 "c:\Employees.xml"
    If doc.parseError.errorCode <> 0 Then
     MsgBox doc.parseError.reason
    End If
    					
  6. Save and run the project.
  7. Click the command button when the form is displayed to parse and validate the XML document that you just created.

REFERENCES

For more information, see the following Web site:

Modification Type:MajorLast Reviewed:1/3/2002
Keywords:kbbug KB313371