Tutorials

Task-driven tutorials and recipes for PageSeeder

How to run XSLT from the command line

Skills requiredXML
Time required (minutes)15
Intended audienceDeveloper
DifficultyEasy
CategoryDocument

Objective

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.

Prerequisites

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 cmd);
  • A decent text editing program such as Notepad++, Sublime or something that is not Windows Notepad. Notepad will have problems with the line endings.

Tutorial

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:
  1. Go to https://www.oracle.com/java  and choose Java for Developers / Java SE.
  2. Download the JDK or JRE .exe for windows (x64 for 64 bit) and run it.

Run the XSLT code

  • Create a data folder  (e.g. c:\ps\films) on the computer and copy to it:
    • the input XML files (*.xml)
    • the XSLT code file (*.xsl)
  • 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