1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| <?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>XSLT</title>
</head>
<body>
<table width="1000" border="1" cellspacing="0" cellpadding="0">
<tr>
<th scope="col">Auteurs</th>
<th scope="col">Titres</th>
<th scope="col">Dates</th>
<th scope="col">Prix</th>
</tr>
<xsl:for-each select="/inventaire/livre">
<tr>
<xsl:choose>
<xsl:when test="(position() mod 2) = 0">
<xsl:attribute name="bgcolor">#CCCCFF</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="bgcolor">#FFCCFF</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<td>
<xsl:value-of select="auteur" />
</td>
<td>
<xsl:value-of select="titre" />
</td>
<td>
<xsl:value-of select="date" />
</td>
<td>
<xsl:value-of select="prix" />
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet> |
Partager