如何验证XML针对具有不同导入和名称空间的XSD?
-
23-10-2019 - |
题
我正在尝试验证一些XML文件,并且由于XSD定义和命名空间的各种问题而失败。
这是公共信息,因此共享数据没有问题:主要XSD在 http://bioinformatics.ua.pt/euadr/euadr_types.xsd 它在名为同一位置导入另一个XSD common_types.xsd, ,我已经在W3C验证器中验证了它们,然后他们通过了。
XML
<?xml version="1.0"?>
<relationship xmlns="http://euadr.biosemantic.erasmusmc.org/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://euadr.biosemantic.erasmusmc.org/ http://bioinformatics.ua.pt/euadr/euadr_types.xsd">
<sourceId>
<source>SMILE</source>
<code>[S]1(=O)(=O)N(C(</code>
</sourceId>
<targetId>
<source>UP</source>
<code>P35354</code>
</targetId>
<creator>http://cgl.imim.es</creator>
<observationDateTime>2010-05-12T19:03:40.097+02:00</observationDateTime>
<informationSources>
<informationSource>
<relationshipType>BINDS</relationshipType>
<interaction>
<type>pIC50</type>
<value>6.55</value>
</interaction>
<evidence>
<type>OBSERVATIONAL</type>
<value>1.0</value>
</evidence>
<databaseIds>
<databaseId>
<source>PDSP</source>
<code>
P35354</code>
</databaseId>
</databaseIds>
</informationSource>
</informationSources>
</relationship>
很简单明了!我已经测试了一些在线验证器,并且收到以下错误
cvc-elt.1: Cannot find the declaration of element 'relationship'.
有人对问题有什么想法吗?是在名称空间的声明中吗? XSD?
在此先感谢您的帮助!
干杯!
解决方案
您的模式定义了一种复杂类型,称为 relationship
但是它没有定义任何命名的元素 relationship
. 。您需要将类似的内容添加到您的第一个XSD中:
<xs:element name="relationship" type="relationship" />
不隶属于 StackOverflow