Project

General

Profile

1
<?xml version="1.0" encoding="ISO-8859-1"?>
2

    
3

    
4

    
5
<!--
6

    
7
Description: transforms a WFS FeatureType node to a GetFeatureType request
8

    
9
Author:      adair
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

    
22

    
23
<xsl:stylesheet version="1.0" 
24

    
25
    xmlns:wfs="http://www.opengis.net/wfs"
26

    
27
    xmlns:wmc="http://www.opengis.net/context" 
28

    
29
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
30

    
31
    xmlns:mb="http://mapbuilder.sourceforge.net/mapbuilder" 
32

    
33
		xmlns:ogc="http://www.opengis.net/ogc"
34

    
35
		xmlns:gml="http://www.opengis.net/gml"
36

    
37
    xmlns:xlink="http://www.w3.org/1999/xlink">
38

    
39

    
40

    
41
  <xsl:output method="xml" omit-xml-declaration="no" encoding="utf-8" indent="no"/>
42

    
43
  <xsl:preserve-space elements="gml:coordinates"/>
44

    
45

    
46

    
47
  <xsl:param name="cs" select="','"/>
48

    
49
  <xsl:param name="ts" select="' '"/>
50

    
51
  <xsl:param name="bBoxMinX"/>
52

    
53
  <xsl:param name="bBoxMinY"/>
54

    
55
  <xsl:param name="bBoxMaxX"/>
56

    
57
  <xsl:param name="bBoxMaxY"/>
58

    
59
  <xsl:param name="srs"/>
60

    
61
  <xsl:param name="version"/>
62

    
63
  
64

    
65
  <xsl:param name="httpMethod">get</xsl:param>
66

    
67
  <xsl:param name="filter"/>
68

    
69
  <xsl:param name="maxFeatures">500</xsl:param>
70

    
71
  <xsl:param name="geometry"/>
72

    
73
  
74

    
75
  <!-- template rule matching source root element -->
76

    
77
  <xsl:template match="wfs:FeatureType">
78

    
79
    <xsl:param name="resourceName" select="wfs:Name"/>
80

    
81
    <xsl:param name="featureSrs" select="wfs:SRS"/>
82

    
83
    <GetFeature version="1.0.0" service="WFS" maxFeatures="{$maxFeatures}">
84

    
85
    
86

    
87
    <xsl:choose>
88

    
89
      <xsl:when test="$httpMethod='post'">
90

    
91
      <Query typeName="{$resourceName}">
92

    
93
         <ogc:Filter>
94

    
95
            <ogc:And>
96

    
97
              <xsl:if test="$bBoxMinX">
98

    
99
                <ogc:BBOX>
100

    
101
                  <ogc:PropertyName><xsl:value-of select="$geometry"/></ogc:PropertyName>
102

    
103
                  <gml:Box srsName="{$srs}">
104

    
105
            <xsl:value-of select="$bBoxMinX"/><xsl:value-of select="$cs"/>
106

    
107
            <xsl:value-of select="$bBoxMinY"/><xsl:value-of select="$ts"/>
108

    
109
            <xsl:value-of select="$bBoxMaxX"/><xsl:value-of select="$cs"/>
110

    
111
            <xsl:value-of select="$bBoxMaxY"/>
112

    
113
                  </gml:Box>
114

    
115
                </ogc:BBOX>
116

    
117
              </xsl:if>
118

    
119
              <xsl:if test="$filter">
120

    
121
                <xsl:value-of select="$filter"/>
122

    
123
              </xsl:if>
124

    
125
            </ogc:And>
126

    
127
          </ogc:Filter>
128

    
129
      </Query>
130

    
131
      </xsl:when>
132

    
133
      <xsl:otherwise>
134

    
135
        <mb:QueryString>
136

    
137
          <xsl:variable name="bbox">
138

    
139
            <xsl:value-of select="$bBoxMinX"/>,<xsl:value-of select="$bBoxMinY"/>,
140

    
141
            <xsl:value-of select="$bBoxMaxX"/>,<xsl:value-of select="$bBoxMaxY"/>
142

    
143
          </xsl:variable>
144

    
145
          <xsl:variable name="query">
146

    
147
         request=GetFeature
148

    
149
    &amp;service=WFS
150

    
151
    &amp;version=<xsl:value-of select="$version"/>
152

    
153
&amp;maxfeatures=<xsl:value-of select="$maxFeatures"/>
154

    
155
   &amp;typename=<xsl:value-of select="$resourceName"/>
156

    
157
          <xsl:if test="$bBoxMinX">
158

    
159
   &amp;bbox=<xsl:value-of select="$bbox"/>
160

    
161
          </xsl:if>
162

    
163
          </xsl:variable>
164

    
165
          <xsl:value-of select="translate(normalize-space($query),' ','')" disable-output-escaping="no"/><xsl:if test="$filter">&amp;filter=<xsl:value-of select="$filter"/></xsl:if>
166

    
167
        </mb:QueryString>
168

    
169
      </xsl:otherwise>
170

    
171
    </xsl:choose>
172

    
173
    </GetFeature>
174

    
175
  </xsl:template>
176

    
177
  
178

    
179
  <!-- template rule matching source root element -->
180

    
181
  <xsl:template match="wmc:FeatureType[wmc:Server/@service='OGC:WFS']">
182

    
183
    <xsl:param name="resourceName" select="wmc:Name"/>
184

    
185
    <xsl:param name="featureSrs" select="wmc:SRS"/>
186

    
187
    <GetFeature version="1.0.0" service="WFS" maxFeatures="{$maxFeatures}"
188

    
189
      xmlns="http://www.opengis.net/wfs"
190

    
191
      xmlns:ogc="http://www.opengis.net/ogc">
192

    
193
    <xsl:choose>
194

    
195
      <xsl:when test="$httpMethod='post'">
196

    
197
      <Query typeName="{$resourceName}">
198

    
199
         <!--ogc:PropertyName>GML_Geometry</ogc:PropertyName>
200

    
201
         <ogc:PropertyName>DEFINITION</ogc:PropertyName>
202

    
203
         <ogc:PropertyName>LU37_CODE</ogc:PropertyName>
204

    
205
         <ogc:PropertyName>YEAR</ogc:PropertyName-->
206

    
207
         <ogc:Filter>
208

    
209
            <ogc:And>
210

    
211
              <xsl:if test="wmc:Geometry">
212

    
213
<xsl:variable name="bbox" select="concat($bBoxMinX,concat(',',concat($bBoxMinY,concat(' ',concat($bBoxMaxX,concat(',',$bBoxMaxY))))))"/>
214

    
215
                <ogc:BBOX>
216

    
217
                  <ogc:PropertyName><xsl:value-of select="wmc:Geometry"/></ogc:PropertyName>
218

    
219
                  <gml:Box srsName="{$srs}">
220

    
221
                    <gml:coordinates><xsl:value-of select="$bbox"/></gml:coordinates>
222

    
223
                  </gml:Box>
224

    
225
                </ogc:BBOX>
226

    
227
              </xsl:if>
228

    
229
              <xsl:if test="ogc:Filter">
230

    
231
                <xsl:copy-of select="ogc:Filter/*"/>
232

    
233
              </xsl:if>
234

    
235
            </ogc:And>
236

    
237
          </ogc:Filter>
238

    
239
      </Query>
240

    
241
      </xsl:when>
242

    
243
      <xsl:otherwise>
244

    
245
        <mb:QueryString>
246

    
247
          <xsl:variable name="cFilterStr"><xsl:value-of select="ogc:Filter"/></xsl:variable>
248

    
249
          <xsl:variable name="bbox">
250

    
251
            <xsl:value-of select="$bBoxMinX"/>,<xsl:value-of select="$bBoxMinY"/>,
252

    
253
            <xsl:value-of select="$bBoxMaxX"/>,<xsl:value-of select="$bBoxMaxY"/>
254

    
255
          </xsl:variable>
256

    
257
          <xsl:variable name="query">
258

    
259
         request=GetFeature
260

    
261
    &amp;service=WFS
262

    
263
    &amp;version=<xsl:value-of select="$version"/>
264

    
265
&amp;maxfeatures=<xsl:value-of select="$maxFeatures"/>
266

    
267
   &amp;typename=<xsl:value-of select="$resourceName"/>
268

    
269
          <xsl:if test="$bBoxMinX">
270

    
271
   &amp;bbox=<xsl:value-of select="$bbox"/>
272

    
273
          </xsl:if>
274

    
275
          </xsl:variable>
276

    
277
          <xsl:value-of select="translate(normalize-space($query),' ','')" disable-output-escaping="no"/><xsl:if test="$cFilterStr">&amp;filter=<xsl:value-of select="normalize-space($cFilterStr)"/></xsl:if>
278

    
279
<!-- TBD something still wrong with filter parameter here -->
280

    
281
        </mb:QueryString>
282

    
283
      </xsl:otherwise>
284

    
285
    </xsl:choose>
286

    
287
    </GetFeature>
288

    
289
  </xsl:template>
290

    
291
  
292

    
293
  
294

    
295
  <xsl:template match="text()|@*"/>
296

    
297

    
298

    
299
</xsl:stylesheet>
300

    
(6-6/14)