[Debutant][XSL] Erreur de code programmation
Bonjour à tous,
C'est mon premier expérience sur XML & XSL. En fait je voudrais essayer de transformer XML au format XHTML via un système de transformation XSL.
En fait, c'est une petite casse-tête, s'il y a une erreur dans le code ci-dessus.
Je vous remercie de m'aider à corriger.
Fichier: xml.xml
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| <?xml version="1.0" ?>
<?xml-stylesheet type='text/xsl' href='web_index.xsl'?>
<table TableNamexml="Test xml avec php et xls">
<Livre ID="1">
<Chapitre>XML Book</Chapitre>
<Page>125</Page>
</Livre>
<Livre ID="2">
<Chapitre>XSL Book O'Reilly</Chapitre>
<Page>652</Page>
</Livre>
<Livre ID="3">
<Chapitre>ASP.NET</Chapitre>
<Page>689</Page>
</Livre>
</table> |
Fichier: web_xml.xsl
Code:
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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
| <?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- localized strings -->
<xsl:variable name='ColumnHeader_Id'>Code</xsl:variable>
<xsl:variable name='ColumnHeader_Chapitre'>Livre</xsl:variable>
<xsl:variable name='ColumnHeader_Page'>Nombre de pages</xsl:variable>
<xsl:template match="table">
<html dir='ltr'>
<head>
<title>
Message Log for <xsl:value-of select="@TableNamexml"/>
</title>
</head>
<body style='margin:0'>
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="middle"><table width="800" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>Liste de: </td>
</tr>
<tr>
<td><table width="800" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="150">Id</td>
<td width="450">Livres</td>
<td width="200">Nb de pages </td>
</tr>
<xsl:template match="Livre">
<tr>
<td width="150">
<xls:for-each select="Livre">
<xls:sort select="@ID" data-type="number" />
<xsl:apply-templates select="." />
</xls:for-each>
</td>
<td width="450">
<xsl:apply-templates select="Chapitre" />
</td>
<td width="200">
<xsl:apply-templates select="Page" />
</td>
</tr>
</xsl:template>
</table></td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet> |
Merci de votre aide
Bien à vous
Fred