Debian Codegraph @

res/res_geolocation/eprofile_to_pidf.xslt

raw symbols SCIP
1 <?xml version="1.0"?>
2 <xsl:stylesheet version="1.1"
3 xmlns:ca="urn:ietf:params:xml:ns:pidf:geopriv10:civicAddr"
4 xmlns:dm="urn:ietf:params:xml:ns:pidf:data-model"
5 xmlns:fn="http://www.w3.org/2005/xpath-functions"
6 xmlns:gbp="urn:ietf:params:xml:ns:pidf:geopriv10:basicPolicy"
7 xmlns:gml="http://www.opengis.net/gml"
8 xmlns:gp="urn:ietf:params:xml:ns:pidf:geopriv10"
9 xmlns:gs="http://www.opengis.net/pidflo/1.0"
10 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
11 xmlns:con="urn:ietf:params:xml:ns:geopriv:conf"
12 xmlns:date="http://exslt.org/dates-and-times">
13
14 <xsl:output method="xml" indent="yes"/>
15 <xsl:strip-space elements="*"/>
16 <xsl:param name="suppress_empty_ca_elements" select="false()"/>
17
18 <!-- REMINDER: The "match" and "select" xpaths refer to the input document,
19 not the output document -->
20
21 <xsl:template match="presence">
22 <!-- xslt will take care of adding all of the namespace declarations
23 from the list above -->
24 <presence xmlns="urn:ietf:params:xml:ns:pidf" entity="{@entity}">
25 <xsl:apply-templates/>
26 </presence>
27 </xsl:template>
28
29 <xsl:template match="person|device">
30 <xsl:element name="dm:{local-name(.)}">
31 <xsl:if test="@id">
32 <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
33 </xsl:if>
34
35 <gp:geopriv>
36 <xsl:apply-templates select="./location-info"/>
37 <xsl:apply-templates select="./usage-rules"/>
38 <xsl:apply-templates select="./method"/>
39 <xsl:apply-templates select="./note-well"/>
40 </gp:geopriv>
41 <xsl:if test="./timestamp">
42 <dm:timestamp>
43 <xsl:value-of select="./timestamp"/>
44 </dm:timestamp>
45 </xsl:if>
46 <xsl:if test="./deviceID">
47 <dm:deviceID>
48 <xsl:value-of select="./deviceID"/>
49 </dm:deviceID>
50 </xsl:if>
51 </xsl:element>
52 </xsl:template>
53
54 <xsl:template match="tuple">
55 <xsl:element name="tuple" namespace="urn:ietf:params:xml:ns:pidf">
56 <xsl:if test="@id">
57 <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
58 </xsl:if>
59 <xsl:element name="status" namespace="urn:ietf:params:xml:ns:pidf">
60 <gp:geopriv>
61 <xsl:apply-templates select="./location-info"/>
62 <xsl:apply-templates select="./usage-rules"/>
63 <xsl:apply-templates select="./method"/>
64 <xsl:apply-templates select="./note-well"/>
65 </gp:geopriv>
66 </xsl:element>
67 <xsl:if test="./timestamp">
68 <xsl:element name="timestamp" namespace="urn:ietf:params:xml:ns:pidf">
69 <xsl:value-of select="./timestamp"/>
70 </xsl:element>
71 </xsl:if>
72 <xsl:if test="./deviceID">
73 <dm:deviceID>
74 <xsl:value-of select="./deviceID"/>
75 </dm:deviceID>
76 </xsl:if>
77 </xsl:element>
78 </xsl:template>
79
80
81 <xsl:template match="location-info">
82 <gp:location-info>
83 <xsl:apply-templates/>
84 </gp:location-info>
85 </xsl:template>
86
87 <!-- When we're using the civicAddress format, the translation is simple.
88 We add gp:location-info and ca:civicAddress, then we just copy in
89 each element, adding the "ca" namespace -->
90
91 <xsl:template match="civicAddress/*">
92 <xsl:if test="not($suppress_empty_ca_elements) or boolean(node())">
93 <xsl:element name="ca:{name()}">
94 <xsl:value-of select="."/>
95 </xsl:element>
96 </xsl:if>
97 </xsl:template>
98
99 <xsl:template match="location-info/civicAddress">
100 <ca:civicAddress xml:lang="{@lang}">
101 <xsl:apply-templates/>
102 </ca:civicAddress>
103 </xsl:template>
104
105 <!-- All GML shapes share common processing for the "srsName" attribute -->
106 <xsl:template name="shape">
107 <xsl:choose>
108 <xsl:when test="@crs = '3d'">
109 <xsl:attribute name="srsName">urn:ogc:def:crs:EPSG::4979</xsl:attribute>
110 </xsl:when>
111 <xsl:otherwise>
112 <xsl:attribute name="srsName">urn:ogc:def:crs:EPSG::4326</xsl:attribute>
113 </xsl:otherwise>
114 </xsl:choose>
115 </xsl:template>
116
117 <!-- The GML shapes themselves. They don't all have the same namespace unfortunately... -->
118
119 <xsl:template match="Point|Circle|Ellipse|ArcBand|Sphere|Ellipsoid">
120 <xsl:variable name="namespace">
121 <xsl:choose>
122 <xsl:when test="name() = 'Point'">
123 <xsl:value-of select="'gml'"/>
124 </xsl:when>
125 <xsl:otherwise>
126 <xsl:value-of select="'gs'"/>
127 </xsl:otherwise>
128 </xsl:choose>
129 </xsl:variable>
130
131 <xsl:element name="{$namespace}:{name()}">
132 <xsl:call-template name="shape"/>
133 <xsl:apply-templates select="./*"/>
134 </xsl:element>
135 </xsl:template>
136
137 <!-- ... and some are more complex than others. -->
138
139 <xsl:template match="Polygon">
140 <gml:Polygon>
141 <xsl:call-template name="shape"/>
142 <gml:exterior>
143 <gml:LinearRing>
144 <xsl:apply-templates select="./pos|posList"/>
145 </gml:LinearRing>
146 </gml:exterior>
147 </gml:Polygon>
148 </xsl:template>
149
150 <!-- Prism with a Polygon and height -->
151 <xsl:template match="Prism">
152 <gs:Prism>
153 <xsl:call-template name="shape"/>
154 <gs:base>
155 <gml:Polygon>
156 <gml:exterior>
157 <gml:LinearRing>
158 <xsl:apply-templates select="./pos|posList"/>
159 </gml:LinearRing>
160 </gml:exterior>
161 </gml:Polygon>
162 </gs:base>
163 <xsl:apply-templates select="./height"/>
164 </gs:Prism>
165 </xsl:template>
166
167 <!-- method has no children so we add the "gp" namespace and copy in the value -->
168 <xsl:template match="method">
169 <gp:method>
170 <xsl:value-of select="."/>
171 </gp:method>
172 </xsl:template>
173
174 <!-- note-well has no children so we add the "gp" namespace and copy in the value -->
175 <xsl:template match="note-well">
176 <gp:note-well>
177 <xsl:value-of select="."/>
178 </gp:note-well>
179 </xsl:template>
180
181 <!-- usage-rules does have children so we add the "gp" namespace and copy in
182 the children, also adding the "gbp" namespace -->
183 <xsl:template match="usage-rules">
184 <gp:usage-rules>
185 <xsl:for-each select="*">
186 <xsl:element name="gbp:{local-name()}">
187 <xsl:value-of select="."/>
188 </xsl:element>
189 </xsl:for-each>
190 </gp:usage-rules>
191 </xsl:template>
192
193 <!-- These are the GML format primitives -->
194
195 <xsl:template name="name-value">
196 <xsl:element name="gml:{name()}">
197 <xsl:value-of select="."/>
198 </xsl:element>
199 </xsl:template>
200
201 <xsl:template name="length">
202 <xsl:element name="gs:{name()}">
203 <xsl:attribute name="uom">urn:ogc:def:uom:EPSG::9001</xsl:attribute>
204 <xsl:value-of select="."/>
205 </xsl:element>
206 </xsl:template>
207
208 <xsl:template name="angle">
209 <xsl:element name="gs:{name()}">
210 <xsl:choose>
211 <xsl:when test="@uom = 'radians'">
212 <xsl:attribute name="uom">urn:ogc:def:uom:EPSG::9101</xsl:attribute>
213 </xsl:when>
214 <xsl:otherwise>
215 <xsl:attribute name="uom">urn:ogc:def:uom:EPSG::9102</xsl:attribute>
216 </xsl:otherwise>
217 </xsl:choose>
218 <xsl:value-of select="."/>
219 </xsl:element>
220 </xsl:template>
221
222 <!-- These are the GML shape parameters -->
223
224 <xsl:template match="orientation"><xsl:call-template name="angle" /></xsl:template>
225 <xsl:template match="radius"><xsl:call-template name="length" /></xsl:template>
226 <xsl:template match="height"><xsl:call-template name="length" /></xsl:template>
227 <xsl:template match="semiMajorAxis"><xsl:call-template name="length" /></xsl:template>
228 <xsl:template match="semiMinorAxis"><xsl:call-template name="length" /></xsl:template>
229 <xsl:template match="verticalAxis"><xsl:call-template name="length" /></xsl:template>
230 <xsl:template match="innerRadius"><xsl:call-template name="length" /></xsl:template>
231 <xsl:template match="outerRadius"><xsl:call-template name="length" /></xsl:template>
232 <xsl:template match="startAngle"><xsl:call-template name="angle" /></xsl:template>
233 <xsl:template match="openingAngle"><xsl:call-template name="angle" /></xsl:template>
234 <xsl:template match="pos"><xsl:call-template name="name-value" /></xsl:template>
235 <xsl:template match="posList"><xsl:call-template name="name-value" /></xsl:template>
236
237 <xsl:template match="confidence">
238 <con:confidence pdf="{@pdf}">
239 <xsl:value-of select="."/>
240 </con:confidence>
241 </xsl:template>
242
243 </xsl:stylesheet>