Hi,I report an issue with on bitbucket, but I think the discussion is more active here. Please ignore this email if this is not the right place to report bug.
--- Copied from Bitbucket ---Thanks for the greate package. I’m using generateDS to create Python bindings for XML schema, and it works pretty well. I have a small issue though: the method to_etree of the generated class does not handle attributes well.
Reproduction of the issue:
The following schema describes an element “Rotation“ with two children
(pitch, yaw) and one attribute (roll). All these children and attributes
are floats between 0 and 360.
<?xml version="1.0" encoding="UTF-8"?><schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.example.org/Rotation/" targetNamespace="http://www.example.org/Rotation/"
<element name="Rotation">
<complexType>
<sequence>
<element name="pitch" type="tns:degree"></element>
<element name="yaw" type="tns:degree"></element>
</sequence>
<attribute name="roll" type="tns:degree" use="required"></attribute>
</complexType>
</element>
<simpleType name="degree">
<restriction base="float">
<minInclusive value="0"></minInclusive>
<maxInclusive value="360"></maxInclusive>
</restriction>
</simpleType>
</schema>
Then I generate the python class with:
generateDS -o rotation.py -f -q --preserve-cdata-tags --export="write etree"
Rotation.xsd
The issue is that the to_etree method of the generated class throws an
error:
import rotation obj = rotation.Rotation(roll=1, pitch=2, yaw=3) obj_etree = obj.to_etree() # Exception here: TypeError: Argument must be bytes or unicode, got 'float'I think the reason is that the generated code does not convert the attribute to string first (lines 935-936):
if self.roll is not None:
element.set('roll', self.roll) # Exception here
I’m missing something or is this a bug in generateDS?
Kind regards,
Van Huynh Le
Rotation.xsd
Description: XML document
<?xml version="1.0" encoding="UTF-8"?> <tns:Rotation roll="0.0" xmlns:tns="http://www.example.org/Rotation/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.example.org/Rotation/ Rotation.xsd "> <pitch>0.0</pitch> <yaw>0.0</yaw> </tns:Rotation>
_______________________________________________ generateds-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/generateds-users
