def attributes(self): attrs = {} for name, value in self.attrib.items(): a = Attr(name) a.value = value attrs[name] = a return NamedNodeMap(attrs, {}, self)
def __init__(self, node, parent, index, siblings=None): Attr.__init__(self, node.name, namespaceURI=node.namespaceURI, localName=node.localName, prefix=node.prefix) self._set_value(node.value) self.ownerDocument = node.ownerDocument self.ownerElement = node.ownerElement self.parentNode = parent self.previousSibling = None self.nextSibling = None if siblings: self.previousSibling = siblings[0] self.nextSibling = siblings[1] if not self.previousSibling: if (index > 0): idx = index - 1 self.previousSibling = XMLTreeModelAttr( parent.attributes.item(idx), parent, idx, (None, self)) if not self.nextSibling: if (index < parent.attributes.length - 1): idx = index + 1 self.nextSibling = XMLTreeModelAttr( parent.attributes.item(idx), parent, idx, (self, None)) elif parent.hasChildNodes(): node = parent.firstChild while _is_blank_node(node): node = node.nextSibling self.nextSibling = node
def __init__(self, node, parent, index, siblings=None): Attr.__init__(self, node.name, namespaceURI=node.namespaceURI, localName=node.localName, prefix=node.prefix) self._set_value(node.value) self.ownerDocument = node.ownerDocument self.ownerElement = node.ownerElement self.parentNode = parent self.previousSibling = None self.nextSibling = None if siblings: self.previousSibling = siblings[0] self.nextSibling = siblings[1] if not self.previousSibling: if index > 0: idx = index - 1 self.previousSibling = XMLTreeModelAttr(parent.attributes.item(idx), parent, idx, (None, self)) if not self.nextSibling: if index < parent.attributes.length - 1: idx = index + 1 self.nextSibling = XMLTreeModelAttr(parent.attributes.item(idx), parent, idx, (self, None)) elif parent.hasChildNodes(): node = parent.firstChild while _is_blank_node(node): node = node.nextSibling self.nextSibling = node