masetto, 16.07.2010 14:07:
i'm trying to validate an OVAL (http://oval.mitre.org) xml document against it's schematron rules Following the manual (http://codespeak.net/lxml/validation.html) i wrote the following piece of code:
from lxml import etree
rule = open("oval-definitions-schematron.sch") defs = open("oval.xml")
sct_doc = etree.parse(rule) try: schematron = etree.Schematron(sct_doc) except etree.SchematronParseError, e: print e.args print e.error_log print e.message
doc = etree.parse(defs) print schematron.validate(doc)
but i got the following error(s):
Document is not a valid Schematron schema oval-definitions-schematron.sch:34:0:ERROR:SCHEMASP:SCHEMAP_NOROOT: Expecting a pattern element instead of phase (repeated N times) ... oval-definitions-schematron.sch:1547:0:ERROR:SCHEMASP:SCHEMAP_NOROOT: Failed to compile context expression oval-def:objects/*/*[@datatype='binary']|oval-def:states/*/*[@datatype='binary']|oval-def:states/*/* (repeated N times)
Try to validate the document with libxml2's xmllint tool on the command line. If that fails, too, try lxml 2.3, which has true ISO Schematron support in the "lxml.isoschematron" package. Stefan