libxslt.py

来自「C++的一个好库。。。现在很流行」· Python 代码 · 共 28 行

PY
28
字号

import utils.makedirs
import os.path
import os
import sys

def libxslt( log, xml_file, xsl_file, output_file, parameters = None ):

    utils.makedirs( os.path.dirname( output_file ) )
    
    if sys.platform == 'win32':
        os.chdir( os.path.dirname( xsl_file ) )

    transform_command = 'xsltproc'
    transform_command = transform_command + ' -o ' + '%s' % output_file.replace( '\\', '/' ).replace( ' ', '%20' )

    if parameters is not None:
         for i in parameters:
             if parameters[i]:
                 parameters[i] = parameters[i].replace( '\\', '/' )
                 transform_command = transform_command + ' --param %s "\'%s\'" ' % ( i, parameters[ i ] )

    transform_command = transform_command + ' "%s" ' % xsl_file.replace( '\\', '/' ).replace( ' ', '%20' )
    transform_command = transform_command + ' "%s" ' % xml_file.replace( '\\', '/' ).replace( ' ', '%20' )
    log( transform_command )
    os.system( transform_command )    

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?