1
|
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
<xsl:stylesheet
|
3
|
xmlns:wmc="http://www.opengis.net/context"
|
4
|
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
5
|
xmlns:gml='http://www.opengis.net/gml'
|
6
|
xmlns:wfs='http://www.opengis.net/wfs'
|
7
|
xmlns:xlink='http://www.w3.org/1999/xlink'
|
8
|
version="1.0">
|
9
|
<!--
|
10
|
Description: Convert a Web Map Context into a HTML Legend
|
11
|
Author: Cameron Shorter cameron ATshorter.net
|
12
|
Licence: LGPL as per: http://www.gnu.org/copyleft/lesser.html
|
13
|
|
14
|
$Id$
|
15
|
$Name$
|
16
|
-->
|
17
|
<xsl:output method="xml" encoding="utf-8"/>
|
18
|
|
19
|
<!-- The common params set for all widgets -->
|
20
|
<xsl:param name="lang">en</xsl:param>
|
21
|
<xsl:param name="modelId"/>
|
22
|
<xsl:param name="widgetId"/>
|
23
|
|
24
|
<xsl:param name="skinDir"/>
|
25
|
<xsl:param name="selectIcon">/images/id.gif</xsl:param>
|
26
|
|
27
|
<!-- Text params for this widget -->
|
28
|
<xsl:param name="title"/>
|
29
|
|
30
|
<!-- The name of the javascript context object to call -->
|
31
|
<xsl:param name="featureName"/>
|
32
|
<xsl:param name="hidden"/>
|
33
|
<xsl:param name="context">config.objects.<xsl:value-of select="$modelId"/></xsl:param>
|
34
|
|
35
|
<!-- Main html -->
|
36
|
<xsl:template match="/wmc:ViewContext">
|
37
|
<table border="0" cellpadding="1" cellspacing="0">
|
38
|
<tr>
|
39
|
<th colspan="3"><xsl:value-of select="$title"/></th>
|
40
|
</tr>
|
41
|
<xsl:apply-templates select="wmc:LayerList/*">
|
42
|
<xsl:sort select="position()" order="descending" data-type="number"/>
|
43
|
</xsl:apply-templates>
|
44
|
|
45
|
</table>
|
46
|
</xsl:template>
|
47
|
|
48
|
<xsl:template match="/wmc:OWSContext">
|
49
|
<table border="0" cellpadding="1" cellspacing="0">
|
50
|
<tr>
|
51
|
<th colspan="3">WMS <xsl:value-of select="$title"/></th>
|
52
|
</tr>
|
53
|
<xsl:apply-templates select="wmc:ResourceList/wmc:Layer">
|
54
|
<xsl:sort select="position()" order="descending" data-type="number"/>
|
55
|
</xsl:apply-templates>
|
56
|
</table>
|
57
|
</xsl:template>
|
58
|
|
59
|
<xsl:template match="/wfs:FeatureCollection">
|
60
|
<table border="0" cellpadding="1" cellspacing="0">
|
61
|
<tr>
|
62
|
<th colspan="3">WFS Features</th>
|
63
|
</tr>
|
64
|
<tr>
|
65
|
<!-- Visiblity -->
|
66
|
<td>
|
67
|
<xsl:if test="$hidden='false'">
|
68
|
<input type="checkbox" checked="true" id="legend_{$featureName}" onclick="{$context}.setHidden('{$featureName}',!document.getElementById('legend_{$featureName}').checked)"/>
|
69
|
</xsl:if>
|
70
|
<xsl:if test="$hidden='true'">
|
71
|
<input type="checkbox" id="legend_{$featureName}" onclick="{$context}.setHidden('{$featureName}',! document.getElementById('legend_{$featureName}').checked)"/>
|
72
|
</xsl:if>
|
73
|
</td>
|
74
|
<!-- No query capability yet -->
|
75
|
<td>
|
76
|
</td>
|
77
|
<td class="legendText">
|
78
|
<xsl:value-of select="$featureName"/>
|
79
|
</td>
|
80
|
</tr>
|
81
|
</table>
|
82
|
</xsl:template>
|
83
|
|
84
|
<!-- Layer -->
|
85
|
<xsl:template match="wmc:Layer">
|
86
|
<tr>
|
87
|
<!-- Visiblity -->
|
88
|
<td>
|
89
|
<xsl:if test="@hidden='0'">
|
90
|
<input type="checkbox" checked="true" id="legend_{wmc:Name}" onclick="{$context}.setHidden('{wmc:Name}',!document.getElementById('legend_{wmc:Name}').checked)"/>
|
91
|
</xsl:if>
|
92
|
<xsl:if test="@hidden='1'">
|
93
|
<input type="checkbox" id="legend_{wmc:Name}" onclick="{$context}.setHidden('{wmc:Name}',! document.getElementById('legend_{wmc:Name}').checked)"/>
|
94
|
</xsl:if>
|
95
|
</td>
|
96
|
<!-- Query Image -->
|
97
|
<td>
|
98
|
<xsl:if test="@queryable='1'">
|
99
|
<img
|
100
|
id="query_{wmc:Name}"
|
101
|
title="Click to set {wmc:Title} as the query layer"
|
102
|
onclick="config.objects.{$widgetId}.selectLayer(config.objects.{$widgetId},'{wmc:Name}')"
|
103
|
src="{$skinDir}{$selectIcon}" />
|
104
|
</xsl:if>
|
105
|
</td>
|
106
|
<!-- Title -->
|
107
|
<td id="{wmc:Title}_legendText" class="legendText">
|
108
|
<xsl:choose>
|
109
|
<xsl:when test="wmc:Title/@xml:lang">
|
110
|
<xsl:value-of select="wmc:Title[@xml:lang=$lang]"/>
|
111
|
</xsl:when>
|
112
|
<xsl:otherwise>
|
113
|
<xsl:value-of select="wmc:Title"/>
|
114
|
</xsl:otherwise>
|
115
|
</xsl:choose>
|
116
|
</td>
|
117
|
</tr>
|
118
|
<!-- StyleList -->
|
119
|
<tr>
|
120
|
<td></td>
|
121
|
<td></td>
|
122
|
<td>
|
123
|
<xsl:if test="wmc:StyleList/wmc:Style[@current='1']/wmc:LegendURL">
|
124
|
<xsl:element name="IMG">
|
125
|
<xsl:attribute name="SRC">
|
126
|
<xsl:value-of select="wmc:StyleList/wmc:Style[@current='1']/wmc:LegendURL/wmc:OnlineResource/@xlink:href"/>
|
127
|
</xsl:attribute>
|
128
|
</xsl:element>
|
129
|
</xsl:if>
|
130
|
</td>
|
131
|
</tr>
|
132
|
</xsl:template>
|
133
|
|
134
|
<xsl:template match="text()|@*"/>
|
135
|
|
136
|
</xsl:stylesheet>
|