December 21, 2024
Applying more complex selection to XML data
In common with other programming languages, XSL provides you with the language/syntax
to write more complex conditions and uses the keywords choose, when, otherwise.
Note: JavaScript will use a different syntax, but the effect is the same
if (some condition)
{
doSomething
}
else
{
doSomethingElse
}
Download and save this file and modify your book.xml
file with this line
<?xml-stylesheet type="text/xsl" href="book5.xsl"?>
Reload book.xml
This tests for a YEAR element greater than 1999. If it is found, the corresponding AUTHOR value is output in bold font (the <strong></strong> tags are used for this). If the YEAR value does not meet this condition, the background colour of the table cell is coloured pale green, <td bgcolor="#CCFFFF">.
Previous page « Sorting XML Data
⇑ Up to top of page