libxslt.py 973 B

123456789101112131415161718192021222324252627
  1. import utils.makedirs
  2. import os.path
  3. import os
  4. import sys
  5. def libxslt( log, xml_file, xsl_file, output_file, parameters = None ):
  6. utils.makedirs( os.path.dirname( output_file ) )
  7. if sys.platform == 'win32':
  8. os.chdir( os.path.dirname( xsl_file ) )
  9. transform_command = 'xsltproc'
  10. transform_command = transform_command + ' -o ' + '%s' % output_file.replace( '\\', '/' ).replace( ' ', '%20' )
  11. if parameters is not None:
  12. for i in parameters:
  13. if parameters[i]:
  14. parameters[i] = parameters[i].replace( '\\', '/' )
  15. transform_command = transform_command + ' --param %s "\'%s\'" ' % ( i, parameters[ i ] )
  16. transform_command = transform_command + ' "%s" ' % xsl_file.replace( '\\', '/' ).replace( ' ', '%20' )
  17. transform_command = transform_command + ' "%s" ' % xml_file.replace( '\\', '/' ).replace( ' ', '%20' )
  18. log( transform_command )
  19. os.system( transform_command )
粤ICP备19079148号