def decode(self, node, errs, where = ""): # flags, tag name, instance attribute assert self.tag != '' nodes = xmlext.getAllNodes(node, self.tag) if not nodes: if self.req == mandatory: errs.append(where + ': ' + _("At least one '%s' tag should have local text") % self.tag ) else: for node in nodes: lang = xmlext.getNodeAttribute(node, 'xml:lang') c = xmlext.getNodeText(node) if not c: errs.append(where + ': ' + _("'%s' language of tag '%s' is empty") % (lang, self.tag)) # FIXME: check for dups and 'en' if not lang: lang = 'en' self[lang] = c
def readtext(node, attr): return xmlext.getNodeAttribute(node, attr)