Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - pagination - sort of [Thread Next] Re: pagination - sort ofTo: NULL Date: 7/8/2005 8:07:00 PM Kim wrote:
> I have my xml and xslt below.I am trying to build previous and Next buttons.
> these would be dependent on what 'page' I would be on. The value of
> 'LessontIntro/testContent/tcc/testContentID' defines what Page I am on. The
> group of pages would change depending on the value of
> 'LessontIntro/testContent/tcc/testID'
>
> For the lesson with the testID of 1010
> I have 3 Id's 155, 156 and 157
>
>
>
> If I am on page 156 - I need to beable to go back to 155 and forward to 157
>
> How do I get the previous and following testContentID's
>
> See my xslt below
>
> I can restrict it down to the pages in the test - but I cannot figure out
> how to get only ONE returened.
>
>
>
Try this. You seemed to be selecting on the wrong node in your for-each.
You needed to go up one more level to the parent of <tcc>
(<testContent>), and then use the preceding/following-sibling axes to
determine if there is a preceding/following page.
Note: I made the assumption that the node order corrisponded canonically
with the page order (i.e. a preceding page/node would always precede the
current node and likewise with a following page/node. If this assumption
is incorrect, then you will have to replace preceding-sibling:: and
following-sibling:: in the the param value "siblingNode" in
call-template with just sibling::.
HTH
Regards,
N. Demos
XSL:
--------------------------------
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="4.0" indent="yes" />
<xsl:variable name="testContentTypeID" select="'11'" />
<xsl:variable name="testID" select="'1010'" />
<xsl:template match="/">
<html>
<head>
<title></title>
</head>
<body>
<xsl:apply-templates
select="results/LessonIntro/testContent/tcc/testID[. = $testID]" />
</body>
</html>
</xsl:template>
<xsl:template match="testID">
<xsl:if test="$testContentTypeID ='11' and
preceding-sibling::testContentID[1]">
<xsl:variable name="varTestContentID"
select="number(preceding-sibling::testContentID[1])" />
<table border="1">
<caption>Current Page:<xsl:text> </xsl:text><xsl:value-of
select="$varTestContentID" /></caption>
<tbody>
<tr>
<th>Page</th>
<th>Node name</th>
<th>Node value</th>
</tr>
<xsl:call-template name="SiblingPage">
<xsl:with-param name="siblingNode"
select="ancestor::testContent[1]/preceding-sibling::testContent[tcc/testID
= $testID and number(tcc/testContentID) = $varTestContentID - 1]" />
<xsl:with-param name="relationText" select="'Previous'" />
</xsl:call-template>
<xsl:call-template name="SiblingPage">
<xsl:with-param name="siblingNode"
select="ancestor::testContent[1]/following-sibling::testContent[tcc/testID
= $testID and number(tcc/testContentID) = $varTestContentID + 1]" />
<xsl:with-param name="relationText" select="'Next'" />
</xsl:call-template>
</tbody>
</table>
</xsl:if>
</xsl:template>
<xsl:template name="SiblingPage">
<xsl:param name="siblingNode" select="''" />
<xsl:param name="relationText" select="''" />
<xsl:if test="$siblingNode != ''">
<tr>
<td><xsl:value-of select="$relationText" /></td>
<td>testContentID</td>
<td>
<xsl:value-of select="$siblingNode/tcc/testContentID"/>
</td>
</tr>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
--
Change "seven" to a digit to email me.
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
