コード例 #1
0
 def process_record(self, session, rec):
     elems = []
     for m in self.maps:
         (xpath, tagPath) = m
         node = z3950.TaggedElement()            
         data = self._resolveData(session, rec, xpath)
         node.content = ('string', str(data))
         node.tagType = 2
         node.tagValue = ('numeric', int(tagPath))
         elems.append(node)
     return StringDocument(elems, self.id, rec.processHistory, parent=rec.parent)
コード例 #2
0
 def characters(self, text, zero, length):
     if (self.nodeStack):
         if (text.isspace()):
             text = " "
         # pre-encode to utf8 to avoid charset/encoding headaches
         # eg these are now octets, not unicode
         text = text.encode('utf8')
         node = z3950.TaggedElement()
         node.tagType = 2
         node.tagValue = ('numeric', 19)
         node.content = ('octets', text)
         self.nodeStack[-1].content[1].append(node)
コード例 #3
0
    def startElement(self, name, attribs):
        node = z3950.TaggedElement()
        node.tagType = 3
        node.tagValue = ('string', name)
        node.content = ('subtree', [])

        for a in attribs:
            # Elements with Metadata
            anode = z3950.TaggedElement()
            md = z3950.ElementMetaData()
            anode.tagType = 3
            anode.tagValue = ('string', a)
            md.message = 'attribute'
            anode.metaData = md
            anode.content = ('octets', attribs[a])
            node.content[1].append(anode)

        if (self.nodeStack):
            self.nodeStack[-1].content[1].append(node)
        else:
            self.top = node
        self.nodeStack.append(node)