Skip to content

Search for Research Data

Search the ANDS Site


Experimenting with XML and XSLT

Requires XSLT Test Tool

Running the Example
  1. Copy the XML below

and paste it into the page at in the edit box beneath the title “Enter your XML code or it's URL:”

Next, copy the XSL below

and paste it into the same page (, this time in the edit box beneath title “Enter your XSLT or it's URL:”

3. Within click to Run Transformation generate the resultant XML, that looks like:

Note: the above XML is in fact also HTML that constructs a table.  If you save it to a .html file and open it in a browser, it will provide the following:

Book Collection

You can also preview the table within by clicking Open Result

Making Changes

  1. Within your source XML at, add the two years of publication (indicated below):

2. Within your XSL at, add lines that will read the year of publication and add it to the table within a new column.  First add the column header, then add a line to populate the value for each book:

Again within click Run Transformation to generate the updated XML that now includes publication year for each book

The table will now include Publication Year

Book Collection 2

Preview the table within by clicking Open Result

Further Exploration if you have time


We have used xpath within our XSLT to indicate which elements to obtain - books/book is the xpath that specifies the root node books and its child book. The subsequent children - title, author, publisher, and publishYear - are all found from the books/book context.

  • Try changing the root node from books to publications and see what happens; for your XSLT to produce the same XML as has been generated so far, you will have to change any reference to books to publications within your XSL as well.
  • Try adding further elements and values to your source XML and determine what additions will be required within the XSL to process these values.  You may like to experiment further with attributes (e.g. <book format=”hardcover”> that would be accessed with @format)


Much can be done to further format your HTML table: colour can be added, cell padding can be configured, fonts can be changed…

  • Experiment with enhancing the resultant HTML - refer to for some inspiration!  To start with, you may like to change the background colour that is set by the XSL within the bgcolor attribute (currently it is #FC99EF).  Be guided by to find the hexadecimal value for a colour of your choice.

in Skills