我试图验证对命名MedisinskeOpplysninger-v1.5.xsd从这个集合的模式的XML文档:http://www.kith.no/upload/1611/v1.5/PLO-schema%20v1.5.zip为什么.NET模式验证声称名称空间lang属性未声明?
基本上,我引用的架构添加到C#中的SchemaSet,并通过指定SchemaSet验证我的XML到XmlReaderSettings的相应属性并运行XmlReader。
我收到以下错误信息:
System.Xml.Schema.XmlSchemaException : The 'http://www.w3.org/XML/1998/namespace:lang' attribute is not declared.
at System.Xml.Schema.XmlSchemaSet.InternalValidationCallback(Object sender, ValidationEventArgs e)
at System.Xml.Schema.BaseProcessor.SendValidationEvent(XmlSchemaException e, XmlSeverityType severity)
at System.Xml.Schema.BaseProcessor.SendValidationEvent(XmlSchemaException e)
at System.Xml.Schema.Compiler.CompileElement(XmlSchemaElement xe)
at System.Xml.Schema.Compiler.Compile()
at System.Xml.Schema.Compiler.Execute(XmlSchemaSet schemaSet, SchemaInfo schemaCompiledInfo)
at System.Xml.Schema.XmlSchemaSet.Compile()
我小提琴手看到.NET正试图从w3c.org下载xml.xsd,但失败(服务器以504响应),所以我试图下载xml.xsd并将其明确包含在我的SchemaSet中。当我尝试这个时,.NET声称
The global attribute 'http://www.w3.org/XML/1998/namespace:lang' has already been declared.
我很困惑。有任何想法吗?
我在.NET 3.5,C#,Visual Studio 2010中,Windows 7的
更新
我试图按照意见伊恩的建议,并从LonData添加的自定义解析器。我可以通过观察Fiddler跟踪来看到它确实有效,因为现在不会尝试解析来自外部地址的模式。
我现在收到以下错误消息: 未声明'http://www.w3.org/2000/09/xmldsig#:Signature'元素。
我的XML目录文件看起来像这样:
<catalog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<systemSuffix systemIdSuffix="XMLSchema.xsd" uri="C:\Users\eax\AppData\Local\Temp\XMLSchema.xsd"/>
<systemSuffix systemIdSuffix="datatypes.dtd" uri="C:\Users\eax\AppData\Local\Temp\datatypes.dtd"/>
<systemSuffix systemIdSuffix="XMLSchema.dtd" uri="C:\Users\eax\AppData\Local\Temp\XMLSchema.dtd"/>
<systemSuffix systemIdSuffix="Xmldsig.xsd" uri="C:\Users\eax\AppData\Local\Temp\Xmldsig.xsd"/>
<systemSuffix systemIdSuffix="xmldsig-core-schema.xsd" uri="C:\Users\eax\AppData\Local\Temp\xmldsig-core-schema.xsd"/>
<systemSuffix systemIdSuffix="xml.xsd" uri="C:\Users\eax\AppData\Local\Temp\xml.xsd"/>
<systemSuffix systemIdSuffix="xhtml1-strict.xsd" uri="C:\Users\eax\AppData\Local\Temp\xhtml1-strict.xsd"/>
</catalog>
这个答案对你有帮助吗? http://stackoverflow.com/questions/3449180/using-net-to-validate-xml-against-a-schema – Ian 2012-01-05 13:15:35
@我不是真的,我已经用结果更新了问题。 – Eyvind 2012-01-12 14:52:28