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 | <!-- boolean params -->
|
---|
11 | <xsl:template match="param[@type='boolean']">
|
---|
12 | <xsl:param name="default" select="@default"/>
|
---|
13 | <xsl:variable name="pname" select='@name'/>
|
---|
14 | <xsl:variable name='pdisplay' select='ancestor::service/display/param[@name=$pname]'/>
|
---|
15 | <select name='{@shortname}'>
|
---|
16 | <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>
|
---|
17 | <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>
|
---|
18 | </select>
|
---|
19 | </xsl:template>
|
---|
20 |
|
---|
21 | <!-- integer params -->
|
---|
22 | <xsl:template match="param[@type='integer']">
|
---|
23 | <xsl:param name="default" select="@default"/>
|
---|
24 | <input type="text" name="{@shortname}" size="3" value="{$default}"/>
|
---|
25 | </xsl:template>
|
---|
26 |
|
---|
27 | <!-- single selection enum params -->
|
---|
28 | <xsl:template match="param[@type='enum_single']">
|
---|
29 | <xsl:param name="default" select="@default"/>
|
---|
30 | <xsl:variable name="pname"><xsl:value-of select='@name'/></xsl:variable>
|
---|
31 | <xsl:variable name='pdisplay' select='ancestor::service/display/param[@name=$pname]'/>
|
---|
32 | <xsl:variable name="current"><xsl:value-of select="$default"/></xsl:variable>
|
---|
33 | <select name="{@shortname}">
|
---|
34 | <xsl:for-each select="option">
|
---|
35 | <xsl:variable name='op_name' select='@name'/>
|
---|
36 | <option value="{@name}"><xsl:if test="@name=$current"><xsl:attribute name="selected"></xsl:attribute></xsl:if><xsl:value-of select='$pdisplay/option[@name=$op_name]'/></option>
|
---|
37 | </xsl:for-each>
|
---|
38 | </select>
|
---|
39 | </xsl:template>
|
---|
40 |
|
---|
41 |
|
---|
42 | <!-- multiple selection enum params -->
|
---|
43 | <!-- how to do defaults for this?? -->
|
---|
44 | <xsl:template match="param[@type='enum_multi']">
|
---|
45 | <xsl:variable name="pname" select='@name'/>
|
---|
46 | <xsl:variable name='pdisplay' select='ancestor::service/display/param[@name=$pname]'/>
|
---|
47 | <select name="{@shortname}" size='2'><xsl:attribute name="multiple"></xsl:attribute>
|
---|
48 | <xsl:for-each select="option">
|
---|
49 | <xsl:variable name='op_name' select='@name'/>
|
---|
50 | <option value="{@name}"><xsl:value-of select='$pdisplay/option[@name=$op_name]'/></option>
|
---|
51 | </xsl:for-each>
|
---|
52 | </select>
|
---|
53 | </xsl:template>
|
---|
54 |
|
---|
55 | <!-- string params -->
|
---|
56 | <xsl:template match="param[@type='string']">
|
---|
57 | <xsl:param name="default" select="@default"/>
|
---|
58 | <xsl:variable name="pname" select='@name'/>
|
---|
59 | <input type="text" name="{@shortname}" size="30" value="{$default}"/>
|
---|
60 | </xsl:template>
|
---|
61 |
|
---|
62 | <!-- large string params -->
|
---|
63 | <xsl:template match="param[@type='text']">
|
---|
64 | <xsl:param name="default" select="@default"/>
|
---|
65 | <xsl:variable name="pname" select='@name'/>
|
---|
66 | <textarea name="{@shortname}" cols="50" rows="3"><xsl:value-of select='$default'/></textarea>
|
---|
67 | </xsl:template>
|
---|
68 | <!-- multi params - params that are combinations of other params -->
|
---|
69 | <xsl:template match="param[@type='multi']">
|
---|
70 | <xsl:variable name="parent" select="@name"/>
|
---|
71 | <table>
|
---|
72 | <tr><td colspan='10'><xsl:value-of select="ancestor::service/display/param[@name=$parent]/name"/></td></tr>
|
---|
73 | <tr>
|
---|
74 | <xsl:for-each select="param">
|
---|
75 | <xsl:variable name='pname' select='@name'/>
|
---|
76 | <td><xsl:value-of select="ancestor::service/display/param[@name=$pname]/name"/></td>
|
---|
77 | </xsl:for-each>
|
---|
78 | </tr>
|
---|
79 | <xsl:apply-templates select="." mode="contents"><xsl:with-param name="occurs" select="@occurs"/></xsl:apply-templates>
|
---|
80 | </table>
|
---|
81 | </xsl:template>
|
---|
82 |
|
---|
83 | <xsl:template match="param[@type='multi']" mode="contents">
|
---|
84 | <xsl:param name="occurs">1</xsl:param>
|
---|
85 | <xsl:variable name="pos" select="@occurs - $occurs"/>
|
---|
86 | <xsl:choose>
|
---|
87 | <xsl:when test="default">
|
---|
88 | <tr><xsl:for-each select="param">
|
---|
89 | <td><xsl:if test="not(@ignore) or @ignore != $pos">
|
---|
90 | <xsl:variable name="pname" select="@name"/>
|
---|
91 | <xsl:variable name="values"><xsl:value-of select="../default[@name=$pname]"/></xsl:variable>
|
---|
92 | <xsl:apply-templates select='.'><xsl:with-param name="default"><xsl:value-of select="java:org.greenstone.gsdl3.util.XSLTUtil.getNumberedItem($values, $occurs)"/></xsl:with-param></xsl:apply-templates>
|
---|
93 | </xsl:if></td>
|
---|
94 | </xsl:for-each></tr>
|
---|
95 | </xsl:when>
|
---|
96 | <xsl:otherwise>
|
---|
97 | <tr><xsl:for-each select="param">
|
---|
98 | <td><xsl:if test="not(@ignore) or @ignore != $pos">
|
---|
99 | <xsl:variable name="pname" select="@name"/>
|
---|
100 | <xsl:apply-templates select='.'/>
|
---|
101 | </xsl:if></td>
|
---|
102 | </xsl:for-each></tr>
|
---|
103 | </xsl:otherwise>
|
---|
104 | </xsl:choose>
|
---|
105 | <!-- recursively call this template to get multiple entries -->
|
---|
106 | <xsl:if test="$occurs > 1">
|
---|
107 | <xsl:apply-templates select="." mode="contents"><xsl:with-param name="occurs" select="$occurs - 1"/></xsl:apply-templates>
|
---|
108 | </xsl:if>
|
---|
109 | </xsl:template>
|
---|
110 |
|
---|
111 |
|
---|
112 | </xsl:stylesheet>
|
---|