Ignore:
Timestamp:
2003-08-19T14:49:26+12:00 (21 years ago)
Author:
kjdon
Message:

paging of teh results is now done by the action, however we still need to work out the numbers for the next and prev buttons

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/web/interfaces/default/transform/querytools.xsl

    r5134 r5194  
    77  exclude-result-prefixes="java util">
    88
    9   <!-- have changed this so it uses service hitsPerPage and startPage if available, otherwise uses interface ones -->
     9  <!-- have changed this so it uses service hitsPerPage and startPage if the service description has a param called hitsPerPage, otherwise uses interface ones -->
    1010  <xsl:template name="resultNavigation">
     11    <!-- hits type -->
     12    <xsl:variable name='ht'>
     13      <xsl:choose>
     14    <xsl:when test="/page/pageResponse/service/paramList/param[@name='hitsPerPage']">s</xsl:when>
     15    <xsl:otherwise>i</xsl:otherwise>
     16      </xsl:choose>
     17    </xsl:variable>
     18   
    1119    <xsl:variable name="param-list" select="/page/pageRequest/paramList"/>
    1220    <!-- hits per page -->
    1321    <xsl:variable name="hpp">
    1422      <xsl:choose>
    15     <xsl:when test="$param-list/param[@name='s1.hitsPerPage']"><xsl:value-of select="$param-list/param[@name='s1.hitsPerPage']/@value"/></xsl:when>
     23    <xsl:when test="$ht='s'"><xsl:value-of select="$param-list/param[@name='s1.hitsPerPage']/@value"/></xsl:when>
    1624    <xsl:when test="$param-list/param[@name='hitsPerPage']"><xsl:value-of select="$param-list/param[@name='hitsPerPage']/@value"/></xsl:when>
    1725    <xsl:otherwise>20</xsl:otherwise>
    1826      </xsl:choose>
    1927    </xsl:variable>
    20     <!-- hits type -->
    21     <xsl:variable name='ht'>
     28    <!-- total docs - this may be in numDocsMatched or numDocsReturned metadata -->
     29    <xsl:variable name="td">
    2230      <xsl:choose>
    23     <xsl:when test="$param-list/param[@name='s1.hitsPerPage']">s</xsl:when>
    24     <xsl:otherwise>i</xsl:otherwise>
     31    <xsl:when test="/page/pageResponse/metadataList/metadata[@name='numDocsReturned']">
     32      <xsl:value-of select="/page/pageResponse/metadataList/metadata[@name='numDocsReturned']"/>
     33    </xsl:when>
     34    <xsl:when test="/page/pageResponse/metadataList/metadata[@name='numDocsMatched']">
     35      <xsl:value-of select="/page/pageResponse/metadataList/metadata[@name='numDocsMatched']"/>
     36    </xsl:when>
     37    <xsl:otherwise> <!-- this is just a fall back - shoudl always have the metadata -->
     38      <xsl:value-of select="count(/page/pageResponse/documentNodeList/documentNode)"/>
     39    </xsl:otherwise>   
    2540      </xsl:choose>
    2641    </xsl:variable>
    27     <!-- total docs -->
    28     <xsl:variable name="td">
    29       <xsl:choose>
    30     <xsl:when test="$ht='s'">
    31       <xsl:value-of select="/page/pageResponse/metadataList/metadata[@name='numDocsMatched']/@value"/>
    32     </xsl:when>
    33     <xsl:otherwise>
    34       <xsl:value-of select="count(/page/pageResponse/documentNodeList/documentNode)"/>
    35     </xsl:otherwise>
    36       </xsl:choose>
    37     </xsl:variable>
     42
    3843    <!-- only continue if hpp != -1 and td > hpp -->
    3944    <xsl:if test="not($hpp=-1) and $td &gt; $hpp">
     
    4146      <xsl:variable name="here">
    4247    <xsl:choose>
    43       <xsl:when test="$param-list/param[@name='s1.startPage']"><xsl:value-of select="$param-list/param[@name='s1.startPage']/@value"/></xsl:when>
     48      <xsl:when test="$ht='s'"><xsl:value-of select="$param-list/param[@name='s1.startPage']/@value"/></xsl:when>
    4449      <xsl:when test="$param-list/param[@name='startPage']"><xsl:value-of select="$param-list/param[@name='startPage']/@value"/></xsl:when>
    4550      <xsl:otherwise>1</xsl:otherwise>
     
    6772    </xsl:if>
    6873  </xsl:template>
    69  
     74   
     75  <xsl:template name="matchDocs">
     76    <!-- If the number of matching documents is known, display it -->
     77    <xsl:variable name="numDocsMatched" select="metadataList/metadata[@name='numDocsMatched']"/>
     78    <xsl:variable name="numDocsReturned" select="metadataList/metadata[@name='numDocsReturned']"/>
     79    <xsl:choose>
     80      <xsl:when test="$numDocsMatched='0' or $numDocsReturned='0'">
     81    <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.nodocsmatch')"/>
     82      </xsl:when>
     83      <xsl:when test="$numDocsMatched='1' or $numDocsReturned='0'">
     84    <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.onedocsmatch')"/>
     85      </xsl:when>
     86      <xsl:when test="$numDocsMatched">
     87    <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.manydocsmatch', $numDocsMatched)"/>
     88    <xsl:if test="$numDocsReturned"> (<xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.docsreturned', $numDocsReturned)"/>)</xsl:if>
     89      </xsl:when>
     90      <xsl:when test="$numDocsReturned">
     91    <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.atleastdocsmatch', $numDocsReturned)"/>
     92      </xsl:when>
     93    </xsl:choose>
     94  </xsl:template>
     95
     96  <!-- paging is now done by the query action, so here we just print out all the docs that we have -->
     97  <xsl:template name="resultList">
     98    <xsl:param name="collName"/>
     99    <table>
     100      <xsl:for-each select="documentNodeList/documentNode">
     101    <tr>
     102      <xsl:apply-templates select=".">
     103        <xsl:with-param name="collName" select="$collName"/>
     104      </xsl:apply-templates>
     105    </tr>       
     106      </xsl:for-each>
     107    </table>   
     108  </xsl:template>
     109
    70110
    71111  <!-- the default doc node template for the query results -->
     
    93133    </xsl:if>
    94134  </xsl:template>
    95  
    96   <xsl:template name="matchDocs">
    97     <!-- If the number of matching documents is known, display it -->
    98     <xsl:variable name="numDocsMatched" select="metadataList/metadata[@name='numDocsMatched']/@value"/>
    99     <xsl:if test="$numDocsMatched">
    100       <xsl:choose>
    101     <xsl:when test="$numDocsMatched='0'">
    102       <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.nodocsmatch')"/>
    103     </xsl:when>
    104     <xsl:when test="$numDocsMatched='1'">
    105       <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.onedocsmatch')"/>
    106     </xsl:when>
    107     <xsl:otherwise>
    108       <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.manydocsmatch', $numDocsMatched)"/>
    109     </xsl:otherwise>
    110       </xsl:choose>
    111     </xsl:if>
    112   </xsl:template>
    113 
    114 
    115   <xsl:template name="resultList">
    116     <xsl:param name="collName"/>
    117     <xsl:variable name="param-list" select="/page/pageRequest/paramList"/>
    118     <!-- hits per page -->
    119     <xsl:variable name="hpp">
    120       <xsl:choose>
    121     <xsl:when test="$param-list/param[@name='s1.hitsPerPage']"><xsl:value-of select="$param-list/param[@name='s1.hitsPerPage']/@value"/></xsl:when>
    122     <xsl:when test="$param-list/param[@name='hitsPerPage']"><xsl:value-of select="$param-list/param[@name='hitsPerPage']/@value"/></xsl:when>
    123     <xsl:otherwise>20</xsl:otherwise>
    124       </xsl:choose>
    125     </xsl:variable>
    126     <xsl:choose>
    127       <xsl:when test="$param-list/param[@name='s1.hitsPerPage'] or $hpp=-1">
    128     <!-- the service has handled the paging, just output all the docs -->
    129     <table>
    130       <xsl:for-each select="documentNodeList/documentNode">
    131         <tr>
    132           <xsl:apply-templates select=".">
    133         <xsl:with-param name="collName" select="$collName"/>
    134           </xsl:apply-templates>
    135         </tr>       
    136       </xsl:for-each>
    137     </table>
    138       </xsl:when>
    139       <xsl:otherwise>
    140     <!-- we have done the paging, only show a selection of the docs -->
    141     <!-- start page -->
    142     <xsl:variable name="sp">
    143       <xsl:choose>
    144         <xsl:when test="$param-list/param[@name='s1.startPage']"><xsl:value-of select="$param-list/param[@name='s1.startPage']/@value"/></xsl:when>
    145         <xsl:when test="$param-list/param[@name='startPage']"><xsl:value-of select="$param-list/param[@name='startPage']/@value"/></xsl:when>
    146         <xsl:otherwise>1</xsl:otherwise>
    147       </xsl:choose>
    148     </xsl:variable>
    149     <table>
    150       <xsl:for-each select="documentNodeList/documentNode">
    151         <xsl:if test=" (position()&gt; (($sp - 1)*$hpp) and position() &lt;= ($sp * $hpp))">
    152           <tr>
    153         <xsl:apply-templates select=".">
    154           <xsl:with-param name="collName" select="$collName"/>
    155         </xsl:apply-templates>
    156           </tr>
    157         </xsl:if>
    158       </xsl:for-each>
    159     </table>
    160       </xsl:otherwise>
    161     </xsl:choose>
    162   </xsl:template>
    163135
    164136</xsl:stylesheet>
Note: See TracChangeset for help on using the changeset viewer.