Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 17th, 2011, 03:56 PM
Registered User
 
Join Date: Nov 2011
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default Is this the right way to do

Hello,

For my website I'm looking for a xslt pagination script to use with Symphony cms.
Now I found this one : http://www.codeproject.com/KB/dotnet/pagination.aspx

But one thing looks wierd to me.
Here's the code:

Code:
 <xsl:for-each select="root/customer">
       <!-- Pagination logic -->
       <xsl:if test="position() &gt;= ($Page * $PageSize) + 1">
        <xsl:if test="position() &lt;= $PageSize + ($PageSize * $Page)">


         <!-- Do display here -->
         
        </xsl:if>
       </xsl:if>
      </xsl:for-each>
When Im on page 1 ($Page=1) and I would display 1 article (pagesize=1)
Then the first xsl is false because position = 1 and page*pagesize =1 + 1 = 2

So in my opion it never reach the <!-- do display here
But how can I take care that there will be something to display.

Roelof
 
Old November 18th, 2011, 04:15 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

At the start of that article it states:
Quote:
Note: First page id is 0
So when you are the first page, $Page will equal 0 and position() will equal 1 for the item you want to display.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old November 18th, 2011, 08:06 AM
Registered User
 
Join Date: Nov 2011
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Oke
But I don't agree complete with you.
It is correct that position will be 1.
$page = 0 .

So 1 > (0*1)+1 so 1 > 0 + 1 so 1 > 1 and that not right so the next if will never be reached in my opionon.

Roelof
 
Old November 18th, 2011, 08:13 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

It is ">=" and not just ">".
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old November 18th, 2011, 08:46 AM
Registered User
 
Join Date: Nov 2011
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks,

Wierd that you then write &gt;= and not simple >= .

Roelof
 
Old November 18th, 2011, 11:59 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Not when ">" is invalid inside an attribute value in XML its not. Actually ">" might be valid but "<" isn't, so they are just being consistent.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old November 19th, 2011, 10:51 AM
Registered User
 
Join Date: Nov 2011
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks, I learned another thing about xslt.

I have another question and I don't know if I can ask here of make another topic.

I have the variable itemsPerPage. I want to change the value. I have read that I cannot change a value of a variable. So I think I need a parameter.

Am I on the right track that I can change the value of a parameter ?
And is there a example how to do that.

Roelof
 
Old November 19th, 2011, 01:35 PM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

parameters are just variables that are set by the XSLT processor and can be passed in at runtime. They cannot be altered either.

Start a new topic and tell us what you are trying to accomplish and we will try to help.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?









Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.