topical media & game development
professional-xml-08-language-choose.xsl / xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<html>
<head>
<title/>
</head>
<body>
<table>
<tbody>
<tr>
<th align="left">Product</th>
<th>Price</th>
</tr>
<xsl:apply-templates select="//product"/>
</tbody>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="product">
<tr>
<td>
<xsl:value-of select="name"/>
</td>
<td>
<xsl:choose>
<xsl:when test="price <= 20">
<xsl:attribute name="bgcolor">#e0e0e0</xsl:attribute>
</xsl:when>
<xsl:when test="price <= 100">
<xsl:attribute name="bgcolor">#00ff00</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="bgcolor">#FF0000</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="format-number(price, '#.00')"/>
</td>
</tr>
</xsl:template>
</xsl:stylesheet>
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.