This site will look much better in a browser that supports web standards, but it is accessible to any browser or Internet device.

John McSweeney - picture detail

John McSweeney

March 12, 2010, 5:33 pm

M150 Data, Computing and Information

Sorting XML Data

 

Now try sorting the data by applying an instruction to sort by value of the TITLE element. Download and save this file and modify your book.xml file with this line
<?xml-stylesheet type="text/xsl" href="book3.xsl"?>

Reload book.xml

Browser output displaying titles sorted in alphabetical order with corresponding names of authors of all the books.

 

The relevant XSL instruction is:
<xsl:sort select="TITLE"/>
Try sorting by the name of the author and remember that where XML is concerned, lowercase author is not the same as uppercase AUTHOR. The correct syntax must be adhered to, or your code will fail. THE XML elements were written in uppercase, although, because XML is extensible, I could have used lowercase. Note that this is not to be confused with writing XHTML tags, which must be written lowercase. Go here for more on this.

Next page » Applying selection to XML data

Previous page « Filtering XML data