Project

General

Profile

1
<?xml version="1.0" encoding="UTF-8"?>
2
<xsl:stylesheet
3
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4
  xmlns:gml="http://www.opengis.net/gml"
5
  version="1.0">
6
<!--
7
Description:  Convert GML to WKT.
8
Precondition: <coordinates> have been converted to <coords> (using
9
    GmlCoordinates2Coord.xsl).
10
Author:       Cameron Shorter cameron ATshorter.net, Nedjo Rogers nedjo ATgworks.ca
11
Licence:      GPL as per: http://www.gnu.org/copyleft/gpl.html
12

    
13
$Id: 
14
$Name$
15
-->
16
  <xsl:output method="xml" encoding="utf-8"/>
17
  
18
  <!-- Root node -->
19
  <xsl:template match="/">
20
    <js>
21
    <xsl:apply-templates/>
22
    </js>
23
  </xsl:template>
24

    
25
  <!-- Match and render a GML Point -->
26
  <xsl:template match="gml:pointMember/gml:Point | gml:pointProperty/gml:Point">
27
    <xsl:variable name="x0" select="gml:coord/gml:X"/>
28
    <xsl:variable name="y0" select="gml:coord/gml:Y"/>
29
    // Point
30
    objRef.setValue('POINT(<xsl:value-of select="$x0"/> <xsl:value-of select="$y0"/>)');
31
  </xsl:template>
32

    
33

    
34
  <!-- Match and render a LineString -->
35
  <xsl:template match="gml:LineString">
36
    <xsl:text>  objRef.setValue('LINESTRING(</xsl:text>
37
    <xsl:for-each select="gml:coord">
38
      <xsl:value-of select="gml:X"/>
39
      <xsl:text> </xsl:text>
40
      <xsl:value-of select="gml:Y"/>
41
      <xsl:if test="following-sibling::gml:coord">
42
        <xsl:text>,</xsl:text>
43
      </xsl:if>
44
    </xsl:for-each>
45
    <xsl:text>)');</xsl:text>
46
  </xsl:template>
47

    
48
  <xsl:template match="text()|@*"/>
49
  
50
</xsl:stylesheet>
(55-55/145)