Recommended course tools
Texteditor of your choice
For getting started with XSLT we first need a good text editor. You can use a texteditor of your choice, but I suggest using an editor which supports:
- XML syntax highlighting.
- Autoclosing XML-tags. It helps you alot when you're writing XML and XSLT (I will explain later what XML tags are if you do not know it yet).
- Displaying unicode encoded (UTF-8) XML in the right way .
A few recommendations for editors
Here are just a few recommendations which support all needed preconditions out of the box:
install on Ubuntu with: sudo apt-get install geany
I recommend downloading the latest Eclipse Classic or Java from http://www.eclipse.org/downloads/ and unpacking it to the directory of your choice. You can run it directly without any installation.
vi or Emacs
I'm pretty sure vi and Emacs also support our preconditions but do not ask me how to configure them ;)
install the latest one from http://www.geany.org/Download/Releases
(see Linux instructions, it's the same for Windows)
install the latest one from http://notepad-plus-plus.org. Autoclose tags is not enabled by default but you can turn it on with a TextFX Plugin http://superuser.com/questions/131542/html-tag-auto-complete-in-notepad
An XSLT processor is the heart of an XSL transformation. It transforms XML to XML, text or even to images or Word files or PDFs. (more explanation here needed)
We will concentrate on two opensourced and widely used XSLT processors for the commandline. One, xsltproc from libxslt, is an XSLT 1.0 processor and the second one, Saxon-B, is an XSLT 2.0 processor.
xsltproc from libxslt (XSLT 1.0)
If you're using Linux, chances are pretty good that you already have xsltproc installed. Try to run it with
Otherwise install it with your package manager.
For Windows I recommend downloading all libxml2 binaries from http://www.zlatkovic.com/libxml.en.html to a directory of your choice and adding them into your PATH.
Windows and Linux
Commandline usage example for xsltproc:
xsltproc -o output.xml stylesheet.xsl input.xml
Saxon-B from Saxonica / Michael Kay (XSLT 2.0)
Install it with your package manager.
Instructions for Ubuntu:
sudo apt-get install libsaxonb-java
Commandline usage example for Saxon-B in Linux:
saxonb-xslt -s:source.xml -xsl:style.xsl -o:output.xml
The last release of Saxon-B was version 188.8.131.52. Do not use Saxon HE even if it has a higher version number. Saxon-B has more functionality than Saxon HE.
Download it from here. You also need java installed.
For the future projects I recommend to have a copy of saxon9.jar in the same directory were you make your XSL transformations.
Commandline usage example for Saxon-B in Windows:
java -jar saxon9.jar -s:source.xml -xsl:style.xsl -o:output.xml
Additional XML related tools
This tools are optional and not needed at first. But if you want to transform complex XML you probably need them or tools which are equivalent.
xmllint is an xml validation tool from libxml2. It is part of libxml2 and already installed on many Linux systems. If you use Windows install the same way as xsltproc. It is very useful to check if a XML file is valid XML (XML can get invalid sometimes, often by mistake after editing it)
Command for checking for valid XML:
xmllint --noout input.xml
- XML Marker 1.1 is a free Windows tool which I also use under Linux with WINE. It shows the tree structure of XML files and is very useful for analysing XML and developing XSLT. It also checks if the XML is a valid XML similar to xmllint.
- Eclipse is an opensource alternative to XML Marker if you want to analyse the tree structure and nesting of a XML.
- Unicode lookup : http://unicodelookup.com/ - website to find unicode for various symbols and languages.