XSLT list item position issue - xslt

pls check the below code. I am matching the list element and as per the below code the position() function returns correct number of the element with in ul elements i.e 1,2,3 where as if i do the test with position i get only ss,ss,ss . Can anyone let me know where am missing ?
XSL-FO
<xsl:template match="html:li" priority="2">
<fo:list-item>
...
<xsl:value-of select="position()"/> -- this returns 1,2,3
<xsl:if test="position() = 1">
<xsl:text>ss</xsl:text> -- only executes
</xsl:if>
<xsl:if test="position() = 2">
<xsl:text>ssddddd</xsl:text> -- does not only execute
</xsl:if>
<xsl:if test="position() = 3">
<xsl:text>sskkkkkkkkk</xsl:text> -- does not only execute
</xsl:if>
</fo:list-item>
</xsl:template
XSL
<xsl:template match="list">
<xsl:if test="list.item">
<xsl:variable name="styleAttr">
<xsl:text>margin-top: 1em;</xsl:text>
</xsl:variable>
<div>
<xsl:if test="string-length($styleAttr) > 0">
<xsl:attribute name="style">
<xsl:value-of select="$styleAttr"/>
</xsl:attribute>
</xsl:if>
<ul>
<xsl:apply-templates select="node()[not(self::list)]" />
</ul>
</div>
</xsl:if>
</xsl:template>
<xsl:template match="list.item" priority="1">
<li style="padding: 0;">
<div style="margin-bottom: 0.5em;">
<xsl:apply-templates />
<xsl:if test="following-sibling::node()[1][self::list]">
<xsl:apply-templates select="following-sibling::node()[1]" />
</xsl:if>
</div>
</li>
</xsl:template>

Related

convert xml to html list with xslt

I have a xslt code to convert an xml file to html list. The input and output samples are as follows:
Input:
<Beverages>
<Water/>
<Coffee/>
<Tea>
<BlackTea/>
<WhiteTea id="cti" value="ctv" >Camomile Tea</WhiteTea>
<GreenTea id="gti" value="gtv">
<Sencha/>
<Gyokuro/>
<Matcha/>
<PiLoChun/>
</GreenTea>
</Tea>
</Beverages>
and the Output:
<ul>
<li>
<span class="caret"><Beverages></span>
<ul class="nested">
<li><span><Water/></span></li>
<li><span><Coffee/></span></li>
<li>
<span class="caret"><Tea></span>
<ul class="nested">
<li><span><BlackTea/></span></li>
<li><span><WhiteTea id="cti" value="ctv"></span>Camomile Tea<span></WhiteTea></span></li>
<li>
<span><GreenTea id="gti" value="gtv"></span>
<ul class="nested">
<li><span><Sencha/></span></li>
<li><span><Gyokuro/></span></li>
<li><span><Matcha/></span></li>
<li><span><PiLoChun/></span></li>
</ul>
<span></GreenTea></span>
</li>
</ul>
</li>
</ul>
<span></Beverages></span>
</li>
</ul>
Here is my xslt but it is not exactly the same as what I want:
<xsl:template match="/">
<ul><xsl:apply-templates/></ul>
</xsl:template>
<xsl:template match="*">
<li> <span class="caret"><xsl:value-of select="concat('<',name())" />
<xsl:for-each select="#*">
<xsl:value-of select="concat(' ',name())"/>=<xsl:value-of select="concat('"',.,'"')" />
</xsl:for-each>></span>
<xsl:if test="text()">
<xsl:apply-templates select="text()" />
</xsl:if>
<xsl:if test="*">
<ul class="nested"><xsl:apply-templates/></ul>
</xsl:if>
<span><xsl:value-of select="concat('<','/' ,name() , '>')" /></span></li>
</xsl:template>
The problem is that this code can not differentiate between parent elements and non parent element. for parent elements we need to add class="caret" attribute, but for non parent elements we shouldn't add this class.
This should work for you.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<ul>
<xsl:apply-templates/>
</ul>
</xsl:template>
<xsl:template match="*">
<li>
<span>
<xsl:if test="*">
<xsl:attribute name="class">
<xsl:value-of select="'caret'"/>
</xsl:attribute>
</xsl:if>
<xsl:value-of select="concat('<',name())"/>
<xsl:for-each select="#*">
<xsl:value-of select="concat(' ', name(), '=', '"', ., '"')"/>
</xsl:for-each>
<xsl:choose>
<xsl:when test="text() or *">
<xsl:value-of select="'>'"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'\>'"/>
</xsl:otherwise>
</xsl:choose>
</span>
<xsl:if test="text()">
<xsl:value-of select="text()"/>
</xsl:if>
<xsl:if test="*">
<ul class="nested">
<xsl:apply-templates/>
</ul>
</xsl:if>
<xsl:if test="text() or *">
<span>
<xsl:value-of select="concat('<','/' ,name() , '>')"/>
</span>
</xsl:if>
</li>
</xsl:template>
</xsl:stylesheet>

insert div after X li

I have an xslt navigation, which I want to break into 2 columns, so that after every 6 "li" it creates a new "div"...
I would like to output to be like this:
<ul>
<div class="col">
<li>link</li>
<li>link</li>
<li>link</li>
<li>link</li>
<li>link</li>
<li>link</li>
</div>
<div class="col">
<li>link</li>
<li>link</li>
<li>link</li>
<li>link</li>
<li>link</li>
<li>link</li>
</div>
</ul>
But not quite sure how to do this
My XSLT:
<?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" omit-xml-declaration="yes" indent="yes" encoding="utf-8" />
<xsl:param name="html-content-type" />
<xsl:template match="/NavigationTree">
<xsl:if test="count(//Page) > 0">
<ul>
<xsl:apply-templates select="Page">
<xsl:with-param name="depth" select="1"/>
</xsl:apply-templates>
</ul>
</xsl:if>
</xsl:template>
<xsl:template match="//Page">
<xsl:param name="depth"/>
<li>
<xsl:attribute name="class">
<xsl:if test="#InPath='True'">inpath </xsl:if>
<xsl:if test="position() = 1">firstitem </xsl:if>
<xsl:if test="position() = count(//Page)">lastitem </xsl:if>
<xsl:if test="#Active='True'">selected</xsl:if>
</xsl:attribute>
<a>
<xsl:attribute name="class">
<xsl:if test="#InPath='True'">inpath </xsl:if>
<xsl:if test="position() = 1">firstitem </xsl:if>
<xsl:if test="position() = count(//Page)">lastitem </xsl:if>
<xsl:if test="#Active='True'">current</xsl:if>
</xsl:attribute>
<xsl:attribute name="href"><xsl:value-of select="#FriendlyHref" disable-output-escaping="yes"/></xsl:attribute>
<xsl:value-of select="#MenuText" disable-output-escaping="yes"/>
</a>
<div class="icon">
<xsl:text disable-output-escaping="yes"><![CDATA[<!--dsfdsfdsf-->]]></xsl:text>
</div>
<xsl:if test="count(Page)">
<ul class="M{#AbsoluteLevel}">
<xsl:apply-templates select="Page">
<xsl:with-param name="depth" select="$depth+1"/>
</xsl:apply-templates>
</ul>
</xsl:if>
</li>
</xsl:template>
</xsl:stylesheet>
A way to do it would be to have a template that matches every 6 Page element:
<xsl:template match="//Page[position() mod 6 = 1]">
<div>
<xsl:apply-templates select="." mode="SecondLevel"/>
<xsl:apply-templates select="following-sibling::Page[position()<6]" mode="SecondLevel"/>
</div>
</xsl:template>
generating the div and applying a second-level template to the current element and its 5 following sibling. The second level template is the one you already have - with an added mode:
<xsl:template match="Page" mode="SecondLevel">
<li>
<xsl:attribute name="class">
<xsl:if test="#InPath='True'">inpath </xsl:if>
<xsl:if test="position() = 1">firstitem </xsl:if>
<xsl:if test="position() = count(//Page)">lastitem </xsl:if>
<xsl:if test="#Active='True'">selected</xsl:if>
</xsl:attribute>
<a>
<xsl:attribute name="class">
<xsl:if test="#InPath='True'">inpath </xsl:if>
<xsl:if test="position() = 1">firstitem </xsl:if>
<xsl:if test="position() = count(//Page)">lastitem </xsl:if>
<xsl:if test="#Active='True'">current</xsl:if>
</xsl:attribute>
<xsl:attribute name="href">
<xsl:value-of select="#FriendlyHref" disable-output-escaping="yes"/>
</xsl:attribute>
<xsl:value-of select="#MenuText" disable-output-escaping="yes"/>
</a>
<div class="icon">
<xsl:text disable-output-escaping="yes"><![CDATA[<!--dsfdsfdsf-->]]></xsl:text>
</div>
</li>
</xsl:template>

stackoverflow is occured in using loops in my code

i've the below xslt
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ntw="Number2Word.uri" exclude-result-prefixes="ntw">
<xsl:output method="html"/>
<xsl:template match="/">
<html>
<head>
<xsl:text disable-output-escaping="yes"><![CDATA[</meta>]]></xsl:text>
<link rel="stylesheet" href="C:\Documents and Settings\u0138039\Desktop\Per\NEW.css" type="text/css"></link>
</head>
<body>
<section class="tr_chapter">
<div class="chapter">
<xsl:apply-templates/>
</div>
</section>
</body>
</html>
</xsl:template>
<xsl:template match="case">
<xsl:apply-templates select="case.head"/>
</xsl:template>
<xsl:template match="case.head">
<div class="section-sect0">
<div class="para">
<xsl:value-of select="./party.line/party[#role='Plaintiff']"/>
</div>
</div>
<div class="section-sect0">
<div class="para">
<xsl:text disable-output-escaping="yes">V</xsl:text>
</div>
</div>
<div class="section-sect0">
<div class="para">
<xsl:value-of select="./party.line/party[#role='Defendant']"/>
</div>
</div>
<xsl:apply-templates select="case.ref.no.group | judge.line"/>
</xsl:template>
<xsl:template match="para">
<div class="para">
<xsl:apply-templates/>
</div>
</xsl:template>
<xsl:template match="case.ref.no.group">
<div class="section-sect3">
<span class="font-style-bold">Court of Appeal</span>
<xsl:text> - </xsl:text>
<xsl:value-of select="case.ref.no[1]/prefix" />
<xsl:text> Nos. </xsl:text>
<xsl:for-each select="case.ref.no">
<xsl:value-of select="number" />
<xsl:text>-</xsl:text>
<xsl:value-of select="year" />
<xsl:if test="not(position() = 2)">
</xsl:if>
</xsl:for-each>
</div>
</xsl:template>
<xsl:template match="judge.line">
<div class="section-sect3">
<xsl:for-each select="judge">
<xsl:value-of select="name"/>
<xsl:if test="not(position() = last())">
<xsl:text>,</xsl:text>
</xsl:if>
</xsl:for-each>
<xsl:text> JC</xsl:text>
</div>
<xsl:apply-templates select="following-sibling::date.group"></xsl:apply-templates>
</xsl:template>
<xsl:template match="date.group">
<div class="section-sect4">
<div class="para">
<xsl:value-of select="./date.line/date"/>
</div>
</div>
<xsl:apply-templates select="//catchwords.group"/>
</xsl:template>
<xsl:template match="catchwords.group">
<div class="y">
<xsl:for-each select="catchwords/catchword">
<xsl:choose>
<xsl:when test="#level=1"><br/>
<span class="font-style-bolditalic">
<xsl:value-of select="."/>
</span>
<xsl:text disable-output-escaping="yes">-</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select=".">
<xsl:value-of select="."></xsl:value-of>
<xsl:if test="not(position() = last()-1)">
<xsl:text disable-output-escaping="yes"> – </xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</div>
<xsl:apply-templates select="//headnotes"/>
</xsl:template>
<xsl:template match="headnotes/para">
<xsl:choose>
<xsl:when test="position()=1">
<div class="x">
<xsl:apply-templates></xsl:apply-templates>
</div>
</xsl:when>
<xsl:otherwise>
<div class="m">
<xsl:apply-templates/>
</div>
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates select="para.group"/>
</xsl:template>
<xsl:template match="para.group">
<div class="section-sect1">
<xsl:value-of select="./heading"/>
</div>
<xsl:for-each select="./para">
<xsl:apply-templates select="node()[not(self::label)]"/>
</xsl:for-each>
<xsl:apply-templates select="//counsel.group"/>
</xsl:template>
<xsl:template name="orderedlist" match="list">
<ol class="eng-orderedlist orderedlist">
<xsl:apply-templates select="list.item/label"/>
</ol>
</xsl:template>
<xsl:template name="orderitempara" match="list.item/label">
<li class="item">
<div class="para">
<span class="item-num">
<xsl:choose>
<xsl:when test="following-sibling::case.considered">
<xsl:apply-templates/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</span>
<xsl:apply-templates select="parent::list.item"/>
</div>
</li>
</xsl:template>
<xsl:template match="list.item">
<xsl:variable name="a">
<xsl:value-of select="./label"/>
</xsl:variable>
<xsl:choose>
<xsl:when test="./label">
<xsl:apply-templates select="child::node()[not(self::label|case.ref)]"/>
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template match="counsel.group" name="j">
<div class="ital">
<xsl:for-each select="./counsel.line">
<div class="para">
<xsl:value-of select="."/>
</div>
</xsl:for-each>
<xsl:text disable-output-escaping="yes">Judgment received: December 4, 2008</xsl:text>
</div>
<xsl:apply-templates select="//ref.group"/>
</xsl:template>
<xsl:template match="ref.group/leg.mentioned">
<div class="section-sect1">
<xsl:text>Legislation mentioned in the judgment</xsl:text>
</div>
<xsl:for-each select="./leg.ref">
<div class="para">
<xsl:value-of select="./citetitle"/>
<xsl:text>, </xsl:text>
<xsl:for-each select="./leg.ptr.group/leg.ptr">
<xsl:value-of select="."/>
<xsl:if test="not(position() = last())">
<xsl:text disable-output-escaping="yes">, </xsl:text>
</xsl:if>
</xsl:for-each>
</div>
</xsl:for-each>
<xsl:text>Cases cited in the judgment</xsl:text>
<xsl:for-each select="//citetitle">
<xsl:if test="parent::case.ref/#annotation">
<div class="ital">
<div class="para">
<xsl:value-of select="."/>
<xsl:value-of select="//citecitation"/>
<xsl:value-of select="parent::case.ref/#court"/>
<xsl:text> (</xsl:text>
<xsl:value-of select="parent::case.ref/#annotation"/>
<xsl:text>)</xsl:text>
</div>
</div>
</xsl:if>
</xsl:for-each>
<xsl:apply-templates select="//judgment"/>
</xsl:template>
<xsl:template match="judgment">
<div class="section-sect1">
<xsl:value-of select="./judge.block/heading/judgename"/>
</div>
<xsl:for-each select="./judge.block/para">
<div class="para">
<span class="new">
<xsl:value-of select="./label"></xsl:value-of>
</span>
<xsl:value-of select="./text()"/>
</div>
<xsl:apply-templates select="./list"/>
</xsl:for-each>
<xsl:for-each select="./judge.block/para.group">
<xsl:if test="./heading">
<div class="section-sect1">
<xsl:value-of select="./heading/text()"/>
</div>
</xsl:if>
<xsl:for-each select="para">
<div class="para">
<span class="new">
<xsl:value-of select="./label"></xsl:value-of>
</span>
<xsl:apply-templates select="child::node()[not(self::label)]"/>
</div>
<xsl:apply-templates select="./list"/>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
<xsl:template match="emphasis">
<xsl:choose>
<xsl:when test="citetitle">
<span class="font-style-italic">
<xsl:apply-templates select="./list.item"/>
</span>
</xsl:when>
<xsl:when test="./#type">
<xsl:variable name="fontStyle">
<xsl:value-of select="concat('font-style-',#type)"/>
</xsl:variable>
<span class="{$fontStyle}">
<xsl:apply-templates/>
</span>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
when i apply this on my below part of my xml it is giving me a stackoverflow error.
<?xml version="1.0" encoding="UTF-8"?>
<case>
<counsel.group>
<counsel.line>Azar Irwan b Moh Arifin (AG’s Chambers) for Public Prosecutor</counsel.line>
<counsel.line>SK Pari (Pari & Co) for first accused</counsel.line></counsel.group>
<ref.group>
<leg.mentioned>
<leg.ref country="India">
<citetitle type="leg" legtype="ord">Indian Penal Code</citetitle>
<leg.ptr.group>
<leg.ptr provision="s" print="yes">302</leg.ptr>
</leg.ptr.group>
</leg.ref>
<leg.ref country="Malaysia">
<citetitle type="leg" legtype="ord">Criminal Procedure Code</citetitle>
<leg.ptr.group>
<leg.ptr provision="ss" print="yes">112</leg.ptr>
<leg.ptr provision="s" print="no">112</leg.ptr>
</leg.ptr.group>
</leg.ref>
<leg.ref country="Malaysia">
<citetitle type="leg" legtype="ord">Penal Code</citetitle>
<leg.ptr.group>
<leg.ptr provision="ss" print="yes">109</leg.ptr>
<leg.ptr provision="s" print="no">299</leg.ptr>
</leg.ptr.group>
</leg.ref>
</leg.mentioned></ref.group>
</case>
please let me know how do i resolve this error and what are the steps to be followed so that in future i don't encounter this error.
Thanks
Your XSLT contains an infinite loop. Your para.group template contains this:
<xsl:apply-templates select="//counsel.group"/>
And then the template for counsel.group has this:
<xsl:apply-templates select="//ref.group"/>
The template for ref.group has this:
<xsl:apply-templates select="//judgment"/>
The template for judgment has this:
<xsl:for-each select="para">
...
<xsl:apply-templates select="child::node()[not(self::label)]"/>
...
</xsl:for-each>
Which cascades down to apply templates on a para.group and then you're back at the beginning. This process goes around in circles until the stack overflows. I think you need to rethink your XSLT to figure out how to prevent infinite recursion.

Umbraco current member details comma separated multiple textstrings list

I'm creating a macro that sources a property from the current member. The property uses the "multiple textstrings" datatype, and each textstring contains a media ID, the version number and the date and time added.
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/>
<xsl:template match="/">
<xsl:if test="count(umbraco.library:GetCurrentMember()/assetDownloads/values/value) > 0">
<ul>
<xsl:for-each select="umbraco.library:GetCurrentMember()/assetDownloads/values/value">
<li>
<xsl:if test="./preview != ''">
<img>
<xsl:attribute name="src">
<xsl:value-of select="./preview" />
</xsl:attribute>
</img>
</xsl:if>
<p><xsl:value-of select="current()"/></p>
</li>
</xsl:for-each>
</ul>
</xsl:if>
</xsl:template>
This results in the following:
1475,1,28-Dec-12 01:26:45
1475,1,28-Dec-12 01:27:03
The first values are the media types ID, the second value is its version number and the third value is the date and time it was downloaded.
This is how to display the first value as the preview image and the nodeName:
<!-- First value as preview image and nodeName -->
<xsl:if test="position() = 1">
<img>
<xsl:attribute name="src">
<xsl:value-of select="umbraco.library:GetMedia(., 0)/preview" />
</xsl:attribute>
</img>
<p><xsl:value-of select="umbraco.library:GetMedia(., 0)/#nodeName" /></p>
</xsl:if>
How can I seperate the string so I can display details from the media type? I'd like to display the preview image from media type and the nodeName of the media type.
Try using Umbraco split function separated via , (Comma) as following
<xsl:variable name="contentSplit" select="umbraco.library:Split(current(), ',')" />
Refactored code:
<xsl:if test="count(umbraco.library:GetCurrentMember()/assetDownloads/values/value) > 0">
<ul>
<xsl:for-each select="umbraco.library:GetCurrentMember()/assetDownloads/values/value">
<li>
<xsl:if test="./preview != ''">
<img>
<xsl:attribute name="src">
<xsl:value-of select="./preview" />
</xsl:attribute>
</img>
</xsl:if>
<p>
<!-- Split values via , comma using below function -->
<xsl:variable name="contentSplit" select="umbraco.library:Split(current(), ',')" />
<xsl:for-each select="$contentSplit/value">
<!-- First value as media type id -->
<xsl:if test="position() = 1">
Media Type Id: <xsl:value-of select="." />
</xsl:if>
<!-- Second value as version number -->
<xsl:if test="position() = 2">
Version: <xsl:value-of select="." />
</xsl:if>
<!-- Third value as date and time of download -->
<xsl:if test="position() = 3">
Date Time: <xsl:value-of select="." />
</xsl:if>
</xsl:for-each>
</p>
</li>
</xsl:for-each>
</ul>
</xsl:if>
Let me know if you need more explanation, Thanks

How to make pagination in XSLT

I have the following XSLT:
<xsl:template match="/">
<div id="dokumentliste">
<xsl:variable name="alleNyheder" select="$currentPage//node" />
<xsl:for-each select="$alleNyheder">
<xsl:sort data-type="text" select="#createDate" order="descending" />
<xsl:if test="./data[#alias='manchet'] != ''">
<div class="newsitem">
<h2>
<xsl:value-of select="./data[#alias='title']"/>
</h2>
<xsl:if test="./data[#alias = 'manchet'] != ''">
<div class="nyhedContent">
<p>
<span class="dokumentListeDato">
<xsl:choose>
<xsl:when test="./data[#alias='date'] != ''">
<xsl:value-of select="umbraco.library:FormatDateTime(./data[#alias='date'], 'dd. MMMM yyyy')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="umbraco.library:FormatDateTime(./#createDate, 'dd. MMMM yyyy')"/>
</xsl:otherwise>
</xsl:choose>
</span>
<xsl:value-of select="./data[#alias = 'manchet']"/>
</p>
</div>
</xsl:if>
<div class="dokumentListe_laes_mere">
<a href="{umbraco.library:NiceUrl(#id)}">
Læs mere<img src="/frontend/images/macro/macro_laes_mere.png" alt="Læs mere"/>
</a>
</div>
</div>
<!-- End newsitem -->
</xsl:if>
</xsl:for-each>
</div>
</xsl:template>
I am making a newslist, and would like to make some sort of pagination. Almost the same one as seen on Google. You know "the usual one".
But I can't figure out how to do this.
The number of newsitems on each page isn't that important, but lets say 10 on each page. When the 10 first newsitems are shown, I would like the pagination to show up. With the "Next" and "Previous" buttons to the right and the left of the numbers.
Is it possible to make this, and have I explained my problem good enough? I use the Umbraco CMS by the way :)
Thank you very much.
-Kim
Something like this:
I've left some code in there for dealing with images in your listing too :-)
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/>
<xsl:template match="/">
<xsl:variable name="recordsPerPage" select="2"/>
<xsl:variable name="pageNumber">
<xsl:choose>
<!-- first page -->
<xsl:when test="umbraco.library:RequestQueryString('page') <= 0 or string(umbraco.library:RequestQueryString('page')) = '' or string(umbraco.library:RequestQueryString('page')) = 'NaN'">0</xsl:when>
<!-- what was passed in -->
<xsl:otherwise>
<xsl:value-of select="umbraco.library:RequestQueryString('page')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="numberOfRecords" select="count($currentPage/node)"/>
<!-- The fun starts here -->
<xsl:call-template name="pagination">
<xsl:with-param name="pageNumber" select="$pageNumber"/>
<xsl:with-param name="recordsPerPage" select="$recordsPerPage" />
<xsl:with-param name="numberOfRecords" select="$numberOfRecords" />
</xsl:call-template>
<ul class="listing self-clear">
<xsl:for-each select="$currentPage/node [string(data [#alias='umbracoNaviHide']) != '1']">
<xsl:sort order="descending" select="data[#alias='releasedOn']"></xsl:sort>
<xsl:if test="position() > $recordsPerPage * number($pageNumber) and position() <= number($recordsPerPage * number($pageNumber) + $recordsPerPage )">
<li>
<xsl:attribute name="class">
<xsl:if test="data[#alias='image'] = ''">
no-img
</xsl:if>
<xsl:if test="position() = $recordsPerPage * (number($pageNumber) + 1)">
last
</xsl:if>
</xsl:attribute>
<h3>
<a href="{umbraco.library:NiceUrl(#id)}">
<xsl:value-of select="#nodeName"/>
</a>
</h3>
<xsl:if test="data[#alias='image'] != ''">
<img src="{data[#alias='image']}" class="drop-shadow" />
</xsl:if>
<p class="date"><xsl:value-of select="umbraco.library:LongDate(data[#alias='releasedOn'])"/></p>
<xsl:value-of select="data[#alias='abstract']" disable-output-escaping="yes"/>
Read More
</li>
</xsl:if>
</xsl:for-each>
</ul>
<xsl:call-template name="pagination">
<xsl:with-param name="pageNumber" select="$pageNumber"/>
<xsl:with-param name="recordsPerPage" select="$recordsPerPage" />
<xsl:with-param name="numberOfRecords" select="$numberOfRecords" />
</xsl:call-template>
</xsl:template>
<xsl:template name="pagination">
<xsl:param name="pageNumber"/>
<xsl:param name="recordsPerPage"/>
<xsl:param name="numberOfRecords"/>
<div class="pagination">
<div class="wrapper">
<xsl:if test="(($pageNumber +1 ) * $recordsPerPage) < ($numberOfRecords)">
Next
</xsl:if>
<xsl:if test="$pageNumber > 0">
Prev
</xsl:if>
<span class="page-nos">
Page
<xsl:call-template name="for.loop">
<xsl:with-param name="i">1</xsl:with-param>
<xsl:with-param name="page" select="$pageNumber +1"></xsl:with-param>
<xsl:with-param name="count" select="ceiling(count($currentPage/node)div $recordsPerPage)"></xsl:with-param>
</xsl:call-template>
</span>
</div>
</div>
</xsl:template>
<xsl:template name="for.loop">
<xsl:param name="i"/>
<xsl:param name="count"/>
<xsl:param name="page"/>
<xsl:if test="$i <= $count">
<span>
<xsl:if test="$page != $i">
<a href="{umbraco.library:NiceUrl($currentPage/#id)}?page={$i - 1}" >
<xsl:value-of select="$i" />
</a>
</xsl:if>
<xsl:if test="$page = $i">
<xsl:value-of select="$i" />
</xsl:if>
</span>
</xsl:if>
<xsl:if test="$i <= $count">
<xsl:call-template name="for.loop">
<xsl:with-param name="i">
<xsl:value-of select="$i + 1"/>
</xsl:with-param>
<xsl:with-param name="count">
<xsl:value-of select="$count"/>
</xsl:with-param>
<xsl:with-param name="page">
<xsl:value-of select="$page"/>
</xsl:with-param>
</xsl:call-template>
</xsl:if>
</xsl:template>
I figured this one out now. I can see that you have just copy/pasted the pagination that where made by Tim Geyssens here: http://www.nibble.be/?p=11
And the code is also kind'a good, but I changed some of it to get it working. I don't know if I should just accept my own answer as the right one, the answer from Myster as the right one or if I can delete this post?