Issue with objectify.parse / lxml.etree.XMLSyntaxError
Hello I am facing an issue using objecjtify.parse when I provide a parser. The function rise lxml.etree.XMLSyntaxError, but I don't understand why. My file validate :
xmllint --noout --schema XMLSchema.xsd myxsd.xsd myxsd.xsd validates
from __future__ import print_function from lxml import etree from lxml import objectify print("libxml_version:"+str(etree.LIBXML_VERSION)) print("libxslt_version:"+str(etree.LIBXSLT_VERSION)) print("lxml_version:"+str(etree.LXML_VERSION)) rawXMLSchema = etree.parse('XMLSchema.xsd') XMLSchema = etree.XMLSchema(rawXMLSchema) doc = etree.parse("myxsd.xsd") valid = XMLSchema.validate(doc) print ('valid: {var}'.format(var=valid)) XMLSchemaParser = objectify.makeparser(schema = XMLSchema) root = objectify.parse('myxsd.xsd',parser=XMLSchemaParser) print("done") Also the exception message is different according to lxml version: libxml_version:(2, 9, 3) libxslt_version:(1, 1, 28) lxml_version:(3, 5, 0, 0) lxml.etree.XMLSyntaxError: Element '{http://www.w3.org/2001/XMLSchema}attribute', attribute 'ref': The QName value 'xml:id' has no corresponding namespace declaration in scope. After pip install --user -U lxml libxml_version:(2, 9, 4) libxslt_version:(1, 1, 29) lxml_version:(3, 6, 4, 0) lxml.etree.XMLSyntaxError: Element '{http://www.w3.org/2001/XMLSchema}simpleType', attribute 'name': '' is not a valid value of the atomic type 'xs:NCName'. How lxml can report libxml_version:(2, 9, 4) while I can only find libxml2.so.2.9.3 on my system ? I am on Ubuntu 16.04.1 Is the issue coming from my file or from the tool ? I see a previous post on this mailing list where libxml2 version 2.9.4 was the one to blame. But in current case I try with 2 different versions and my knowledge of xml, lxml and libxml2 can't help me to conclude. Any help would be welcome. Thomas
participants (1)
-
Thomas Burg