problème de parametre dans select XSL
J'ai un fichier XML et une XSL que j'utilise via PHP.
Je passe des parametres à la feuille XSL, je les affiches et voit bien leur valeur, mais dans le select que je veux modifier il m'affiche toutes mes pages :(
le code est plus parlant :)
PS : j'ai fait de l'élagage pour ne garder que ce qui est utile.
le XML
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
|
<?xml version="1.0" encoding="UTF-8"?>
<categories>
<cat id="accueil" label="Accueil">
<page type="edito" background="/img/backgrounds/bg1.jpg">
<title>
<![CDATA[this is edito1]]>
</title>
<text>
<![CDATA[this is the text]]>
</text>
</page>
<page type="edito">
<title>
<![CDATA[this is accueil edito2]]>
</title>
<text>
<![CDATA[this is the text]]>
</text>
</page>
<page type="edito">
<title>
<![CDATA[this is accueil edito3]]>
</title>
<text>
<![CDATA[this is the text]]>
</text>
</page>
</cat>
<cat id="carres" label="Les carrés">
<page type="edito">
<title>
<![CDATA[this is carres edito1]]>
</title>
<text>
<![CDATA[this is the text of carrés]]>
</text>
</page>
<page type="edito">
<title>
<![CDATA[this is carres edito2]]>
</title>
<text>
<![CDATA[this is the text of carrés]]>
</text>
</page>
</cat>
<cat id="papeterie" label="Papeterie">
<page type="edito">
<title>
<![CDATA[this is papeterie edito1]]>
</title>
<text>
<![CDATA[this is the text of papier]]>
</text>
</page>
</cat>
</categories> |
et la 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
|
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" encoding="UTF-8"
doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
omit-xml-declaration="yes"
/>
<xsl:param name="catid"/>
<xsl:param name="pagenum"/>
<xsl:template match="/">
<xsl:value-of select="$catid"/>
<xsl:value-of select="$pagenum"/>
<xsl:variable name="cat" select="descendant::cat[@id=$catid]"/>
<html dir="ltr" lang="fr-FR">
<head></head>
<body>
<div id="wrapper">
<div id="content">
<xsl:apply-templates select="descendant::cat[@id=$catid]/page[$pagenum]" />
</div>
</div>
</body>
</html>
</xsl:template>
<xsl:template match="page">
<xsl:value-of select="title" />
</xsl:template>
</xsl:stylesheet> |
ça merde sur cette ligne :
Code:
1 2
|
<xsl:apply-templates select="descendant::cat[@id=$catid]/page[$pagenum]" /> |
Et ça m'affiche toutes les pages de la categorie :(
avant j'avais
Code:
1 2
|
<xsl:apply-templates select="descendant::cat[@id=$catid]/page" /> |
cela permettait d'attaquer tous les noeuds <page> du XML
maintenant je ne veux afficher qu'une seule page, en fonction de l'id que j'aurai passé. Mais ça ne marche pas
pourtant si je fais :
Code:
1 2
|
<xsl:apply-templates select="descendant::cat[@id=$catid]/page[1]" /> |
j'ai bien la page 1, si je met un 2, j'ai bien la page 2
qu'est ce que j'ai loupé :'( :'(