[XSL] Affichage hors boucle
Bonjour à tous,
Voilà je fais appel à vous pour comprendre le fonctionnement d'une feuille de style XSLT.
J'ai repris un exemple sur le forum pour tester et chez moi cela ne marche pas.
Voici mes fichiers :
XML
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| <?xml version="1.0" encoding="ISO-8859-1"?>
<fiche>
<struct>
<var name="id">5</var>
<var name="nom"><string>dsffsdsfdfsd</string></var>
<var name="prenom"><string>fdssdfsfdsfdsdfdsf</string></var>
<var name="statut">1</var>
<var name="pageWebPerso"><![CDATA[www]]></var>
<var name=""><![CDATA[..]]></var>
<var name="photo">NULL</var>
<var name="distenctions">NULL</var>
<var name="implicationprojet">1</var>
</struct>
</fiche> |
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 66 67 68 69 70 71 72 73 74 75 76 77 78 79
| <?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp " ">
<!ENTITY copy "©">
<!ENTITY reg "®">
<!ENTITY trade "">
<!ENTITY mdash "">
<!ENTITY ldquo "">
<!ENTITY rdquo "">
<!ENTITY pound "£">
<!ENTITY yen "¥">
<!ENTITY euro "">
]>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="iso-8859-1" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
<xsl:template>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>Yihaa</title>
</head>
<body>
<center>
<a href="aj-pers.html">Ajouter une nouvelle personne</a>
<form method="POST">
<table border="1">
<tr>
<th>Id</th>
<th>Nom</th>
<th>Prenom</th>
<th>/</th>
<th>/</th>
<th>/</th>
<th>/</th>
<th>/</th>
<th>/</th>
<th>/</th>
</tr>
<xsl:apply-templates />
</table>
<p>
<!--<xsl:value-of select="@strValue" />-->
<input type="submit" name="action" value="Editer" />
<input type="submit" name="action" value="Supprimer" />
</p>
</form>
</center>
</body>
</html>
</xsl:template>
<xsl:template match="fiche">
<tr>
<td align="center"><xsl:value-of select="struct/var[@name='id']" /></td>
<td align="center"><xsl:value-of select="struct/var[@name='nom']" /></td>
<td align="center"><xsl:value-of select="struct/var[@name='prenom']" /></td>
<td align="center"><xsl:value-of select="struct/var[@name='status']" /></td>
<td align="center"><xsl:value-of select="struct/var[@name='pageWebPerso']" /></td>
<td align="center"><xsl:value-of select="struct/var[@name='pageWebGRMIAO']" /></td>
<td align="center"><xsl:value-of select="struct/var[@name='photo']" /></td>
<td align="center"><xsl:value-of select="struct/var[@name='distenctions']" /></td>
<td align="center"><xsl:value-of select="struct/var[@name='implicationprojet']" /></td>
<td>
<!--<xsl:value-of select="@strValue" />
<xsl:if test="@textValue='Y'">
<input name="selection[]" type="submit" align="center" checked="Y" value="Y" />
</xsl:if>
<xsl:if test="not(@textValue='Y')">
<input name="selection[]" type="checkbox" align="center" value="Y" />
</xsl:if>-->
<xsl:element name="input">
<xsl:attribute name="name">selection[]</xsl:attribute>
<xsl:attribute name="type">checkbox</xsl:attribute>
<xsl:attribute name="value"><xsl:value-of select="struct/var[@name='id']" /></xsl:attribute>
</xsl:element>
</td>
</tr>
</xsl:template>
</xsl:stylesheet> |
PHP
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| <?php
$dom = DomDocument::load('index.xsl');
$proc = new XSLTProcessor;
$proc->importStylesheet($dom);
$dom = new DomDocument;
$dom->preserveWhiteSpace = FALSE;
$dom->formatOutput = TRUE;
$dom->load('index.xml');
echo $proc->transformToXML($dom);
?> |
Ce qui se passe c'est que je n'ai rien qui s'affiche avant l'affichage dans ma boucle, j'ai bien mon doctype et mes un ligne du tableau (vu que je n'ai qu'un seul élément) mais je n'ai rien d'autre.
Quelqu'un pourrait-il m'aiguiller ?
Merci d'avance