コード例 #1
0
ファイル: write_scixml.py プロジェクト: danieldmm/minerva
 def repl_func(m):
     """
         Replaces <CIT ID=0 /> with <REF ID=cit0 REFID=ref0 />
     """
     cit_id=m.group(1) # this is the actual unique identifier of a citation in the document
     ref_id=doc.citation_by_id[cit_id]["ref_id"] # this is the id of the reference the cit cites
     return u'<REF ID="'+safe_unicode(cit_id)+u'" REFID="'+safe_unicode(ref_id)+'" />'
コード例 #2
0
ファイル: write_scixml.py プロジェクト: danieldmm/minerva
    def write(self, doc, filename):
        """
        """
        self.already_rendered=[]
        lines=[]
        lines.append('<?xml version="1.0" encoding="UTF-8"?>')
        lines.append('<!DOCTYPE PAPER SYSTEM "paper-structure-annotation.dtd">')

        lines.append("<PAPER>")
        lines.extend(self.writeMetadata(doc))
        lines.extend(self.writeAbstract(doc))
        lines.extend(self.writeBody(doc))
        lines.extend(self.writeReferences(doc))
        lines.append("</PAPER>")

        lines2=[]
        for line in lines:
            lines2.append(safe_unicode(line))

        lines=lines2
    ##    text="\n".join(lines)
        f=codecs.open(filename,"w", encoding="utf-8",errors="ignore")
    ##    f.writelines([line+"\n" for line in lines])
        f.writelines(lines)
        f.close()