擅长:python、mysql、java
<p>使用xsd架构<a href="http://www.iso.org/schema/isosts/isosts-v1.1.zip" rel="nofollow noreferrer">from archive</a>和<code>lxml.etree.XMLSchema</code>解决:</p>
<pre><code>def validate(self, filename: str):
file = open(filename)
schema_filename = '/path/to/ISOSTS.xsd'
schema_file = open(schema_filename)
sct_doc = etree.parse(schema_file)
xmlschema = etree.XMLSchema(sct_doc)
doc = etree.parse(file)
result = xmlschema.validate(doc)
file.close()
schema_file.close()
return result
</code></pre>