2

我正在尝试将一些链接的 XSD 文件加载为 LXML 模式,但我怀疑它们没有通过<include>和正确加载<import>

LXML 是否需要手动导入每个链接的 XSD 文件?如果是这样,如何去做呢?如果不是,我的方法有什么问题:

我所指的确切文件可以在这里找到:https ://github.com/NordPool/Day-Ahead-Public

提取文件并在目录中运行 python 后,我执行以下操作:

from lxml import etree
xmlschema_doc = etree.parse('urn-ediel-org-neg-spotmarket-biddocument-1-0.xsd')
etree.XMLSchema(xmlschema_doc)

但我收到以下错误:

---------------------------------------------------------------------------
XMLSchemaParseError                       Traceback (most recent call last)
<ipython-input-273-fd473f61b95f> in <module>()
      1 xmlschema_doc = etree.parse(xsdRoot + 'urn-ediel-org-neg-spotmarket-biddocument-1-0.xsd')
----> 2 etree.XMLSchema(xmlschema_doc)

src/lxml/xmlschema.pxi in lxml.etree.XMLSchema.__init__ (src/lxml/lxml.etree.c:191759)()

XMLSchemaParseError: simple type 'LocalRestrictedAllocationModeType', attribute 'base': The QName value '{urn:entsoe.eu:wgedi:codelists}LocalAllocationModeType' does not resolve to a(n) simple type definition., line 5

一些 XSD 文件应该在 中../../core/,但修复文件中的引用以使用同一目录实际上并不能解决问题。

我确信这在 Altova XMLSpy 中得到了验证。

4

0 回答 0