如何针对具有不同导入和命名空间的XSD验证XML?

时间:2010-06-02 16:22:43

标签: xml namespaces xsd xsd-validation

我正在尝试验证一些XML文件,但由于XSD定义和命名空间的各种问题而导致我失败...

这是公开信息,因此共享数据没问题:主XSD位于http://bioinformatics.ua.pt/euadr/euadr_types.xsd,它在名为 common_types.xsd 的同一位置导入另一个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?

提前感谢您的帮助!

干杯!

1 个答案:

答案 0 :(得分:0)

您的架构定义了一个名为relationship的复杂类型,但它没有定义任何名为relationship的元素。你想在你的第一个XSD中添加这样的东西:

<xs:element name="relationship" type="relationship" />