joins2ways_z_ID_Way.xsl 3.7 KB

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