我一直在互联网上努力寻找如何对XML atom提要进行分页的线索,但没有成功。如何在页面上显示用于导航的分页?即第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>
.
.
.我没有太多使用XML的经验,所以请耐心等待。我见过这个:Pagination in feeds like ATOM and RSS?,但它没有回答我的问题。有什么想法吗伙计们。我真的很感激。
非常感谢各位。
发布于 2015-06-04 17:48:07
因为你没有展示你尝试过的东西,所以很难准确地弄清楚你想要什么。如果您想要计算给定页面长度的Atom提要中的页面数量,那么可以使用简单的算法:
<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>https://stackoverflow.com/questions/30624442
复制相似问题