How to run XSLT from the command line
|Time required (minutes)||15|
XSLT is a W3C standard programming language primarily designed to process XML content. One task it is particularly well suited to is transforming XML to another syntax such as plain text or HTML or to an alternate XML structure. This tutorial shows how to do an XSLT transformation using the Windows command line.
To complete this tutorial requires:
- Software to read and write zip files (e.g. 7-Zip or on Windows right-click Extract all/Send to Compressed).
- Access to the command prompt on a local computer (on Windows run
- A decent text editing program such as Notepad++, Sublime or something that is not Windows Notepad. Notepad will have problems with the line endings.
Installing an XSLT processor
To interpret and run XSLT code requires an XSLT processor. The steps below will install the Saxon XSLT processor on Windows.
- If it is not already present, install Java as follows:
- Go to https://www.oracle.com/java and choose Java for Developers / Java SE.
- Download the JDK or JRE .exe for windows (x64 for 64 bit) and run it.
- Go to http://sourceforge.net/projects/saxon/files/ , download the latest SaxonHE
.zipfile and unzip it to the
Run the XSLT code
- Create a data folder (e.g.
c:\ps\films) on the computer and copy to it:
- the input XML files (
- the XSLT code file (
- Open a command prompt in the data folder and use Saxon to process the XML with the XSLT code. For example:
> java -jar c:\saxon\saxon9he.jar -s:myinput.xml -xsl:myxslt.xsl -o:myoutput.xml
Open the output in a text editor to check the content.
Created on , last edited on