comparison gnv/src/main/webapp/WEB-INF/config/templates/describe-ui.xsl @ 413:0ce07c6e132c

Refactored xsl sheet for ui's dynamic part: Removed local-name() method, put 'group' items into a table to be well aligned and set the size of multi select boxes to max 5 items or less. gnv/trunk@621 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 25 Jan 2010 14:53:38 +0000
parents d812c5b62eb4
children 59c6c7b62e43
comparison
equal deleted inserted replaced
412:49898531c0b6 413:0ce07c6e132c
1 <?xml version="1.0" encoding="UTF-8"?> 1 <?xml version="1.0" encoding="UTF-8"?>
2 <xsl:stylesheet version="1.0" 2 <xsl:stylesheet version="1.0"
3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 xmlns="http://www.w3.org/2002/xforms" 4 xmlns="http://www.w3.org/2002/xforms"
5 xmlns:xform="http://www.w3.org/2002/xforms" 5 xmlns:xform="http://www.w3.org/2002/xforms"
6 xmlns:art="http://www.intevation.de/2009/artifacts"> 6 xmlns:art="http://www.intevation.de/2009/artifacts"
7 <xsl:output method="html" version="1.0" encoding="UTF-8" omit-xml-declaration="no"/> 7 exclude-result-prefixes="xform art">
8 8
9 <xsl:template match="*[local-name() = 'select']"> 9 <xsl:output
10 method="html" version="1.0" encoding="UTF-8" omit-xml-declaration="no" />
11
12 <!-- single select -->
13 <xsl:template match="xform:select1">
10 <xsl:variable name="selectName" select="@ref"/> 14 <xsl:variable name="selectName" select="@ref"/>
11 <legend><xsl:value-of select="*[local-name() = 'label']"/></legend> 15 <legend><xsl:value-of select="xform:label"/></legend>
12 <select name="{$selectName}" multiple="multiple" size="6"> <xsl:apply-templates/></select> 16 <select name="{$selectName}">
13 <br/> 17 <xsl:apply-templates />
14    </xsl:template> 18 </select>
15 <xsl:template match="*[local-name() = 'select1']"> 19 </xsl:template>
20
21
22 <!-- multi select -->
23 <xsl:template match="xform:select">
16 <xsl:variable name="selectName" select="@ref"/> 24 <xsl:variable name="selectName" select="@ref"/>
17 <legend><xsl:value-of select="*[local-name() = 'label']"/></legend> 25 <xsl:variable name="items" select="count(//xform:item)"/>
18 <select name="{$selectName}"> <xsl:apply-templates/></select> 26
19 <br/> 27 <legend><xsl:value-of select="xform:label"/></legend>
20    </xsl:template>
21 <xsl:template match="*[local-name() = 'item']">
22 <xsl:variable name="optionValue" select="*[local-name() = 'value']"/>
23 <xsl:choose> 28 <xsl:choose>
24 <xsl:when test="@selected = 'true'"> 29 <xsl:when test="$items &lt; 5">
25 <option value="{$optionValue}" selected="selected"><xsl:value-of select="*[local-name() = 'label']"></xsl:value-of></option> 30 <select name="{$selectName}" multiple="multiple" size="{$items}">
26 </xsl:when> 31 <xsl:apply-templates/>
27 <xsl:otherwise> 32 </select>
28 <option value="{$optionValue}"><xsl:value-of select="*[local-name() = 'label']"></xsl:value-of></option> 33 </xsl:when>
29 </xsl:otherwise> 34 <xsl:otherwise>
35 <select name="{$selectName}" multiple="multiple" size="5">
36 <xsl:apply-templates />
37 </select>
38 </xsl:otherwise>
30 </xsl:choose> 39 </xsl:choose>
31 </xsl:template> 40 </xsl:template>
32 41
33 <xsl:template match="*[local-name() = 'group']"> 42
34 <xsl:variable name="selectName" select="@ref"/> 43 <!-- options for select -->
35 <legend><xsl:value-of select="*[local-name() = 'label']"/></legend> 44 <xsl:template match="xform:item">
36 <xsl:apply-templates/> 45 <xsl:variable name="optionValue" select="xform:value"/>
37    </xsl:template> 46 <xsl:choose>
38 47 <xsl:when test="@selected = 'true'">
39 <xsl:template match="*[local-name() = 'input']"> 48 <option value="{$optionValue}" selected="selected">
40 <xsl:variable name="inputValue" select="*[local-name() = 'value']"/> 49 <xsl:value-of select="xform:label"/>
50 </option>
51 </xsl:when>
52 <xsl:otherwise>
53 <option value="{$optionValue}">
54 <xsl:value-of select="xform:label"/>
55 </option>
56 </xsl:otherwise>
57 </xsl:choose>
58 </xsl:template>
59
60
61 <xsl:template match="xform:group">
62 <legend>
63 <xsl:value-of select="xform:label"/>
64 </legend>
65 <table class="dynamic">
66 <xsl:apply-templates/>
67 </table>
68 </xsl:template>
69
70
71 <xsl:template match="xform:input">
72 <xsl:variable name="inputValue" select="xform:value"/>
41 <xsl:variable name="inputName" select="@ref"/> 73 <xsl:variable name="inputName" select="@ref"/>
74 <xsl:variable name="label" select="xform:label"/>
42 75
43 <!-- TODO: Remove this when we have the GIS interface. (slt) --> 76 <!-- TODO: Remove this when we have the GIS interface. (slt) -->
44 <xsl:choose> 77 <xsl:choose>
45 <xsl:when test="$inputName = 'mesh_linestring'"> 78 <xsl:when test="$inputName = 'mesh_linestring'">
46 <a href="javascript:copy_demo_wkt_line();"><xsl:text>Beispiel WKT-Linestring einf&#252;gen:</xsl:text></a><br/> 79 <a href="javascript:copy_demo_wkt_line();"><xsl:text>Beispiel WKT-Linestring einf&#252;gen:</xsl:text></a><br/>
47 </xsl:when> 80 </xsl:when>
48 <xsl:when test="$inputName = 'mesh_polygon'"> 81 <xsl:when test="$inputName = 'mesh_polygon'">
49 <a href="javascript:copy_demo_wkt_polygon();"><xsl:text>Beispiel WKT-Polygon einf&#252;gen:</xsl:text></a><br/> 82 <a href="javascript:copy_demo_wkt_polygon();"><xsl:text>Beispiel WKT-Polygon einf&#252;gen:</xsl:text></a><br/>
50 </xsl:when> 83 </xsl:when>
51 </xsl:choose> 84 </xsl:choose>
52 85
53 <xsl:choose> 86 <tr>
54 <xsl:when test="*[local-name() = 'label']!= ''"> 87 <xsl:choose>
55 <xsl:value-of select="*[local-name() = 'label']"/>: 88 <xsl:when test="$label != ''">
56 </xsl:when> 89 <td><xsl:value-of select="$label"/>:</td>
57 </xsl:choose> 90 </xsl:when>
91 </xsl:choose>
58 92
59 <input type="text" id="{$inputName}" name="{$inputName}" value="{$inputValue}" /><br/> 93 <td>
94 <input type="text" id="{$inputName}" name="{$inputName}" value="{$inputValue}" /><br/>
95 </td>
96 </tr>
60 </xsl:template> 97 </xsl:template>
61 98
62 <xsl:template match="*[local-name() = 'label']"> 99
100 <xsl:template match="xform:label">
101 <!-- do nothing here -->
63 </xsl:template> 102 </xsl:template>
103
64 </xsl:stylesheet> 104 </xsl:stylesheet>

http://dive4elements.wald.intevation.org