asText.xsl 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns:xs="http://www.w3.org/2001/XMLSchema"
  4. xmlns:bp="https://procesy5.pl/biale_plamy-schema.xsd"
  5. exclude-result-prefixes="xs"
  6. version="2.0">
  7. <xsl:template match="asText">
  8. <xsl:variable name="LINESTRING" select=" substring-before( substring-after(normalize-space(.),'LINESTRING (') , ')') "/>
  9. <!--<test1><xsl:copy-of select="$LINESTRING"/></test1>-->
  10. <xsl:for-each select="tokenize($LINESTRING,',')">
  11. <bp:Path_Point>
  12. <!--<xsl:attribute name="test2" select="."/>-->
  13. <xsl:variable name="pos">
  14. <xsl:for-each select="tokenize(.,' ')">
  15. <pos>
  16. <xsl:attribute name="pos" select="position()"/>
  17. <xsl:value-of select="."/>
  18. </pos>
  19. </xsl:for-each>
  20. </xsl:variable>
  21. <xsl:choose>
  22. <xsl:when test="string-length($pos/pos[@pos=1]/text())&gt;0">
  23. <xsl:attribute name="X" select="$pos/pos[@pos=1]"/>
  24. <xsl:attribute name="Y" select="$pos/pos[@pos=2]"/>
  25. </xsl:when>
  26. <xsl:otherwise>
  27. <xsl:attribute name="X" select="$pos/pos[@pos=2]"/>
  28. <xsl:attribute name="Y" select="$pos/pos[@pos=3]"/>
  29. </xsl:otherwise>
  30. </xsl:choose>
  31. <!--<test3><xsl:copy-of select="$pos"/></test3>-->
  32. </bp:Path_Point>
  33. </xsl:for-each>
  34. </xsl:template>
  35. <xsl:template match="asText" mode="POINT">
  36. <xsl:variable name="LINESTRING" select=" substring-before( substring-after(normalize-space(.),'POINT (') , ')') "/>
  37. <!--<test1><xsl:copy-of select="$LINESTRING"/></test1>-->
  38. <xsl:for-each select="tokenize($LINESTRING,',')">
  39. <bp:Path_Point>
  40. <!--<xsl:attribute name="test2" select="."/>-->
  41. <xsl:variable name="pos">
  42. <xsl:for-each select="tokenize(.,' ')">
  43. <pos>
  44. <xsl:attribute name="pos" select="position()"/>
  45. <xsl:value-of select="."/>
  46. </pos>
  47. </xsl:for-each>
  48. </xsl:variable>
  49. <xsl:choose>
  50. <xsl:when test="string-length($pos/pos[@pos=1]/text())&gt;0">
  51. <xsl:attribute name="X" select="$pos/pos[@pos=1]"/>
  52. <xsl:attribute name="Y" select="$pos/pos[@pos=2]"/>
  53. </xsl:when>
  54. <xsl:otherwise>
  55. <xsl:attribute name="X" select="$pos/pos[@pos=2]"/>
  56. <xsl:attribute name="Y" select="$pos/pos[@pos=3]"/>
  57. </xsl:otherwise>
  58. </xsl:choose>
  59. <!--<test3><xsl:copy-of select="$pos"/></test3>-->
  60. </bp:Path_Point>
  61. </xsl:for-each>
  62. </xsl:template>
  63. </xsl:stylesheet>