joins2ways_z_ID_Way.xsl 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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:output indent="yes"/>
  8. <xsl:strip-space elements="*"/>
  9. <xsl:param name="ways_2ID_Way.xml" select="'ways_2ID_Way.xml'"/>
  10. <xsl:variable name="ways_2ID_Way" select="doc($ways_2ID_Way.xml)"/>
  11. <xsl:variable name="points2joins" select="doc('points2joins.xml')"/>
  12. <xsl:template match="joins2ways">
  13. <joins2ways_z_ID_Way>
  14. <xsl:variable name="joins2ways">
  15. <xsl:apply-templates/>
  16. </xsl:variable>
  17. <xsl:for-each select="$joins2ways/item">
  18. <xsl:sort select="number(@ID_Way)"/>
  19. <xsl:copy-of select="."/>
  20. </xsl:for-each>
  21. </joins2ways_z_ID_Way>
  22. </xsl:template>
  23. <xsl:template match="item">
  24. <item>
  25. <xsl:copy-of select="@*"/>
  26. <xsl:if test="$ways_2ID_Way/ways_2ID_Way/item[@id=current()/item[1]/text()]/text()">
  27. <xsl:attribute name="ID_Way" select="$ways_2ID_Way/ways_2ID_Way/item[@id=current()/item[1]/text()]/text()"/>
  28. </xsl:if>
  29. <xsl:if test="$points2joins/points2joins/item[text()= current()/@id]">
  30. <xsl:attribute name="ID_Point" select="$points2joins/points2joins/item[text()= current()/@id]/text()"/>
  31. </xsl:if>
  32. <xsl:for-each select="item">
  33. <xsl:element name="item">
  34. <xsl:attribute name="id" select="@id"/>
  35. <xsl:attribute name="ID_WAY" select="$ways_2ID_Way/ways_2ID_Way/item[@id=current()/text()]/text()"/>
  36. <xsl:copy-of select="text()"/>
  37. </xsl:element>
  38. </xsl:for-each>
  39. </item>
  40. </xsl:template>
  41. </xsl:stylesheet>