source: trunk/gsdl3/web/interfaces/classic/transform/query-common.xsl@ 9874

Last change on this file since 9874 was 9874, checked in by kjdon, 19 years ago

merged from branch ant-install-branch: merge 1

  • Property svn:keywords set to Author Date Id Revision
File size: 8.1 KB
Line 
1<?xml version="1.0" encoding="ISO-8859-1"?>
2<xsl:stylesheet version="1.0"
3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 xmlns:java="http://xml.apache.org/xslt/java"
5 xmlns:util="xalan://org.greenstone.gsdl3.util.XSLTUtil"
6 extension-element-prefixes="java util"
7 exclude-result-prefixes="java util">
8
9 <!--<xsl:include href="service-params.xsl"/>-->
10 <xsl:template match="service">
11 <xsl:param name="collName"/>
12 <xsl:variable name="subaction" select="../pageRequest/@subaction"/>
13 <form name="QueryForm" method="get" action="{$library_name}">
14 <input type="hidden" name="a" value="q"/>
15 <input type="hidden" name="sa" value="{$subaction}"/>
16 <input type="hidden" name="rt" value="rd"/>
17 <input type="hidden" name="s" value="{@name}"/>
18 <input type="hidden" name="c" value="{$collName}"/>
19 <input type="hidden" name="startPage" value="1"/>
20 <xsl:apply-templates select="paramList"/>
21 </form>
22 </xsl:template>
23
24 <!-- a special handling of the param list - we override the one in service-params -->
25 <xsl:template match="paramList" priority='2'>
26 <table>
27 <tr><td>
28 Search for <xsl:apply-templates select="param[@name='index']"><xsl:with-param name="default"><xsl:apply-templates select="param[@name='index']" mode="calculate-default"/></xsl:with-param></xsl:apply-templates><xsl:if test="param[@name='level']">at <xsl:apply-templates select="param[@name='level']"><xsl:with-param name="default"><xsl:apply-templates select="param[@name='level']" mode="calculate-default"/></xsl:with-param></xsl:apply-templates> level</xsl:if><xsl:call-template name='query_mode'/>
29 </td></tr>
30 <tr><td></td></tr>
31 <xsl:call-template name="query-and-submit"/>
32 </table>
33 </xsl:template>
34
35 <!-- new template for match mode -->
36 <xsl:template name='query_mode'>
37 <xsl:variable name="qt" select="/page/pageRequest/paramList/param[@name='qt']/@value"/>
38 <xsl:choose>
39 <xsl:when test="$qt=1">
40 <xsl:variable name="qfm" select="/page/pageRequest/paramList/param[@name='qfm']/@value"/>
41 <xsl:choose>
42 <xsl:when test="$qfm=1">
43 and display results in <xsl:apply-templates select="param[@name='sortBy']"><xsl:with-param name="default"><xsl:apply-templates select="param[@name='sortBy']" mode="calculate-default"/></xsl:with-param></xsl:apply-templates> order
44 </xsl:when>
45 <xsl:otherwise>
46 which contain <xsl:apply-templates select="param[@name='matchMode']"><xsl:with-param name="default"><xsl:apply-templates select="param[@name='matchMode']" mode="calculate-default"/></xsl:with-param></xsl:apply-templates> of
47 </xsl:otherwise>
48 </xsl:choose>
49 </xsl:when>
50 <xsl:otherwise>
51 <xsl:variable name="ct" select="/page/pageRequest/paramList/param[@name='ct']/@value"/>
52 <xsl:variable name="qm" select="/page/pageRequest/paramList/param[@name='qm']/@value"/>
53 <xsl:choose>
54 <xsl:when test="$qm=1 and $ct=0">
55 using ranked/bool query
56 </xsl:when>
57 <xsl:when test="$qm=1 and $ct=1">
58 and display results in <xsl:apply-templates select="param[@name='sortBy']"><xsl:with-param name="default"><xsl:apply-templates select="param[@name='sortBy']" mode="calculate-default"/></xsl:with-param></xsl:apply-templates> order
59 </xsl:when>
60 <xsl:otherwise>
61 which contain <xsl:apply-templates select="param[@name='matchMode']"><xsl:with-param name="default"><xsl:apply-templates select="param[@name='matchMode']" mode="calculate-default"/></xsl:with-param></xsl:apply-templates> of the words
62 </xsl:otherwise>
63 </xsl:choose>
64 </xsl:otherwise>
65 </xsl:choose>
66 </xsl:template>
67
68 <xsl:template match="param[@name='matchMode']" mode='query1'>
69 <xsl:param name='default'/>
70 <xsl:variable name="qfm" select="/page/pageRequest/paramList/param[@name='qfm']/@value"/>
71 <xsl:choose>
72 <xsl:when test="$qfm=1">
73 and display results in <xsl:apply-templates select="../param[@name='sortBy']"><xsl:with-param name="default" select="$default"/></xsl:apply-templates> order
74 </xsl:when>
75 <xsl:otherwise>
76 which contain <xsl:apply-templates select='.'><xsl:with-param name="default" select="$default"/></xsl:apply-templates> of the words
77 </xsl:otherwise>
78 </xsl:choose>
79 </xsl:template>
80
81 <xsl:template name="query-and-submit">
82 <xsl:variable name="qt" select="/page/pageRequest/paramList/param[@name='qt']/@value"/>
83 <xsl:choose>
84 <xsl:when test="$qt=1"> <!-- doing form query -->
85 <xsl:variable name="qfm" select="/page/pageRequest/paramList/param[@name='qfm']/@value"/>
86 <xsl:choose>
87 <xsl:when test="$qfm=1">
88 <tr><td><xsl:apply-templates select="param[@name='complexField']"/></td></tr>
89 </xsl:when>
90 <xsl:otherwise>
91 <tr><td><xsl:apply-templates select="param[@name='simpleField']"/></td></tr>
92 </xsl:otherwise>
93 </xsl:choose>
94 <tr><td align='right'>
95 <input type="submit"><xsl:attribute name="value"><xsl:value-of select="../displayItem[@name='submit']"/></xsl:attribute></input>
96 </td></tr>
97 </xsl:when>
98 <xsl:otherwise> <!-- doing text query -->
99 <xsl:variable name="qb" select="/page/pageRequest/paramList/param[@name='qb']/@value"/>
100 <xsl:choose>
101 <xsl:when test="$qb=1"><!-- large query box -->
102 <tr><td>
103 <textarea name="query" cols='63' rows='10'>
104 <xsl:apply-templates select="param[@name='query']" mode="calculate-default"/><xsl:text> </xsl:text><!-- put a space here just in case there is no value- mozilla craps out if have a <textarea /> element -->
105 </textarea>
106 </td></tr>
107 <tr><td align='right'>
108 <input type="submit"><xsl:attribute name="value"><xsl:value-of select="../displayItem[@name='submit']"/></xsl:attribute></input>
109 </td></tr>
110 </xsl:when>
111 <xsl:otherwise>
112 <tr><td>
113 <xsl:variable name="qs"><xsl:apply-templates select="param[@name='query']" mode="calculate-default"/></xsl:variable>
114 <nobr><xsl:apply-templates select="param[@name='query']"><xsl:with-param name="default" select="java:org.greenstone.gsdl3.util.XSLTUtil.tidyWhitespace($qs)"/></xsl:apply-templates><input type="submit"><xsl:attribute name="value"><xsl:value-of select="../displayItem[@name='submit']"/></xsl:attribute></input></nobr>
115 </td></tr>
116 </xsl:otherwise>
117 </xsl:choose>
118 </xsl:otherwise>
119 </xsl:choose>
120 </xsl:template>
121
122 <!-- overwrite the multi param to use our value of occurs, not the one with the param -->
123 <xsl:template match="param[@type='multi']" priority='2'>
124 <xsl:variable name="parent" select="@name"/>
125 <table>
126 <tr>
127 <xsl:for-each select="param">
128 <xsl:variable name='pname' select='@name'/>
129 <td><xsl:value-of select="displayItem[@name='name']"/></td>
130 </xsl:for-each>
131 </tr>
132 <!-- the number of times to display this is the qfn variable -->
133 <xsl:variable name="numbox"><xsl:choose><xsl:when test="/page/pageRequest/paramList/param[@name='qfn']"><xsl:value-of select="/page/pageRequest/paramList/param[@name='qfn']/@value"/></xsl:when><xsl:otherwise>4</xsl:otherwise></xsl:choose></xsl:variable>
134 <xsl:apply-templates select="." mode="contents"><xsl:with-param name="occurs" select="$numbox"/><xsl:with-param name="pos" select="0"/></xsl:apply-templates>
135 </table>
136 </xsl:template>
137
138 <xsl:template match="param[@type='multi']" mode="contents">
139 <xsl:param name="occurs"/>
140 <xsl:param name="pos"/>
141 <!-- <xsl:variable name="pos" select="@occurs - $occurs"/>-->
142 <tr><xsl:for-each select="param">
143 <xsl:variable name="pname" select="@name"/>
144 <xsl:variable name="values" select="/page/pageRequest/paramList/param[@name=$pname]/@value"/>
145 <td><xsl:choose>
146 <xsl:when test="not(@ignore) or @ignore != $pos">
147 <xsl:apply-templates select='.'><xsl:with-param name="default" select="java:org.greenstone.gsdl3.util.XSLTUtil.getNumberedItem($values, $pos)"/></xsl:apply-templates>
148 </xsl:when>
149 <xsl:otherwise><!-- put in a hidden placeholder -->
150 <input type="hidden" name='{@name}' value=''/>
151 </xsl:otherwise>
152 </xsl:choose></td>
153 </xsl:for-each></tr>
154 <!-- recursively call this template to get multiple entries -->
155 <xsl:if test="$pos &lt; ($occurs - 1)">
156 <xsl:apply-templates select="." mode="contents"><xsl:with-param name="occurs" select="$occurs"/><xsl:with-param name="pos" select="$pos+1"/></xsl:apply-templates>
157 </xsl:if>
158 </xsl:template>
159
160</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.