Changeset 6687
- Timestamp:
- 2004-02-02T13:46:36+13:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/web/interfaces/nzdl/transform/query.xsl
r6244 r6687 11 11 <xsl:include href="service-params.xsl"/> 12 12 <xsl:include href="querytools.xsl"/> 13 13 <xsl:include href="query-common.xsl"/> 14 14 <xsl:output method="html"/> 15 15 … … 53 53 54 54 <!-- If query term information is available, display it --> 55 <br/>56 55 <xsl:call-template name="termInfo"/> 57 56 <!-- If the number of matching documents is known, display it --> … … 66 65 </xsl:template> 67 66 68 69 <xsl:template match="service">70 <xsl:param name="collName"/>71 <xsl:variable name="subaction" select="../pageRequest/@subaction"/>72 <form name="QueryForm" method="get" action="{$library_name}">73 <input type="hidden" name="a" value="q"/>74 <input type="hidden" name="sa" value="{$subaction}"/>75 <input type="hidden" name="rt" value="r"/>76 <input type="hidden" name="s" value="{@name}"/>77 <input type="hidden" name="c" value="{$collName}"/>78 <input type="hidden" name="hn" value="1"/>79 <xsl:apply-templates select="paramList"/>80 </form>81 </xsl:template>82 83 <!-- a special handling of the param list - we override the one in service-params -->84 <xsl:template match="paramList" priority='2'>85 <table>86 <tr><td>87 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'/>88 </td></tr>89 <xsl:call-template name="query-and-submit"/>90 </table>91 </xsl:template>92 93 <!-- new template for match mode -->94 <xsl:template name='query_mode'>95 <xsl:variable name="qt" select="/page/pageRequest/paramList/param[@name='qt']/@value"/>96 <xsl:choose>97 <xsl:when test="$qt=1">98 <xsl:variable name="qfm" select="/page/pageRequest/paramList/param[@name='qfm']/@value"/>99 <xsl:choose>100 <xsl:when test="$qfm=1">101 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> order102 </xsl:when>103 <xsl:otherwise>104 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> of105 </xsl:otherwise>106 </xsl:choose>107 </xsl:when>108 <xsl:otherwise>109 <xsl:variable name="ct" select="/page/pageRequest/paramList/param[@name='ct']/@value"/>110 <xsl:variable name="qm" select="/page/pageRequest/paramList/param[@name='qm']/@value"/>111 <xsl:choose>112 <xsl:when test="$qm=1 and $ct=0">113 using ranked/bool query114 </xsl:when>115 <xsl:when test="$qm=1 and $ct=1">116 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> order117 </xsl:when>118 <xsl:otherwise>119 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 words120 </xsl:otherwise>121 </xsl:choose>122 </xsl:otherwise>123 </xsl:choose>124 </xsl:template>125 126 <xsl:template match="param[@name='matchMode']" mode='query1'>127 <xsl:param name='default'/>128 <xsl:variable name="qfm" select="/page/pageRequest/paramList/param[@name='qfm']/@value"/>129 <xsl:choose>130 <xsl:when test="$qfm=1">131 and display results in <xsl:apply-templates select="../param[@name='sortBy']"><xsl:with-param name="default" select="$default"/></xsl:apply-templates> order132 </xsl:when>133 <xsl:otherwise>134 which contain <xsl:apply-templates select='.'><xsl:with-param name="default" select="$default"/></xsl:apply-templates> of the words135 </xsl:otherwise>136 </xsl:choose>137 </xsl:template>138 139 <xsl:template name="query-and-submit">140 <xsl:variable name="qt" select="/page/pageRequest/paramList/param[@name='qt']/@value"/>141 <xsl:choose>142 <xsl:when test="$qt=1"> <!-- doing form query -->143 <xsl:variable name="qfm" select="/page/pageRequest/paramList/param[@name='qfm']/@value"/>144 <xsl:choose>145 <xsl:when test="$qfm=1">146 <tr><td><xsl:apply-templates select="param[@name='complexField']"/></td></tr>147 </xsl:when>148 <xsl:otherwise>149 <tr><td><xsl:apply-templates select="param[@name='simpleField']"/></td></tr>150 </xsl:otherwise>151 </xsl:choose>152 <tr><td align='right'>153 <input type="submit"><xsl:attribute name="value"><xsl:value-of select="../displayItem[@name='submit']"/></xsl:attribute></input>154 </td></tr>155 </xsl:when>156 <xsl:otherwise> <!-- doing text query -->157 <xsl:variable name="qb" select="/page/pageRequest/paramList/param[@name='qb']/@value"/>158 <xsl:choose>159 <xsl:when test="$qb=1"><!-- large query box -->160 <tr><td>161 <textarea name="query" cols='63' rows='10'>162 <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 -->163 </textarea>164 </td></tr>165 <tr><td align='right'>166 <input type="submit"><xsl:attribute name="value"><xsl:value-of select="../displayItem[@name='submit']"/></xsl:attribute></input>167 </td></tr>168 </xsl:when>169 <xsl:otherwise>170 <tr><td>171 <xsl:variable name="qs"><xsl:apply-templates select="param[@name='query']" mode="calculate-default"/></xsl:variable>172 <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>173 </td></tr>174 </xsl:otherwise>175 </xsl:choose>176 </xsl:otherwise>177 </xsl:choose>178 </xsl:template>179 180 <!-- overwrite the multi param to use our value of occurs, not the one with the param -->181 <xsl:template match="param[@type='multi']" priority='2'>182 <xsl:variable name="parent" select="@name"/>183 <table>184 <tr>185 <xsl:for-each select="param">186 <xsl:variable name='pname' select='@name'/>187 <td><xsl:value-of select="displayItem[@name='name']"/></td>188 </xsl:for-each>189 </tr>190 <!-- the number of times to display this is the qfn variable -->191 <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>192 <xsl:apply-templates select="." mode="contents"><xsl:with-param name="occurs" select="$numbox"/><xsl:with-param name="pos" select="0"/></xsl:apply-templates>193 </table>194 </xsl:template>195 196 <xsl:template match="param[@type='multi']" mode="contents">197 <xsl:param name="occurs"/>198 <xsl:param name="pos"/>199 <!-- <xsl:variable name="pos" select="@occurs - $occurs"/>-->200 <tr><xsl:for-each select="param">201 <xsl:variable name="pname" select="@name"/>202 <xsl:variable name="values" select="/page/pageRequest/paramList/param[@name=$pname]/@value"/>203 <td><xsl:choose>204 <xsl:when test="not(@ignore) or @ignore != $pos">205 <xsl:apply-templates select='.'><xsl:with-param name="default" select="java:org.greenstone.gsdl3.util.XSLTUtil.getNumberedItem($values, $pos)"/></xsl:apply-templates>206 </xsl:when>207 <xsl:otherwise><!-- put in a hidden placeholder -->208 <input type="hidden" name='{@name}' value=''/>209 </xsl:otherwise>210 </xsl:choose></td>211 </xsl:for-each></tr>212 <!-- recursively call this template to get multiple entries -->213 <xsl:if test="$pos < ($occurs - 1)">214 <xsl:apply-templates select="." mode="contents"><xsl:with-param name="occurs" select="$occurs"/><xsl:with-param name="pos" select="$pos+1"/></xsl:apply-templates>215 </xsl:if>216 </xsl:template>217 67 </xsl:stylesheet>
Note:
See TracChangeset
for help on using the changeset viewer.