Exemplo n.º 1
0
 def __init__(self, outputParams, baseUri, implementation=implementation):
     """
     Note: The implementation must support createRootNode(baseUri).
     """
     NullWriter.__init__(self, outputParams)
     self._document = implementation.createRootNode(baseUri)
     self._destination_node = self._document
     self._characterData = []
     self._escapeOutput = True
     return
Exemplo n.º 2
0
    def create_doc(my, root_name="snapshot"):
        #from xml.dom.minidom import getDOMImplementation
        #impl = getDOMImplementation()
        #my.doc = impl.createDocument(None, root_name, None)

        my.doc = implementation.createRootNode(None)
        if root_name != None:
            root = my.doc.createElementNS(None,root_name)
            my.doc.appendChild(root)
        return my.doc
Exemplo n.º 3
0
 def __init__(self, outputParams, baseUri, implementation=implementation):
     """
     Note: The implementation must support createRootNode(baseUri).
     """
     NullWriter.__init__(self, outputParams)
     self._document = implementation.createRootNode(baseUri)
     self._destination_node = self._document
     self._characterData = []
     self._escapeOutput = True
     return
Exemplo n.º 4
0
    def build_dom_and_apply_style_sheet(self, xsl, file):
        #doc = xml.dom.minidom.Document()
        doc = implementation.createRootNode('file:///article.xml')

        self.app.ann_frame.build_xml(doc)

        xsltproc = Processor()
        xsltproc.appendStylesheet(DefaultFactory.fromUri(Uri.OsPathToUri(xsl)))
        output = xsltproc.runNode(doc, 'file:///article.xml')

        outFile = open(file, 'w')
        outFile.write(output)
        outFile.close()
Exemplo n.º 5
0
    def build_dom_and_apply_style_sheet(self, xsl, file):
        #doc = xml.dom.minidom.Document()
        doc = implementation.createRootNode('file:///article.xml')

        self.app.ann_frame.build_xml(doc)
            
        xsltproc = Processor()
        xsltproc.appendStylesheet(DefaultFactory.fromUri(Uri.OsPathToUri(xsl)))
        output = xsltproc.runNode(doc, 'file:///article.xml')

        outFile = open(file,'w')
        outFile.write(output)
        outFile.close()                  
Exemplo n.º 6
0
 def __init__(self, dicDatos):
     self.salida = StringIO()
     #self.doc = implementation.createDocument(EMPTY_NAMESPACE,'article', None,'articulo')
     #self.doc.publicId="-//OASIS//DTD DocBook XML V4.2//EN"
     #self.doc.systemId="http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"
     self.raiz = implementation.createRootNode('file:///article.xml')
     self.articulo = self.raiz.createElementNS(EMPTY_NAMESPACE,  'article')
     self.raiz.appendChild(self.articulo)
     self.articulo.setAttributeNS(None, 'lang', "es")
     self.raiz.publicId="-//OASIS//DTD DocBook XML V4.2//EN"
     #self.raiz.systemId="http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"
     self.raiz.systemId="/usr/share/sgml/docbook/dtd/xml/4.2/docbookx.dtd"
     self.convertir(dicDatos)
     self.articleinfo(dicDatos)
     self.cuerpo(dicDatos)
     print dicDatos
Exemplo n.º 7
0
    def test(self):
        # I create a test doc
        # TODO
        doc = implementation.createRootNode('file:///article.xml')
        docArtic = doc.createElementNS(EMPTY_NAMESPACE, 'article')
        doc.appendChild(docArtic)
        docelement = doc.createElementNS(EMPTY_NAMESPACE, 'title')
        docelement.appendChild(doc.createTextNode(u'Titulo del articulo'))
        docArtic.appendChild(docelement)

        # Print the doc
        PrettyPrint(doc)

        # run the doc + styleSheet
        #out = StringIO()
        
        return self.processor.runNode(doc) #, outputStream=out)#dom_doc)
Exemplo n.º 8
0
    def export_to_xml(self, file = None):
        if self.export_xml is None:
            self.export_xml = os.path.join(".", "print.xml")
        if file is None:
            file = asksaveasfilename(title="Export to XML as...",
                            filetypes=[("XML files","*.xml"),("All files","*")],
                            initialfile=os.path.split(self.export_xml)[1],
                            initialdir=os.path.split(self.export_xml)[0])

        if file == "" or file is ():
            return 

        doc = implementation.createRootNode('file:///article.xml')

        self.app.ann_frame.build_xml(doc)
            
        outFile = open(file,'w')
        Print(doc, stream=outFile)
        outFile.close()                  
Exemplo n.º 9
0
    def export_to_xml(self, file=None):
        if self.export_xml is None:
            self.export_xml = os.path.join(".", "print.xml")
        if file is None:
            file = asksaveasfilename(
                title="Export to XML as...",
                filetypes=[("XML files", "*.xml"), ("All files", "*")],
                initialfile=os.path.split(self.export_xml)[1],
                initialdir=os.path.split(self.export_xml)[0])

        if file == "" or file is ():
            return

        doc = implementation.createRootNode('file:///article.xml')

        self.app.ann_frame.build_xml(doc)

        outFile = open(file, 'w')
        Print(doc, stream=outFile)
        outFile.close()
Exemplo n.º 10
0
 def startDocument(self):
     from Ft.Xml.Domlette import implementation
     self._ownerDoc = implementation.createRootNode()
     self._namespaces = {}
     self._nodeStack = [self._ownerDoc]
     return
Exemplo n.º 11
0
def doc_from_fragment(node):
    doc = implementation.createRootNode(generate_uri())
    new_node = doc.importNode(node, True)
    doc.appendChild(new_node)
    return doc
Exemplo n.º 12
0
 def startDocument(self):
     from Ft.Xml.Domlette import implementation
     self._ownerDoc = implementation.createRootNode()
     self._namespaces = {}
     self._nodeStack = [self._ownerDoc]
     return
Exemplo n.º 13
0
def doc_from_fragment(node):
    doc = implementation.createRootNode(generate_uri())
    new_node = doc.importNode(node, True)
    doc.appendChild(new_node)
    return doc