1 |
4307
|
leinfelder
|
<?xml version="1.0" encoding="ISO-8859-1"?>
|
2 |
|
|
<!--
|
3 |
|
|
Description: Generates a EBRIM Catalog Query from Filter Paramaters provided
|
4 |
|
|
Author: rdewit
|
5 |
|
|
Licence: LGPL as specified in http://www.gnu.org/copyleft/lesser.html .
|
6 |
|
|
|
7 |
|
|
$Id:$
|
8 |
|
|
$Name: $
|
9 |
|
|
-->
|
10 |
|
|
|
11 |
|
|
<xsl:stylesheet version="1.0"
|
12 |
|
|
xmlns:wmc="http://www.opengis.net/context"
|
13 |
|
|
xmlns:wms="http://www.opengis.net/wms"
|
14 |
|
|
xmlns:ogc="http://www.opengis.net/ogc"
|
15 |
|
|
xmlns:ows="http://www.opengis.net/ows"
|
16 |
|
|
xmlns:csw="http://www.opengis.net/cat/csw"
|
17 |
|
|
xmlns:gml="http://www.opengis.net/gml"
|
18 |
|
|
xmlns:rim="urn:oasis:names:tc:ebxml-regrep:rim:xsd:2.5"
|
19 |
|
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
20 |
|
|
xmlns:wfs="http://www.opengis.net/wfs"
|
21 |
|
|
xmlns:sld="http://www.opengis.net/sld"
|
22 |
|
|
xmlns:owscat="http://www.ec.gc.ca/owscat"
|
23 |
|
|
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
24 |
|
|
xmlns:xlink="http://www.w3.org/1999/xlink">
|
25 |
|
|
|
26 |
|
|
<xsl:output method="xml" encoding="utf-8" omit-xml-declaration="yes"/>
|
27 |
|
|
<xsl:strip-space elements="*"/>
|
28 |
|
|
|
29 |
|
|
|
30 |
|
|
<!-- Match Root -->
|
31 |
|
|
<xsl:template match="/">
|
32 |
|
|
|
33 |
|
|
<GetRecords
|
34 |
|
|
xmlns:csw="http://www.opengis.net/csw"
|
35 |
|
|
xmlns:ogc="http://www.opengis.net/ogc"
|
36 |
|
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
37 |
|
|
xmlns:gml="http://www.opengis.net/gml"
|
38 |
|
|
csw:schemaLocation="http://www.opengis.net/csw http://schemas.cubewerx.com/csw/2.0.0/CSW-discovery.xsd"
|
39 |
|
|
ogc:schemaLocation="http://www.opengis.net/ogc http://schemas.cubewerx.com/schemas/filter/1.0.0/filter.xsd"
|
40 |
|
|
service="WRS"
|
41 |
|
|
version="2.0.0"
|
42 |
|
|
outputFormat="text/xml"
|
43 |
|
|
startPosition="1"
|
44 |
|
|
maxRecords="1000"
|
45 |
|
|
resultType="RESULTS">
|
46 |
|
|
|
47 |
|
|
<Query typeNames="ExtrinsicObject Association=ServiceAssociation Service">
|
48 |
|
|
<ElementName>/ExtrinsicObject</ElementName>
|
49 |
|
|
<ElementName>/Service</ElementName>
|
50 |
|
|
|
51 |
|
|
<!-- Check if there is a (non-empty) filter node -->
|
52 |
|
|
<!-- If so, loop through children and look for templates that match them -->
|
53 |
|
|
<xsl:if test="filter/*">
|
54 |
|
|
<Constraint>
|
55 |
|
|
<ogc:Filter>
|
56 |
|
|
<ogc:And>
|
57 |
|
|
<xsl:for-each select="filter/*">
|
58 |
|
|
<xsl:if test="node()">
|
59 |
|
|
<xsl:apply-templates select="."/>
|
60 |
|
|
</xsl:if>
|
61 |
|
|
</xsl:for-each>
|
62 |
|
|
</ogc:And>
|
63 |
|
|
</ogc:Filter>
|
64 |
|
|
</Constraint>
|
65 |
|
|
</xsl:if>
|
66 |
|
|
|
67 |
|
|
</Query>
|
68 |
|
|
</GetRecords>
|
69 |
|
|
|
70 |
|
|
</xsl:template>
|
71 |
|
|
|
72 |
|
|
|
73 |
|
|
<xsl:template match="serviceassociation">
|
74 |
|
|
<!-- Link the layer (coming from the extrinsic object), to the service object via the "Serves" association -->
|
75 |
|
|
<!-- Can be things like: OperatesOn, Serves, etc -->
|
76 |
|
|
<ogc:And>
|
77 |
|
|
<ogc:PropertyIsEqualTo>
|
78 |
|
|
<ogc:PropertyName>/ExtrinsicObject/@ID</ogc:PropertyName>
|
79 |
|
|
<ogc:PropertyName>/ServiceAssociation/@targetObject</ogc:PropertyName>
|
80 |
|
|
</ogc:PropertyIsEqualTo>
|
81 |
|
|
<ogc:PropertyIsLike>
|
82 |
|
|
<ogc:PropertyName>/ServiceAssociation/@associationType</ogc:PropertyName>
|
83 |
|
|
<ogc:Literal><xsl:value-of select="."/></ogc:Literal>
|
84 |
|
|
</ogc:PropertyIsLike>
|
85 |
|
|
<ogc:PropertyIsEqualTo>
|
86 |
|
|
<ogc:PropertyName>/Service/@ID</ogc:PropertyName>
|
87 |
|
|
<ogc:PropertyName>/ServiceAssociation/@sourceObject</ogc:PropertyName>
|
88 |
|
|
</ogc:PropertyIsEqualTo>
|
89 |
|
|
</ogc:And>
|
90 |
|
|
</xsl:template>
|
91 |
|
|
|
92 |
|
|
<xsl:template match="featuretype">
|
93 |
|
|
<!-- The object type has to be either a feature type WFS_layer or WMS_Layer -->
|
94 |
|
|
<ogc:Or>
|
95 |
|
|
<ogc:PropertyIsLike>
|
96 |
|
|
<ogc:PropertyName>/ExtrinsicObject/@objectType</ogc:PropertyName>
|
97 |
|
|
<ogc:Literal>FeatureType</ogc:Literal>
|
98 |
|
|
</ogc:PropertyIsLike>
|
99 |
|
|
<ogc:PropertyIsLike>
|
100 |
|
|
<ogc:PropertyName>/ExtrinsicObject/@objectType</ogc:PropertyName>
|
101 |
|
|
<ogc:Literal><xsl:value-of select="."/></ogc:Literal>
|
102 |
|
|
</ogc:PropertyIsLike>
|
103 |
|
|
</ogc:Or>
|
104 |
|
|
</xsl:template>
|
105 |
|
|
|
106 |
|
|
<xsl:template match="servicetype">
|
107 |
|
|
<!-- Can be things like: WFS, WMS, etc -->
|
108 |
|
|
<ogc:And>
|
109 |
|
|
<ogc:PropertyIsEqualTo>
|
110 |
|
|
<ogc:PropertyName>/Service/Slot/@name</ogc:PropertyName>
|
111 |
|
|
<ogc:Literal>Service Type</ogc:Literal>
|
112 |
|
|
</ogc:PropertyIsEqualTo>
|
113 |
|
|
<ogc:PropertyIsEqualTo>
|
114 |
|
|
<ogc:PropertyName>/Service/Slot/ValueList/Value</ogc:PropertyName>
|
115 |
|
|
<ogc:Literal><xsl:value-of select="."/></ogc:Literal>
|
116 |
|
|
</ogc:PropertyIsEqualTo>
|
117 |
|
|
</ogc:And>
|
118 |
|
|
</xsl:template>
|
119 |
|
|
|
120 |
|
|
<xsl:template match="keywords">
|
121 |
|
|
<xsl:call-template name="tokenize">
|
122 |
|
|
<xsl:with-param name="inputString" select="concat(normalize-space(.),' ')"/>
|
123 |
|
|
<xsl:with-param name="resultElement" select="'keyword'"/>
|
124 |
|
|
</xsl:call-template>
|
125 |
|
|
</xsl:template>
|
126 |
|
|
|
127 |
|
|
<xsl:template name="keyword">
|
128 |
|
|
<xsl:param name="keyword"/>
|
129 |
|
|
<ogc:Or>
|
130 |
|
|
<ogc:PropertyIsLike>
|
131 |
|
|
<ogc:PropertyName>/ExtrinsicObject/Name/LocalizedString/@value</ogc:PropertyName>
|
132 |
|
|
<ogc:Literal>%<xsl:value-of select="$keyword"/>%</ogc:Literal>
|
133 |
|
|
</ogc:PropertyIsLike>
|
134 |
|
|
<ogc:PropertyIsLike>
|
135 |
|
|
<ogc:PropertyName>/ExtrinsicObject/Description/LocalizedString/@value</ogc:PropertyName>
|
136 |
|
|
<ogc:Literal>%<xsl:value-of select="$keyword"/>%</ogc:Literal>
|
137 |
|
|
</ogc:PropertyIsLike>
|
138 |
|
|
<ogc:And>
|
139 |
|
|
<ogc:PropertyIsEqualTo>
|
140 |
|
|
<ogc:PropertyName>/ExtrinsicObject/Slot/@name</ogc:PropertyName>
|
141 |
|
|
<ogc:Literal>Keyword</ogc:Literal>
|
142 |
|
|
</ogc:PropertyIsEqualTo>
|
143 |
|
|
<ogc:PropertyIsLike>
|
144 |
|
|
<ogc:PropertyName>/ExtrinsicObject/Slot/ValueList/Value</ogc:PropertyName>
|
145 |
|
|
<ogc:Literal>%<xsl:value-of select="$keyword"/>%</ogc:Literal>
|
146 |
|
|
</ogc:PropertyIsLike>
|
147 |
|
|
</ogc:And>
|
148 |
|
|
</ogc:Or>
|
149 |
|
|
</xsl:template>
|
150 |
|
|
|
151 |
|
|
<!-- TODO: make this generic -->
|
152 |
|
|
<xsl:template match="location">
|
153 |
|
|
<ogc:BBOX>
|
154 |
|
|
<ogc:PropertyName>/ExtrinsicObject/Slot[@name='FootPrint']/ValueList/Value[1]</ogc:PropertyName>
|
155 |
|
|
<gml:Box srsName="EPSG:4326">
|
156 |
|
|
<gml:coordinates><xsl:value-of select="."/></gml:coordinates>
|
157 |
|
|
</gml:Box>
|
158 |
|
|
</ogc:BBOX>
|
159 |
|
|
</xsl:template>
|
160 |
|
|
|
161 |
|
|
|
162 |
|
|
<!-- Code to tokenize a string into nodes -->
|
163 |
|
|
<!-- This can be used to convert a string with keywords to an XML representation -->
|
164 |
|
|
<!-- It fails with the last word if there is no whitespace after that word :-S -->
|
165 |
|
|
<!-- http://www.biglist.com/lists/xsl-list/archives/200603/msg00083.html -->
|
166 |
|
|
<xsl:template name="tokenize">
|
167 |
|
|
<xsl:param name="inputString"/>
|
168 |
|
|
<xsl:param name="separator" select="' '"/>
|
169 |
|
|
<xsl:param name="resultElement" select="'item'"/>
|
170 |
|
|
<xsl:variable
|
171 |
|
|
name="token"
|
172 |
|
|
select="substring-before($inputString, $separator)"
|
173 |
|
|
/>
|
174 |
|
|
<xsl:variable
|
175 |
|
|
name="nextToken"
|
176 |
|
|
select="substring-after($inputString, $separator)"
|
177 |
|
|
/>
|
178 |
|
|
|
179 |
|
|
<xsl:if test="$token">
|
180 |
|
|
<xsl:call-template name="keyword">
|
181 |
|
|
<xsl:with-param name="keyword" select="$token"/>
|
182 |
|
|
</xsl:call-template>
|
183 |
|
|
</xsl:if>
|
184 |
|
|
|
185 |
|
|
<xsl:if test="$nextToken">
|
186 |
|
|
<xsl:call-template name="tokenize">
|
187 |
|
|
<xsl:with-param
|
188 |
|
|
name="inputString"
|
189 |
|
|
select="$nextToken"/>
|
190 |
|
|
<xsl:with-param
|
191 |
|
|
name="separator"
|
192 |
|
|
select="$separator"/>
|
193 |
|
|
<xsl:with-param
|
194 |
|
|
name="resultElement"
|
195 |
|
|
select="$resultElement"/>
|
196 |
|
|
</xsl:call-template>
|
197 |
|
|
</xsl:if>
|
198 |
|
|
</xsl:template>
|
199 |
|
|
|
200 |
|
|
<xsl:template match="text()|@*"/>
|
201 |
|
|
|
202 |
|
|
</xsl:stylesheet>
|