我正在關注的lxml validation documentation構建驗證對數學ML 3.0架構一個給定的XML字符串的類。下面是類:lxml/MathML XML Schema - 如何解決「內容模型不確定性」。錯誤?
class XMLSchema(object):
def __init__(self, path_to_xsd_file):
with open(path_to_xsd_file) as f:
xmlschema_doc = etree.parse(f)
self.xmlschema = etree.XMLSchema(xmlschema_doc)
def validate(self, well_formed_xml_string):
"""Validates a well-formed XML string against an XML schema.
Returns True if xml_string is valid, False if not.
"""
xml = etree.parse(StringIO(well_formed_xml_string))
return self.xmlschema.validate(xml)
實例化它產生如下:
>>> x = XMLSchema('mathml3.xsd')
Traceback (most recent call last):
...
lxml.etree.XMLSchemaParseError: complex type
'annotation-xml.model': The content model is not determinist., line 42
我該如何解決這個問題?
架構是〜1900線長,很遺憾。 well_formed_xml_string = <數學的xmlns = 「http://www.w3.org/1998/Math/MathML」> – MikeRand 2012-01-17 21:16:05
well_formed_xml_string ='<數學的xmlns = 「http://www.w3.org/1998/Math/MathML」 >' – MikeRand 2012-01-17 21:24:48