我正在使用 lxml schematron 模块验证 xml 文档。它运行良好,但我无法显示设置为属性的验证报告。我找不到如何将它作为 XML 树来处理。
这是我使用的代码片段:
xdoc = etree.parse("mydoc.xml")
# schematron code removed for clarity
f = StringIO.StringIO('''<schema>...</schema>''')
sdoc = etree.parse(f)
schematron = isoschematron.Schematron(sdoc, store_schematron=True, store_xslt=True, store_report=True)
if schematron.validate(xdoc):
print "ok"
else:
tprint "ko"
report = isoschematron.Schematron.validation_report
>>> type(report)
<type 'property'>
>>> dir(report)
['__class__', '__delattr__', '__delete__', '__doc__', '__format__', '__get__',
'__getattribute__', '__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__',
'__repr__', '__set__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__',
'deleter', 'fdel', 'fget', 'fset', 'getter', 'setter']
>>> report.__doc__
'ISO-schematron validation result report (None if result-storing has\n been turned off).\n
lxml 文档在这一点上并不清楚。有人可以帮我获取 xml 报告树吗?