[XSLT] Méthode Muench avec les attributs
Bonjour à toutes et à tous.
J'aimerais établir la liste des attributs place distincts de mon fichier XML. C'est à dire dans le cas ci-dessous obtenir la liste "Hoi An, Kontum".
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| <gallery version="0.4" images_root="./images/" thumbs_root="./images/thumbs/" thumbs_size="125">
<photo photograph="didier" date="2007:12:28 07:53:42" place="Hoi An">
<comment></comment>
<thumb>7077c6296c5a8e3125f4269e0d4f51ab</thumb>
<filename>Affiche-7.jpg</filename>
</photo>
<photo photograph="didier" date="2007:12:28 07:53:49" place="Hoi An">
<comment></comment>
<thumb>490b6d9b6a48f6b4d63c1125b7c70116</thumb>
<filename>Affiche-8.jpg</filename>
</photo>
<photo photograph="yankel" date="2007:12:27 13:07:55" place="Kontum">
<comment></comment>
<thumb>3c22a1a1545519f37316ec46db0b0871</thumb>
<filename>P1020519.JPG</filename>
</photo>
<photo photograph="yankel" date="2007:12:28 03:43:47" place="Hoi An">
<comment></comment>
<thumb>751a48d7bd6b64589b2ada9f94e44d7e</thumb>
<filename>P1020539.JPG</filename>
</photo>
</gallery> |
J'ai vu divers exemple de la méthode muench afin de trier les noeuds, mais jamais les attributs :/
J'ai besoin d'établir cette liste au sein du template gallery (dans le for-each)
Code:
1 2 3 4 5 6 7 8 9
| <xsl:key name="photo" match="photo" use="place"/>
<xsl:template match="gallery">
<xsl:for-each select="photo/@place[generate-id(.)=generate-id(key('photo', .)[1]/@place)]">
<xsl:sort select="."/>
<xsl:element name="photo">
<xsl:copy-of select="//photo[@place = current()]"/>
</xsl:element>
</xsl:for-each>
</xsl:template> |
Merci de voter aide :)