我一直在想方設法使用xslt批量轉換目錄中的文件。我嘗試了xml扳手和其他一些軟件,但是我需要將所有這些放在腳本或批處理中,以便我可以根據需要運行。批量轉換xslt xml
我一直在使用如下raptorxml命令行開始了一個批處理文件:
C:\Program Files (x86)\Altova\RaptorXMLServer2013\bin>RaptorXML.exe xslt --input=c:\data\test1.xml --output=c:\data\output1.xml c:\data\test.xsl
file:///c:/data/test1.xml: result="OK" xslt-output-files="file:///c:/data/output1.xml"
當我嘗試下面把這個批處理文件,我不明白這是怎麼回事的事情 - 不能確定腳本是否運行或出現任何錯誤。試圖將ECHO置於中間,但也沒有幫助。我嘗試使用> log.log將輸出重定向到日誌,但這隻會得到文件中每行的回顯。我無法在外觀中看到變量的值,或者如何調用raptorxml形成。任何提示或指針都會有幫助 - 謝謝。
這裏是我的批處理文件:我運行它batchxform.bat C:\data\ip
cls
call :treeProcess
goto :eof
:treeProcess
cd %1
for %%f in (*.xml) do (
RaptorXML.exe xslt --input=%%f --output=c:\data\op\%%~nf.xml c:\data\test.xsl
)
for /D %%d in (%1) do (
cd %%d
call :treeProcess
cd ..
)
exit /b
初始答案/文章後,我加入了更多的邏輯從另一個調用腳本從輸入迪爾斯的所有子目錄處理文件。想到這裏共享該腳本:
ECHO OFF
set _xform=C:\Users\gkalra\Documents\work\Annotation\code\batchxform.cmd
rem call _xform %1
FOR /R %1 %%G in (.) DO (
Pushd %%G
Echo now in %%G
rem dir /b "%%G/*.xml"
call "%_xform%" %%G
Popd
)
Echo "back home"
對於一個你應該使用'pushd'和'popd',而不是'cd' – Monacraft
是的的確是一..意識到遲到。 –