Bug on xmlclass XML file attributes generation fixed
authorlbessard
Fri, 07 Sep 2007 10:27:20 +0200
changeset 86 4f1dbdb0bed2
parent 85 fd17b0e0fd7e
child 87 ce2607713931
Bug on xmlclass XML file attributes generation fixed
xmlclass/xmlclass.py
--- a/xmlclass/xmlclass.py	Tue Sep 04 17:12:48 2007 +0200
+++ b/xmlclass/xmlclass.py	Fri Sep 07 10:27:20 2007 +0200
@@ -91,7 +91,10 @@
     elif type_compute in ["unsignedLong","long","integer"]:
         return int(value)
     elif type_compute == "decimal":
-        return float(value)
+        computed_value = float(value)
+        if computed_value % 1 == 0:
+            return int(computed_value)
+        return computed_value
     elif type_compute in ["string","anyURI","NMTOKEN","language"]:
         return value
     elif type_compute == "time":
@@ -740,9 +743,12 @@
                 return text
             elif values[1] == "attribute":
                 value = getattr(self, attr, None)
-                if values[0].startswith("cls"):
-                    value = value.getValue()
-                computed_value = ComputeValue(value)
+                if value != None:
+                    if values[0].startswith("cls"):
+                        value = value.getValue()
+                    computed_value = ComputeValue(value)
+                else:
+                    computed_value = None
                 if values[2] != "optional" or value != computed_value:
                     if len(bases) > 0:
                         base_extras[attr] = value