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

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

made a lot of changes, cant remember tham all. config stuff is now global params, translate stuff is now done on the fly using java and XSLTUtil, redoing the document display stuff so that it switches automatically between toc, page nav, and just displaying the text

  • Property svn:keywords set to Author Date Id Revision
File size: 4.8 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<!-- boolean params -->
11 <xsl:template match="param[@type='boolean']">
12 <xsl:param name="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"/>
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"/>
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:choose>
33 <xsl:when test="count(option) = 1">
34 <xsl:value-of select='$pdisplay/option'/>
35 <input type='hidden' name='{@shortname}'><xsl:attribute name='value'><xsl:value-of select='option/@name'/></xsl:attribute></input>
36 </xsl:when>
37 <xsl:otherwise>
38 <select name="{@shortname}">
39 <xsl:for-each select="option">
40 <xsl:variable name='op_name' select='@name'/>
41 <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>
42 </xsl:for-each>
43 </select>
44 </xsl:otherwise>
45 </xsl:choose>
46 </xsl:template>
47
48
49 <!-- multiple selection enum params -->
50 <!-- how to do defaults for this?? -->
51 <xsl:template match="param[@type='enum_multi']">
52 <xsl:variable name="pname" select='@name'/>
53 <xsl:variable name='pdisplay' select='ancestor::service/display/param[@name=$pname]'/>
54 <select name="{@shortname}" size='2'><xsl:attribute name="multiple"></xsl:attribute>
55 <xsl:for-each select="option">
56 <xsl:variable name='op_name' select='@name'/>
57 <option value="{@name}"><xsl:value-of select='$pdisplay/option[@name=$op_name]'/></option>
58 </xsl:for-each>
59 </select>
60 </xsl:template>
61
62 <!-- string params -->
63 <xsl:template match="param[@type='string']">
64 <xsl:param name="default"/>
65 <input type="text" name="{@shortname}" size="50" value="{$default}"/>
66 </xsl:template>
67
68 <!-- large string params -->
69 <xsl:template match="param[@type='text']">
70 <xsl:param name="default"/>
71 <textarea name="{@shortname}" cols="50" rows="3"><xsl:value-of select='$default'/></textarea>
72 </xsl:template>
73
74 <!-- multi params - params that are combinations of other params -->
75 <xsl:template match="param[@type='multi']">
76 <xsl:variable name="parent" select="@name"/>
77 <table>
78 <tr><td colspan='10'><xsl:value-of select="ancestor::service/display/param[@name=$parent]/name"/></td></tr>
79 <tr>
80 <xsl:for-each select="param">
81 <xsl:variable name='pname' select='@name'/>
82
83 <td><xsl:value-of select="ancestor::service/display/param[@name=$pname]/name"/></td>
84 </xsl:for-each>
85 </tr>
86 <xsl:apply-templates select="." mode="contents"><xsl:with-param name="occurs" select="@occurs"/></xsl:apply-templates>
87 </table>
88 </xsl:template>
89
90 <xsl:template match="param[@type='multi']" mode="contents">
91 <xsl:param name="occurs">1</xsl:param>
92 <xsl:variable name="pos" select="@occurs - $occurs"/>
93 <tr><xsl:for-each select="param">
94 <xsl:variable name="pname" select="@name"/>
95 <xsl:variable name="values" select="/page/pageRequest/paramList/param[@name=$pname]/@value"/>
96 <td><xsl:choose>
97 <xsl:when test="not(@ignore) or @ignore != $pos">
98 <xsl:apply-templates select='.'><xsl:with-param name="default" select="java:org.greenstone.gsdl3.util.XSLTUtil.getNumberedItem($values, $pos)"/></xsl:apply-templates>
99 </xsl:when>
100 <xsl:otherwise><!-- put in a hidden placeholder -->
101 <input type="hidden" name='{@shortname}' value=''/>
102 </xsl:otherwise>
103 </xsl:choose></td>
104 </xsl:for-each></tr>
105 <!-- recursively call this template to get multiple entries -->
106 <xsl:if test="$occurs &gt; 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>
Note: See TracBrowser for help on using the repository browser.