I got the following error
==
Incorrect definition for root element in schema
==
when I try to validate an xml file using a schema(.xsd).
When I execute that code I get the above error at the "oxmlSchemaCache.Add" line. XSDDoc is
a global variable defined as an MSXML2.DOMDocument which I successfully read as xml in another part
of the program. The first part of the schema looks like the following. What is wrong?
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd=" elementFormDefault="qualified">
' Code
Dim oxmlTempDoc As DOMDocument
Dim oxmlSchemaCache As XMLSchemaCache
Set oxmlTempDoc = New DOMDocument
Set oxmlSchemaCache = New XMLSchemaCache
ValidateXML = True
oxmlTempDoc.async = False
oxmlTempDoc.validateOnParse = False
oxmlSchemaCache.Add "", XSDDoc
Set oxmlTempDoc.schemas = oxmlSchemaCache
oxmlTempDoc.Load gstrTempFileName
If oxmlTempDoc.parseError <> 0 Then
Err.Raise vbObjectError + 1, "PO Validation", oxmlTempDoc.parseError.reason
ValidateXML = False
Exit Function
End If
Set oxmlTempDoc = Nothing
Set oxmlSchemaCache = Nothing
==
Incorrect definition for root element in schema
==
when I try to validate an xml file using a schema(.xsd).
When I execute that code I get the above error at the "oxmlSchemaCache.Add" line. XSDDoc is
a global variable defined as an MSXML2.DOMDocument which I successfully read as xml in another part
of the program. The first part of the schema looks like the following. What is wrong?
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd=" elementFormDefault="qualified">
' Code
Dim oxmlTempDoc As DOMDocument
Dim oxmlSchemaCache As XMLSchemaCache
Set oxmlTempDoc = New DOMDocument
Set oxmlSchemaCache = New XMLSchemaCache
ValidateXML = True
oxmlTempDoc.async = False
oxmlTempDoc.validateOnParse = False
oxmlSchemaCache.Add "", XSDDoc
Set oxmlTempDoc.schemas = oxmlSchemaCache
oxmlTempDoc.Load gstrTempFileName
If oxmlTempDoc.parseError <> 0 Then
Err.Raise vbObjectError + 1, "PO Validation", oxmlTempDoc.parseError.reason
ValidateXML = False
Exit Function
End If
Set oxmlTempDoc = Nothing
Set oxmlSchemaCache = Nothing