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

发布于 2024-09-04 03:20:05 字数 1862 浏览 4 评论 0原文

我正在尝试验证一些 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 的?

预先感谢您的帮助!

干杯!

I am trying to validate a few XML files and I'm failing due to various issues with the XSD definition and the namespaces...

This is public info, so no problem sharing data: the main XSD is at http://bioinformatics.ua.pt/euadr/euadr_types.xsd and it imports another XSD at the same location named common_types.xsd, I've validated them in W3C validator, and they passed.

The 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>

is straightforward and well-formed! I've tested a few online validators, and I'm getting the following error

cvc-elt.1: Cannot find the declaration of element 'relationship'.

Does anyone has any idea of what the problem is? Is it in the declaration of the namespaces? Of the XSD?

Thanks in advance for your help!

Cheers!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

清风夜微凉 2024-09-11 03:20:05

您的架构定义了一个名为 relationship 的复杂类型,但它没有定义任何名为 relationship 的元素。您需要将如下内容添加到您的第一个 XSD 中:

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

Your schema defines a complex type called relationship but it doesn't define any elements named relationship. You'll want to add something like this to your first XSD:

<xs:element name="relationship" type="relationship" /> 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文