"xmlns: URI is not absolute" mystery/bug?

I'm trying to parse some XML using a parser with schema. The XML contains a data error, and should raise: lxml.etree.XMLSyntaxError: Element '{xmlapi_1.0}routerId': [facet 'minInclusive'] The value '0' is less than the minimum value allowed ('1'). Instead, I'm getting lxml.etree.XMLSyntaxError: xmlns: URI xmlapi_1.0 is not absolute, line 2, column 17 I suspect what is happening is the "URI xmlapi_1.0 is not absolute" is a warning and is being ignored, but when the later data error is encountered, the "URI is not absolute" is the first message found and it is being erroneously returned instead. As an aside, is it possible to ignore the above data error somehow and continue loading the XML (I don't control the source of data, nor the schema - both are massive and machine generated)? The code below demonstrates the problem: from lxml import objectify, etree schema = etree.XMLSchema(etree.fromstring('''\ <?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="xmlapi_1.0" xmlns="xmlapi_1.0" elementFormDefault="qualified"> <xsd:element name="container"> <xsd:complexType> <xsd:all> <xsd:element name="routerId" minOccurs="0"> <xsd:simpleType> <xsd:restriction base="xsd:int"> <xsd:minInclusive value="1"/> <xsd:maxInclusive value="10240"/> </xsd:restriction> </xsd:simpleType> </xsd:element> </xsd:all> </xsd:complexType> </xsd:element> </xsd:schema> ''')) parser = objectify.makeparser(schema=schema) fails = '''\ <?xml version="1.0"?> <container xmlns="xmlapi_1.0"> <routerId>0</routerId> </container> ''' result = objectify.fromstring(fails, parser) -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/

Hi,
As an aside, is it possible to ignore the above data error somehow and continue loading the XML (I don't control the source of data, nor the schema - both are massive and machine generated)? [...] parser = objectify.makeparser(schema=schema)
fails = '''\ <?xml version="1.0"?> <container xmlns="xmlapi_1.0"> <routerId>0</routerId> </container> ''' result = objectify.fromstring(fails, parser)
Separate parsing and validation, i.e. don't use a schema-aware parser (details: http://lxml.de/validation.html#xmlschema). Holger Landesbank Baden-Wuerttemberg Anstalt des oeffentlichen Rechts Hauptsitze: Stuttgart, Karlsruhe, Mannheim, Mainz HRA 12704 Amtsgericht Stuttgart

As an aside, is it possible to ignore the above data error somehow and continue loading the XML (I don't control the source of data, nor the schema - both are massive and machine generated)?
Separate parsing and validation, i.e. don't use a schema-aware parser (details: http://lxml.de/validation.html#xmlschema).
I don't actually need or want the validation - what I do want is the type hints it provides to objectify. Is there a way to pass the schema type information to objectify without also performing validation? -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/
participants (2)
-
Andrew McNamara
-
Holger Joukl