source: main/trunk/greenstone3/web/interfaces/default/transform/service-params.xsl@ 23779

Last change on this file since 23779 was 23779, checked in by davidb, 13 years ago

Two new interfaces - 'default' now tries to use the client's XSLT capabilities of the web browser, falling back to the 'traditional' interface if this fails.

  • Property svn:keywords set to Author Date Id Revision
File size: 8.2 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 extension-element-prefixes="java">
6
7 <!-- handling of the different types of params on a service form
8 - these now only output the selection box/text box etc, not the name -->
9
10 <!-- the default param list handling -->
11 <xsl:template match="paramList">
12 <xsl:param name="ns">s1.</xsl:param>
13 <ul id="queryitemlist">
14 <xsl:for-each select="param">
15 <xsl:choose>
16 <xsl:when test="@type='multi'">
17 <li><xsl:apply-templates select='.'><xsl:with-param name="ns" select="$ns"/></xsl:apply-templates></li>
18 </xsl:when>
19 <xsl:otherwise>
20 <xsl:variable name="pvalue"><xsl:apply-templates select="." mode="calculate-default"><xsl:with-param name="ns" select="$ns"/></xsl:apply-templates></xsl:variable>
21 <li><xsl:value-of select="displayItem[@name='name']"/><xsl:apply-templates select="."><xsl:with-param name="default" select="$pvalue"/><xsl:with-param name="ns" select="$ns"/></xsl:apply-templates></li>
22 </xsl:otherwise>
23 </xsl:choose>
24 </xsl:for-each>
25 </ul>
26 </xsl:template>
27
28 <!-- puts all the params into a=p&p=h type form - need to change this if use
29 multi params -->
30 <xsl:template match="paramList" mode="cgi">
31 <xsl:param name="ns">s1.</xsl:param>
32 <xsl:for-each select="param">
33 <xsl:variable name='pname' select="@name"/>
34 <xsl:text>&amp;</xsl:text><xsl:value-of select="$ns"/><xsl:value-of select="@name"/>=<xsl:apply-templates select="." mode="calculate-default"><xsl:with-param name='ns' select='$ns'/></xsl:apply-templates>
35 </xsl:for-each>
36 </xsl:template>
37
38 <xsl:template match="param" mode="calculate-default">
39 <xsl:param name="ns">s1.</xsl:param>
40 <xsl:variable name="pname"><xsl:value-of select="$ns"/><xsl:value-of select="@name"/></xsl:variable>
41 <xsl:choose>
42 <xsl:when test="/page/pageRequest/paramList/param[@name=$pname]">
43 <xsl:choose>
44 <xsl:when test="@type='enum_multi'"><xsl:text>,</xsl:text>
45 <xsl:for-each select="/page/pageRequest/paramList/param[@name=$pname]">
46 <xsl:value-of select="@value"/>,
47 </xsl:for-each>
48 </xsl:when>
49 <xsl:otherwise>
50 <xsl:value-of select="/page/pageRequest/paramList/param[@name=$pname]/@value"/>
51 </xsl:otherwise>
52 </xsl:choose>
53 </xsl:when>
54 <xsl:otherwise>
55 <xsl:value-of select="@default"/>
56 </xsl:otherwise>
57 </xsl:choose>
58 </xsl:template>
59
60 <!-- invisible params - used by other stuff. in the query form, we set to teh default -->
61 <xsl:template match="param[@type='invisible']">
62 <xsl:param name="ns">s1.</xsl:param>
63 <input type='hidden' name='concat($ns, @name)' value='{@default}'/>
64 </xsl:template>
65 <!-- boolean params -->
66 <xsl:template match="param[@type='boolean']">
67 <xsl:param name="ns">s1.</xsl:param>
68 <xsl:param name="default"/>
69
70 <select name='{$ns}{@name}'>
71 <option value="0"><xsl:if test="$default='0'"><xsl:attribute name="selected"></xsl:attribute></xsl:if><xsl:value-of select="option[@name='0']/displayItem[@name='name']"/></option>
72 <option value="1"><xsl:if test="$default='1'"><xsl:attribute name="selected"></xsl:attribute></xsl:if><xsl:value-of select="option[@name='1']/displayItem[@name='name']"/></option>
73 </select>
74 </xsl:template>
75
76 <!-- integer params -->
77 <xsl:template match="param[@type='integer']">
78 <xsl:param name="ns">s1.</xsl:param>
79 <xsl:param name="default"/>
80
81 <input type="text" name="{$ns}{@name}" size="3" value="{$default}"/>
82 </xsl:template>
83
84 <!-- single selection enum params -->
85 <xsl:template match="param[@type='enum_single']">
86 <xsl:param name="ns">s1.</xsl:param>
87 <xsl:param name="default"/>
88
89 <xsl:choose>
90 <xsl:when test="count(option) = 1">
91 <xsl:text> </xsl:text><xsl:value-of select="option/displayItem[@name='name']"/>
92 <input type='hidden' name='{$ns}{@name}'><xsl:attribute name='value'><xsl:value-of select='option/@name'/></xsl:attribute></input>
93 </xsl:when>
94 <xsl:otherwise>
95
96 <select name="{$ns}{@name}">
97 <xsl:for-each select="option">
98 <option value="{@name}"><!--<xsl:if test="@name=$default"><xsl:attribute name="selected"></xsl:attribute></xsl:if>--><xsl:value-of select="displayItem[@name='name']"/></option>
99 </xsl:for-each>
100 </select>
101 </xsl:otherwise>
102 </xsl:choose>
103 </xsl:template>
104
105
106 <!-- multiple selection enum params -->
107 <!-- how to do defaults for this?? -->
108 <!-- Don't need to do anything here, handled automatically in the list -->
109 <xsl:template match="param[@type='enum_multi']">
110 <xsl:param name="ns">s1.</xsl:param>
111 <xsl:param name="default"/>
112 <select name="{$ns}{@name}" size='2'><xsl:attribute name="multiple"></xsl:attribute>
113 <xsl:for-each select="option">
114 <option value="{@name}"><xsl:if test="contains($default, concat(',', @name, ','))"><xsl:attribute name="selected"></xsl:attribute></xsl:if><xsl:value-of select="displayItem[@name='name']"/></option>
115 </xsl:for-each>
116 </select>
117 </xsl:template>
118
119 <!-- string params -->
120 <xsl:template match="param[@type='string']">
121 <xsl:param name="ns">s1.</xsl:param>
122 <xsl:param name="default"/>
123
124 <input type="text" name="{$ns}{@name}" size="50" value="{$default}"/>
125 </xsl:template>
126
127 <!-- large string params -->
128 <xsl:template match="param[@type='text']">
129 <xsl:param name="ns">s1.</xsl:param>
130 <xsl:param name="default"/>
131
132 <textarea name="{$ns}{@name}" cols="50" rows="3"><xsl:value-of select='$default'/></textarea>
133 </xsl:template>
134
135 <!-- multi params - params that are combinations of other params -->
136 <xsl:template match="param[@type='multi']">
137 <xsl:param name="ns">s1.</xsl:param>
138 <xsl:variable name="parent" select="@name"/>
139 <table>
140 <tr class="queryfieldheading"><xsl:value-of select="displayItem[@name='name']"/>
141 <xsl:for-each select="param">
142 <td class="queryfieldname"><xsl:value-of select="displayItem[@name='name']"/></td>
143 </xsl:for-each>
144 </tr>
145
146 <xsl:apply-templates select="." mode="contents"><xsl:with-param name="occurs" select="@occurs"/><xsl:with-param name="ns" select="$ns"/></xsl:apply-templates>
147 </table>
148 </xsl:template>
149
150 <xsl:template match="param[@type='multi']" mode="contents">
151 <xsl:param name="ns">s1.</xsl:param>
152 <xsl:param name="occurs">1</xsl:param>
153 <xsl:variable name="pos" select="@occurs - $occurs"/>
154 <tr class="queryfieldrow"><xsl:for-each select="param">
155 <xsl:variable name="pname" select="@name"/>
156 <xsl:variable name="values" select="/page/pageRequest/paramList/param[@name=$pname]/@value"/>
157 <td class="queryfieldcell"><xsl:choose>
158 <xsl:when test="not(@ignore) or @ignore != $pos">
159 <xsl:apply-templates select='.'><xsl:with-param name="default" select="$values|$pos"/><xsl:with-param name="ns" select="$ns"/></xsl:apply-templates>
160 </xsl:when>
161 <xsl:otherwise><!-- put in a hidden placeholder -->
162 <input type="hidden" name='{$ns}{@name}' value=''/>
163 </xsl:otherwise>
164 </xsl:choose></td>
165 </xsl:for-each></tr>
166 <!-- recursively call this template to get multiple entries -->
167 <xsl:if test="$occurs &gt; 1">
168 <xsl:apply-templates select="." mode="contents"><xsl:with-param name="occurs" select="$occurs - 1"/><xsl:with-param name="ns" select="$ns"/></xsl:apply-templates>
169 </xsl:if>
170 </xsl:template>
171
172
173</xsl:stylesheet>
174
175<!-- a param list that puts params in pairs- wont work as is with new
176 param handling stuff -->
177<!--
178 <xsl:template match="paramList">
179 <p/><table width="537">
180 <xsl:choose>
181 <xsl:when test='count(param)>4'>
182 <xsl:for-each select="param[position() mod 2 = 1]">
183 <tr><xsl:apply-templates select="."/>
184 <xsl:if test="following-sibling::param[1]"><xsl:apply-templates select='following-sibling::param[1]'/></xsl:if></tr>
185 </xsl:for-each>
186 </xsl:when>
187 <xsl:otherwise>
188 <xsl:for-each select="param">
189 <tr><xsl:apply-templates select='.'/></tr>
190 </xsl:for-each>
191 </xsl:otherwise>
192 </xsl:choose>
193 </table>
194 </xsl:template>
195-->
Note: See TracBrowser for help on using the repository browser.