Bonjour,
Je suis plus que novice en XSLT et je bloque d'ailleurs des le depart.
J'ai repris l'exemple http://www.developpez.biz/downloads/...rs-xml-xls.pdf au debut tout roule puis quand j'essaie d'ajouter la condition <xsl:if test=".[artiste='Johnny']"> blablabla </xsl:if> le coco s'emballe et me dit:
Je travaille avec wamp, j'ai bien coche l'extension PHP_xsl.XSLTProcessor::importStylesheet() [xsltprocessor.importstylesheet]: Invalid expression in C:\wamp\www\xslt\xslt.php on line 19
XSLTProcessor::importStylesheet() [xsltprocessor.importstylesheet]: compilation error: file file:///C:/wamp/www/xslt/xslt.xsl line 15 element if in C:\wamp\www\xslt\xslt.php on line 19
XSLTProcessor::importStylesheet() [xsltprocessor.importstylesheet]: xsl:if : could not compile test expression '.[artiste='Johnny']' in C:\wamp\www\xslt\xslt.php on line 19
XSLTProcessor::transformToXml() [xsltprocessor.transformtoxml]: No stylesheet associated to this object in C:\wamp\www\xslt\xslt.php on line 20
J'ai ceci dans phpinfo:
XSL enabled
libxslt Version 1.1.23
libxslt compiled against libxml Version 2.6.32
EXSLT enabled
libexslt Version 0.8.13
Voici mes codes:
xslt.php:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 <?php $XmlData = "liste.xml"; $XslData = "xslt.xsl"; $doc = new DOMDocument(); $xsl = new XSLTProcessor(); $doc->load($XslData); $xsl->importStyleSheet($doc); $doc->load($XmlData); echo $xsl->transformToXML($doc); ?>
liste.xml:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 <?xml version="1.0" encoding="ISO-8859-1"?> <?xml-stylesheet type="text/xsl" href="xslt.xsl"?> <compilation> <mp3> <titre>Foule sentimentale</titre> <artiste>Alain Souchon</artiste> </mp3> <mp3> <titre>I ve got that tune</titre> <artiste>Chinese man</artiste> </mp3> <mp3> <titre>Les etoiles filantes</titre> <artiste>Les cowboys fringants</artiste> </mp3> <mp3> <titre>Insane the brain</titre> <artiste>Cypress Hill</artiste> </mp3> <mp3> <titre>Allumer le feu</titre> <artiste>Johnny</artiste> </mp3> </compilation>
xslt.xsl:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 <?xml version="1.0" encoding="ISO-8859-1"?> <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 HTML 4.01//EN" doctype-system="http://www.w3.org/TR/html4/strict.dtd" indent="yes" /> <xsl:template match="/"> <html><body> <p>OPOPOP </p> <table border="1" cellspacing="0" cellpadding="3"> <tr bgcolor="#FFFF00"> <td>Titre</td> <td>Artiste</td> </tr> <xsl:for-each select="compilation/mp3"> <xsl:if test=".[artiste='Johnny']"> <tr> <td><xsl:value-of select="titre"/></td> <td><xsl:value-of select="artiste"/></td> </tr> </xsl:if> </xsl:for-each> </table> </body></html> </xsl:template> </xsl:stylesheet>
Un grand, grand merci d'avance
Partager