I have been trying to figure out a way to batch transform files in directory using an xslt. I tried xml wrench and a few other software but i need to put all this in a script or batch that i can run as needed.
I have started out with a batch file using raptorxml command line as below:
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"
When I try to put this in a batch file as below, I can not understand a thing of what's going on - can't make out if the script ran or was there any error.. Tried putting ECHO in between but that did not help either. I tried to redirect the output to a log using >log.log but that would just get an echo of each of the lines in the file.. i cant see the value of the variables in the look or how the call to raptorxml is being formed. Any hints or pointers will be helpful - thanks.
Here is my batch file: I run it as 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
After the initial answer/post, I added more logic to call the script from another to process files from all subdirs of the input dirs. Thought of sharing that script here:
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"
pushdandpopdinstead ofcd