grapht.xsl 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. exclude-result-prefixes="xs"
  5. xmlns:grapht="http://biuro.biall-net.pl/xmlschema_procesy5/WPS_Functions/graph_tree/graph_tree.xsd"
  6. xmlns:get_wfs_recurse_xsl="http://biuro.biall-net.pl/xmlschema_procesy5/WPS_Functions/get_wfs_recurse_xsl.xsd"
  7. xmlns:y="http://www.yworks.com/xml/graphml"
  8. xmlns:wfs="http://www.opengis.net/wfs"
  9. xmlns:gml="http://www.opengis.net/gml"
  10. xmlns:xlink="http://www.w3.org/1999/xlink"
  11. xmlns:p5="https://biuro.biall-net.pl/wfs"
  12. version="2.0">
  13. <xsl:output indent="yes"/>
  14. <xsl:strip-space elements="*"/>
  15. <xsl:template match="get_wfs_recurse_xsl:context.PRIMARYKEY|get_wfs_recurse_xsl:nodes" mode="#all"/>
  16. <!--
  17. a.binder Metody optumalizacji wizualizacji danych do weryfikacji czy są gotowe funckje/biblioteki do tego
  18. 1) NearestMiddleShortcut
  19. A - B - C => A - - - C
  20. 2) MiddlePathShortcut
  21. A - B - C - D => A - - - D
  22. 3) MiddleGroup
  23. - C1 - D1 / - D1
  24. A - B + => A [B: C1,C2 ] -
  25. - C2 - D2 \ - D2
  26. 4) CutPath
  27. A - B - C - D => C - D
  28. 5) TypesGroup
  29. A1 - B1 - C1
  30. A2 - B2 - C2 => [ A1, A2, A3 ] = [ B1, B2, B3 ] = [ C1, C2, C3 ]
  31. A3 - B3 - C3
  32. 6) TypesAndFlowsGroup
  33. [ ] - - - - - - [ ]
  34. A1 - B1 - C1 [ A1 ] [ B1 ]- - [ C1 ]
  35. C2 - B2 - A2 => [ B2 ]- - [ A2 ] [ C3 ]
  36. B3 - A3 - C3 [ B3 ] [ A3 ]
  37. mixing this types also
  38. -->
  39. <xsl:function name="wfs:primary_key">
  40. <xsl:param name="xlink:href"/>
  41. <xsl:variable name="tokens" select="count(tokenize($xlink:href,'\.'))"/>
  42. <xsl:value-of select="tokenize($xlink:href,'\.')[$tokens]"/>
  43. </xsl:function>
  44. <xsl:function name="wfs:namespace">
  45. <xsl:param name="xlink:href"/>
  46. <xsl:value-of select=" substring-before($xlink:href,'#')"/>
  47. </xsl:function>
  48. <xsl:function name="wfs:element">
  49. <xsl:param name="xlink:href"/>
  50. <xsl:variable name="element_w_fid" select="substring-after($xlink:href,'#')"/>
  51. <xsl:value-of select="substring-before($element_w_fid,'.')"/>
  52. </xsl:function>
  53. <xsl:function name="wfs:fid">
  54. <xsl:param name="xlink:href"/>
  55. <xsl:value-of select="concat( wfs:element($xlink:href),'.', wfs:primary_key($xlink:href))"/>
  56. </xsl:function>
  57. <xsl:template match="wfs:FeatureCollection" mode="grapht:analyze_nodes">
  58. <grapht:analyze_nodes>
  59. <xsl:for-each-group select=".//*[*|@xlink:href]" group-by="name()">
  60. <xsl:copy copy-namespaces="no">
  61. <xsl:attribute name="grapht:count" select="count(current-group())"/>
  62. <xsl:attribute name="grapht:count.xlink" select="count(current-group()[@xlink:href])"/>
  63. <grapht:analyze_nodes.xlink.rebuild_tree_inputs>
  64. <xsl:for-each select=" current-group()[@xlink:href]" > <!-- -group group-by="@fid" -->
  65. <xsl:sort select="count(ancestor::node())"/>
  66. <xsl:copy copy-namespaces="no">
  67. <xsl:copy-of select="@*"/>
  68. <xsl:variable name="grapht.fid" select="wfs:fid(@xlink:href)"/>
  69. <xsl:attribute name="grapht.fid" select="$grapht.fid"/>
  70. <xsl:attribute name="grapht:ancestor.count" select="count(ancestor::node())"/>
  71. <xsl:apply-templates mode="grapht:analyze_nodes.xlink.rebuild_tree" select="root()//*[*[@fid= $grapht.fid ]]"> <!-- and * -->
  72. <xsl:with-param name="fid" select="$grapht.fid"/>
  73. <xsl:with-param name="root.node" select="root()"/>
  74. </xsl:apply-templates>
  75. </xsl:copy>
  76. </xsl:for-each>
  77. </grapht:analyze_nodes.xlink.rebuild_tree_inputs>
  78. </xsl:copy>
  79. </xsl:for-each-group>
  80. </grapht:analyze_nodes>
  81. </xsl:template>
  82. <xsl:template match="*" mode="grapht:analyze_nodes.xlink.rebuild_tree">
  83. <xsl:param name="fid" required="yes"/>
  84. <xsl:param name="root.node" required="yes"/>
  85. <xsl:copy copy-namespaces="no">
  86. <!--<xsl:element name="{../name()}">-->
  87. <xsl:copy-of select="@*"/>
  88. <!--</xsl:element>-->
  89. </xsl:copy>
  90. </xsl:template>
  91. </xsl:stylesheet>