edge_paths_with_PE_controll.xsl 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  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:import href="PE_wariant_bit_table.xsl"/>
  8. <xsl:output indent="yes"/>
  9. <xsl:strip-space elements="*"/>
  10. <xsl:param name="PE_Price" select="1500"/>
  11. <xsl:param name="Cable_Price" select="10"/>
  12. <xsl:param name="edge_paths_with_PE.xml"/>
  13. <!-- bedziemy od najdluzszej drogi starac sie rozmiescic PE w oparciu o rozmieszczenie klientow oraz odleglosci -->
  14. <xsl:template match="edge_joins_filled_paths">
  15. <xsl:variable name="edge_joins_filled_paths_len">
  16. <xsl:for-each select="item">
  17. <xsl:sort select="number(asText/@len)" order="descending"/>
  18. <Path>
  19. <xsl:attribute name="id" select="@id"/>
  20. <xsl:attribute name="len" select="asText/@len"/>
  21. <xsl:attribute name="Points_cnt" select="asText/@Points_cnt"/>
  22. </Path>
  23. </xsl:for-each>
  24. </xsl:variable>
  25. <xsl:variable name="edge_paths_with_PE_controll">
  26. <edge_paths_with_PE_controll>
  27. <xsl:apply-templates select="$edge_joins_filled_paths_len" mode="PointMatrixGroup"/>
  28. </edge_paths_with_PE_controll>
  29. </xsl:variable>
  30. <xsl:copy-of select="$edge_paths_with_PE_controll"/>
  31. <xsl:result-document href="edge_paths_with_PE.xml">
  32. <xsl:apply-templates select="$edge_paths_with_PE_controll" mode="edge_paths_with_PE.xml"/>
  33. </xsl:result-document>
  34. </xsl:template>
  35. <xsl:template match="edge_paths_with_PE_controll" mode="edge_paths_with_PE.xml">
  36. <PE_candidates_dump>
  37. <xsl:apply-templates mode="edge_paths_with_PE.xml"/>
  38. </PE_candidates_dump>
  39. </xsl:template>
  40. <xsl:template match="Path" mode="edge_paths_with_PE.xml">
  41. <LINESTRING>
  42. <xsl:attribute name="ID_Way" select="@id"/>
  43. <xsl:attribute name="Count" select="@Count"/>
  44. <xsl:attribute name="ID_Point_count" select="@Points_cnt"/>
  45. <xsl:attribute name="distance"/>
  46. <xsl:attribute name="dumb_frequency" select="''"/>
  47. <xsl:apply-templates mode="edge_paths_with_PE.xml"/>
  48. </LINESTRING>
  49. </xsl:template>
  50. <xsl:template match="PointMatrixGroupPE" mode="edge_paths_with_PE.xml">
  51. <xsl:apply-templates mode="edge_paths_with_PE.xml"/>
  52. </xsl:template>
  53. <xsl:template match="PointMatrixGroup" mode="edge_paths_with_PE.xml">
  54. <!--<test_matrux><xsl:copy-of select="."></xsl:copy-of></test_matrux>-->
  55. <xsl:apply-templates mode="edge_paths_with_PE.xml"/>
  56. </xsl:template>
  57. <xsl:template match="odpalam_liczenie" mode="edge_paths_with_PE.xml">
  58. <xsl:apply-templates mode="edge_paths_with_PE.xml"/>
  59. </xsl:template>
  60. <xsl:template match="koniec_wariantow" mode="edge_paths_with_PE.xml">
  61. <xsl:apply-templates mode="edge_paths_with_PE.xml"/>
  62. </xsl:template>
  63. <xsl:template match="bp:Path_Point" mode="edge_paths_with_PE.xml">
  64. <xsl:copy-of select="."/>
  65. </xsl:template>
  66. <xsl:template match="variant" mode="edge_paths_with_PE.xml"/>
  67. <xsl:template match="Path" mode="PointMatrixGroup">
  68. <Path>
  69. <xsl:variable name="edge_joins_filled_path" select=" doc(concat('edge_joins_filled_paths/edge_joins_filled_paths.',@id,'.xml'))"/>
  70. <xsl:attribute name="id" select="@id"/>
  71. <xsl:attribute name="Points_cnt" select="@Points_cnt"/>
  72. <xsl:variable name="Points_cnt" select="@Points_cnt"/>
  73. <xsl:attribute name="len" select="@len"/>
  74. <xsl:attribute name="Count" select="count($edge_joins_filled_path/edge_joins_filled_paths_xml/asText_XMl/LineString)"/>
  75. <xsl:variable name="len" select="@len"/>
  76. <!--<xsl:variable name="edge_joins_filled_paths" select="collection( 'edge_joins_filled_paths?select=*.xml;recurse=yes')"/>-->
  77. <!--<EdgeWayJoinsPair>
  78. <xsl:copy-of select="$edge_joins_filled_path"></xsl:copy-of>
  79. </EdgeWayJoinsPair>-->
  80. <!-- liczmy najwieksza roznice odleglosci miedzy punktami -->
  81. <!-- rozmieszczamy prawidlowo PE na danej trasie -->
  82. <xsl:variable name="EconomicDistanceCut">
  83. <EconomicDistanceCut>
  84. <xsl:for-each select="$edge_joins_filled_path/edge_joins_filled_paths_xml/asText_XMl/LineString">
  85. <distance>
  86. <xsl:attribute name="pos" select="position()"/>
  87. <xsl:attribute name="not_id" select="@not_id"/>
  88. <xsl:attribute name="len" select="@len"/>
  89. <xsl:attribute name="id_path" select="@id_path"/>
  90. <xsl:attribute name="Points" select="count(Points)"/>
  91. <xsl:variable name="Points" select="count(Points)"/>
  92. <xsl:variable name="Ways" select="count(Ways)"/>
  93. <xsl:choose>
  94. <xsl:when test="$Ways or $Points">
  95. <xsl:attribute name="point_count" select="$Points + $Ways"/>
  96. </xsl:when>
  97. </xsl:choose>
  98. </distance>
  99. </xsl:for-each>
  100. </EconomicDistanceCut>
  101. </xsl:variable>
  102. <!--<xsl:copy-of select="$EconomicDistanceCut"/>-->
  103. <xsl:variable name="EconomicDistanceCut2">
  104. <EconomicDistanceCut2>
  105. <xsl:for-each select="$EconomicDistanceCut/EconomicDistanceCut/distance">
  106. <distance2>
  107. <xsl:attribute name="distance" select="sum( $EconomicDistanceCut/EconomicDistanceCut/distance[number(@pos )&lt; number(current()/@pos )]/@len)"/>
  108. <!-- suma do poprzedniego pkt tylko dla tych co maja pkt-->
  109. <xsl:choose>
  110. <xsl:when test="@point_count&gt;0">
  111. <xsl:variable name="max_pos_z_pkt" select="max($EconomicDistanceCut/EconomicDistanceCut/distance[
  112. number(@pos )&lt; number(current()/@pos ) and number(@point_count)&gt;0
  113. ]/@pos)"/>
  114. <xsl:attribute name="max_pos_z_pkt" select="$max_pos_z_pkt"/>
  115. <xsl:variable name="disttopkt" select="sum( $EconomicDistanceCut/EconomicDistanceCut/distance[
  116. number(@pos )&lt; number(current()/@pos )
  117. and number(@pos) &gt;= number($max_pos_z_pkt)
  118. ]/@len)"/>
  119. <xsl:attribute name="disttopkt" select="$disttopkt" />
  120. <xsl:variable name="cost_dist" select="$Cable_Price * $disttopkt * @point_count"/>
  121. <xsl:attribute name="cost_dist" select="$cost_dist"/>
  122. <xsl:attribute name="point_count" select="@point_count"/>
  123. <xsl:if test="$cost_dist &gt; $PE_Price">
  124. <xsl:attribute name="cut_by_pe" select="1"/>
  125. </xsl:if>
  126. <xsl:attribute name="not_id" select="@not_id"/>
  127. </xsl:when>
  128. <xsl:otherwise>
  129. <xsl:attribute name="point_count" select="0"/>
  130. </xsl:otherwise>
  131. </xsl:choose>
  132. <xsl:attribute name="id_path" select="@id_path"/>
  133. <xsl:copy-of select="@point_count"/>
  134. <xsl:copy-of select="@pos"/>
  135. <xsl:copy-of select="@len"/>
  136. </distance2>
  137. </xsl:for-each>
  138. </EconomicDistanceCut2>
  139. </xsl:variable>
  140. <xsl:copy-of select="$EconomicDistanceCut2"/>
  141. <xsl:variable name="elements_cnt" select="count($EconomicDistanceCut2/EconomicDistanceCut2/distance2[@point_count &gt; 0])"/><!-- liczba wezlow potencjalnych licbza PE-->
  142. <xsl:variable name="bit_max" select="round($len div ( $PE_Price div $Cable_Price ) + count($EconomicDistanceCut2/EconomicDistanceCut2/distance2[@cost_dist &gt; $PE_Price]) )"/><!-- max licbza PE-->
  143. <!-- pogrupujemy elementy co 50 metrow -->
  144. <xsl:variable name="PointMatrixGroup">
  145. <PointMatrixGroup>
  146. <xsl:for-each-group select="$EconomicDistanceCut2/EconomicDistanceCut2/distance2" group-by="round( @distance div ( $PE_Price div $Cable_Price + 50 ))">
  147. <PointMatrixGroupPos>
  148. <xsl:variable name="elements_cnt_Pos" select="count(current-group()[@point_count &gt; 0])"/>
  149. <xsl:variable name="bit_max_Pos" select="round(sum( current-group()/@disttopkt ) div ( $PE_Price div 20 ) )"/>
  150. <xsl:attribute name="distanceGr" select=" current-grouping-key()"/>
  151. <xsl:attribute name="elements_cnt_Pos" select="$elements_cnt_Pos"/>
  152. <xsl:attribute name="bit_max_Pos" select="$bit_max_Pos"/>
  153. <xsl:attribute name="id_path" select="@id_path"/>
  154. <xsl:attribute name="point_count_Pos" select="sum(current-group()/@point_count)"/>
  155. <xsl:attribute name="LineStringCount" select="count( current-group())"/>
  156. <xsl:attribute name="len_sum" select="sum(current-group()/@len)"/>
  157. <xsl:attribute name="distanceBeg" select="min(current-group()/number(@distance))"/>
  158. <xsl:attribute name="distanceEnd" select="max(current-group()/number(@distance))"/>
  159. <!--<xsl:attribute name="GroupPos" select="position()"/>-->
  160. <xsl:for-each select="current-group()">
  161. <distance2>
  162. <xsl:attribute name="PosMatrGroup" select="position()"/>
  163. <xsl:copy-of select="@*"></xsl:copy-of>
  164. </distance2>
  165. </xsl:for-each>
  166. </PointMatrixGroupPos>
  167. </xsl:for-each-group>
  168. </PointMatrixGroup>
  169. </xsl:variable>
  170. <!-- wsadzamy PE w grupach i moze w kilku wariantach - najlepiej tam gdzie jest najwiecej klientow najpierw
  171. gdzie najwiecej klientow walimy wezly - grupujemy ilosciami klientow dzielac sume drogi na ilosc przewidzianych wezlow
  172. -->
  173. <!-- debug -->
  174. <xsl:copy-of select="$PointMatrixGroup"/>
  175. <PointMatrixGroupPE>
  176. <xsl:for-each select="$PointMatrixGroup/PointMatrixGroup">
  177. <xsl:for-each select="PointMatrixGroupPos">
  178. <xsl:variable name="bit_max_Pos" select="@bit_max_Pos"/>
  179. <xsl:variable name="point_count_Pos" select="@point_count_Pos"/>
  180. <xsl:variable name="distanceGr" select="@distanceGr"/>
  181. <PointMatrixGroup>
  182. <xsl:attribute name="bit_max_Pos" select="$bit_max_Pos"/><xsl:attribute name="point_count_Pos" select="$point_count_Pos"/><xsl:attribute name="distanceGr" select="$distanceGr"/>
  183. <xsl:attribute name="LineStringCount" select="@LineStringCount"/>
  184. <xsl:attribute name="len_sum" select="@len_sum"/>
  185. <xsl:attribute name="point_count_Pos" select="@point_count_Pos"/>
  186. <xsl:attribute name="distanceBeg" select="@distanceBeg"/>
  187. <xsl:attribute name="distanceEnd" select="@distanceEnd"/>
  188. <!-- ida kandydaci -->
  189. <xsl:variable name="candidates">
  190. <xsl:for-each select="distance2[( position() &lt;= $bit_max_Pos and @point_count &gt;0 ) or ( position()=1 and $point_count_Pos &gt; 0 ) or position()= last()]"> <!-- jak jest maly wspolczynnik to chociaz jeden punkt jak sa punkty jakies w tej grupie -->
  191. <xsl:sort select="@cost_dist" order="descending"/>
  192. <bp:Path_Point>
  193. <xsl:attribute name="DebugPosPoint" select="position()"/>
  194. <xsl:attribute name="PosMatrGroup" select="@PosMatrGroup"/>
  195. <xsl:attribute name="distanceGr" select="$distanceGr"/>
  196. <xsl:attribute name="pos" select="@pos"/>
  197. <xsl:attribute name="len" select="@len"/>
  198. <xsl:attribute name="distance" select="@distance"/>
  199. <xsl:attribute name="cost_dist" select="@cost_dist"/>
  200. <xsl:attribute name="id_path" select="@id_path"/>
  201. <xsl:attribute name="point_count" select="@point_count"/>
  202. <xsl:attribute name="X" select="$edge_joins_filled_path/edge_joins_filled_paths_xml/asText_XMl/LineString[@id_path = current()/@id_path]/@X"/>
  203. <xsl:attribute name="Y" select="$edge_joins_filled_path/edge_joins_filled_paths_xml/asText_XMl/LineString[@id_path = current()/@id_path]/@Y"/>
  204. </bp:Path_Point>
  205. </xsl:for-each>
  206. </xsl:variable>
  207. <xsl:choose>
  208. <xsl:when test="count($candidates/bp:Path_Point) &lt; 10 and count($candidates/bp:Path_Point)&gt;1">
  209. <xsl:variable name="max_bit">
  210. <xsl:for-each select="1 to count($candidates/bp:Path_Point)"><xsl:value-of select="1"/></xsl:for-each>
  211. </xsl:variable>
  212. <odpalam_liczenie>
  213. <xsl:call-template name="calculate_optimum">
  214. <xsl:with-param name="candidates" select="$candidates"/>
  215. <xsl:with-param name="elements_cnt" select="count($candidates/bp:Path_Point)"/>
  216. <xsl:with-param name="max_bit" select="$max_bit"/>
  217. </xsl:call-template>
  218. </odpalam_liczenie>
  219. </xsl:when>
  220. <xsl:otherwise>
  221. <xsl:copy-of select="$candidates"></xsl:copy-of>
  222. </xsl:otherwise>
  223. </xsl:choose>
  224. </PointMatrixGroup>
  225. </xsl:for-each>
  226. </xsl:for-each>
  227. </PointMatrixGroupPE>
  228. <!--<PointMatrix>
  229. <xsl:attribute name="bit_max" select="$bit_max"/>
  230. <xsl:attribute name="elements_cnt" select="$elements_cnt"/>
  231. <xsl:attribute name="num_extr" select="count($EconomicDistanceCut2/EconomicDistanceCut2/distance2[@cost_dist &gt; $PE_Price])"/>
  232. <!-\-<xsl:call-template name="PE_wariant">
  233. <xsl:with-param name="elements_cnt" select="$elements_cnt"/>
  234. <xsl:with-param name="bit_max" select="$bit_max"/>
  235. </xsl:call-template>-\->
  236. </PointMatrix>-->
  237. </Path>
  238. </xsl:template>
  239. <xsl:template name="calculate_optimum">
  240. <xsl:param name="candidates" required="yes"/>
  241. <xsl:param name="elements_cnt" required="yes"/>
  242. <xsl:param name="variant" select="1"/>
  243. <xsl:param name="max_bit" required="yes"/>
  244. <xsl:param name="best_cost"/><xsl:param name="best_variant"/>
  245. <xsl:variable name="bit" select=" string-join(bp:decimalToBitFill($variant,$elements_cnt),'')"/>
  246. <xsl:variable name="cand_to_calc">
  247. <xsl:for-each select="$candidates/bp:Path_Point">
  248. <xsl:sort select="@distance"/>
  249. <bp:Path_Point>
  250. <!--<xsl:attribute name="bit" select="$bit"/>-->
  251. <xsl:attribute name="bin_pos" select="substring($bit, position(),1)"/>
  252. <xsl:copy-of select="@*"/>
  253. <xsl:copy-of select="bp:Path_Point"></xsl:copy-of>
  254. </bp:Path_Point>
  255. </xsl:for-each>
  256. </xsl:variable>
  257. <!-- debug -->
  258. <variant><xsl:attribute name="variant" select="$variant"/>
  259. <xsl:attribute name="cur_bit" select="$bit"/>
  260. <xsl:attribute name="best_cost" select="$best_cost"/>
  261. <xsl:attribute name="best_variant" select="$best_variant"/>
  262. <xsl:copy-of select="$cand_to_calc"/>
  263. </variant>
  264. <xsl:variable name="calc_cost_way">
  265. <xsl:call-template name="calc_cost_way"><xsl:with-param name="cand_to_calc" select="$cand_to_calc"/></xsl:call-template>
  266. </xsl:variable>
  267. <xsl:variable name="cost_sum">
  268. <costs>
  269. <xsl:attribute name="Cable_Price" select="sum($calc_cost_way/cost/@Cable_Price)" />
  270. <xsl:attribute name="PE_Price" select="sum($calc_cost_way/cost/@PE_Price)"/>
  271. <xsl:attribute name="Price" select="sum($calc_cost_way/cost/@Price)"/>
  272. <xsl:copy-of select="$calc_cost_way"/>
  273. </costs>
  274. </xsl:variable>
  275. <xsl:copy-of select="$cost_sum"></xsl:copy-of>
  276. <xsl:variable name="best">
  277. <xsl:variable name="cur_Price" select="$cost_sum/costs/@Price"/>
  278. <xsl:choose>
  279. <xsl:when test="number($cur_Price) &lt; number($best_cost) or not($best_cost) ">
  280. <best>
  281. <xsl:attribute name="best_cost" select="$cur_Price"/>
  282. <xsl:attribute name="best_variant" select="$bit"/>
  283. </best>
  284. </xsl:when>
  285. <xsl:otherwise>
  286. <best>
  287. <xsl:attribute name="best_cost" select="$best_cost"/>
  288. <xsl:attribute name="best_variant" select="$best_variant"/>
  289. </best>
  290. </xsl:otherwise>
  291. </xsl:choose>
  292. </xsl:variable>
  293. <!--<xsl:copy-of select="$best"/>-->
  294. <xsl:choose>
  295. <xsl:when test="$bit = $max_bit">
  296. <koniec_wariantow>
  297. <xsl:attribute name="best_variant" select="$best_variant"/>
  298. <xsl:for-each select="$candidates/bp:Path_Point">
  299. <xsl:sort select="@distance"/>
  300. <xsl:if test="substring($best_variant, position(),1)='1'"><!-- jak wystawiony w wariancie-->
  301. <bp:Path_Point>
  302. <xsl:attribute name="bit" select="$best_variant"/>
  303. <xsl:attribute name="bin_pos" select="substring($best_variant, position(),1)"/>
  304. <xsl:copy-of select="@*"/>
  305. <xsl:attribute name="Price" select="$best_cost"/>
  306. <xsl:copy-of select="bp:Path_Point"/>
  307. </bp:Path_Point>
  308. </xsl:if>
  309. </xsl:for-each>
  310. </koniec_wariantow></xsl:when>
  311. <xsl:otherwise>
  312. <xsl:call-template name="calculate_optimum">
  313. <xsl:with-param name="candidates" select="$candidates"/>
  314. <xsl:with-param name="max_bit" select="$max_bit"/>
  315. <xsl:with-param name="variant" select="$variant + 1"/>
  316. <xsl:with-param name="elements_cnt" select="$elements_cnt"/>
  317. <xsl:with-param name="best_cost" select="$best/best/@best_cost"/>
  318. <xsl:with-param name="best_variant" select="$best/best/@best_variant"/>
  319. </xsl:call-template>
  320. </xsl:otherwise>
  321. </xsl:choose>
  322. </xsl:template>
  323. <xsl:template name="calc_cost_way"><!-- do wyliczenia ile wyjda kable w takiej konfiguracji -->
  324. <xsl:param name="cand_to_calc" required="yes"/>
  325. <xsl:for-each select="$cand_to_calc/bp:Path_Point">
  326. <xsl:choose>
  327. <xsl:when test="@bin_pos=0"><!-- szukamy gdzie ma najblizej i za ile -->
  328. <xsl:variable name="way_up_id" select="max($cand_to_calc/bp:Path_Point[@bin_pos=1 and @id_path &lt; current()/@id_path ]/number(@id_path))"/>
  329. <xsl:variable name="way_up_len" >
  330. <xsl:choose>
  331. <xsl:when test="$way_up_id">
  332. <xsl:value-of select="number( current()/@distance) - number($cand_to_calc/bp:Path_Point[@id_path=$way_up_id]/@distance)"/></xsl:when>
  333. <xsl:otherwise><xsl:value-of select="-1"/></xsl:otherwise>
  334. </xsl:choose>
  335. </xsl:variable>
  336. <xsl:variable name="way_dn_id" select="max($cand_to_calc/bp:Path_Point[@bin_pos=1 and @id_path &gt; current()/@id_path ]/number(@id_path)) " />
  337. <xsl:variable name="way_dn_len">
  338. <xsl:choose>
  339. <xsl:when test="$way_dn_id">
  340. <xsl:value-of select=" number($cand_to_calc/bp:Path_Point[@id_path=$way_dn_id]/@distance ) - current()/@distance"/>
  341. </xsl:when>
  342. <xsl:otherwise><xsl:value-of select="-1"/></xsl:otherwise>
  343. </xsl:choose>
  344. </xsl:variable>
  345. <xsl:choose><!-- czy w gore czy w dol -->
  346. <xsl:when test=" number($way_up_len) &gt;= number($way_dn_len) and number($way_dn_len) &gt; 0 or $way_up_len=-1"> <!--and not($way_dn_len='NaN') -->
  347. <cost>
  348. <xsl:variable name="Cable_Price_sum">
  349. <xsl:choose>
  350. <xsl:when test="number(@point_count) &gt; 0 ">
  351. <xsl:value-of select="$Cable_Price * $way_dn_len * number(@point_count) "/>
  352. </xsl:when>
  353. <xsl:otherwise>
  354. <xsl:value-of select="$Cable_Price * $way_dn_len "/> <!-- todo @point_count -->
  355. </xsl:otherwise>
  356. </xsl:choose>
  357. </xsl:variable>
  358. <!-- todo @point_count -->
  359. <xsl:attribute name="PE_Price" select="0"/>
  360. <xsl:attribute name="Cable_Price" select="$Cable_Price_sum"/>
  361. <xsl:attribute name="Price" select="$Cable_Price_sum"/>
  362. <xsl:attribute name="choosed" select="'down'"/>
  363. <xsl:attribute name="way_up_id" select="$way_up_id"/><xsl:attribute name="way_up_len" select="$way_up_len"/>
  364. <xsl:attribute name="way_dn_id" select="$way_dn_id"/><xsl:attribute name="way_dn_len" select="$way_dn_len"/>
  365. </cost>
  366. </xsl:when>
  367. <xsl:otherwise>
  368. <cost>
  369. <xsl:variable name="Cable_Price_sum">
  370. <xsl:choose>
  371. <xsl:when test="number(@point_count) &gt; 0 ">
  372. <xsl:value-of select="$Cable_Price * $way_up_len * number(@point_count) "/>
  373. </xsl:when>
  374. <xsl:otherwise>
  375. <xsl:value-of select="$Cable_Price * $way_up_len "/> <!-- todo @point_count -->
  376. </xsl:otherwise>
  377. </xsl:choose>
  378. </xsl:variable>
  379. <xsl:attribute name="Cable_Price" select="$Cable_Price_sum"/> <!-- todo @point_count -->
  380. <xsl:attribute name="PE_Price" select="0"/>
  381. <xsl:attribute name="Price" select="$Cable_Price_sum"/>
  382. <xsl:attribute name="choosed" select="'up'"/>
  383. <xsl:attribute name="way_up_id" select="$way_up_id"/><xsl:attribute name="way_up_len" select="$way_up_len"/>
  384. <xsl:attribute name="way_dn_id" select="$way_dn_id"/><xsl:attribute name="way_dn_len" select="$way_dn_len"/>
  385. </cost>
  386. </xsl:otherwise>
  387. </xsl:choose>
  388. </xsl:when>
  389. <xsl:otherwise>
  390. <cost>
  391. <xsl:attribute name="Cable_Price" select="0"/>
  392. <xsl:attribute name="PE_Price" select="$PE_Price"/>
  393. <xsl:attribute name="Price" select="$PE_Price"/>
  394. </cost>
  395. </xsl:otherwise>
  396. </xsl:choose>
  397. </xsl:for-each>
  398. </xsl:template>
  399. </xsl:stylesheet>