コード例 #1
0
ファイル: rdfa.py プロジェクト: scrapinghub/extruct
 def attributes(self):
     attrs = {}
     for name, value in self.attrib.items():
         a = Attr(name)
         a.value = value
         attrs[name] = a
     return NamedNodeMap(attrs, {}, self)
コード例 #2
0
    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
コード例 #3
0
 def attributes(self):
     attrs = {}
     for name, value in self.attrib.items():
         a = Attr(name)
         a.value = value
         attrs[name] = a
     return NamedNodeMap(attrs, {}, self)
コード例 #4
0
    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