use of abstract class in validation schema

Bug #1502406 reported by bfranco
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
lxml
Invalid
Undecided
Unassigned

Bug Description

here is a bug, i think....

Or is it possible to give me a solution:

xsd file is attached.

simple lxml code ==========================================

from lxml import etree
xmlout = etree.Element("animals")
tmp = etree.SubElement(xmlout, "animal")
tmp.set("xsi:type","sheepType")

# --- validation
xsdinfile = "database.xsd"
xmloutfile= "test.xml"
print " -","input xsd file:",xsdinfile
print " -","output xml file:",xmloutfile

schema = etree.XMLSchema(etree.parse(xsdinfile))
valid = schema.validate(xmlout)
schema.assertValid(xmlout)
print " -","validation:",valid

with open(xmloutfile, 'w') as output_file:
    output_file.write(etree.tostring(xmlout, pretty_print = True))

========================================================

output error ==================================================
python lmxl_test.py
Traceback (most recent call last):
  File "lmxl_test.py", line 4, in <module>
    tmp.set("xsi:type","sheepType")
  File "lxml.etree.pyx", line 744, in lxml.etree._Element.set (src/lxml/lxml.etree.c:44335)
  File "apihelpers.pxi", line 549, in lxml.etree._setAttributeValue (src/lxml/lxml.etree.c:19484)
  File "apihelpers.pxi", line 1583, in lxml.etree._attributeValidOrRaise (src/lxml/lxml.etree.c:29377)
ValueError: Invalid attribute name u'xsi:type'
========== ==================================================

please could you send me a solution ?

Revision history for this message
bfranco (biglosr) wrote :
Revision history for this message
scoder (scoder) wrote :

Note that the error occurs *before* the validation. See
http://lxml.de/tutorial.html#namespaces

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

Other bug subscribers

Bug attachments

Remote bug watches

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