Is it possible to validate an XML file against XSD 1.1 in Python?(是否可以在 Python 中针对 XSD 1.1 验证 XML 文件?)
问题描述
我想使用 lxml.XMLSchema 针对 XSD 文件验证 XML 文件.但问题是 XSD 在 1.1 中.所以它不起作用.
I want validate an XML file against an XSD file using lxml.XMLSchema. But the problem is the XSD is in 1.1. So it doesn't work.
这是 XML 的一部分:
This is a part of the XML:
<?xml version="1.0" encoding="UTF-8"?>
<dictionary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="!!assert.xsd">
<SizeType>10</SizeType>
</dictionary>
这是它的 XSD 文件:
And this is its XSD file:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:element name="SizeType">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:assertion test="$value = 10"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:schema>
那么,是否可以针对使用 xs:assertion
语句 (1.1) 的 XSD 文件来验证 XML 文件?
So, is it possible to validate an XML file against a XSD file that uses xs:assertion
statements (1.1)?
我认为这个问题与此密切相关:lxml with schema 1.1
I think this question is closely related to this: lxml with schema 1.1
推荐答案
截至 2013 年 11 月上旬,只有以下 XML 处理器支持 XSD 1.1:
As of early November 2013, only the following XML processors support XSD 1.1:
- Xerces-J 与 PsychoPath XPath 2.0
- 萨克森EE
- Altova
目前还没有用 Python 编写的可针对 XSD 1.1 进行验证的 XML 解析器.
There is no XML parser written in Python that validates against XSD 1.1 yet.
这篇关于是否可以在 Python 中针对 XSD 1.1 验证 XML 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:是否可以在 Python 中针对 XSD 1.1 验证 XML 文件?


- pytorch 中的自适应池是如何工作的? 2022-07-12
- padding='same' 转换为 PyTorch padding=# 2022-01-01
- 如何在 python3 中将 OrderedDict 转换为常规字典 2022-01-01
- 分析异常:路径不存在:dbfs:/databricks/python/lib/python3.7/site-packages/sampleFolder/data; 2022-01-01
- 沿轴计算直方图 2022-01-01
- 如何将一个类的函数分成多个文件? 2022-01-01
- python-m http.server 443--使用SSL? 2022-01-01
- 使用Heroku上托管的Selenium登录Instagram时,找不到元素';用户名'; 2022-01-01
- python check_output 失败,退出状态为 1,但 Popen 适用于相同的命令 2022-01-01
- 如何在 Python 的元组列表中对每个元组中的第一个值求和? 2022-01-01