def append_attributes(self, content): """ Append attribute nodes into L{Content.data}. Attributes in the I{schema} or I{xml} namespaces are skipped. @param content: The current content being unmarshalled. @type content: L{Content} """ attributes = AttrList(content.node.attributes) for attr in attributes.real(): name = attr.name value = attr.value self.append_attribute(name, value, content)
def postprocess(self, content): """ Perform final processing of the resulting data structure as follows: - Mixed values (children and text) will have a result of the I{content.node}. - Simi-simple values (attributes, no-children and text) will have a result of a property object. - Simple values (no-attributes, no-children with text nodes) will have a string result equal to the value of the content.node.getText(). @param content: The current content being unmarshalled. @type content: L{Content} @return: The post-processed result. @rtype: I{any} """ node = content.node if len(node.children) and node.hasText(): return node attributes = AttrList(node.attributes) if attributes.rlen() and \ not len(node.children) and \ node.hasText(): p = Factory.property(node.name, node.getText()) return merge(content.data, p) if len(content.data): return content.data lang = attributes.lang() if content.node.isnil(): return None if not len(node.children) and content.text is None: if self.nillable(content): return None else: return Text('', lang=lang) if isinstance(content.text, basestring): return Text(content.text, lang=lang) else: return content.text