Jelajahi Sumber

do przkszt geom

a.binder 9 tahun lalu
induk
melakukan
69089a76ff
1 mengubah file dengan 37 tambahan dan 0 penghapusan
  1. 37 0
      SE/dev/php-cli/asText.xsl

+ 37 - 0
SE/dev/php-cli/asText.xsl

@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+    xmlns:xs="http://www.w3.org/2001/XMLSchema"
+    xmlns:bp="https://procesy5.pl/biale_plamy-schema.xsd"
+    exclude-result-prefixes="xs"
+    version="2.0">
+    
+    
+    <xsl:template match="asText">
+        <xsl:variable name="LINESTRING" select=" substring-before( substring-after(normalize-space(.),'LINESTRING (') , ')')  "/>
+        <!--<test1><xsl:copy-of select="$LINESTRING"/></test1>-->
+        <xsl:for-each select="tokenize($LINESTRING,',')">
+            <bp:Path_Point>
+                <!--<xsl:attribute name="test2" select="."/>-->
+                <xsl:variable name="pos">
+                <xsl:for-each select="tokenize(.,' ')">
+                    <pos>
+                        <xsl:attribute name="pos" select="position()"/>
+                        <xsl:value-of select="."/>
+                    </pos>
+                </xsl:for-each>
+                </xsl:variable>
+                <xsl:choose>
+                    <xsl:when test="string-length($pos/pos[@pos=1]/text())&gt;0">
+                        <xsl:attribute name="X" select="$pos/pos[@pos=1]"/>
+                        <xsl:attribute name="Y" select="$pos/pos[@pos=2]"/>
+                    </xsl:when>
+                    <xsl:otherwise>
+                        <xsl:attribute name="X" select="$pos/pos[@pos=2]"/>
+                        <xsl:attribute name="Y" select="$pos/pos[@pos=3]"/>
+                    </xsl:otherwise>
+                </xsl:choose>
+                <!--<test3><xsl:copy-of select="$pos"/></test3>-->
+            </bp:Path_Point>
+        </xsl:for-each>
+    </xsl:template>
+</xsl:stylesheet>