我尝试扩展ISOSTSXSD方案来支持SVG图像标记。
我找到了XSD scheme for SVG,并把它放在ISOSTS.xsd
附近。
现在我尝试扩展ISOSTS.xsd
:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:mml="http://www.w3.org/1998/Math/MathML"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tbx="urn:iso:std:iso:30042:ed-1"
xmlns:xlink="http://www.w3.org/1999/xlink"
<!-- my line -->
xmlns:svg="http://www.w3.org/2000/svg"
elementFormDefault="qualified">
<xs:import namespace="http://www.w3.org/1998/Math/MathML"
schemaLocation="ncbi-mathml2/mathml2.xsd"/>
<xs:import namespace="http://www.w3.org/1999/xlink"
schemaLocation="xlink.xsd"/>
<!-- XSD import of namespace http://www.w3.org/2001/XMLSchema-instance suppressed (not necessary) -->
<xs:import namespace="http://www.w3.org/XML/1998/namespace"
schemaLocation="xml.xsd"/>
<xs:import namespace="urn:iso:std:iso:30042:ed-1"
schemaLocation="tbx.xsd"/>
<!-- my line -->
<xs:import namespace="http://www.w3.org/2000/svg"
schemaLocation="SVG.xsd"/>
....
<xs:element name="p">
<xs:complexType mixed="true">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<!-- my line --> <xs:element ref="svg:svg"/>
<xs:element ref="email"/>
....
但我在尝试加载方案时出错:
^{pr2}$错误消息:
File "src/lxml/xmlschema.pxi", line 87, in lxml.etree.XMLSchema.init (src/lxml/lxml.etree.c:197819)
lxml.etree.XMLSchemaParseError: Element '{http://www.w3.org/2001/XMLSchema}element', attribute 'ref': References from this schema to components in the namespace 'http://www.w3.org/2000/svg' are not allowed, since not indicated by an import statement., line 4664
怎么了?在
使用SVG的下一个XSD模式解决的问题:https://github.com/dumistoklus/svg-xsd-schema
我复制了您的三个修改(为SVG名称空间声明名称空间绑定,导入SVG名称空间,并引用svg:svg元素),但没有从Xerces或Saxon EE得到错误。在
所以在我看来你做的一切都是对的。在
错误消息表明您的XSD验证器没有接收导入。在
如果我不得不猜测(我想我必须这样做,因为虽然您已经给出了一个非常简洁的问题陈述,但我们没有可复制的错误),那么您的验证器正在查看一个临时版本的模式文档,其中引用svg:svg有已添加到p的内容模型中,但xs:import语句尚未添加到架构文档的开头。在
可能您的Python字节码已经过期,您的Python需要重新编译?(纯粹是推测;我不知道lxml在编译时生成了多少模式信息,在运行时生成了多少模式信息)
我觉得这条信息似乎很清楚,我不知道你不明白其中的哪一部分。您的模式文档为不同名称空间(mathml、xlink、xml等)导入架构组件,但它没有尝试导入SVG的模式,错误消息告诉您。
相关问题 更多 >
编程相关推荐