--- a/OSSEval/entity/models.py
+++ b/OSSEval/entity/models.py
@@ -7,18 +7,14 @@
actual_entity_app = models.CharField(max_length=200) #the app where the above classes are
def from_xml(self, xmldoc, insert = True):
if not insert:
- self.id = xmldoc.getElementsByTagName('Id')[0].firstChild.data
- self.name = xmlMinidom.getString(xmldoc, 'Name')
- self.actual_entity_class = xmlMinidom.getString(xmldoc, 'ActualEntityClass')
- self.actual_entity_app = xmlMinidom.getString(xmldoc, 'ActualEntityApp')
+ self.id = xmlMinidom.getNaturalAttribute(xmldoc, 'Id')
+ self.name = xmlMinidom.getStringAttribute(xmldoc, 'Name')
+ self.actual_entity_class = xmlMinidom.getStringAttribute(xmldoc, 'ActualEntityClass')
+ self.actual_entity_app = xmlMinidom.getStringAttribute(xmldoc, 'ActualEntityApp')
# I save so I get the ID (if insert == True)
self.save()
def to_xml(self):
- str_xml = "<Id>" + str(self.id) + "</Id>"
- str_xml += "<Name>" + self.name + "</Name>"
- str_xml += "<ActualEntityClass>" + self.actual_entity_class + "</ActualEntityClass>"
- str_xml += "<ActualEntityApp>" + self.actual_entity_app + "</ActualEntityApp>"
- return "<Entity>" + str_xml + "</Entity>"
+ return '<Entity Id="' + str(self.id) + '" Name="' + self.name + '" ActualEntityClass="' + self.actual_entity_class + '" ActualEntityApp="' + self.actual_entity_app + '"/>'
def __unicode__(self):
return self.name