XMLファイルとXMLスキーマを取り込んで、そのスキーマに対してXMLファイルを検証する小さなXMLバリデーターを作成しました。XMLファイルを除いて、次の内容でうまく機能します。
<?xml version="1.0" encoding="utf-8"?>
<xc:program xmlns:xc="http:\\www.something.com\Schema\XC10" xc:version="4.0.22.0" >
<xc:namespaceDecls>
<xc:namespaceDecl xc:namespaceDeclURI="urn:swift:xsd:abc">
<xc:namespaceDeclPrefix>n</xc:namespaceDeclPrefix>
</xc:namespaceDecl>
</xc:namespaceDecls>
</xc:program>
このXMLファイルをさまざまなスキーマに対して検証しようとしました。どのスキーマを選択しても、このXMLファイルは有効なものとして出力されます。私が行方不明になっているのは何ですか?関連するコードは次のとおりです。
//'Create a schema cache and add the given schema to it.
Dim schemaCache As New Schema.XmlSchemaSet
schemaCache.Add(targetNamespace, schemaFilename)
//'Create an XML DOMDocument object.
Dim xmlDom As New XmlDocument
//'Assign the schema cache to the DOM document.
//'schemas collection.
xmlDom.Schemas = schemaCache
//'Load selected file as the DOM document.
xmlDom.Load(xmlFilename)
xmlDom.Validate(AddressOf ValidationCallBack)