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
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
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()
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()
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
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)
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()
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()
def startDocument(self): from Ft.Xml.Domlette import implementation self._ownerDoc = implementation.createRootNode() self._namespaces = {} self._nodeStack = [self._ownerDoc] return
def doc_from_fragment(node): doc = implementation.createRootNode(generate_uri()) new_node = doc.importNode(node, True) doc.appendChild(new_node) return doc