微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

XSD:在一个文件中合并两个模式

如何解决XSD:在一个文件中合并两个模式

使用 lxml 我正在尝试使用 XSD 验证 XML 文档。

问题: 该架构继承自另一个架构,并且(可能)因为文件不是本地文件,所以我收到一条错误消息。

架构来源: https://github.com/IHEC/ihec-ecosystems/tree/master/schemas/xml

使用的架构:

  • SRA.experiment.xsd
  • SRA.sample.xsd

两者都继承自:

  • SRA.common.xsd

问题:是否可以将 SRA.experiment.xsdSRA.sample.xsd 分别与 SRA.common.xsd 合并?

这是使用其中一种架构的示例:

import lxml.etree
from urllib.request import urlopen

xsd = urlopen("https://raw.githubusercontent.com/IHEC/ihec-ecosystems/master/schemas/xml/SRA.sample.xsd").read()
schema = lxml.etree.XMLSchema(lxml.etree.fromstring(xsd))

错误

Traceback (most recent call last):
  File "delme.py",line 5,in <module>
    schema = lxml.etree.XMLSchema(lxml.etree.fromstring(xsd))
  File "src/lxml/xmlschema.pxi",line 88,in lxml.etree.XMLSchema.__init__
lxml.etree.XMLSchemaParseError: complex type 'SampleType',attribute 'base': The QName value '{SRA.common}ObjectType' does not resolve to a(n) simple type deFinition.,line 17

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。