xmlclass/xmlclass.py
changeset 1734 750eeb7230a1
parent 1732 94ffe74e6895
child 1736 7e61baa047f0
equal deleted inserted replaced
1733:dea107dce0c4 1734:750eeb7230a1
   708         children_infos = []
   708         children_infos = []
   709         children = []
   709         children = []
   710         for child in node.childNodes:
   710         for child in node.childNodes:
   711             if child.nodeName not in ["#comment", "#text"]:
   711             if child.nodeName not in ["#comment", "#text"]:
   712                 namespace, childname = DecomposeQualifiedName(child.nodeName)
   712                 namespace, childname = DecomposeQualifiedName(child.nodeName)
   713                 children_structure += "%s "%childname
   713                 children_structure += "%s " % childname
   714         result = elements_model.match(children_structure)
   714         result = elements_model.match(children_structure)
   715         if not result:
   715         if not result:
   716             raise ValueError("Invalid structure for \"%s\" children!. First element invalid." % node.nodeName)
   716             raise ValueError("Invalid structure for \"%s\" children!. First element invalid." % node.nodeName)
   717         valid = result.groups()[0]
   717         valid = result.groups()[0]
   718         if len(valid) < len(children_structure):
   718         if len(valid) < len(children_structure):
  1097             if infos is not None:
  1097             if infos is not None:
  1098                 if infos["type"] != SIMPLETYPE:
  1098                 if infos["type"] != SIMPLETYPE:
  1099                     raise ValueError("\"%s\" type is not a simple type!" % attribute["attr_type"])
  1099                     raise ValueError("\"%s\" type is not a simple type!" % attribute["attr_type"])
  1100                 attrname = attribute["name"]
  1100                 attrname = attribute["name"]
  1101                 if attribute["use"] == "optional":
  1101                 if attribute["use"] == "optional":
  1102                     classmembers["add%s"%attrname] = generateAddMethod(attrname, self, attribute)
  1102                     classmembers["add%s" % attrname] = generateAddMethod(attrname, self, attribute)
  1103                     classmembers["delete%s"%attrname] = generateDeleteMethod(attrname)
  1103                     classmembers["delete%s" % attrname] = generateDeleteMethod(attrname)
  1104                 classmembers["set%s"%attrname] = generateSetMethod(attrname)
  1104                 classmembers["set%s" % attrname] = generateSetMethod(attrname)
  1105                 classmembers["get%s"%attrname] = generateGetMethod(attrname)
  1105                 classmembers["get%s" % attrname] = generateGetMethod(attrname)
  1106             else:
  1106             else:
  1107                 raise ValueError("\"%s\" type unrecognized!" % attribute["attr_type"])
  1107                 raise ValueError("\"%s\" type unrecognized!" % attribute["attr_type"])
  1108             attribute["attr_type"] = infos
  1108             attribute["attr_type"] = infos
  1109 
  1109 
  1110         for element in classinfos["elements"]:
  1110         for element in classinfos["elements"]:
  1111             if element["type"] == CHOICE:
  1111             if element["type"] == CHOICE:
  1112                 elmtname = element["name"]
  1112                 elmtname = element["name"]
  1113                 choices = ComputeContentChoices(self, name, element)
  1113                 choices = ComputeContentChoices(self, name, element)
  1114                 classmembers["get%schoices"%elmtname] = generateGetChoicesMethod(element["choices"])
  1114                 classmembers["get%schoices" % elmtname] = generateGetChoicesMethod(element["choices"])
  1115                 if element["maxOccurs"] == "unbounded" or element["maxOccurs"] > 1:
  1115                 if element["maxOccurs"] == "unbounded" or element["maxOccurs"] > 1:
  1116                     classmembers["append%sbytype" % elmtname] = generateAppendChoiceByTypeMethod(element["maxOccurs"], self, element["choices"])
  1116                     classmembers["append%sbytype" % elmtname] = generateAppendChoiceByTypeMethod(element["maxOccurs"], self, element["choices"])
  1117                     classmembers["insert%sbytype" % elmtname] = generateInsertChoiceByTypeMethod(element["maxOccurs"], self, element["choices"])
  1117                     classmembers["insert%sbytype" % elmtname] = generateInsertChoiceByTypeMethod(element["maxOccurs"], self, element["choices"])
  1118                 else:
  1118                 else:
  1119                     classmembers["set%sbytype" % elmtname] = generateSetChoiceByTypeMethod(self, element["choices"])
  1119                     classmembers["set%sbytype" % elmtname] = generateSetChoiceByTypeMethod(self, element["choices"])