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 :
<?xml version="1.0" encoding="UTF-8"?> <categories> <cat id="accueil" label="Accueil"> <page type="edito" background="/img/backgrounds/bg1.jpg"> <headcustom> <![CDATA[ <script type="text/javascript"> //this is custom code </script> ]]> </headcustom> <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 :
<?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 :
- <xsl:apply-templates select="descendant::cat[@id=$catid]/page[$pagenum]" />
|
avant j'avais
Code :
- <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 :
- <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é

Message édité par gatsu35 le 06-03-2010 à 11:04:01
---------------
Blablaté par Harko