view gnv/src/main/webapp/WEB-INF/config/templates/describe-ui.xsl @ 582:b8ea9383d285

Implemented a One-Step-Back-History. gnv/trunk@723 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 02 Mar 2010 10:53:30 +0000
parents 60caaa265e2b
children 97d90e314af5
line wrap: on
line source
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" 
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
                xmlns="http://www.w3.org/2002/xforms" 
                xmlns:xform="http://www.w3.org/2002/xforms" 
                xmlns:art="http://www.intevation.de/2009/artifacts"
                exclude-result-prefixes="xform art">

    <xsl:output
        method="html" version="1.0" encoding="UTF-8" omit-xml-declaration="no" />

    <!-- single select -->
    <xsl:template match="xform:select1">
        <xsl:variable name="selectName" select="@ref"/>
        <legend><xsl:value-of select="xform:label"/></legend>
        <select name="{$selectName}">
            <xsl:apply-templates />
        </select>
    </xsl:template>


    <!-- multi select -->
    <xsl:template match="xform:select">
        <xsl:variable name="selectName" select="@ref"/>
        <xsl:variable name="items" select="count(//xform:item)"/>

        <legend><xsl:value-of select="xform:label"/></legend>
        <xsl:choose>
            <xsl:when test="$items = 1">
                <select name="{$selectName}" multiple="multiple" size="{$items}">
                    <xsl:apply-templates mode="selected"/>
                </select>
            </xsl:when>
            <xsl:when test="$items &lt; 5">
                <select name="{$selectName}" multiple="multiple" size="{$items}">
                    <xsl:apply-templates/>
                </select>
            </xsl:when>
            <xsl:otherwise>
                <select name="{$selectName}" multiple="multiple" size="5">
                    <xsl:apply-templates />
                </select>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>


    <!-- options for select -->
    <xsl:template match="xform:item">
        <xsl:variable name="optionValue" select="xform:value"/>
        <xsl:choose>
            <xsl:when test="@selected = 'true'">
                <option value="{$optionValue}" selected="selected">
                    <xsl:value-of select="xform:label"/>
                </option>
            </xsl:when>
            <xsl:otherwise>
                <option value="{$optionValue}">
                    <xsl:value-of select="xform:label"/>
                </option>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>


    <xsl:template match="xform:item" mode="selected">
        <xsl:variable name="optionValue" select="xform:value"/>
            <option value="{$optionValue}" selected="selected">
                <xsl:value-of select="xform:label"/>
            </option>
    </xsl:template>



    <xsl:template match="xform:group">
        <xsl:variable name="selectcount" select="count(xform:select)"/>

        <legend>
            <xsl:value-of select="xform:label"/>
        </legend>

        <xsl:choose>
            <xsl:when test="$selectcount &lt; '2'">
                <table class="dynamic">
                    <xsl:apply-templates/>
                </table>
            </xsl:when>
            <xsl:otherwise>
                <table class="static">
                    <tr>
                        <td><!-- nothing here --></td>
                        <xsl:for-each select="xform:select[1]/xform:item">
                            <td class="matrixHeader"><xsl:value-of select="position()"/>.</td>
                        </xsl:for-each>
                    </tr>
                    <xsl:apply-templates mode="matrix" />
                </table>
                <xsl:apply-templates select="xform:select[1]" mode="matrixLegend"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <!-- template for rendering parameter matrix -->
    <xsl:template match="xform:select" mode="matrix">
        <tr>
            <td><xsl:value-of select="@label" /></td>
            <xsl:apply-templates mode="matrix" />
        </tr>
    </xsl:template>

    <!-- template for rendering parameter matrix -->
    <xsl:template match="xform:select" mode="matrixLegend">
        <table>
            <xsl:for-each select="xform:item">
                <tr>
                    <td><xsl:value-of select="position()" />.:</td>
                    <td><xsl:value-of select="@parameter" /></td>
                </tr>
            </xsl:for-each>
        </table>
    </xsl:template>

    <!-- template for rendering parameter matrix -->
    <xsl:template match="xform:item" mode="matrix">
        <xsl:variable name="value" select="xform:value/text()"/>
        <xsl:variable name="name" select="@ref"/>
        <td>
            <xsl:choose>
            <xsl:when test="@disabled = 'true'">
                <input type="checkbox" name="{$name}" value="{$value}" disabled="true"></input>
            </xsl:when>
            <xsl:otherwise>
                <input type="checkbox" name="{$name}" value="{$value}"></input>
            </xsl:otherwise>
            </xsl:choose>
        </td>
    </xsl:template>


    <xsl:template match="xform:input">
        <xsl:variable name="inputValue" select="xform:value"/>
        <xsl:variable name="inputName" select="@ref"/>
        <xsl:variable name="label" select="xform:label"/>
        
        <!-- TODO: Remove this when we have the GIS interface. (slt) --> 
        <xsl:choose>
            <xsl:when test="$inputName = 'mesh_linestring'">
                <a href="javascript:copy_demo_wkt_line();"><xsl:text>Beispiel WKT-Linestring einf&#252;gen:</xsl:text></a><br/>
            </xsl:when>
            <xsl:when test="$inputName = 'mesh_polygon'">
                <a href="javascript:copy_demo_wkt_polygon();"><xsl:text>Beispiel WKT-Polygon einf&#252;gen:</xsl:text></a><br/>
            </xsl:when>
        </xsl:choose>

        <tr>
            <xsl:choose>
                <xsl:when test="$label != ''">
                    <td><xsl:value-of select="$label"/>:</td>
               </xsl:when>
            </xsl:choose>

            <td>
                <input type="text" id="{$inputName}" name="{$inputName}" value="{$inputValue}" /><br/>
            </td>
        </tr>
    </xsl:template>


    <xsl:template match="xform:label">
        <!-- do nothing here -->
    </xsl:template>

</xsl:stylesheet>

http://dive4elements.wald.intevation.org