ClulessChris
IS-IT--Management
I'm trying to validate an XML against the XSD Schema.
At the point of adding the SchemaCache I get the error Incorrect definition for the root element in schema.
I may be completely wrong but I maybe missing a required namespace. I've having trouble understanding the MSXML model and I'm struggling to understand what I need here.
I'd be thankful for any help.
The XML header example:
At the point of adding the SchemaCache I get the error Incorrect definition for the root element in schema.
I may be completely wrong but I maybe missing a required namespace. I've having trouble understanding the MSXML model and I'm struggling to understand what I need here.
I'd be thankful for any help.
Code:
XML_FILE = "XML File Path"
XSD_FILE = "XSD File Path"
Set xmlDoc = CreateObject("MSXML2.DOMDocument")
xmlDoc.async = False
xmlDoc.validateOnParse = False
xmlDoc.resolveExternals = False
xmlDoc.Load XML_FILE
' Open XSD file
Set objXSD = CreateObject("MSXML2.DOMDocument")
objXSD.async = False
objXSD.Load XSD_FILE
' Populate schema cache
Set objSchemaCache = CreateObject("MSXML2.XMLSchemaCache")
[b][red]objSchemaCache.Add "", objXSD[/red][/b]
' XSD XML Bind
Set xmlDoc.Schemas = objSchemaCache
'Error visualization
Set objErr = xmlDoc.Validate()
If objErr.errorCode <> 0 Then
sResult = "Error parser: " & objErr.errorCode & "; " & objErr.reason
Else
sResult = "No errors found"
End If
XSD_Validation = sResult
The XML header example:
Code:
<ftc:FATCA_OECD xmlns:xsi="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema-instance"[/URL] xmlns="urn:oecd:ties:fatca:v1" xmlns:ftc="urn:oecd:ties:fatca:v1" xmlns:iso="urn:oecd:ties:isofatcatypes:v1"
xmlns:sfa="urn:oecd:ties:stffatcatypes:v1" version="1.1">