예제 #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