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

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

documentType att now docType, changed where and how the display info is formatted

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