def _add_element_attlist(self, element, xmlattribute, ident): try: attrmap = element.get_attribute("ATTRIBUTES") kwattrmap = element.get_attribute("KWATTRIBUTES") except KeyError: element.add_attribute("ATTRIBUTES", AttributeMap()) element.add_attribute("KWATTRIBUTES", AttributeMap()) attrmap = element.get_attribute("ATTRIBUTES") kwattrmap = element.get_attribute("KWATTRIBUTES") attrmap[xmlattribute.name] = ident keywordname = keyword_identifier(normalize_unicode(xmlattribute.name)) kwattrmap[keywordname] = ident
def new_attribute(self, elem, a_name, a_type, a_decl, a_def): "Receives the declaration of a new attribute." attr = XMLAttribute(a_name, a_type, a_decl, a_def) ident = attr.get_identifier() self._allattributes[ident] = attr try: element = self.elements[elem] except KeyError: # Got a forward attribute definition (defined before element) try: fwdattribs, fwdkwattribs = self._forwardattributes[elem] except KeyError: fwdattribs = AttributeMap() fwdkwattribs = AttributeMap() self._forwardattributes[elem] = (fwdattribs, fwdkwattribs) fwdattribs[a_name] = ident keywordname = keyword_identifier(normalize_unicode(a_name)) fwdkwattribs[keywordname] = ident else: self._add_element_attlist(element, attr, ident)
def get_identifier(uname): return identifier(normalize_unicode(uname))
def new_general_entity(self, name, val): "Receives internal general entity declarations." self.general_entities[normalize_unicode(name)] = val