joins2ways_z_ID_Way.xsl 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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="ways2drogi.xml" select="'ways2drogi.xml'"/>
  10. <xsl:variable name="ways2drogi" select="doc($ways2drogi.xml)"/>
  11. <xsl:param name="points2joins.xml" select="'points2joins.xml'"/>
  12. <xsl:variable name="points2joins" select="doc($points2joins.xml)"/>
  13. <xsl:param name="joins2ways_z_ID_Way_tempdir" select="'joins2ways_z_ID_Way'"/>
  14. <xsl:template match="joins2ways">
  15. <joins2ways_z_ID_Way>
  16. <!--<xsl:variable name="joins2ways">
  17. <xsl:apply-templates/>
  18. </xsl:variable>-->
  19. <!-- <xsl:for-each select="$joins2ways/item">-->
  20. <!-- <xsl:copy-of select="."/>-->
  21. <!--</xsl:for-each>-->
  22. <xsl:apply-templates/>
  23. </joins2ways_z_ID_Way>
  24. </xsl:template>
  25. <xsl:template match="item">
  26. <xsl:variable name="item" select="."/>
  27. <xsl:variable name="ID_Point" select="$points2joins/points2joins/item[text()= current()/@id]/@id"/>
  28. <xsl:variable name="id" select="@id"/>
  29. <xsl:variable name="items">
  30. <xsl:for-each select="item">
  31. <item>
  32. <xsl:copy-of select="$item/@*"/>
  33. <xsl:attribute name="ID_Way" select="$ways2drogi/ways2drogi/item[@id=current()/text()]/text()"/>
  34. <xsl:if test="$ID_Point">
  35. <xsl:attribute name="ID_Point" select="$ID_Point"/>
  36. </xsl:if>
  37. <xsl:attribute name="item_copied_pos" select="position()"/>
  38. <!-- moze miec wiecej punktow-->
  39. <xsl:for-each select="$points2joins/points2joins/item[text()= $id]">
  40. <Points><xsl:value-of select=" @id"/></Points>
  41. </xsl:for-each>
  42. <xsl:for-each select="$item/item">
  43. <xsl:element name="item">
  44. <xsl:attribute name="id" select="@id"/>
  45. <xsl:attribute name="ID_WAY" select="$ways2drogi/ways2drogi/item[@id=current()/text()]/text()"/>
  46. <xsl:copy-of select="text()"/>
  47. </xsl:element>
  48. </xsl:for-each>
  49. </item>
  50. </xsl:for-each>
  51. </xsl:variable>
  52. <xsl:variable name="items_grouped">
  53. <xsl:for-each-group select="$items/item" group-by="@ID_Way">
  54. <item>
  55. <xsl:copy-of select="@*"/>
  56. <!--<xsl:attribute name="ID_Way_count" select="$ID_Way_count"/>-->
  57. <xsl:copy-of select="item"/>
  58. <xsl:copy-of select="Points"/>
  59. </item>
  60. </xsl:for-each-group>
  61. </xsl:variable>
  62. <xsl:copy-of select="$items_grouped"/>
  63. <xsl:result-document href="{$joins2ways_z_ID_Way_tempdir}/joins2ways_z_ID_Way.{@id}.{@ID_Way}.xml">
  64. <joins2ways_z_ID_Way>
  65. <xsl:attribute name="id" select="@id"/>
  66. <xsl:copy-of select="$items_grouped"/>
  67. </joins2ways_z_ID_Way>
  68. </xsl:result-document>
  69. </xsl:template>
  70. </xsl:stylesheet>