PAging i xslt hvordan, fortsat?
Jeg har flg. xml struktur:<artikel>
<afsnit>
<overskrift/>
<underoversrift/>
<broedtekst>
<liste>
<item/>
...
</liste>
<billede/>
</broedtekst>
<afsnit>
</artikel>
Jeg har så lavet flg. style:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:variable name="totalNumberOfPages">
<xsl:value-of select="count(artikel/afsnit)"/>
</xsl:variable>
<xsl:template match="/">
<html>
<head>
<title/>
<link rel="stylesheet" type="text/css" href="style1.css"/>
<xsl:call-template name="buildJavaScript"/>
</head>
<body>
<center>
<div align="center" class="boks">
<table border="0" cellspacing="0" cellpadding="2">
<tr>
<td width="735px" height="90px" colspan="3" class="BannerTD"/>
</tr>
<tr>
<td width="100%" height="15px" colspan="3" class="TDSmall">
<table align="right">
<tbody>
<tr>
<td>
<a href="#" class="SmallMenu">xxxx</a>
</td>
<td>
<a href="#" class="SmallMenu"> Kontakt</a>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td width="140px" height="758px" valign="top" class="MenuTD">
<h5 align="center" class="menuCol">.:: MENU ::.</h5>
<a href="index.htm" class="menuLink">> Forside</a><br/>
<a href="#" class="menuLink">> Skoleprojekter</a><br/>
<a href="Synopser.htm" class="menuLink">> Synopser</a><br/>
<a href="#" class="menuLink">> Egne applikationer</a><br/>
<a href="Bogsalg.xml" class="menuLink">> Bogsalg</a><br/>
<a href="Links.xml" class="menuLink">> Links</a></td>
<td width="625px">
<h5 align="center">.:: APPLIKATIONER ::. <br/>
---------------------------------------------------------------------------
</h5>
<div id="currentPage" class="selosDiv">
<xsl:apply-templates/>
<xsl:call-template name="buildPaging">
<xsl:with-param name="currentPage">1</xsl:with-param>
</xsl:call-template>
</div>
</td>
</tr>
</table>
</div>
</center>
</body>
</html>
</xsl:template>
<xsl:template match="afsnit">
<xsl:variable name="currentPage"/>
<center>
<div id="page{position()}" style="display:none;">
<xsl:apply-templates select="overskrift"/>
<xsl:apply-templates select="overskrift2"/>
<xsl:apply-templates select="tekst"/>
</div>
</center>
</xsl:template>
<xsl:template match="overskrift">
<h3 align="center">
<xsl:value-of select="."/>
</h3>
</xsl:template>
<xsl:template match="overskrift2">
<h5 align="center">
<xsl:value-of select="."/>
</h5>
</xsl:template>
<xsl:template match="tekst">
<xsl:value-of select="."/>
<xsl:apply-templates select="liste"/>
<xsl:apply-templates select="billede"/>
</xsl:template>
<xsl:template match="liste">
<ol>
<xsl:for-each select="//item">
<li>
<xsl:value-of select="."/>
</li>
</xsl:for-each>
</ol>
</xsl:template>
<xsl:template match="billede">
<img align="left" class="SelosPic">
<!-- Oprettes paa denne maade fordi der ikke kan staa < eller > inde i et tag. -->
<xsl:attribute name="src"><xsl:value-of select="text()"/></xsl:attribute>
<xsl:attribute name="width">300</xsl:attribute>
<xsl:attribute name="height">220</xsl:attribute>
</img>
</xsl:template>
<xsl:template name="buildPaging">
<xsl:param name="currentPage"/>
<xsl:if test="number( $currentPage ) <= $totalNumberOfPages">
<a>
<xsl:attribute name="href">java script:void(0)</xsl:attribute>
<xsl:attribute name="onclick">showPage( <xsl:value-of select="$currentPage"/> );</xsl:attribute>
<xsl:value-of select="$currentPage"/>
</a>
<xsl:if test="number( $currentPage ) < $totalNumberOfPages">
<xsl:text> | </xsl:text>
<xsl:call-template name="buildPaging">
<xsl:with-param name="currentPage">
<xsl:value-of select="number( $currentPage ) + 1"/>
</xsl:with-param>
</xsl:call-template>
</xsl:if>
</xsl:if>
</xsl:template>
<xsl:template name="buildJavaScript">
<script type="text/javascript" language="javascript">
<xsl:comment><![CDATA[
window.onload = init;
var objCurrentPage = null;
function init()
{
objCurrentPage = document.getElementById( "currentPage" );
showPage( 1 );
}
function showPage( intPageNumber )
{
var objNewPage = document.getElementById( "page" + intPageNumber );
objCurrentPage.innerHTML = objNewPage.innerHTML;
}
]]></xsl:comment>
</script>
</xsl:template>
</xsl:stylesheet>
Nogen der kan se hvorfor det ikke virker, den viser kun første afsnit og ikke nogle tal til at page. Den tæller formentlig forkert sammen?!
Hjæælp....