如何使用或执行命令CMD将Xalan与Python脚本/Cod结合使用

2024-07-04 16:50:39 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在做一项任务,同时学习使用Python2.7和XalanXSLT处理器编程。你知道吗

代码:

    import wx, os
    from subprocess import call

    def OnImport(self, event):
    if self.Controler is not None and not self.CheckSaveBeforeClosing():
        return
    filepath = ""
    if self.Controler is not None:
        filepath = self.Controler.GetFilePath()
    if filepath != "":
        directory = os.path.dirname(filepath)
    else:
        directory = os.getcwd()


    #Choose Source File
    dialogIn = wx.FileDialog(self, _("Choose a model file"), directory, "",  _("model files (*.xml)|*.xml|All files|*.*"), wx.OPEN)
    if dialogIn.ShowModal() == wx.ID_OK:
        filepath = dialogIn.GetPath()
    else:
        return
    dialogIn.Destroy()


    #Choose Out XML Directory
    dirpath = ""
    dialogOut = wx.DirDialog (self,"Choose Out XML Directory","",wx.OPEN)
    if dialogOut.ShowModal () == wx.ID_OK:
        dirpath =  dialogOut.GetPath ()
        filepathplc = dirpath + "\plc.xml"

    # calling xalan via cmd
        call (['java', '-classpath', '"xalan.jar";"serializer.jar"', 'org.apache.xalan.xslt.Process', '-in', filepath, '-xsl', 'C:\Users\User\Desktop\XSL_Folder\debproj3.xsl', '-out', filepathplc, '/n'])
    else:
        return
    dialogOut.Destroy ()

我想用xalan xslt处理器和调用xalan部分来做xslt,但是什么也没有得到。我想用cmd写这个命令:

    java -classpath "xalan.jar";"serializer.jar" org.apache.xalan.xslt.Process -in "source directory file" -xsl "xsl directory file" -out "output  target directory file"

Tags: selfifosdirectoryjarfilewxxsl

热门问题