Project

General

Profile

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, '?')">&amp;</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"/>&amp;REQUEST=GetFeatureInfo&amp;SRS=<xsl:value-of select="$srs"/>&amp;BBOX=<xsl:value-of select="$bbox"/>&amp;WIDTH=<xsl:value-of select="$width"/>&amp;HEIGHT=<xsl:value-of select="$height"/>&amp;INFO_FORMAT=<xsl:value-of select="$infoFormat"/>&amp;FEATURE_COUNT=<xsl:value-of select="$featureCount"/>&amp;QUERY_LAYERS=<xsl:value-of select="$queryLayer"/>&amp;X=<xsl:value-of select="$xCoord"/>&amp;Y=<xsl:value-of select="$yCoord"/>
120

    
121
    </url>
122

    
123
  </xsl:template>
124

    
125
</xsl:stylesheet>
126

    
(11-11/14)