def runNode(self, DomNode):
     """ classic XSLT transformation """
     self.first_pass = True
     self.currentRule = None
     self.our_writer = Dom.CustomDomWriter()
     Processor.runNode(self, DomNode, writer=self.our_writer)
     self.last_result = self.our_writer.getResult()
     self.first_pass = False
     return self.our_writer.getResult()
 def runNode(self,DomNode):
   """ classic XSLT transformation """
   self.first_pass = True
   self.currentRule = None
   self.our_writer = Dom.CustomDomWriter()
   Processor.runNode(self,DomNode,writer=self.our_writer)
   self.last_result = self.our_writer.getResult()
   self.first_pass = False
   return self.our_writer.getResult()
Ejemplo n.º 3
0
        def applyXslt(self,
                      xslStylesheet,
                      topLevelParams=None,
                      extFunctionMap=None,
                      baseUri='file:',
                      styleSheetCache=None):
            extFunctionMap = extFunctionMap or {}

            from Ft.Xml.Xslt.Processor import Processor
            processor = Processor()

            if styleSheetCache:
                styleSheet = styleSheetCache.getValue(xslStylesheet, baseUri)
                processor.appendStylesheetInstance(styleSheet, baseUri)
            else:
                processor.appendStylesheet(
                    InputSource.DefaultFactory.fromString(
                        xslStylesheet, baseUri))  #todo: fix baseUri

            for (k, v) in extFunctionMap.items():
                namespace, localName = k
                processor.registerExtensionFunction(namespace, localName, v)

            return processor.runNode(self.dom, None, 0,
                                     topLevelParams), processor.stylesheet
Ejemplo 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()
Ejemplo 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()                  
Ejemplo n.º 6
0
 def runNode(self,node,nameSpace=EMPTY_NAMESPACE):
     self.writer.write(codecs.getdecoder('utf-8')(XsltProcessor.runNode(self,node,nameSpace))[0])
Ejemplo n.º 7
0
 def runNode(self,node,nameSpace=EMPTY_NAMESPACE):
     self.streamWriter.write(codecs.getdecoder(DEFAULT_ENCODING)(XsltProcessor.runNode(self,node,nameSpace))[0])