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

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

default param list handling moved into service-params.xsl

  • Property svn:keywords set to Author Date Id Revision
File size: 6.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 <p/><table width="100%">
13 <xsl:for-each select="param">
14 <xsl:choose>
15 <xsl:when test="@type='multi'">
16 <tr><td colspan='2'>
17 <xsl:apply-templates select='.'/></td></tr>
18 </xsl:when>
19 <xsl:otherwise>
20 <xsl:variable name="pname" select="@name"/>
21 <xsl:variable name="pvalue"><xsl:apply-templates select="." mode="calculate-default"/></xsl:variable>
22 <tr><td><xsl:value-of select='ancestor::service/display/param[@name=$pname]/name'/></td><td align="right"><xsl:apply-templates select="."><xsl:with-param name="default" select="$pvalue"/></xsl:apply-templates></td></tr>
23 </xsl:otherwise>
24 </xsl:choose>
25 </xsl:for-each>
26 </table>
27 </xsl:template>
28
29
30 <!-- a param list that puts params in pairs- wont work as is with new
31 param handling stuff -->
32 <!--
33 <xsl:template match="paramList">
34 <p/><table width="537">
35 <xsl:choose>
36 <xsl:when test='count(param)>4'>
37 <xsl:for-each select="param[position() mod 2 = 1]">
38 <tr><xsl:apply-templates select="."/>
39 <xsl:if test="following-sibling::param[1]"><xsl:apply-templates select='following-sibling::param[1]'/></xsl:if></tr>
40</xsl:for-each>
41</xsl:when>
42 <xsl:otherwise>
43 <xsl:for-each select="param">
44 <tr><xsl:apply-templates select='.'/></tr>
45</xsl:for-each>
46</xsl:otherwise>
47</xsl:choose>
48</table>
49</xsl:template>
50 -->
51<!-- boolean params -->
52 <xsl:template match="param[@type='boolean']">
53 <xsl:param name="default"/>
54 <xsl:variable name="pname" select='@name'/>
55 <xsl:variable name='pdisplay' select='ancestor::service/display/param[@name=$pname]'/>
56 <select name='{@shortname}'>
57 <option value="0"><xsl:if test="$default='0'"><xsl:attribute name="selected"></xsl:attribute></xsl:if><xsl:value-of select='$pdisplay/option[@name="0"]'/></option>
58 <option value="1"><xsl:if test="$default='1'"><xsl:attribute name="selected"></xsl:attribute></xsl:if><xsl:value-of select='$pdisplay/option[@name="1"]'/></option>
59 </select>
60 </xsl:template>
61
62 <!-- integer params -->
63 <xsl:template match="param[@type='integer']">
64 <xsl:param name="default"/>
65 <input type="text" name="{@shortname}" size="3" value="{$default}"/>
66 </xsl:template>
67
68 <!-- single selection enum params -->
69 <xsl:template match="param[@type='enum_single']">
70 <xsl:param name="default"/>
71 <xsl:variable name="pname"><xsl:value-of select='@name'/></xsl:variable>
72 <xsl:variable name='pdisplay' select='ancestor::service/display/param[@name=$pname]'/>
73 <xsl:choose>
74 <xsl:when test="count(option) = 1">
75 <xsl:value-of select='$pdisplay/option'/>
76 <input type='hidden' name='{@shortname}'><xsl:attribute name='value'><xsl:value-of select='option/@name'/></xsl:attribute></input>
77 </xsl:when>
78 <xsl:otherwise>
79 <select name="{@shortname}">
80 <xsl:for-each select="option">
81 <xsl:variable name='op_name' select='@name'/>
82 <option value="{@name}"><xsl:if test="@name=$default"><xsl:attribute name="selected"></xsl:attribute></xsl:if><xsl:value-of select='$pdisplay/option[@name=$op_name]'/></option>
83 </xsl:for-each>
84 </select>
85 </xsl:otherwise>
86 </xsl:choose>
87 </xsl:template>
88
89
90 <!-- multiple selection enum params -->
91 <!-- how to do defaults for this?? -->
92 <xsl:template match="param[@type='enum_multi']">
93 <xsl:variable name="pname" select='@name'/>
94 <xsl:variable name='pdisplay' select='ancestor::service/display/param[@name=$pname]'/>
95 <select name="{@shortname}" size='2'><xsl:attribute name="multiple"></xsl:attribute>
96 <xsl:for-each select="option">
97 <xsl:variable name='op_name' select='@name'/>
98 <option value="{@name}"><xsl:value-of select='$pdisplay/option[@name=$op_name]'/></option>
99 </xsl:for-each>
100 </select>
101 </xsl:template>
102
103 <!-- string params -->
104 <xsl:template match="param[@type='string']">
105 <xsl:param name="default"/>
106 <input type="text" name="{@shortname}" size="50" value="{$default}"/>
107 </xsl:template>
108
109 <!-- large string params -->
110 <xsl:template match="param[@type='text']">
111 <xsl:param name="default"/>
112 <textarea name="{@shortname}" cols="50" rows="3"><xsl:value-of select='$default'/></textarea>
113 </xsl:template>
114
115 <!-- multi params - params that are combinations of other params -->
116 <xsl:template match="param[@type='multi']">
117 <xsl:variable name="parent" select="@name"/>
118 <table>
119 <tr><td colspan='10'><xsl:value-of select="ancestor::service/display/param[@name=$parent]/name"/></td></tr>
120 <tr>
121 <xsl:for-each select="param">
122 <xsl:variable name='pname' select='@name'/>
123
124 <td><xsl:value-of select="ancestor::service/display/param[@name=$pname]/name"/></td>
125 </xsl:for-each>
126 </tr>
127 <xsl:apply-templates select="." mode="contents"><xsl:with-param name="occurs" select="@occurs"/></xsl:apply-templates>
128 </table>
129 </xsl:template>
130
131 <xsl:template match="param[@type='multi']" mode="contents">
132 <xsl:param name="occurs">1</xsl:param>
133 <xsl:variable name="pos" select="@occurs - $occurs"/>
134 <tr><xsl:for-each select="param">
135 <xsl:variable name="pname" select="@name"/>
136 <xsl:variable name="values" select="/page/pageRequest/paramList/param[@name=$pname]/@value"/>
137 <td><xsl:choose>
138 <xsl:when test="not(@ignore) or @ignore != $pos">
139 <xsl:apply-templates select='.'><xsl:with-param name="default" select="java:org.greenstone.gsdl3.util.XSLTUtil.getNumberedItem($values, $pos)"/></xsl:apply-templates>
140 </xsl:when>
141 <xsl:otherwise><!-- put in a hidden placeholder -->
142 <input type="hidden" name='{@shortname}' value=''/>
143 </xsl:otherwise>
144 </xsl:choose></td>
145 </xsl:for-each></tr>
146 <!-- recursively call this template to get multiple entries -->
147 <xsl:if test="$occurs &gt; 1">
148 <xsl:apply-templates select="." mode="contents"><xsl:with-param name="occurs" select="$occurs - 1"/></xsl:apply-templates>
149 </xsl:if>
150 </xsl:template>
151
152
153</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.