Ian's books
| CPU Magazine
XSLT Part 6: Booleans and XPath, and Fancy Sorting
As described in the June 2003 issue of
CPU - Computer Power User
magazine. This article builds on the examples described in the April and
May 2003 issues. These examples are found
here (April)
(http://www.iangraham.org/writing/cpu-articles/apr03/) and
here (May)
(http://www.iangraham.org/writing/cpu-articles/may03/).
Examples
A) Downloadable ZIP File
- There are lots of little examples here -- why not download the
whole lot as a ZIP file -- jun03.zip --
and install them on your own machine?
B) The Raw Data
- demo.xml -- The simple example XML data
document used in the article -- this contains the raw data that
is transformed into HTML. A plain text version is available at
demo.txt. This is the same file introduced last
month, which is slightly different from the demo file used in the
april '03
article.
- demo-withPI.xml -- This is basically
the same as demo.xml, but with an xml-stylesheet PI at the
beginning of the document referencng a style sheet named
transform.xsl . Note that you will need to edit this document
(and change the name of the stylesheet) to test out the examples
included here. Modern browsers (IE 6 / Mozilla 1+/Netscape 7+) are
able to take this XML data, apply the transform to it, and display
the generated HTML.
A plain text version of this document
is available at demo-withPI.txt.
C) The XSLT Stylesheets
- transform-fail.xsl -- The
example XSLT that incorrectly sorts the XXX.
A plain text listing is available at
transform-fail.txt.
- transform-succeed.xsl -- The
example XSLT, described in the article, that correctly filters
by year (> 1900) and provides alternate background colors to the
rows.
A plain text version is available at
transform-succeed.txt.
- transform-multisort.xsl -- The
example XSLT, described in the article, that sorts first by birth
year, and second by name. Note how the name sort is applied after
the year sort -- that is, names are sorted within a given birth year.
The stylesheet has also been modified to print out the row numbers at
the end of each row (the $rowCount parameter value).
A plain text version is available at
transform-multisort.txt.
- transform-datesort.xsl -- The
same XSLT as transform-multisort.xsl, but with the alphabetical <xsl:sort>
element removed. The figure in the article was created using this and the preceding
style sheet.
A plain text version is available at
transform-datesort.txt.
Tutorials, Books, References, and Tools