/docs/MyDocs

To get this branch, use:
bzr branch http://darksoft.org/webbzr/docs/MyDocs

« back to all changes in this revision

Viewing changes to Methods/Mapping/xsl/xsl2ogml.xsl

  • Committer: Suren A. Chilingaryan
  • Date: 2009-04-09 03:21:08 UTC
  • Revision ID: csa@dside.dyndns.org-20090409032108-w4edamdh4adrgdu3
import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="UTF-8"?>
 
2
  <!--
 
3
  Version 0.2 by Stefan Keller, http://geoconverter.hsr.ch
 
4
  Original version by Schuyler Erle.
 
5
  Based on OSM REST API 0.5.
 
6
  /-->
 
7
  <xsl:stylesheet xmlns="http://osm.maptools.org/"
 
8
    xmlns:osm="http://www.openstreetmap.org/gml/"
 
9
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 
10
    xmlns:gml="http://www.opengis.net/gml" version="1.0">
 
11
  <xsl:output method="xml"/>
 
12
  <xsl:output indent="yes"/>
 
13
 
 
14
  <xsl:template match="/">
 
15
    <xsl:text>
 
16
</xsl:text>
 
17
    <osm:FeatureCollection>
 
18
      <xsl:for-each select="/osm/way">
 
19
        <xsl:call-template name="way"/>
 
20
      </xsl:for-each>
 
21
      <xsl:text>
 
22
 
 
23
</xsl:text>
 
24
    </osm:FeatureCollection>
 
25
  </xsl:template>
 
26
 
 
27
  <xsl:template match="/osm/way" name="way">
 
28
    <xsl:text>
 
29
 
 
30
</xsl:text>
 
31
    <gml:featureMember>
 
32
      <osm:way fid="{@id}">
 
33
        <osm:id><xsl:value-of select="@id"/></osm:id>
 
34
        <osm:timestamp><xsl:value-of select="@timestamp"/></osm:timestamp>
 
35
        <osm:user><xsl:value-of select="@user"/></osm:user>
 
36
        <osm:geometryProperty>
 
37
          <gml:LineString>
 
38
            <gml:coordinates><xsl:apply-templates select="nd"/></gml:coordinates>
 
39
          </gml:LineString>
 
40
        </osm:geometryProperty>
 
41
        <xsl:apply-templates select="tag"/>
 
42
      </osm:way>
 
43
    </gml:featureMember>
 
44
  </xsl:template>
 
45
 
 
46
  <xsl:key name='nodeById' match='/osm/node' use='@id'/>
 
47
 
 
48
  <xsl:template match="/osm/way/nd">
 
49
    <xsl:variable name='ref' select="@ref"/>
 
50
    <xsl:variable name='node' select='key("nodeById",$ref)'/>
 
51
    <xsl:value-of select="$node/@lon"/>,<xsl:value-of select="$node/@lat"/>
 
52
    <xsl:text> </xsl:text>
 
53
  </xsl:template>
 
54
 
 
55
  <xsl:template match="/osm/way/tag">
 
56
    <xsl:variable name="osm_element" select="translate(@k, translate(@k, 'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ_-.0123456789', ''), '_')"/>
 
57
    <!-- xsl:variable name="osm_element" select="@k"/ -->
 
58
    <xsl:if test="string($osm_element)">
 
59
      <xsl:element name="osm:{$osm_element}">
 
60
        <xsl:value-of select="@v"/>
 
61
      </xsl:element>
 
62
    </xsl:if>
 
63
  </xsl:template>
 
64
 
 
65
  </xsl:stylesheet>