source: trunk/gsdl3/interfaces/default/transform/basicquery.xsl@ 3765

Last change on this file since 3765 was 3765, checked in by mdewsnip, 21 years ago

Changed to support new query results format, with "numDocsMatched" and query term information.

  • Property svn:keywords set to Author Date Id Revision
File size: 5.0 KB
RevLine 
[3595]1<?xml version="1.0" encoding="ISO-8859-1"?>
2<xsl:stylesheet version="1.0"
3xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
4
5<xsl:include href="style.xsl"/>
6<xsl:include href="service-params.xsl"/>
7
8<xsl:output method="html"/>
9
10<xsl:template match="page">
11
[3752]12<xsl:variable name="collName">
13 <xsl:value-of select="request/paramList/param[@name='c']/@value"/>
14</xsl:variable>
[3595]15
16<html>
17<xsl:call-template name="greenstoneHead"/>
18<body xsl:use-attribute-sets="body-style">
[3752]19
20<table border="0" cellspacing="0" cellpadding="0" width="100%">
21<tr/><td valign="top" width="65"><img src="interfaces/default/images/spacer.gif" width="65" height="1" alt="" border="0"></img></td>
22<td/><center><table width="537"><tr/><td/>
23
[3595]24<center>
25<xsl:call-template name="collectionPageBanner">
26<xsl:with-param name="collName" select="$collName"/>
27</xsl:call-template>
28<xsl:apply-templates select="service">
29<xsl:with-param name="collName" select="$collName"/>
30</xsl:apply-templates>
[3752]31</center>
[3595]32<xsl:apply-templates select="response">
33<xsl:with-param name="collName" select="$collName"/>
34</xsl:apply-templates>
[3752]35<xsl:call-template name="greenBar"/>
[3595]36<xsl:call-template name="greenstoneFooter"/>
[3752]37
38</table></center>
39</table>
[3595]40</body>
41</html>
42</xsl:template>
43
44<xsl:template match="service">
45<xsl:param name="collName">coll-name</xsl:param>
46<xsl:variable name="subaction"><xsl:value-of select="../request/@subaction"/></xsl:variable>
47<xsl:variable name='library' select='ancestor::page/config/library_name'/>
48<h3><xsl:value-of select="display/name"/></h3><p/>
49<form name="QueryForm" method="get" action="/gsdl3/{$library}">
50<xsl:apply-templates select="paramList"/>
51<input type="hidden" name="a" value="q"/>
52<input type="hidden" name="sa" value="{$subaction}"/>
[3686]53<input type="hidden" name="rt" value="r"/>
54<input type="hidden" name="s" value="{@name}"/>
[3595]55<input type="hidden" name="c" value="{$collName}"/>
56<input type="submit"><xsl:attribute name="value"><xsl:value-of select='display/submit'/></xsl:attribute></input>
57</form>
58</xsl:template>
59
60<xsl:template match="paramList">
[3752]61 <p/><table width="537">
62 <xsl:for-each select="param">
63 <xsl:choose>
64 <xsl:when test="@type='multi'">
65 <tr><td colspan='2'>
66 <xsl:apply-templates select='.'/></td></tr>
67 </xsl:when>
68 <xsl:otherwise>
69 <xsl:variable name="pname" select="@name"/>
70 <tr><td><xsl:value-of select='ancestor::service/display/param[@name=$pname]/name'/></td><td align="right"><xsl:apply-templates select="."/></td></tr>
71 </xsl:otherwise>
72 </xsl:choose>
73 </xsl:for-each>
74 </table>
[3595]75</xsl:template>
76
77
78<!-- a param list that puts params in pairs- wont work as is with new
79param handling stuff -->
80<!--
81<xsl:template match="paramList">
82<p/><table width="537">
83<xsl:choose>
84<xsl:when test='count(param)>4'>
85<xsl:for-each select="param[position() mod 2 = 1]">
86<tr><xsl:apply-templates select="."/>
87<xsl:if test="following-sibling::param[1]"><xsl:apply-templates select='following-sibling::param[1]'/></xsl:if></tr>
88</xsl:for-each>
89</xsl:when>
90<xsl:otherwise>
91<xsl:for-each select="param">
92<tr><xsl:apply-templates select='.'/></tr>
93</xsl:for-each>
94</xsl:otherwise>
95</xsl:choose>
96</table>
97</xsl:template>
98-->
99
[3752]100
101<!-- Process the query response -->
[3595]102<xsl:template match="response">
[3752]103 <xsl:param name="collName">coll-name</xsl:param>
104 <xsl:call-template name="greenBarResults"/>
[3595]105
[3752]106 <!-- If query term information is available, display it -->
107 <br/>
[3765]108 <xsl:if test="count(content/termList/term) > 0">
[3752]109 <small>
110 Word count:
[3765]111 <xsl:for-each select="content/termList/term">
[3752]112 <xsl:if test="position() > 1">, </xsl:if>
[3765]113 <xsl:value-of select="@name"/>: <xsl:value-of select="@count"/>
[3752]114 </xsl:for-each>
115 </small><br/>
116 </xsl:if>
117
118 <!-- If the number of matching documents is known, display it -->
[3765]119 <xsl:variable name="numDocsMatched" select="metadataList/metadata[@name='numDocsMatched']/@value"/>
120 <xsl:if test="$numDocsMatched">
[3752]121 <xsl:choose>
[3765]122 <xsl:when test="$numDocsMatched='0'">
[3752]123 No documents matched the query.
124 </xsl:when>
[3765]125 <xsl:when test="$numDocsMatched='1'">
[3752]126 1 document matched the query.
127 </xsl:when>
128 <xsl:otherwise>
[3765]129 <xsl:value-of select="$numDocsMatched"/> documents matched the query.
[3752]130 </xsl:otherwise>
131 </xsl:choose>
132 </xsl:if>
133
134 <!-- Display the matching documents -->
135 <table>
136 <tr valign="top">
137 <xsl:for-each select="content/documentList/document">
138 <tr>
139 <xsl:apply-templates select=".">
140 <xsl:with-param name="collName" select="$collName"/>
141 </xsl:apply-templates>
142 </tr>
143 </xsl:for-each>
144 </tr>
145 </table>
[3686]146</xsl:template>
[3595]147
148
[3752]149<xsl:template match="document">
150 <xsl:param name="collName">coll-name</xsl:param>
151 <xsl:variable name="library" select="ancestor::page/config/library_name"/>
[3595]152
[3752]153 <td><a href="{$library}?a=d&amp;c={$collName}&amp;d={@name}">link</a></td>
154 <td><xsl:value-of select="metadataList/metadata[@name='Title']"/></td>
155</xsl:template>
[3595]156
157
[3752]158<xsl:template name="greenBarResults">
159 <p/>
160 <center>
161 <img src="interfaces/default/images/qryresb.gif" width="537" height="17"/>
162 </center>
163</xsl:template>
[3595]164
[3752]165</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.