Not properly objectifying attributes
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
lxml |
New
|
Undecided
|
Unassigned |
Bug Description
= VERSION INFO =
Python : sys.version_
lxml.etree : (4, 4, 1, 0)
libxml used : (2, 9, 9)
libxml compiled : (2, 9, 9)
libxslt used : (1, 1, 33)
libxslt compiled : (1, 1, 33)
= ISSUE =
It seems that when objectifying, attributes don't seem to be properly following the XSI schema.
= REPRODUCTION =
I have attached a tarball of a POC (there are some irrelevant function calls before it; they can be ignored). It demonstrates that text() objects are indeed properly identified and objectified as e.g. xs:positiveInteger => int() as according to their xsi type, but attributes with e.g. base type xs:positiveInteger are interpolated as type str().
./test.py in the tarball should get you a dump and it's commented with where it does what I... don't expect it to.
Is this expected?
Sorry; worth noting that the XSD and XML validate per xmllint(1):
[bts@cylon testxml]$ xmllint --noout --schema test.xsd test.xml
test.xml validates
and via lxml's validation as well (done from the same directory as the POC tarball):
[bts@cylon testxml]$ python
Python 3.7.4 (default, Oct 4 2019, 06:57:26)
[GCC 9.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import base
>>> import XSD
>>> xsd = XSD.XSD()
>>> xml = base.XML()
>>> xsd.isValid(xml)
True