[4047] | 1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
| 2 | <xsl:stylesheet version="1.0"
|
---|
[4712] | 3 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
---|
| 4 | xmlns:java="http://xml.apache.org/xslt/java"
|
---|
| 5 | extension-element-prefixes="java">
|
---|
[4047] | 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']">
|
---|
[4253] | 12 | <xsl:param name="default"/>
|
---|
[4047] | 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']">
|
---|
[4253] | 23 | <xsl:param name="default"/>
|
---|
[4047] | 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']">
|
---|
[4253] | 29 | <xsl:param name="default"/>
|
---|
[4047] | 30 | <xsl:variable name="pname"><xsl:value-of select='@name'/></xsl:variable>
|
---|
| 31 | <xsl:variable name='pdisplay' select='ancestor::service/display/param[@name=$pname]'/>
|
---|
[4253] | 32 | <xsl:choose>
|
---|
| 33 | <xsl:when test="count(option) = 1">
|
---|
| 34 | <xsl:value-of select='$pdisplay/option'/>
|
---|
[4712] | 35 | <input type='hidden' name='{@shortname}'><xsl:attribute name='value'><xsl:value-of select='option/@name'/></xsl:attribute></input>
|
---|
[4253] | 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>
|
---|
[4047] | 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']">
|
---|
[4253] | 64 | <xsl:param name="default"/>
|
---|
| 65 | <input type="text" name="{@shortname}" size="50" value="{$default}"/>
|
---|
[4047] | 66 | </xsl:template>
|
---|
| 67 |
|
---|
| 68 | <!-- large string params -->
|
---|
| 69 | <xsl:template match="param[@type='text']">
|
---|
[4253] | 70 | <xsl:param name="default"/>
|
---|
[4047] | 71 | <textarea name="{@shortname}" cols="50" rows="3"><xsl:value-of select='$default'/></textarea>
|
---|
| 72 | </xsl:template>
|
---|
[4253] | 73 |
|
---|
[4047] | 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'/>
|
---|
[4253] | 82 |
|
---|
[4047] | 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"/>
|
---|
[4253] | 93 | <tr><xsl:for-each select="param">
|
---|
[4256] | 94 | <xsl:variable name="pname" select="@name"/>
|
---|
[4712] | 95 | <xsl:variable name="values" select="/page/pageRequest/paramList/param[@name=$pname]/@value"/>
|
---|
[4256] | 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 -->
|
---|
[4712] | 101 | <input type="hidden" name='{@shortname}' value=''/>
|
---|
[4256] | 102 | </xsl:otherwise>
|
---|
| 103 | </xsl:choose></td>
|
---|
[4253] | 104 | </xsl:for-each></tr>
|
---|
[4047] | 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>
|
---|