"""Demonstrates the Transformer object. """ import Pyana import sys import time xsl = r''' ''' xml = 'Hello World' t = Pyana.Transformer() # Python XPath extensions can be installed on a per-transformation object # basis using: # t.installExtension() # t.installExtensionWithContext() # t.removeExtension t.setStylesheetParams({'excitement' : "'!'"}) # Disable validation for source documents (disabled is the default) t.useValidation = 0 startTime = time.clock() for i in range(100): t.transform2String(xml, xsl) print 'Time to transform (x100) without compilation: %.4fs' % (time.clock() - startTime) compiled = t.compileStylesheet(xsl) parsed = t.parseSource(xml) startTime = time.clock() for i in range(100): t.transform2String(parsed, compiled) print 'Time to transform (x100) with compilation: %.4fs' % (time.clock() - startTime)