Created
January 4, 2011 19:21
-
-
Save bpierre/765244 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8" ?> | |
<data> | |
<contributions> | |
<pagination | |
total-entries="11" | |
total-pages="2" | |
entries-per-page="10" | |
current-page="1" /> | |
</contributions> | |
</data> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<xsl:stylesheet version="1.0" | |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | |
<xsl:template match="data"> | |
<!-- On déclare une variable qui pointe sur pagination, plus pratique --> | |
<xsl:variable name="pagination" select="/data/contributions/pagination" /> | |
<!-- | |
Si la page n’est pas la première, on affiche le lien « précédent » | |
Pour le numéro dans le lien, on fait @current-page-1 | |
--> | |
<xsl:if test="$pagination/@current-page != 1"> | |
<a href="http://example.com/{$pagination/@current-page-1}">Précédent</a> | |
<xsl:text> </xsl:text> <!-- Un espace dans un xsl:text, sinon il est ignoré --> | |
</xsl:if> | |
<!-- La page affichée, rien de compliqué ici --> | |
<span> | |
<xsl:text>Page </xsl:text> | |
<xsl:value-of select="$pagination/@current-page" /> | |
<xsl:text>/</xsl:text> | |
<xsl:value-of select="$pagination/@total-pages" /> | |
</span> | |
<!-- | |
Si la page n’est pas la dernière, on affiche le lien « suivant » | |
Pour le numéro dans le lien, on fait @current-page+1 | |
--> | |
<xsl:if test="$pagination/@current-page != $pagination/@total-pages"> | |
<xsl:text> </xsl:text> <!-- Un espace dans un xsl:text, sinon il est ignoré --> | |
<a href="http://example.com/{$pagination/@current-page+1}">Suivant</a> | |
</xsl:if> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment