J'ai écrit un petit validateur XML, qui accepte un fichier XML et un schéma XML et valide les fichiers XML par rapport à ce schéma. Il fonctionne bien, sauf pour un fichier XML, avec ce contenu:VB.Net Valider un xml par rapport à un schéma (problème étrange)
<?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>
J'ai essayé de valider ce fichier XML contre un tas de différents schémas. Quel que soit le schéma que je sélectionne, ce fichier XML est valide. Qu'est-ce qui me manque? Voici la pièce correspondante du code:
//'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)