2

I've been searching the internet hard to get clues how to paginate XML atom feed, but not been successful. How can I display the pagination for navigation on a page? i.e. pages 1 2 ..9

<?xml version="1.0" encoding="utf-8" ?> 
<feed xmlns:s="http://feed.example.com/services" xmlns="http://www.w3.org/2005/Atom">
<title type="text">org select - with 'Field' in name</title> 
<id>http://feed.example.com/orga/srvic/name/Field</id> 
<rights type="text">Copyright 2015</rights> 
<updated>2010-05-09</updated> 
<category term="Search" /> 
<logo>http://www.org.uk/orgcservices/docs/logo.jpg</logo> 
<author>
<name>org select</name> 
<uri>http://www.sampleorg.uk</uri> 
<email>wbsrvcs@example.com</email> 
</author>

<link rel="self" type="application/atom+xml" title="org select - Practices with 'Field' in name" href="http://feed.example.com/organisations/services/name/Field?apikey=12345" /> 
<link rel="first" type="application/atom+xml" title="first" length="1000" href="http://feed.example.com/organisations/services/name/Field?apikey=12345&page=1" /> 
<link rel="next" type="application/atom+xml" title="next" length="1000" href="http://feed.example.com/organisations/services/name/Field?apikey=12345&page=2" /> 
<link rel="last" type="application/atom+xml" title="last" length="1000" href="http://feed.example.com/organisations/services/name/Field?apikey=12345&page=9" />

<tracking xmlns="http://feed.example.com/services"><img style="border: 0; width: 1px; height: 1px;" alt="" src="http://webtrendsample.com/dfgfgh56dgd5/ddds.gif?fffuri=/organisations%2fservices%2fname%2fField&wt.js=no&wt.cg_n=feed"/></tracking> 
<entry>
<id>http://feed.example.com/organisations/services/245645634</id> 
<title type="text">Field Tree House</title> 
<updated>2015-05-12T08:08:08Z</updated> 
<link rel="self" title="Field Tree House Surgery" href="http://feed.example.com/organisations/services/24308?apikey=12345" /> 
<link rel="alternate" title="Field Tree House Surgery" href="http://www.org.uk/Srvcs/DR/Default.aspx?id=34343434" /> 
<content type="application/xml">
<s:organisationSummary>
<s:name>Field Tree House</s:name> 
<s:odsCode>JD12345</s:odsCode> 
<s:address>
<s:addressLine>Field Tree House</s:addressLine> 
<s:addressLine>John Street</s:addressLine> 
<s:addressLine>Lirkam</s:addressLine> 
<s:addressLine>Stockion</s:addressLine> 
<s:postcode>DWQ4 22GW</s:postcode> 
</s:address>
<s:contact type="General">
<s:telephone>111 2223333444</s:telephone> 
</s:contact>
</s:organisationSummary>
</content>
</entry>

<entry>
.
.
.

I don't have much experience with XML, so please bear with me. I have seen this: Pagination in feeds like ATOM and RSS? but this doesn't answer my query. Any ideas guys. I'd really appreciate it.

Thanks very much guys.

Community
  • 1
  • 1
ricricric
  • 21
  • 2
  • possible duplicate of [Pagination in feeds like ATOM and RSS?](http://stackoverflow.com/questions/1301392/pagination-in-feeds-like-atom-and-rss) – Jon Hanna Jun 03 '15 at 15:29

1 Answers1

0

As you did not show what you tried, it is hard to figure out exactly what you want. If you want to compute the number of pages, given a page length, in an Atom feed, then it is simple arithmetics:

<xsl:variable name="page-length" select="10"/>

<xsl:template match="atom:feed">
   <xsl:variable name="total" select="count(atom:entry)"/>
   <xsl:choose>
      <xsl:when test="$total eq 0">
         <p>No entry.</p>
      </xsl:when>
      <xsl:otherwise>
         <p>
            <xsl:text>Pages: </xsl:text>
            <xsl:value-of select="(($total - 1) idiv $page-length) + 1"/>
         </p>
      </xsl:otherwise>
   </xsl:choose>
</xsl:template>
Florent Georges
  • 2,190
  • 1
  • 15
  • 24