Hello everybody,
I use msxml version4 and I want to validate a xml file against a XDR file.
When I change for example this to type int <ElementType name="CompanyName" dt:type="string" /> then I would expect to receive an error... but I don't get any errors at all !
Does anyone know what should be wrong ?
I hope someone could help me out !
Thanks,
Bjorn
here's my XDR file :
VB Code:
<?xml version="1.0" ?> <Schema xmlns="urn:schemas-microsoft-com:xml-data" xmlns:dt="urn:schemas-microsoft-com:xml:datatypes" xmlns:sql="urn:schemas-microsoft-com:xml-sql"> <ElementType name="CustomerID" dt:type="int" /> <ElementType name="CompanyName" dt:type="int" /> <ElementType name="City" dt:type="string" /> <ElementType name="ROOT" sql:is-constant="1"> <element type="Customers" /> </ElementType> <ElementType name="Customers" sql:relation="Cust" > <element type="CustomerID" sql:field="CustomerID" /> <element type="CompanyName" sql:field="CompanyName" /> <element type="City" sql:field="City" /> </ElementType> </Schema>
This is my XML file :
VB Code:
<ROOT> <Customers> <CustomerID>1111</CustomerID> <CompanyName>Sean Chai</CompanyName> <City>NY</City> </Customers> <Customers> <CustomerID>1112</CustomerID> <CompanyName>Tom Johnston</CompanyName> <City>LA</City> </Customers> <Customers> <CustomerID>1113</CustomerID> <CompanyName>Institute of Art</CompanyName> </Customers> </ROOT>
And this is my code to validate :
VB Code:
Dim xmlschema As MSXML2.XMLSchemaCache40 xmlschema = New MSXML2.XMLSchemaCache40() xmlschema.add("", "c:\temp\temp2\SampleSchema.xml") 'Create an XML DOMDocument object. Dim xmldom As MSXML2.DOMDocument40 xmldom = New MSXML2.DOMDocument40() 'Assign the schema cache to the DOM document. 'schemas collection. xmldom.schemas = xmlschema 'Load books.xml as the DOM document. xmldom.async = False xmldom.validate() xmldom.load("c:\temp\temp2\Samplexml.xml") 'Return validation results in message to the user. If xmldom.parseError.errorCode <> 0 Then MsgBox(xmldom.parseError.errorCode & " " & _ xmldom.parseError.reason) Else MsgBox("No Error") End If





Reply With Quote