source: trunk/gsdl3/web/interfaces/default/transform/service-params.xsl@ 9011

Last change on this file since 9011 was 5195, checked in by kjdon, 21 years ago

invisible params should have s1. added on too

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