source: greenstone3/trunk/web/interfaces/oran/transform/.old/service-params.xsl@ 19860

Last change on this file since 19860 was 19860, checked in by oranfry, 15 years ago

stuff still needed to keep the transform going

File size: 7.9 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='{$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 <select name='{$ns}{@name}'>
70 <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>
71 <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>
72 </select>
73 </xsl:template>
74
75 <!-- integer params -->
76 <xsl:template match="param[@type='integer']">
77 <xsl:param name="ns">s1.</xsl:param>
78 <xsl:param name="default"/>
79 <input type="text" name="{$ns}{@name}" size="3" value="{$default}"/>
80 </xsl:template>
81
82 <!-- single selection enum params -->
83 <xsl:template match="param[@type='enum_single']">
84 <xsl:param name="ns">s1.</xsl:param>
85 <xsl:param name="default"/>
86 <xsl:choose>
87 <xsl:when test="count(option) = 1">
88 <xsl:value-of select="option/displayItem[@name='name']"/>
89 <input type='hidden' name='{$ns}{@name}'><xsl:attribute name='value'><xsl:value-of select='option/@name'/></xsl:attribute></input>
90 </xsl:when>
91 <xsl:otherwise>
92 <select name="{$ns}{@name}">
93 <xsl:for-each select="option">
94 <option value="{@name}"><xsl:if test="@name=$default"><xsl:attribute name="selected"></xsl:attribute></xsl:if><xsl:value-of select="displayItem[@name='name']"/></option>
95 </xsl:for-each>
96 </select>
97 </xsl:otherwise>
98 </xsl:choose>
99 </xsl:template>
100
101
102 <!-- multiple selection enum params -->
103 <!-- how to do defaults for this?? -->
104 <xsl:template match="param[@type='enum_multi']">
105 <xsl:param name="ns">s1.</xsl:param>
106 <xsl:param name="default"/>
107 <select name="{$ns}{@name}" size='2'><xsl:attribute name="multiple"></xsl:attribute>
108 <xsl:for-each select="option">
109 <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>
110 </xsl:for-each>
111 </select>
112 </xsl:template>
113
114 <!-- string params -->
115 <xsl:template match="param[@type='string']">
116 <xsl:param name="ns">s1.</xsl:param>
117 <xsl:param name="default"/>
118 <input type="text" name="{$ns}{@name}" size="50" value="{$default}"/>
119 </xsl:template>
120
121 <!-- large string params -->
122 <xsl:template match="param[@type='text']">
123 <xsl:param name="ns">s1.</xsl:param>
124 <xsl:param name="default"/>
125 <textarea name="{$ns}{@name}" cols="50" rows="3"><xsl:value-of select='$default'/></textarea>
126 </xsl:template>
127
128 <!-- multi params - params that are combinations of other params -->
129 <xsl:template match="param[@type='multi']">
130 <xsl:param name="ns">s1.</xsl:param>
131 <xsl:variable name="parent" select="@name"/>
132 <table>
133 <tr class="queryfieldheading"><xsl:value-of select="displayItem[@name='name']"/>
134 <xsl:for-each select="param">
135 <td class="queryfieldname"><xsl:value-of select="displayItem[@name='name']"/></td>
136 </xsl:for-each>
137 </tr>
138
139 <xsl:apply-templates select="." mode="contents"><xsl:with-param name="occurs" select="@occurs"/><xsl:with-param name="ns" select="$ns"/></xsl:apply-templates>
140 </table>
141 </xsl:template>
142
143 <xsl:template match="param[@type='multi']" mode="contents">
144 <xsl:param name="ns">s1.</xsl:param>
145 <xsl:param name="occurs">1</xsl:param>
146 <xsl:variable name="pos" select="@occurs - $occurs"/>
147 <tr class="queryfieldrow"><xsl:for-each select="param">
148 <xsl:variable name="pname" select="@name"/>
149 <xsl:variable name="values" select="/page/pageRequest/paramList/param[@name=$pname]/@value"/>
150 <td class="queryfieldcell"><xsl:choose>
151 <xsl:when test="not(@ignore) or @ignore != $pos">
152 <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>
153 </xsl:when>
154 <xsl:otherwise><!-- put in a hidden placeholder -->
155 <input type="hidden" name='{$ns}{@name}' value=''/>
156 </xsl:otherwise>
157 </xsl:choose></td>
158 </xsl:for-each></tr>
159 <!-- recursively call this template to get multiple entries -->
160 <xsl:if test="$occurs &gt; 1">
161 <xsl:apply-templates select="." mode="contents"><xsl:with-param name="occurs" select="$occurs - 1"/><xsl:with-param name="ns" select="$ns"/></xsl:apply-templates>
162 </xsl:if>
163 </xsl:template>
164
165
166</xsl:stylesheet>
167
168 <!-- a param list that puts params in pairs- wont work as is with new
169 param handling stuff -->
170 <!--
171 <xsl:template match="paramList">
172 <p/><table width="537">
173 <xsl:choose>
174 <xsl:when test='count(param)>4'>
175 <xsl:for-each select="param[position() mod 2 = 1]">
176 <tr><xsl:apply-templates select="."/>
177 <xsl:if test="following-sibling::param[1]"><xsl:apply-templates select='following-sibling::param[1]'/></xsl:if></tr>
178 </xsl:for-each>
179 </xsl:when>
180 <xsl:otherwise>
181 <xsl:for-each select="param">
182 <tr><xsl:apply-templates select='.'/></tr>
183 </xsl:for-each>
184 </xsl:otherwise>
185 </xsl:choose>
186 </table>
187 </xsl:template>
188 -->
Note: See TracBrowser for help on using the repository browser.