I've created a RELAX NG schema document and an XML instance document that conforms to this schema. I'm using the python lxml library to parse and validate the files.
I'm looking into using the lxml.objectify API and followed the examples here more or less without problems until I reached the "Asserting a Schema" section.
I see that in the example it uses an etree.XMLSchema type but I think/thought/hope that I somehow could pass an etree.RelaxNG type too, but alas:
relaxng_doc = etree.parse('schema/link.rng')
relaxng = etree.RelaxNG(relaxng_doc)
parser = objectify.makeparser(schema = relaxng)
Gives me:
Traceback (most recent call last):
File "C:\Users\rubin\Source\Projects\Even\even.py", line 26, in <module>
parser = objectify.makeparser(schema = relaxng)
File "lxml.objectify.pyx", line 1801, in lxml.objectify.makeparser (src/lxml\lxml.objectify.c:19114)
File "parser.pxi", line 1261, in lxml.etree.XMLParser.__init__ (src/lxml\lxml.etree.c:80303)
TypeError: Argument 'schema' has incorrect type (expected lxml.etree.XMLSchema, got lxml.etree.RelaxNG)
I'm still quite new to this stuff so before I start to accept that lxml.objectify's makeparser can only use a W3C XML Schema 1.0 xsd parser, I thought I'd ask here: Am I correct that the lxml.objectify API can only validate using W3C XML Schema, and not with RELAX NG schema?