Revision 4307
Added by ben leinfelder over 15 years ago
wms_GetFeatureInfo.xsl | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
<!-- |
|
6 |
|
|
7 |
Description: parses an OGC context document to generate a GetFeatureInfo url |
|
8 |
|
|
9 |
Author: Nedjo |
|
10 |
|
|
11 |
Licence: LGPL as specified in http://www.gnu.org/copyleft/lesser.html . |
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
$Id$ |
|
16 |
|
|
17 |
$Name$ |
|
18 |
|
|
19 |
--> |
|
20 |
|
|
21 |
<xsl:stylesheet version="1.0" xmlns:cml="http://www.opengis.net/context" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xlink="http://www.w3.org/1999/xlink"> |
|
22 |
|
|
23 |
<xsl:output method="xml"/> |
|
24 |
|
|
25 |
<!--xsl:strip-space elements="*"/--> |
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
<!-- parameters to be passed into the XSL --> |
|
30 |
|
|
31 |
<!-- The name of the WMS GetFeatureInfo layer --> |
|
32 |
|
|
33 |
<xsl:param name="queryLayer"/> |
|
34 |
|
|
35 |
<xsl:param name="xCoord"/> |
|
36 |
|
|
37 |
<xsl:param name="yCoord"/> |
|
38 |
|
|
39 |
<xsl:param name="infoFormat" select="text/html"/> |
|
40 |
|
|
41 |
<xsl:param name="featureCount" select="1"/> |
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
<!-- Global variables --> |
|
46 |
|
|
47 |
<xsl:variable name="bbox"> |
|
48 |
|
|
49 |
<xsl:value-of select="/cml:ViewContext/cml:General/cml:BoundingBox/@minx"/>,<xsl:value-of select="/cml:ViewContext/cml:General/cml:BoundingBox/@miny"/>,<xsl:value-of select="/cml:ViewContext/cml:General/cml:BoundingBox/@maxx"/>,<xsl:value-of select="/cml:ViewContext/cml:General/cml:BoundingBox/@maxy"/> |
|
50 |
|
|
51 |
</xsl:variable> |
|
52 |
|
|
53 |
<xsl:variable name="width"> |
|
54 |
|
|
55 |
<xsl:value-of select="/cml:ViewContext/cml:General/cml:Window/@width"/> |
|
56 |
|
|
57 |
</xsl:variable> |
|
58 |
|
|
59 |
<xsl:variable name="height"> |
|
60 |
|
|
61 |
<xsl:value-of select="/cml:ViewContext/cml:General/cml:Window/@height"/> |
|
62 |
|
|
63 |
</xsl:variable> |
|
64 |
|
|
65 |
<xsl:variable name="srs" select="/cml:ViewContext/cml:General/cml:BoundingBox/@SRS"/> |
|
66 |
|
|
67 |
|
|
68 |
|
|
69 |
<!-- Root template --> |
|
70 |
|
|
71 |
<xsl:template match="/"> |
|
72 |
|
|
73 |
<xsl:apply-templates select="cml:ViewContext/cml:LayerList/cml:Layer[cml:Name=$queryLayer]"/> |
|
74 |
|
|
75 |
</xsl:template> |
|
76 |
|
|
77 |
|
|
78 |
|
|
79 |
<!-- Layer template --> |
|
80 |
|
|
81 |
<xsl:template match="cml:Layer"> |
|
82 |
|
|
83 |
|
|
84 |
|
|
85 |
<!-- Layer variables --> |
|
86 |
|
|
87 |
<xsl:variable name="version"> |
|
88 |
|
|
89 |
<xsl:value-of select="cml:Server/@version"/> |
|
90 |
|
|
91 |
</xsl:variable> |
|
92 |
|
|
93 |
<xsl:variable name="baseUrl"> |
|
94 |
|
|
95 |
<xsl:value-of select="cml:Server/cml:OnlineResource/@xlink:href"/> |
|
96 |
|
|
97 |
</xsl:variable> |
|
98 |
|
|
99 |
<xsl:variable name="firstJoin"> |
|
100 |
|
|
101 |
<xsl:choose> |
|
102 |
|
|
103 |
<xsl:when test="substring($baseUrl,string-length($baseUrl))='?'"></xsl:when> |
|
104 |
|
|
105 |
<xsl:when test="contains($baseUrl, '?')">&</xsl:when> |
|
106 |
|
|
107 |
<xsl:otherwise>?</xsl:otherwise> |
|
108 |
|
|
109 |
</xsl:choose> |
|
110 |
|
|
111 |
</xsl:variable> |
|
112 |
|
|
113 |
|
|
114 |
|
|
115 |
<!-- Print the URL --> |
|
116 |
|
|
117 |
<url> |
|
118 |
|
|
119 |
<xsl:value-of select="$baseUrl"/><xsl:value-of select="$firstJoin"/>VERSION=<xsl:value-of select="$version"/>&REQUEST=GetFeatureInfo&SRS=<xsl:value-of select="$srs"/>&BBOX=<xsl:value-of select="$bbox"/>&WIDTH=<xsl:value-of select="$width"/>&HEIGHT=<xsl:value-of select="$height"/>&INFO_FORMAT=<xsl:value-of select="$infoFormat"/>&FEATURE_COUNT=<xsl:value-of select="$featureCount"/>&QUERY_LAYERS=<xsl:value-of select="$queryLayer"/>&X=<xsl:value-of select="$xCoord"/>&Y=<xsl:value-of select="$yCoord"/> |
|
120 |
|
|
121 |
</url> |
|
122 |
|
|
123 |
</xsl:template> |
|
124 |
|
|
125 |
</xsl:stylesheet> |
|
126 |
|
|
1 |
<?xml version="1.0"?> |
|
2 |
<xsl:stylesheet xmlns:wmc="http://www.opengis.net/context" xmlns:mb="http://mapbuilder.sourceforge.net/mapbuilder" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.0"><xsl:output method="xml" omit-xml-declaration="yes" encoding="utf-8" indent="no"/><xsl:param name="queryLayer"/><xsl:param name="xCoord"/><xsl:param name="yCoord"/><xsl:param name="infoFormat" select="text/html"/><xsl:param name="featureCount" select="1"/><xsl:param name="bBoxMinX"/><xsl:param name="bBoxMinY"/><xsl:param name="bBoxMaxX"/><xsl:param name="bBoxMaxY"/><xsl:param name="srs"/><xsl:param name="width"/><xsl:param name="height"/><xsl:param name="version"/><xsl:param name="httpMethod">get</xsl:param><xsl:variable name="bbox"><xsl:value-of select="$bBoxMinX"/>,<xsl:value-of select="$bBoxMinY"/>,<xsl:value-of select="$bBoxMaxX"/>,<xsl:value-of select="$bBoxMaxY"/></xsl:variable><xsl:template match="wmc:Layer"><xsl:variable name="baseUrl"><xsl:value-of select="wmc:Server/wmc:OnlineResource/@xlink:href"/></xsl:variable><xsl:variable name="imgFormat"><xsl:value-of select="wmc:FormatList/wmc:Format[@current='1']"/></xsl:variable><xsl:variable name="firstJoin"><xsl:choose><xsl:when test="substring($baseUrl,string-length($baseUrl))='?'"/><xsl:when test="contains($baseUrl, '?')">&</xsl:when><xsl:otherwise>?</xsl:otherwise></xsl:choose></xsl:variable><xsl:choose><xsl:when test="$httpMethod='post'"><Query typeName="{$queryLayer}"/></xsl:when><xsl:otherwise><mb:QueryString><xsl:variable name="query"> |
|
3 |
REQUEST=GetFeatureInfo |
|
4 |
&SERVICE=WMS |
|
5 |
&VERSION=<xsl:value-of select="$version"/> |
|
6 |
&SRS=<xsl:value-of select="$srs"/> |
|
7 |
&LAYERS=<xsl:value-of select="$queryLayer"/> |
|
8 |
&BBOX=<xsl:value-of select="$bbox"/> |
|
9 |
&WIDTH=<xsl:value-of select="$width"/> |
|
10 |
&HEIGHT=<xsl:value-of select="$height"/> |
|
11 |
&INFO_FORMAT=<xsl:value-of select="$infoFormat"/> |
|
12 |
&FEATURE_COUNT=<xsl:value-of select="$featureCount"/> |
|
13 |
&QUERY_LAYERS=<xsl:value-of select="$queryLayer"/> |
|
14 |
&X=<xsl:value-of select="$xCoord"/> |
|
15 |
&Y=<xsl:value-of select="$yCoord"/> |
|
16 |
&FORMAT=<xsl:value-of select="$imgFormat"/></xsl:variable><xsl:value-of select="translate(normalize-space($query),' ','')" disable-output-escaping="no"/></mb:QueryString></xsl:otherwise></xsl:choose></xsl:template><xsl:template match="comment()|text()|processing-instruction()"/></xsl:stylesheet> |
Also available in: Unified diff
upgrade to MapBuilder 1.5rc2 - includes support for Firefox 3 compatibility (yes, it is also EOLed)