| 1 |
<?xml version="1.0" encoding="UTF-8"?> |
| 2 |
<!-- |
| 3 |
|
| 4 |
Transform plain XML cities XML to valid GML. |
| 5 |
|
| 6 |
Author: Just van den Broecke, Just Objects B.V. |
| 7 |
--> |
| 8 |
<xsl:stylesheet version="1.0" |
| 9 |
xmlns:ogr="http://ogr.maptools.org/" |
| 10 |
xmlns:gml="http://www.opengis.net/gml" |
| 11 |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| 12 |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
| 13 |
> |
| 14 |
<xsl:output method="xml" omit-xml-declaration="no" indent="yes"/> |
| 15 |
<xsl:strip-space elements="*"/> |
| 16 |
|
| 17 |
<xsl:template match="/"> |
| 18 |
<ogr:FeatureCollection |
| 19 |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| 20 |
xmlns:ogr="http://ogr.maptools.org/" |
| 21 |
xmlns:gml="http://www.opengis.net/gml" |
| 22 |
xsi:schemaLocation="http://ogr.maptools.org/ ../gmlcities.xsd http://www.opengis.net/gml http://schemas.opengis.net/gml/2.1.2/feature.xsd" |
| 23 |
> |
| 24 |
<gml:boundedBy> |
| 25 |
<gml:Box> |
| 26 |
<gml:coord><gml:X>-180.0</gml:X><gml:Y>-90.0</gml:Y></gml:coord> |
| 27 |
<gml:coord><gml:X>180.0</gml:X><gml:Y>90.0</gml:Y></gml:coord> |
| 28 |
</gml:Box> |
| 29 |
</gml:boundedBy> |
| 30 |
<!-- Loop through all cities. --> |
| 31 |
<xsl:apply-templates/> |
| 32 |
</ogr:FeatureCollection> |
| 33 |
</xsl:template> |
| 34 |
|
| 35 |
<!-- Make each city an ogr:featureMember. --> |
| 36 |
<xsl:template match="city"> |
| 37 |
<gml:featureMember> |
| 38 |
<ogr:City> |
| 39 |
<ogr:name> |
| 40 |
<xsl:value-of select="name"/> |
| 41 |
</ogr:name> |
| 42 |
<ogr:geometry> |
| 43 |
<gml:Point srsName="urn:ogc:def:crs:EPSG:4326"> |
| 44 |
<gml:coordinates><xsl:value-of select="lat"/>,<xsl:value-of select="lon"/></gml:coordinates> |
| 45 |
</gml:Point> |
| 46 |
</ogr:geometry> |
| 47 |
</ogr:City> |
| 48 |
</gml:featureMember> |
| 49 |
</xsl:template> |
| 50 |
</xsl:stylesheet> |