def xmlWithXsl( self, xsl ): try: import Pyana except: raise FMProError( 'The Pyana library is not installed. You can download a copy from http://pyana.sourceforge.net.' ) xsl = open( xsl, 'rb' ) return str( Pyana.transform2String( self.data, xsl ) )
def render(self, source_xml, content_type): """ Render document using libxslt. """ # handle URI's as if they were in the ZODB t = Pyana.Transformer() resolver = UriResolver(self) t.setEntityResolver(resolver) return t.transform2String(StringSource(source_xml), StringSource(self()))
def xmlWithXsl(self, xsl): try: import Pyana except: raise FMProError( 'The Pyana library is not installed. You can download a copy from http://pyana.sourceforge.net.' ) xsl = open(xsl, 'rb') return str(Pyana.transform2String(self.data, xsl))
from __future__ import absolute_import import Pyana import tempfile import webbrowser import sys from six.moves import urllib source_uri = Pyana.URI('file:' + urllib.request.pathname2url(sys.argv[1])) style_uri = Pyana.URI('file:' + urllib.request.pathname2url(sys.argv[2])) if len(sys.argv) > 3: target_file_name = sys.argv[3] else: target_file_name = tempfile.mktemp('.html') Pyana.transformToFile(source_uri, style_uri, target_file_name) webbrowser.open(target_file_name)
import Pyana xmlsource = "test.xml" xsltsource = "base.xsl" # From URIs print Pyana.transform2String( source=Pyana.URI(xmlsource), style=Pyana.URI(xsltsource))
def transformStrings(xmldata, xsldata, outpath=None): results = Pyana.transform2String(xmldata, xsldata) if outpath: file(outpath, 'w').write(results) else: print results