Reputation: 1
I have a lot of XML files in folders - one XML for one page of a book. I need to put all the XMLs together in one root XML file and then make first transformation using XSL for removing namespaces and unwanted attributes (I have a XSL stylesheet for that), save the new XML and than transform it again using another stylesheet (I have prepared it too) and save the result text file. I do it at home in Oxygen with one XML file, but I need to make this process automatic, run it with some script. I must work in Windows and without Oxygen, customer has not any software for it and wants to make it by himself. How to put XMLs together without writing a root XML with !ENTITY tags? What software tools (for XSL transformation) can I use? How to make such script for Windows? I do programming in Python and a little in Java. Thank you very much.
Upvotes: 0
Views: 178
Reputation: 10188
For putting the XML files together so that you can process them as one file, one option would be to to write a cmd.exe batch script which produces a root XML file with external entity references to all your XML files.
Perhaps something like this (assuming the XML file names without the extension are allowed entity names):
@echo off
del root.xml 2> nul
(
echo ^<!DOCTYPE root [
for %%f in (*.xml) do (echo ^<!ENTITY %%~nf SYSTEM "%%f"^>)
echo ]^>
echo ^<root^>
for %%f in (*.xml) do (echo ^&%%~nf;)
echo ^</root^>
) > root.tmp
move root.tmp root.xml > nul
Alternatively, you could just output the file names using some XML tags, and access the files using the document()
function from your XSLT.
For running a XSLT transformation from the command line, you could use for example the msxsl.exe command line utility, which is a frontend to the MSXML library probably already installed on your system.
msxsl root.xml stylesheet.xsl
Upvotes: 0