grapht.pattern.1.cluster.1.select.xsl 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496
  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. xmlns:default_db__x3A__BI_audit_ENERGA_PRACOWNICY="https://biuro.biall-net.pl/wfs/default_db/BI_audit_ENERGA_PRACOWNICY"
  13. xmlns:default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI="https://biuro.biall-net.pl/wfs/default_db/BI_audit_ENERGA_RUM_KONTRAHENCI"
  14. xmlns:default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row="https://biuro.biall-net.pl/wfs/default_db/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row"
  15. xmlns:default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object="https://biuro.biall-net.pl/wfs/default_db/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object"
  16. xmlns:default_db__x3A__BI_audit_taxpayer="https://biuro.biall-net.pl/wfs/default_db/BI_audit_taxpayer"
  17. xmlns:default_db__x3A__TERYT_adresy="https://biuro.biall-net.pl/wfs/default_db/TERYT_adresy"
  18. xmlns:default_db__x3A__BI_audit_KRS="https://biuro.biall-net.pl/wfs/default_db/BI_audit_KRS"
  19. xmlns:default_db__x3A__BI_audit_KRS_person="https://biuro.biall-net.pl/wfs/default_db/BI_audit_KRS_person"
  20. xmlns:default_db__x3A__BI_audit_KRS_company="https://biuro.biall-net.pl/wfs/default_db/BI_audit_KRS_company"
  21. xmlns:default_db__x3A__BI_audit_MSIG="https://biuro.biall-net.pl/wfs/default_db/BI_audit_MSIG"
  22. xmlns:default_db__x3A__BI_audit_MSIG_person="https://biuro.biall-net.pl/wfs/default_db/BI_audit_MSIG_person"
  23. xmlns:default_db__x3A__BI_audit_MSIG_company="https://biuro.biall-net.pl/wfs/default_db/BI_audit_MSIG_company"
  24. xmlns:default_db__x3A__BI_audit_MSIG_name="https://biuro.biall-net.pl/wfs/default_db/BI_audit_MSIG_name"
  25. xmlns:default_db__x3A__BI_audit_ENERGA_PRACOWNICY_adresy="https://biuro.biall-net.pl/wfs/default_db/BI_audit_ENERGA_PRACOWNICY_adresy"
  26. xmlns:xp5r="http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache.public/xinclude_p5_recurse/xinclude_p5_recurse.xsd"
  27. version="2.0">
  28. <xsl:output indent="yes"/>
  29. <xsl:strip-space elements="*"/>
  30. <!--<xsl:template match="get_wfs_recurse_xsl:context.PRIMARYKEY|get_wfs_recurse_xsl:nodes" mode="#all"/>-->
  31. <xsl:param name="grapht.temp"/>
  32. <xsl:param name="debug.filter" select="'(9177)|(9177)'"/>
  33. <xsl:param name="grapht.xsl.testing"/>
  34. <xsl:param name="grapht.testing.analyze_nodes.grapht.fid.xml"/>
  35. <!-- zalozenia
  36. grapht:analyze_fid
  37. grapht:analyze_nodes.tree fid="BI_audit_KRS_person.150746"
  38. grapht:analyze_nodes.tree.clousure.searched
  39. search there for range limit - 5? ???
  40. <grapht:path_to grapht:fid="BI_audit_ENERGA_PRACOWNICY_adresy.11"
  41. grapht:path="2"
  42. grapht:node_from="BI_audit_ENERGA_PRACOWNICY.9"/>
  43. -->
  44. <xsl:function name="wfs:primary_key">
  45. <xsl:param name="xlink:href"/>
  46. <xsl:variable name="tokens" select="count(tokenize($xlink:href,'\.'))"/>
  47. <xsl:value-of select="tokenize($xlink:href,'\.')[$tokens]"/>
  48. </xsl:function>
  49. <xsl:function name="wfs:namespace">
  50. <xsl:param name="xlink:href"/>
  51. <xsl:value-of select=" substring-before($xlink:href,'#')"/>
  52. </xsl:function>
  53. <xsl:function name="wfs:element">
  54. <xsl:param name="xlink:href"/>
  55. <xsl:variable name="element_w_fid" select="substring-after($xlink:href,'#')"/>
  56. <xsl:value-of select="substring-before($element_w_fid,'.')"/>
  57. </xsl:function>
  58. <xsl:function name="wfs:fid">
  59. <xsl:param name="xlink:href"/>
  60. <xsl:if test="string-length($xlink:href) &gt;0">
  61. <xsl:value-of select="concat( wfs:element($xlink:href),'.', wfs:primary_key($xlink:href))"/>
  62. </xsl:if>
  63. </xsl:function>
  64. <xsl:template match="@fid" mode="grapht:fid">
  65. <xsl:attribute name="grapht:fid" select="."/>
  66. </xsl:template>
  67. <xsl:template match="@xlink:href" mode="grapht:fid">
  68. <xsl:attribute name="grapht:fid" select="wfs:fid(.)"/>
  69. </xsl:template>
  70. <xsl:template match="@*" mode="grapht:fid"/>
  71. <xsl:template match="wfs:FeatureCollection" mode="grapht:analyze_nodes">
  72. <grapht:analyze_nodes>
  73. <xsl:for-each-group select=".//*[(*|@xlink:href) and not(name()='gml:featureMember')]" group-by="name()">
  74. <xsl:copy copy-namespaces="no">
  75. <xsl:attribute name="grapht:count" select="count(current-group())"/>
  76. <xsl:attribute name="grapht:count.xlink" select="count(current-group()[@xlink:href])"/>
  77. <xp5r:cache xmlns:xp5r="http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache.public/xinclude_p5_recurse/xinclude_p5_recurse.xsd"
  78. xp5r:id="{local-name()}"
  79. xp5r:basedir="{$grapht.temp}"
  80. xp5r:stylesheet="{$grapht.xsl.testing}">
  81. <xp5r:namespace namespace="http://biuro.biall-net.pl/xmlschema_procesy5/WPS_Functions/graph_tree/graph_tree.xsd" name="grapht"/>
  82. <xp5r:namespace namespace="http://www.opengis.net/wfs" name="wfs"/>
  83. <xp5r:namespace namespace="http://www.opengis.net/gml" name="gml"/>
  84. <xp5r:namespace namespace="http://www.w3.org/1999/xlink" name="xlink"/>
  85. <xp5r:param name="debug.filter" value="{$debug.filter}"/>
  86. <xp5r:apply-template mode="grapht:analyze_nodes.xp5r" select=".">
  87. <xp5r:context-node>
  88. <xp5r:for-each-group
  89. select="doc('{$grapht.testing.analyze_nodes.grapht.fid.xml}')/wfs:FeatureCollection//*[(*|@xlink:href) and not(name()='gml:featureMember') and name()='{name()}']"
  90. group-by="name()"/>
  91. </xp5r:context-node>
  92. <!--<xsl:apply-templates mode="grapht:analyze_nodes.xp5r" select="."/>-->
  93. </xp5r:apply-template>
  94. </xp5r:cache>
  95. </xsl:copy>
  96. </xsl:for-each-group>
  97. </grapht:analyze_nodes>
  98. </xsl:template>
  99. <xsl:template match="*" mode="grapht:analyze_nodes.xp5r">
  100. <grapht:analyze_fid><!-- for name grouped -->
  101. <!--<debug.copy>
  102. <xsl:copy>
  103. <xsl:copy-of select="@*"/>
  104. <current.group>
  105. <xsl:copy-of select="current-group()"/>
  106. </current.group>
  107. <current.root>
  108. <xsl:copy-of select="root()"/>
  109. </current.root>
  110. </xsl:copy>
  111. </debug.copy>-->
  112. <!--<xsl:for-each-group select="current-group()[ matches(@p5:primaryKey,$debug.filter) ]" group-by="@fid">-->
  113. <xsl:for-each select="current-group()[ count(descendant::*[* |@xlink:href]) &gt;0 and matches(@p5:primaryKey,$debug.filter) ]"> <!-- FILTER -->
  114. <xsl:message>#136 maching @fid=<xsl:value-of select="@fid"/>; for matches(@p5:primaryKey=<xsl:value-of select="@p5:primaryKey"/>,$debug.filter=<xsl:value-of select="$debug.filter"/>) </xsl:message>
  115. <grapht:analyze_nodes.tree>
  116. <xsl:attribute name="fid" select="@fid"/>
  117. <xsl:attribute name="p5:primaryKey" select="@p5:primaryKey"/>
  118. <xsl:attribute name="xlink:href" select="@xlink:href"/>
  119. <xsl:attribute name="grapht:pos" select="position()"/>
  120. <xsl:variable name="grapht:anchestor.count" select=" count(ancestor::*)"/>
  121. <xsl:attribute name="grapht:anchestor.count" select="$grapht:anchestor.count"/>
  122. <xsl:variable name="grapht:childs.count" select="count(descendant::*[* |@xlink:href])"/>
  123. <xsl:attribute name="grapht:childs.count" select="$grapht:childs.count"/>
  124. <xsl:variable name="grapht:last_child.fid" select="descendant::*[ * | @xlink:href][$grapht:childs.count]/concat(@fid,wfs:fid(@xlink:href))"/>
  125. <xsl:attribute name="grapht:last_child.fid" select="$grapht:last_child.fid"/>
  126. <!--<xsl:attribute name="grapht:root.fid" select=" ancestor::*[@fid][1]/@fid"/>-->
  127. <xsl:apply-templates mode="grapht:fid" select="@*"/>
  128. <!--<xsl:copy copy-namespaces="no">-->
  129. <!--<xsl:attribute name="fid" select="@fid"/>-->
  130. <!--<grapht:analyze_nodes.tree.childs>
  131. <xsl:attribute name="grapht:parent.childs.count" select="$grapht:childs.count"/>
  132. <xsl:attribute name="grapht:parent.ancestor.count" select="count( ancestor::*)"/>
  133. <!-\-<xsl:apply-templates mode="grapht:analyze_nodes.tree.childs" select="descendant::*[*|@xlink:href]">
  134. <xsl:with-param name="grapht:parent.childs.count" select="$grapht:childs.count"/>
  135. <xsl:with-param name="grapht:parent.ancestor.count" select="count(ancestor::*)"/>
  136. <xsl:with-param name="grapht:last_child.fid" select="$grapht:last_child.fid"/>
  137. </xsl:apply-templates>-\->
  138. <!-\-<xsl:for-each-group select="descendant::*[*|@xlink:href]" group-by="concat(@fid,wfs:fid(@xlink:href))">
  139. <xsl:apply-templates mode="grapht:analyze_nodes.tree.childs" select=".">
  140. <xsl:with-param name="grapht:parent.childs.count" select="$grapht:childs.count"/>
  141. <xsl:with-param name="grapht:parent.ancestor.count" select="count(ancestor::*)"/>
  142. <xsl:with-param name="grapht:last_child.fid" select="$grapht:last_child.fid"/>
  143. </xsl:apply-templates>
  144. </xsl:for-each-group>-\->
  145. </grapht:analyze_nodes.tree.childs>-->
  146. <!--<grapht:analyze_nodes.xlink.rebuild_tree_inputs>
  147. <xsl:attribute name="debug">#147 temporary disabled</xsl:attribute>
  148. <!-\-<xsl:for-each select=" current-group()[@xlink:href and matches(@p5:primaryKey,$debug.filter) ]" > <!-\\- -group group-by="@fid" -\\->
  149. <xsl:sort select="count(ancestor::node())"/>
  150. <xsl:copy copy-namespaces="no">
  151. <xsl:copy-of select="@*"/>
  152. <xsl:variable name="grapht.fid" select="wfs:fid(@xlink:href)"/>
  153. <xsl:attribute name="grapht.fid" select="$grapht.fid"/>
  154. <xsl:attribute name="grapht:ancestor.count" select="count(ancestor::node())"/>
  155. <xsl:apply-templates mode="grapht:analyze_nodes.xlink.rebuild_tree" select="root()//*[*[@fid= $grapht.fid ]]"> <!-\\- and * -\\->
  156. <xsl:with-param name="fid" select="$grapht.fid"/>
  157. <xsl:with-param name="root.node" select="root()"/>
  158. </xsl:apply-templates>
  159. </xsl:copy>
  160. </xsl:for-each>-\->
  161. </grapht:analyze_nodes.xlink.rebuild_tree_inputs>-->
  162. <!--</xsl:copy>-->
  163. <grapht:analyze_nodes.tree.clousure.searched>
  164. <xsl:variable name="current.parent.fid" select="@grapht:fid"/>
  165. <xsl:for-each select="root()//*[ not(@grapht:fid = $current.parent.fid) and (* or @xlink:href or @fid) and ( matches(@p5:primaryKey,$debug.filter) )]"> <!-- or matches($current.parent.fid,$debug.filter) FILTER -->
  166. <!--<xsl:message>#280 searching path from <xsl:value-of select="$current.parent.fid"/> to <xsl:value-of select="concat(@fid,wfs:fid(@xlink:href))"/></xsl:message>-->
  167. <grapht:path_to>
  168. <xsl:attribute name="grapht:fid" select="@grapht:fid"/>
  169. <xsl:choose>
  170. <xsl:when test="ancestor::*[@grapht:fid=$current.parent.fid ]">
  171. <!--<xsl:message>#285 parent path found for <xsl:value-of select="$current.parent.fid"/> </xsl:message>-->
  172. <xsl:variable name="curr.ancerstor.count" select="count(ancestor::*)"/>
  173. <xsl:variable name="parent.ancerstor.count" select="ancestor::*[@grapht:fid=$current.parent.fid][1]/count(ancestor::*)"/>
  174. <xsl:attribute name="curr.ancerstor.count" select="$curr.ancerstor.count"/>
  175. <xsl:attribute name="parent.ancerstor.count" select="$parent.ancerstor.count"/>
  176. <xsl:attribute name="grapht:path" select="$curr.ancerstor.count - $parent.ancerstor.count"/>
  177. <xsl:attribute name="grapht:node_from" select="@grapht:fid"/>
  178. </xsl:when>
  179. <xsl:otherwise>
  180. <xsl:apply-templates mode="grapht:analyze_nodes.tree.clousure.searched" select="." >
  181. <xsl:with-param name="current.parent.fid" select="$current.parent.fid"/>
  182. <xsl:with-param name="grapht:fid" select="@grapht:fid"/>
  183. </xsl:apply-templates>
  184. </xsl:otherwise>
  185. </xsl:choose>
  186. </grapht:path_to>
  187. </xsl:for-each>
  188. </grapht:analyze_nodes.tree.clousure.searched>
  189. </grapht:analyze_nodes.tree>
  190. </xsl:for-each>
  191. <!--</xsl:for-each-group>-->
  192. </grapht:analyze_fid>
  193. </xsl:template>
  194. <xsl:template match="*" mode="grapht:analyze_nodes.tree.childs">
  195. <xsl:param name="grapht:parent.childs.count" required="yes"/>
  196. <xsl:param name="grapht:parent.ancestor.count" required="yes"/>
  197. <xsl:param name="grapht:last_child.fid" required="yes"/>
  198. <xsl:variable name="grapht:childs.count" select="count(descendant::*[* |@xlink:href])"/>
  199. <xsl:copy copy-namespaces="no">
  200. <xsl:copy-of select="@*"/>
  201. <xsl:attribute name="grapht:last_child.fid" select="descendant::*[ * | @xlink:href][$grapht:childs.count]/concat(@fid,wfs:fid(@xlink:href))"/>
  202. <xsl:apply-templates mode="grapht:fid" select="@*"/>
  203. <xsl:attribute name="grapht:ancestor.count" select="count(ancestor::*)"/>
  204. <xsl:attribute name="grapht:childs.count" select="$grapht:childs.count"/>
  205. <xsl:attribute name="grapht:parent.ancestor.count" select="$grapht:parent.ancestor.count"/>
  206. <xsl:attribute name="grapht:ancestor.path.len" select="count(ancestor::*) - $grapht:parent.ancestor.count"/>
  207. <xsl:attribute name="grapht:last_child.fid" select="$grapht:last_child.fid"/>
  208. </xsl:copy>
  209. </xsl:template>
  210. <xsl:template match="*[not(@fid or @xlink:href)]" mode="grapht:analyze_nodes.tree.childs"/>
  211. <xsl:template match="*" mode="grapht:analyze_nodes.xlink.rebuild_tree">
  212. <xsl:param name="fid" required="yes"/>
  213. <xsl:param name="root.node" required="yes"/>
  214. <xsl:copy copy-namespaces="no">
  215. <!--<xsl:element name="{../name()}">-->
  216. <xsl:copy-of select="@*"/>
  217. <xsl:apply-templates mode="grapht:fid" select="@*"/>
  218. <!--</xsl:element>-->
  219. </xsl:copy>
  220. </xsl:template>
  221. <!-- todo unique grapht:analyze_nodes.tree.ancestors -->
  222. <xsl:template match="grapht:analyze_nodes" mode="grapht:analyze_nodes.paths">
  223. <grapht:analyze_nodes.paths>
  224. <xsl:apply-templates mode="grapht:analyze_nodes.paths"/>
  225. </grapht:analyze_nodes.paths>
  226. </xsl:template>
  227. <xsl:template match="*" mode="grapht:analyze_nodes.paths">
  228. <xsl:copy copy-namespaces="no">
  229. <xsl:copy-of select="@*"/>
  230. <xsl:apply-templates mode="grapht:fid" select="@*"/>
  231. <xsl:apply-templates mode="grapht:analyze_nodes.paths"/>
  232. </xsl:copy>
  233. </xsl:template>
  234. <xsl:template match="gml:featureMember" mode="grapht:analyze_nodes.paths grapht:analyze_nodes.paths.unique"/>
  235. <xsl:template match="grapht:analyze_fid" mode="grapht:analyze_nodes.paths">
  236. <!-- szukam unkalnych parentow jakie mam, z najkrotsza sciezka
  237. , a potem szukam dla nich jakie oni maja dzieci unikalne, najkrotsze sciezki
  238. -->
  239. <xsl:message>#217 running grapht:analyze_nodes.paths with debug.filter=<xsl:value-of select="$debug.filter"/></xsl:message>
  240. <xsl:copy copy-namespaces="no">
  241. <xsl:copy-of select="@*"/>
  242. <xsl:for-each select="grapht:analyze_nodes.tree" > <!-- group-by="@fid" -->
  243. <xsl:message>#221 foreach grapht:analyze_nodes.tree @grapht:fid=<xsl:value-of select="@grapht:fid"/>; @grapht:pos=<xsl:value-of select="@grapht:pos"/>; group-by="@fid"=<xsl:value-of select="@fid"/>; @p5:primaryKey=<xsl:value-of select="@p5:primaryKey"/>; </xsl:message>
  244. <xsl:variable name="current.parent.fid" select="@grapht:fid"/>
  245. <xsl:variable name="current.parent.pos" select="@grapht:pos"/>
  246. <xsl:variable name="grapht:last_child.fid" select="@grapht:last_child.fid"/>
  247. <xsl:variable name="grapht:anchestor.count" select="@grapht:anchestor.count"/>
  248. <xsl:copy copy-namespaces="no">
  249. <xsl:copy-of select="@*"/>
  250. <grapht:analyze_nodes.tree.clousure>
  251. <!--<xsl:attribute name="debug.288"> looking for @grapht:last_child.fid=$grapht:last_child.fid = <xsl:value-of select="$grapht:last_child.fid"/> ] </xsl:attribute>-->
  252. <xsl:for-each select="root()//grapht:analyze_nodes.tree[not(@grapht:fid = $current.parent.fid) and @grapht:last_child.fid=$grapht:last_child.fid and ( matches(@p5:primaryKey,$debug.filter) or matches($current.parent.fid,$debug.filter) ) ]"> <!-- FILTER -->
  253. <grapht:path>
  254. <xsl:attribute name="grapht:path.len" select="$grapht:anchestor.count - number(@grapht:anchestor.count) "/>
  255. <xsl:attribute name="grapht:fid" select="@grapht:fid"/>
  256. <xsl:copy-of select="@*"/>
  257. </grapht:path>
  258. </xsl:for-each>
  259. </grapht:analyze_nodes.tree.clousure>
  260. </xsl:copy>
  261. </xsl:for-each>
  262. </xsl:copy>
  263. </xsl:template>
  264. <!--<xsl:template match="grapht:analyze_fid" mode="grapht:analyze_nodes.paths">
  265. <!-\- szukam unkalnych parentow jakie mam, z najkrotsza sciezka
  266. , a potem szukam dla nich jakie oni maja dzieci unikalne, najkrotsze sciezki
  267. -\->
  268. <xsl:message>#217 running grapht:analyze_nodes.paths with debug.filter=<xsl:value-of select="$debug.filter"/></xsl:message>
  269. <xsl:copy copy-namespaces="no">
  270. <xsl:copy-of select="@*"/>
  271. <xsl:for-each select="grapht:analyze_nodes.tree" > <!-\- group-by="@fid" -\->
  272. <xsl:message>#221 foreach grapht:analyze_nodes.tree @grapht:fid=<xsl:value-of select="@grapht:fid"/>; @grapht:pos=<xsl:value-of select="@grapht:pos"/>; group-by="@fid"=<xsl:value-of select="@fid"/>; @p5:primaryKey=<xsl:value-of select="@p5:primaryKey"/>; </xsl:message>
  273. <xsl:variable name="current.parent.fid" select="@grapht:fid"/>
  274. <xsl:variable name="current.parent.pos" select="@grapht:pos"/>
  275. <xsl:copy copy-namespaces="no">
  276. <xsl:copy-of select="@*"/>
  277. <grapht:analyze_nodes.tree.ancestors>
  278. <xsl:for-each select="grapht:analyze_nodes.tree.childs/*[ matches(@p5:primaryKey,$debug.filter) ]" ><!-\-group-by="@fid" FILTERING -\->
  279. <xsl:sort select="@grapht:fid"/>
  280. <xsl:variable name="current.analyze_nodes.tree.ancestors.fid" select="@grapht:fid"/>
  281. <!-\-<xsl:variable name="current.analyze_nodes.tree.ancestors.pos" select="@grapht:pos"/>-\->
  282. <xsl:message>#245 current.analyze_nodes.tree.ancestors.fid=<xsl:value-of select="@grapht:fid"/>; <!-\-@grapht:pos=<xsl:value-of select="@grapht:pos"/>;-\-></xsl:message>
  283. <!-\- grapht:ancestor.path.len -\->
  284. <xsl:copy copy-namespaces="no">
  285. <xsl:copy-of select="@*"/>
  286. <grapht:analyze_nodes.tree.childs.paths.to_childs>
  287. <!-\- <xsl:for-each select="current-group()">
  288. <xsl:copy copy-namespaces="no">
  289. <xsl:copy-of select="@*"/>-\->
  290. <grapht:analyze_nodes.tree.childs.paths.to_childs.childs>
  291. <xsl:attribute name="debug">#223 dla znalezionych ojcow, szukam innych dzieci </xsl:attribute>
  292. <xsl:for-each select="root()//grapht:analyze_fid/grapht:analyze_nodes.tree[not(@grapht:fid=$current.parent.fid)]/grapht:analyze_nodes.tree.childs/*[@grapht:fid = $current.analyze_nodes.tree.ancestors.fid and matches(@p5:primaryKey,$debug.filter)]"> <!-\- FILTER -\->
  293. <xsl:copy copy-namespaces="no">
  294. <xsl:copy-of select="@*"/>
  295. <!-\-<xsl:for-each select="ancestor::*">
  296. <ancestor>
  297. <xsl:copy copy-namespaces="no">
  298. <xsl:copy-of select="@*"/>
  299. </xsl:copy>
  300. </ancestor>
  301. </xsl:for-each>-\->
  302. </xsl:copy>
  303. </xsl:for-each>
  304. </grapht:analyze_nodes.tree.childs.paths.to_childs.childs>
  305. <!-\-</xsl:copy>
  306. </xsl:for-each>-\->
  307. </grapht:analyze_nodes.tree.childs.paths.to_childs>
  308. </xsl:copy>
  309. </xsl:for-each>
  310. </grapht:analyze_nodes.tree.ancestors>
  311. </xsl:copy>
  312. </xsl:for-each>
  313. </xsl:copy>
  314. </xsl:template>-->
  315. <!--<xsl:template match="grapht:analyze_fid" mode="grapht:analyze_nodes.paths">
  316. <!-\- szukam unkalnych parentow jakie mam, z najkrotsza sciezka
  317. , a potem szukam dla nich jakie oni maja dzieci unikalne, najkrotsze sciezki
  318. -\->
  319. <xsl:message>#217 running grapht:analyze_nodes.paths with debug.filter=<xsl:value-of select="$debug.filter"/></xsl:message>
  320. <xsl:copy copy-namespaces="no">
  321. <xsl:copy-of select="@*"/>
  322. <xsl:for-each select="grapht:analyze_nodes.tree" > <!-\- group-by="@fid" -\->
  323. <xsl:message>#221 foreach grapht:analyze_nodes.tree @grapht:fid=<xsl:value-of select="@grapht:fid"/>; @grapht:pos=<xsl:value-of select="@grapht:pos"/>; group-by="@fid"=<xsl:value-of select="@fid"/>; @p5:primaryKey=<xsl:value-of select="@p5:primaryKey"/>; </xsl:message>
  324. <xsl:variable name="current.parent.fid" select="@grapht:fid"/>
  325. <xsl:variable name="current.parent.pos" select="@grapht:pos"/>
  326. <xsl:copy copy-namespaces="no">
  327. <xsl:copy-of select="@*"/>
  328. <grapht:analyze_nodes.tree.ancestors>
  329. <xsl:for-each select="grapht:analyze_nodes.tree.childs/*[ matches(@p5:primaryKey,$debug.filter) ]" ><!-\-group-by="@fid" FILTERING -\->
  330. <xsl:sort select="@grapht:fid"/>
  331. <xsl:variable name="current.analyze_nodes.tree.ancestors.fid" select="@grapht:fid"/>
  332. <!-\-<xsl:variable name="current.analyze_nodes.tree.ancestors.pos" select="@grapht:pos"/>-\->
  333. <xsl:message>#245 current.analyze_nodes.tree.ancestors.fid=<xsl:value-of select="@grapht:fid"/>; <!-\-@grapht:pos=<xsl:value-of select="@grapht:pos"/>;-\-></xsl:message>
  334. <!-\- grapht:ancestor.path.len -\->
  335. <xsl:copy copy-namespaces="no">
  336. <xsl:copy-of select="@*"/>
  337. <grapht:analyze_nodes.tree.childs.paths.to_childs>
  338. <!-\- <xsl:for-each select="current-group()">
  339. <xsl:copy copy-namespaces="no">
  340. <xsl:copy-of select="@*"/>-\->
  341. <grapht:analyze_nodes.tree.childs.paths.to_childs.childs>
  342. <xsl:attribute name="debug">#223 dla znalezionych ojcow, szukam innych dzieci </xsl:attribute>
  343. <xsl:for-each select="root()//grapht:analyze_fid/grapht:analyze_nodes.tree[not(@grapht:fid=$current.parent.fid)]/grapht:analyze_nodes.tree.childs/*[@grapht:fid = $current.analyze_nodes.tree.ancestors.fid and matches(@p5:primaryKey,$debug.filter)]"> <!-\- FILTER -\->
  344. <xsl:copy copy-namespaces="no">
  345. <xsl:copy-of select="@*"/>
  346. <!-\-<xsl:for-each select="ancestor::*">
  347. <ancestor>
  348. <xsl:copy copy-namespaces="no">
  349. <xsl:copy-of select="@*"/>
  350. </xsl:copy>
  351. </ancestor>
  352. </xsl:for-each>-\->
  353. </xsl:copy>
  354. </xsl:for-each>
  355. </grapht:analyze_nodes.tree.childs.paths.to_childs.childs>
  356. <!-\-</xsl:copy>
  357. </xsl:for-each>-\->
  358. </grapht:analyze_nodes.tree.childs.paths.to_childs>
  359. </xsl:copy>
  360. </xsl:for-each>
  361. </grapht:analyze_nodes.tree.ancestors>
  362. </xsl:copy>
  363. </xsl:for-each>
  364. </xsl:copy>
  365. </xsl:template>-->
  366. <!--<xsl:template match="*" mode="grapht:analyze_nodes.paths.analyze_fid">
  367. <xsl:copy copy-namespaces="no">
  368. <xsl:copy-of select="@*"/>
  369. <!-\- szukam unkalnych parentow jakie mam, z najkrotsza sciezka
  370. , a potem szukam dla nich jakie oni maja dzieci unikalne, najkrotsze sciezki
  371. -\->
  372. <xsl:for-each-group select=""></xsl:for-each-group>
  373. </xsl:copy>
  374. </xsl:template>-->
  375. <xsl:template match="*" mode="grapht:analyze_nodes.grapht.fid">
  376. <xsl:copy copy-namespaces="no">
  377. <xsl:copy-of select="@*"/>
  378. <xsl:apply-templates mode="grapht:fid" select="@*"/>
  379. <xsl:apply-templates mode="#current"/>
  380. </xsl:copy>
  381. </xsl:template>
  382. <xsl:template match="grapht:analyze_nodes.paths" mode="grapht:analyze_nodes.paths.unique">
  383. <grapht:analyze_nodes.paths.unique>
  384. <xsl:apply-templates mode="#current"/>
  385. </grapht:analyze_nodes.paths.unique>
  386. </xsl:template>
  387. <xsl:template match="*" mode="grapht:analyze_nodes.paths.unique">
  388. <xsl:copy copy-namespaces="no">
  389. <xsl:copy-of select="@*"/>
  390. <xsl:apply-templates mode="grapht:fid" select="@*"/>
  391. <xsl:apply-templates mode="grapht:analyze_nodes.paths.unique"/>
  392. </xsl:copy>
  393. </xsl:template>
  394. <xsl:template match="grapht:analyze_fid" mode="grapht:analyze_nodes.paths.unique">
  395. <xsl:copy copy-namespaces="no">
  396. <xsl:copy-of select="@*"/>
  397. <xsl:for-each select="grapht:analyze_nodes.tree">
  398. <xsl:copy copy-namespaces="no">
  399. <xsl:copy-of select="@*"/>
  400. <xsl:variable name="grapht:anchestor.count" select="@grapht:anchestor.count"/>
  401. <xsl:variable name="current.parent.fid" select="@grapht:fid"/>
  402. <xsl:message>#437 mode grapht:analyze_nodes.paths.unique @grapht:fid=<xsl:value-of select="@grapht:fid"/>; </xsl:message>
  403. <xsl:copy-of select="grapht:analyze_nodes.tree.clousure"/>
  404. <grapht:analyze_nodes.tree.clousure.referred>
  405. <xsl:attribute name="debug.452.current.parent.fid" select="$current.parent.fid"/>
  406. <xsl:attribute name="grapht:anchestor.count" select="$grapht:anchestor.count"/>
  407. <xsl:for-each select="root()//*[grapht:analyze_nodes.tree.clousure[grapht:path[@grapht:fid = $current.parent.fid]]]">
  408. <xsl:copy copy-namespaces="no">
  409. <xsl:attribute name="grapht:path.len" select=" number($grapht:anchestor.count) - number(@grapht:anchestor.count)"/>
  410. <xsl:copy-of select="@*"/>
  411. </xsl:copy>
  412. </xsl:for-each>
  413. </grapht:analyze_nodes.tree.clousure.referred>
  414. </xsl:copy>
  415. </xsl:for-each>
  416. </xsl:copy>
  417. </xsl:template>
  418. <xsl:template match="*" mode="grapht:analyze_nodes.tree.clousure.searched">
  419. <xsl:param name="current.parent.fid" required="yes"/>
  420. <xsl:param name="grapht:fid" required="yes"/>
  421. <xsl:param name="grapht:path" select="1"/>
  422. <xsl:choose>
  423. <xsl:when test="descendant-or-self::*[@grapht:fid=$current.parent.fid ]">
  424. <xsl:attribute name="grapht:path" select="$grapht:path"/>
  425. <xsl:attribute name="grapht:node_from" select="@grapht:fid"/>
  426. </xsl:when>
  427. <xsl:otherwise>
  428. <!--<xsl:message>#552 going parent to search by grapht:path=<xsl:value-of select="$grapht:path"/>;</xsl:message>-->
  429. <xsl:apply-templates mode="grapht:analyze_nodes.tree.clousure.searched" select="parent::node()">
  430. <xsl:with-param name="current.parent.fid" select="$current.parent.fid"/>
  431. <xsl:with-param name="grapht:fid" select="$grapht:fid"/>
  432. <xsl:with-param name="grapht:path" select="number($grapht:path) + 1"/>
  433. </xsl:apply-templates>
  434. </xsl:otherwise>
  435. </xsl:choose>
  436. </xsl:template>
  437. </xsl:stylesheet>