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