Schema fails to validate: '' is not a valid value of the atomic type 'xs:int'

Bug #1615510 reported by Rotem
22
This bug affects 4 people
Affects Status Importance Assigned to Milestone
lxml
Fix Released
Undecided
Unassigned

Bug Description

Recently started failing with the following code:

---
from lxml import etree
SCHEMA = """<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
   attributeFormDefault="unqualified">
  <xs:element name="testsuite" type="testsuite"/>
  <xs:complexType name="testsuite">
    <xs:attribute name="errors" type="xs:int">
    </xs:attribute>
  </xs:complexType>
</xs:schema>"""

schema_root = etree.XML(SCHEMA)
schema = etree.XMLSchema(schema_root)

XML = """
<testsuite errors="0"></testsuite>
"""
xml = etree.fromstring(XML, parser=etree.XMLParser(schema=schema))
---

I get:

XMLSyntaxError: Element 'testsuite', attribute 'errors': '' is not a valid value of the atomic type 'xs:int'

Python            : sys.version_info(major=3, minor=5, micro=2, releaselevel='final', serial=0)
lxml.etree          : (3, 6, 1, 0)
libxml used         : (2, 9, 4)
libxml compiled     : (2, 9, 4)
libxslt used        : (1, 1, 29)
libxslt compiled    : (1, 1, 29)

Revision history for this message
Ronald Dilley (ronald-d-dilley-jr) wrote :

I'm getting a nearly identical issue to this bug, except with xs:float values versus xs:int.

Does not seem to be present in 3.6.0 or 3.6.1.
Definitely in version 3.6.4.
Have not tried 3.6.2 or 3.6.3.

Revision history for this message
Hans-Thomas (htmue-h) wrote :

The bug seems to be related to libxml 2.9.4.

I see the bug with lxml-3.6.0 and lxml-3.6.4 linked against libxml2-2.9.4
but not when using libxml2-2.9.3.

Validation fails also for boolean attributes.

Moreover the bug appears only when using a validating parser. Validating a document parsed with a non-validating parser works fine.

Revision history for this message
Caleb Morse (morse-caleb) wrote :

This bug appears to have been fixed by libmx2 in this commit: https://git.gnome.org/browse/libxml2/commit/?id=3169602058bd2d04913909e869c61d1540bc7fb4, and was reported here: https://bugzilla.gnome.org/show_bug.cgi?id=766834.

They haven't released a new version with that bugfix yet though.

Revision history for this message
scoder (scoder) wrote :

(Most) binary wheels of lxml 4.0.0 come with libxml2 2.9.5, which should resolve this issue.

Changed in lxml:
milestone: none → 4.0.0
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.