Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: pagination - sort of

From: "N. Demos" <stormbringer_seven@-------.--->
To: 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.


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent