home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-cocoon-addon-1.4.9-installer.exe / search2html.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2004-07-12  |  8.1 KB  |  225 lines

  1. <?xml version="1.0"?>
  2. <!--
  3.   Copyright 1999-2004 The Apache Software Foundation
  4.  
  5.   Licensed under the Apache License, Version 2.0 (the "License");
  6.   you may not use this file except in compliance with the License.
  7.   You may obtain a copy of the License at
  8.  
  9.       http://www.apache.org/licenses/LICENSE-2.0
  10.  
  11.   Unless required by applicable law or agreed to in writing, software
  12.   distributed under the License is distributed on an "AS IS" BASIS,
  13.   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.   See the License for the specific language governing permissions and
  15.   limitations under the License.
  16. -->
  17.  
  18. <xsl:stylesheet
  19.   version="1.0"
  20.   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  21.   xmlns:search="http://apache.org/cocoon/search/1.0"
  22. >
  23.  
  24.   <xsl:template match="search:results">
  25.     <html>
  26.       <head>
  27.         <title>Index Search</title>
  28.         <link title="Default Style" href="/styles/main.css" rel="stylesheet"/>
  29.       </head>
  30.       <body bgcolor="white" alink="red" link="blue" vlink="blue">
  31.         <a href="http://jakarta.apache.org/lucene/">
  32.           <img border="0" alt="Lucene Logo" src="images/lucene_green_300.gif"/>
  33.         </a>
  34.         <h1>IndexSearch</h1>
  35.         
  36.         <p>
  37.           <small>
  38.             <a href="welcome">Welcome</a> |
  39.             <a href="statistic">Index Statistic</a>
  40.           </small>
  41.         </p>
  42.         
  43.         <form action="">
  44.           <input type="text" name="queryString" size="60" value="{@query-string}"/>
  45.            
  46.           <input type="submit" name="Search" value="Search"/>
  47.         </form>
  48.         Search Help
  49.         <table cellspacing="2" cellpadding="2">
  50.           <tr bgcolor="#dddedd" valign="top">
  51.           <td width="50%"><font size="-2" >
  52.             <ul>
  53.               <li>free AND "text search"
  54.                 Search for documents containing "free" and the 
  55.                 phrase "text search"
  56.               </li>
  57.               <li>+text search
  58.                 Search for documents containing "text" and 
  59.                 preferentially containing "search".
  60.               </li>
  61.               <li>giants -football
  62.                 Search for "giants" but omit documents containing "football"
  63.               </li>
  64.             </ul>
  65.           </font></td>
  66.           
  67.           <td><font size="-2">
  68.             <ul>
  69.               <li>body:john
  70.                 Search for documents containing "john" in the  body field.
  71.                 The field "body" is used by default.
  72.                 Thus query "body:john" is equivalent to query "john".
  73.               </li>
  74.               <li>s1@title:cocoon
  75.                 Search for documents containing "cocoon" in the
  76.                 using field s1@title, ie searching in
  77.                 title attribute of s1 element of xml document.
  78.               </li>
  79.             </ul>
  80.           </font></td>
  81.           </tr>
  82.         </table>
  83.         
  84.         <xsl:apply-templates/>
  85.       </body>
  86.     </html>
  87.   </xsl:template>
  88.  
  89.   <xsl:template match="search:hits">
  90.     <p>
  91.       Total Hits <xsl:value-of select="@total-count"/>
  92.       Pages <xsl:value-of select="@count-of-pages"/>
  93.     </p>
  94.     <p>
  95.       Page:
  96.       <xsl:for-each select="/search:results/search:navigation/search:navigation-page">
  97.         <xsl:call-template name="navigation-link"> 
  98.           <xsl:with-param name="query-string" select="/search:results/@query-string"/>
  99.           <xsl:with-param name="page-length" select="/search:results/@page-length"/>
  100.           <xsl:with-param name="start-index" select="@start-index"/>
  101.           <xsl:with-param name="link-text" select="position()"/>
  102.         </xsl:call-template>
  103.       </xsl:for-each>
  104.     </p>
  105.     
  106.     <p>
  107.     <xsl:call-template name="navigation-paging-link">
  108.       <xsl:with-param name="query-string" select="/search:results/@query-string"/>
  109.       <xsl:with-param name="page-length" select="/search:results/@page-length"/>
  110.       <xsl:with-param name="has-previous" select="/search:results/search:navigation/@has-previous"/>
  111.       <xsl:with-param name="has-next" select="/search:results/search:navigation/@has-next"/>
  112.       <xsl:with-param name="previous-index" select="/search:results/search:navigation/@previous-index"/>
  113.       <xsl:with-param name="next-index" select="/search:results/search:navigation/@next-index"/>
  114.     </xsl:call-template>
  115.     </p>
  116.     <hr/>
  117.     
  118.     <table border="1" width="90%" cellpadding="4">
  119.       <tr>
  120.         <td>Score</td><td>Rank</td><td>URI</td>
  121.       </tr>
  122.       <xsl:apply-templates/>
  123.     </table>
  124.   </xsl:template>
  125.  
  126.   <xsl:template match="search:navigation">
  127.     <p>
  128.     <xsl:call-template name="navigation-paging-form">
  129.       <xsl:with-param name="query-string"><xsl:value-of select="/search:results/@query-string"/></xsl:with-param>
  130.       <xsl:with-param name="page-length"><xsl:value-of select="/search:results/@page-length"/></xsl:with-param>
  131.       <xsl:with-param name="has-previous"><xsl:value-of select="@has-previous"/></xsl:with-param>
  132.       <xsl:with-param name="has-next"><xsl:value-of select="@has-next"/></xsl:with-param>
  133.       <xsl:with-param name="previous-index"><xsl:value-of select="@previous-index"/></xsl:with-param>
  134.       <xsl:with-param name="next-index"><xsl:value-of select="@next-index"/></xsl:with-param>
  135.     </xsl:call-template>
  136.     </p>
  137.   </xsl:template>
  138.   
  139.   <xsl:template match="search:hit">
  140.     <tr>
  141.       <td>
  142.         <xsl:value-of select="format-number( @score, '### %' )"/>
  143.       </td>
  144.       <td>
  145.         <xsl:value-of select="@rank"/>
  146.       </td>
  147.       <td>
  148.         <a target="_blank" href="{@uri}">
  149.           <xsl:value-of select="@uri"/>
  150.         </a>
  151.       </td>
  152.     </tr>
  153.   </xsl:template>
  154.  
  155.   <xsl:template name="navigation-paging-form">
  156.     <xsl:param name="query-string"/>
  157.     <xsl:param name="page-length"/>
  158.     <xsl:param name="has-previous"/>
  159.     <xsl:param name="has-next"/>
  160.     <xsl:param name="previous-index"/>
  161.     <xsl:param name="next-index"/>
  162.  
  163.     <xsl:if test="$has-previous = 'true'">
  164.       <form action="findIt">
  165.         <input type="hidden" name="startIndex" value="{$previous-index}"/>
  166.         <input type="hidden" name="queryString" value="{$query-string}"/>
  167.         <input type="hidden" name="pageLength" value="{$page-length}"/>
  168.         <input type="submit" name="previous" value="previous"/>
  169.       </form>
  170.     </xsl:if>
  171.     
  172.     <xsl:if test="$has-next = 'true'">
  173.       <form action="findIt">
  174.         <input type="hidden" name="startIndex" value="{$next-index}"/>
  175.         <input type="hidden" name="queryString" value="{$query-string}"/>
  176.         <input type="hidden" name="pageLength" value="{$page-length}"/>
  177.         <input type="submit" name="next" value="next"/>
  178.       </form>
  179.     </xsl:if>
  180.     
  181.   </xsl:template>
  182.  
  183.   <xsl:template name="navigation-paging-link">
  184.     <xsl:param name="query-string"/>
  185.     <xsl:param name="page-length"/>
  186.     <xsl:param name="has-previous"/>
  187.     <xsl:param name="has-next"/>
  188.     <xsl:param name="previous-index"/>
  189.     <xsl:param name="next-index"/>
  190.  
  191.     <xsl:if test="$has-previous = 'true'">
  192.       
  193.       <xsl:call-template name="navigation-link">
  194.         <xsl:with-param name="query-string"><xsl:value-of select="$query-string"/></xsl:with-param>
  195.         <xsl:with-param name="page-length"><xsl:value-of select="$page-length"/></xsl:with-param>
  196.         <xsl:with-param name="start-index"><xsl:value-of select="$previous-index"/></xsl:with-param>
  197.         <xsl:with-param name="link-text">Previous Page Of Hits</xsl:with-param>
  198.       </xsl:call-template>
  199.     </xsl:if>
  200.      
  201.     <xsl:if test="$has-next = 'true'">
  202.       <a href="findIt?startIndex={$next-index}&queryString={$query-string}&pageLength={$page-length}">
  203.         Next Page Of Hits
  204.       </a>
  205.     </xsl:if>
  206.   </xsl:template>
  207.   
  208.   <xsl:template name="navigation-link">
  209.     <xsl:param name="query-string"/>
  210.     <xsl:param name="page-length"/>
  211.     <xsl:param name="start-index"/>
  212.     <xsl:param name="link-text"/>
  213.  
  214.     <a href="findIt?startIndex={$start-index}&queryString={$query-string}&pageLength={$page-length}">
  215.       <xsl:value-of select="$link-text"/>
  216.     </a>
  217.      
  218.   </xsl:template>
  219.  
  220.   <xsl:template match="@*|node()" priority="-2"><xsl:copy><xsl:apply-templates select="@*|node()"/></xsl:copy></xsl:template>
  221.   <xsl:template match="text()" priority="-1"><xsl:value-of select="."/></xsl:template>
  222.  
  223. </xsl:stylesheet>
  224.  
  225.