MORE INFORMATION
MSXML DOM: Attribute Values Must Be Normalized Before Validation
The XSD
normalizedString data type represents strings that have been normalized with respect to white spaces. For example, line feed (#xA) characters, carriage return (#xD) characters, and tab (#x9) characters in a string are converted to space (#x20) characters. The data value of an XML attribute whose data type is
normalizedString must be normalized before the XML instance document is validated. The October 2001 RTM version of the MSXML 4.0 DOM does not normalize such attribute values before it validates an XML instance document. Because of this, you receive the following validation error message when MSXML 4.0 parses a
normalizedString attribute value that contains carriage return characters, line feed characters, or tab characters:
The attribute: '<attribute name>' has an invalid value according to its data type.
To reproduce this behavior, use the October 2001 RTM release of MSXML 4.0 to validate the following XML document, Testnormalization.xml
<?xml version='1.0'?>
<root att="sample program"> <!-- There is a TAB character between the words sample and program -->
</root>
against the following sample XSD schema, Testnormalization.xsd:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="root">
<xsd:complexType>
<xsd:attribute name="att" type="xsd:normalizedString"/>
</xsd:complexType>
</xsd:element>
</xsd:schema>
back to the top
MSXML DOM Validation: Incorrect Error Message on Second Call to DOM Validate Method When XSD Schema Defines an ID Attribute
When you execute the
validate method of the October 2001 RTM release of the MSXML 4.0
DOMDocument object more than one time, you may receive the following validation error message the second time you execute the method, even when the value of an
ID attribute (that is, an attribute whose data type in the XSD schema has been defined as
ID) is not duplicated:
The ID '<ID Value>' is duplicated
The initial validation does not raise an error message. The error message that you receive when the
validate method is executed the second time reports an incorrect duplication of an
ID attribute value that occurs only one time in the source XML document.
NOTE: If an ID attribute value is duplicated, this error message is valid.
Steps to Reproduce the Behavior- With the October 2001 RTM release of MSXML 4.0, use the following code to create a sample XML document and a sample XSD schema:
Projects.xsd
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Data" type="Projects"/>
<xs:complexType name="Projects">
<xs:sequence>
<xs:element name="project" type="projectData" minOccurs="0"
maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="projectData">
<xs:sequence>
<xs:element name="title" type="xs:string"/>
</xs:sequence>
<xs:attribute name="projectID" type="xs:ID"/>
</xs:complexType>
</xs:schema>
Projects.xml
<?xml version="1.0"?>
<Data>
<project projectID="p1">
<title>Project 1</title>
</project>
<project projectID="p2">
<title>Project 2</title>
</project>
</Data>
- Use the following Microsoft Visual Basic 6.0 code to validate the Projects.xml file:NOTE: You must add a reference to Microsoft XML, v4.0 to your Visual Basic project.
Dim xmlschema As MSXML2.XMLSchemaCache40
Set xmlschema = New MSXML2.XMLSchemaCache40
xmlschema.Add "", "c:\projects.xsd"
Dim xmldom As MSXML2.DOMDocument40
Set xmldom = New MSXML2.DOMDocument40
Set xmldom.schemas = xmlschema
xmldom.async = False
xmldom.validateOnParse = False
xmldom.Load "c:\projects.xml"
Dim parseError As MSXML2.IXMLDOMParseError
Set parseError = xmldom.Validate
If parseError.errorCode <> 0 Then
MsgBox "Error Code : " & parseError.errorCode _
& vbCrLf & vbCrLf & "Description : " & parseError.reason _
& vbCrLf & "Source Text : " & parseError.srcText, , "XSD Validation Result"
Else
MsgBox "No Error", , "XSD Validation Result"
End If
'Call validate again. This raises an incorrect error (even when the XML is valid)
'when the schema defines an XSD ID attribute.
Set perror = xmldom.Validate
If perror <> 0 Then
MsgBox "Error Code : " & perror.errorCode _
& vbCrLf & vbCrLf & "Description : " & perror.reason _
& vbCrLf & "Source Text : " & perror.srcText, , "XSD Validation Result"
Else
MsgBox "No Error", , "XSD Validation Result"
End If
back to the top
An NMTOKEN Value with Multiple Colon (:) Characters Is Treated as an XML Name
Multiple occurrences of the colon (:) character in an
NMTOKEN data value should be permitted. However, the October 2001 RTM release of MSXML 4.0 treats
NMTOKEN values that have multiple instances of the colon (:) character as XML names. Because of this, you receive the following error message when the parser parses
NMTOKEN values that contain two or more colon (:) characters:
Multiple colons are not allowed in a name
To reproduce this behavior, use the following code to create a sample XML document and a sample Document Type Definition (DTD), and then use an MSXML 4.0 (October 2001 RTM version)
DOMDocument object to load and validate Person.xml:
Person.dtd
<!ELEMENT persons (person+)>
<!ELEMENT person EMPTY>
<!ATTLIST person
id ID #REQUIRED
first_name CDATA #REQUIRED
last_name CDATA #REQUIRED
dept CDATA #REQUIRED
DateOfJoining NMTOKEN #REQUIRED
>
Person.xml
<?xml version="1.0"?>
<!DOCTYPE persons SYSTEM "PERSON.DTD">
<persons>
<person id="_1" first_name="Jim" last_name="Stanton" dept="Information Systems" DateOfJoining="9-20-199923:50:55"/>
</persons>
back to the top
Microsoft Internet Explorer XMLHTTP BUG - Access to Local Files
The following Microsoft Knowledge Base article describes this security problem:
317244 MS02-008: XMLHTTP Control in MSXML 4.0 Can Permit Access to Local Files
The MSXML 4.0 SP1 release includes the fix that this article describes. You do not have to separately download and install the fix for the MSXML 4.0 RTM release after you install MSXML 4.0 SP1.
back to the top