equal
deleted
inserted
replaced
720 def GenerateElement(element_name, attributes, elements_model, |
720 def GenerateElement(element_name, attributes, elements_model, |
721 accept_text=False): |
721 accept_text=False): |
722 def ExtractElement(factory, node): |
722 def ExtractElement(factory, node): |
723 attrs = factory.ExtractNodeAttrs(element_name, node, attributes) |
723 attrs = factory.ExtractNodeAttrs(element_name, node, attributes) |
724 children_structure = "" |
724 children_structure = "" |
725 children_infos = [] |
|
726 children = [] |
725 children = [] |
727 for child in node.childNodes: |
726 for child in node.childNodes: |
728 if child.nodeName not in ["#comment", "#text"]: |
727 if child.nodeName not in ["#comment", "#text"]: |
729 namespace, childname = DecomposeQualifiedName(child.nodeName) |
728 namespace, childname = DecomposeQualifiedName(child.nodeName) |
730 children_structure += "%s " % childname |
729 children_structure += "%s " % childname |
1276 return classCreatefunction |
1275 return classCreatefunction |
1277 |
1276 |
1278 |
1277 |
1279 def generateGetattrMethod(factory, class_definition, classinfos): |
1278 def generateGetattrMethod(factory, class_definition, classinfos): |
1280 attributes = dict([(attr["name"], attr) for attr in classinfos["attributes"] if attr["use"] != "prohibited"]) |
1279 attributes = dict([(attr["name"], attr) for attr in classinfos["attributes"] if attr["use"] != "prohibited"]) |
1281 optional_attributes = dict([(attr["name"], True) for attr in classinfos["attributes"] if attr["use"] == "optional"]) |
|
1282 elements = dict([(element["name"], element) for element in classinfos["elements"]]) |
1280 elements = dict([(element["name"], element) for element in classinfos["elements"]]) |
1283 |
1281 |
1284 def getattrMethod(self, name): |
1282 def getattrMethod(self, name): |
1285 if name in attributes: |
1283 if name in attributes: |
1286 attribute_infos = attributes[name] |
1284 attribute_infos = attributes[name] |
1577 attribute["attr_type"] = FindTypeInfos(factory, attribute["attr_type"]) |
1575 attribute["attr_type"] = FindTypeInfos(factory, attribute["attr_type"]) |
1578 if attribute["use"] == "required": |
1576 if attribute["use"] == "required": |
1579 self.set(attribute["name"], attribute["attr_type"]["generate"](attribute["attr_type"]["initial"]())) |
1577 self.set(attribute["name"], attribute["attr_type"]["generate"](attribute["attr_type"]["initial"]())) |
1580 for element in classinfos["elements"]: |
1578 for element in classinfos["elements"]: |
1581 if element["type"] != CHOICE: |
1579 if element["type"] != CHOICE: |
1582 element_name = ( |
|
1583 etree.QName(factory.NSMAP["xhtml"], "p") |
|
1584 if element["type"] == ANY |
|
1585 else factory.etreeNamespaceFormat % element["name"]) |
|
1586 initial = GetElementInitialValue(factory, element) |
1580 initial = GetElementInitialValue(factory, element) |
1587 if initial is not None: |
1581 if initial is not None: |
1588 map(self.append, initial) |
1582 map(self.append, initial) |
1589 return initMethod |
1583 return initMethod |
1590 |
1584 |