p5dkp.ditafiles.func.xsl 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <xsl:stylesheet xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning"
  3. xmlns:xs="http://www.w3.org/2001/XMLSchema"
  4. xmlns:p5bws="http://biuro.biall-net.pl/xmlschema_procesy5/WPS_Functions/WPS_Functions.xsd"
  5. xmlns:system_cache__appinfo="http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache/appinfo.xsd"
  6. xmlns:p5dkp="http://biuro.biall-net.pl/xmlschema_procesy5/WPS_Functions/dita_kosztorys_projektowy/p5dkp.xsd"
  7. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  8. xmlns:p5suis="http://biuro.biall-net.pl/xmlschema_procesy5/WPS_Functions/system_ui_info_speech/system_ui_info_speech.xsd"
  9. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  10. xmlns:p5xsda="http://biuro.biall-net.pl/xmlschema_procesy5/WPS_Functions/xsd_asserts/p5xsda.xsd"
  11. xmlns:ditaarch="http://dita.oasis-open.org/architecture/2005/"
  12. xmlns:system_cache__dita="http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache/dita.xsd"
  13. xmlns:p5dg="http://biuro.biall-net.pl/xmlschema_procesy5/WPS_Functions/documentation_generator/documentation_generator.xsd"
  14. exclude-result-prefixes="xs ditaarch"
  15. version="2.0">
  16. <xsl:include href="../documentation_generator/p5dg.filepath.xsl"/>
  17. <xsl:include href="p5dkp.ditafiles.func.isditafile.xsl"/>
  18. <xsl:output indent="yes" method="xml" exclude-result-prefixes="ditaarch"/>
  19. <!--<xsl:output indent="yes" method="xml" standalone="no" doctype-public="-//OASIS//DTD DITA Glossary Group//EN" doctype-system="glossgroup.dtd"/>-->
  20. <xsl:strip-space elements="*"/>
  21. <xsl:param name="ditafiles.func.merge_path.map.path1" select="'/Users/a.binder/procesy5-dita-templates-druki/7007.Dostarczenie_systemu_Myjni_Inteligentnej/klient.workers/'"/><!-- target -->
  22. <xsl:param name="ditafiles.func.merge_path.href1" select="'rafa__rogoz.ditamap'"/>
  23. <xsl:param name="ditafiles.func.merge_path.map.path2" select="'/Users/a.binder/procesy5-dita-templates-druki'"/><!-- source -->
  24. <xsl:param name="ditafiles.func.merge_path.href2" select="'7007.Dostarczenie_systemu_Myjni_Inteligentnej/projekt_7007_dostarczenie_systemu_aplikacji_mobilnej_dla_myjni.ditamap'"/>
  25. <xsl:template name="p5dkp:ditafiles.func.merge_path">
  26. <p5dkp:ditafiles.func.merge_path>
  27. <xsl:copy-of select="p5dkp:ditafiles.func.merge_path($ditafiles.func.merge_path.map.path1,$ditafiles.func.merge_path.href1,$ditafiles.func.merge_path.map.path2,$ditafiles.func.merge_path.href2)"/>
  28. </p5dkp:ditafiles.func.merge_path>
  29. </xsl:template>
  30. <xsl:function name="p5dkp:ditafiles.func.isditamapfile">
  31. <xsl:param name="href"/>
  32. <xsl:choose>
  33. <xsl:when test="contains($href,'.ditamap')">
  34. <xsl:value-of select="true()"/>
  35. </xsl:when>
  36. </xsl:choose>
  37. </xsl:function>
  38. <xsl:function name="p5dkp:ditafiles.file_from_fullpath.rel">
  39. <xsl:param name="fullpath"/>
  40. <xsl:variable name="out">
  41. <xsl:for-each select="tokenize($fullpath,'/')">
  42. <xsl:choose>
  43. <xsl:when test="position() = 1">
  44. <xsl:value-of select="concat(.,'/')"/>
  45. </xsl:when>
  46. <xsl:when test="position() = last()">
  47. <xsl:value-of select="concat(.,'/')"/>
  48. </xsl:when>
  49. <xsl:otherwise>
  50. <xsl:value-of select="concat(.,'/')"/>
  51. </xsl:otherwise>
  52. </xsl:choose>
  53. </xsl:for-each>
  54. </xsl:variable>
  55. <xsl:value-of select="p5dg:filepath.clean($out)"/>
  56. </xsl:function>
  57. <xsl:function name="p5dkp:ditafiles.file_from_fullpath">
  58. <xsl:param name="fullpath"/>
  59. <xsl:variable name="path_len" select="count(tokenize($fullpath,'/'))"/>
  60. <xsl:variable name="out">
  61. <xsl:choose>
  62. <xsl:when test="$path_len &gt; 0">
  63. <xsl:for-each select="tokenize($fullpath,'/')">
  64. <xsl:choose>
  65. <xsl:when test="position() = last()">
  66. <xsl:value-of select="."/>
  67. </xsl:when>
  68. </xsl:choose>
  69. </xsl:for-each>
  70. </xsl:when>
  71. <xsl:otherwise>
  72. <xsl:value-of select="$fullpath"/>
  73. </xsl:otherwise>
  74. </xsl:choose>
  75. </xsl:variable>
  76. <xsl:value-of select="$out"/>
  77. </xsl:function>
  78. <xsl:function name="p5dkp:ditafiles.dir_from_fullpath">
  79. <xsl:param name="fullpath"/>
  80. <!--<xsl:message>#98 <xsl:value-of select="$fullpath"/></xsl:message>-->
  81. <xsl:variable name="path_len" select="count(tokenize($fullpath,'/'))"/>
  82. <xsl:variable name="out">
  83. <xsl:choose>
  84. <xsl:when test="$path_len &gt; 0">
  85. <xsl:for-each select="tokenize($fullpath,'/')">
  86. <xsl:choose>
  87. <xsl:when test="position() = 1">
  88. <xsl:value-of select="concat(.,'/')"/>
  89. </xsl:when>
  90. <xsl:when test="position() &lt; $path_len and not(position() = last())">
  91. <xsl:value-of select="concat(.,'/')"/>
  92. </xsl:when>
  93. </xsl:choose>
  94. </xsl:for-each>
  95. </xsl:when>
  96. </xsl:choose>
  97. </xsl:variable>
  98. <xsl:value-of select="$out"/>
  99. </xsl:function>
  100. <xsl:function name="p5dkp:ditafiles.func.merge_path.string.file">
  101. <xsl:param name="map.path1"/>
  102. <xsl:param name="href1"/>
  103. <xsl:param name="map.path2"/>
  104. <xsl:param name="href2"/>
  105. <xsl:value-of select="concat(p5dkp:ditafiles.func.merge_path.string($map.path1,$href1,$map.path2,$href2),'/',$href1)"/>
  106. </xsl:function>
  107. <xsl:function name="p5dkp:ditafiles.func.merge_path.string">
  108. <xsl:param name="map.path1"/>
  109. <xsl:param name="href1"/>
  110. <xsl:param name="map.path2"/>
  111. <xsl:param name="href2"/>
  112. <xsl:variable name="p5dkp:ditafiles.func.merge_path">
  113. <p5dkp:ditafiles.func.merge_path>
  114. <xsl:copy-of select="p5dkp:ditafiles.func.merge_path($map.path1,$href1,$map.path2,$href2)" copy-namespaces="no"/>
  115. </p5dkp:ditafiles.func.merge_path>
  116. </xsl:variable>
  117. <xsl:variable name="merge_path">
  118. <xsl:for-each select="$p5dkp:ditafiles.func.merge_path//result/path">
  119. <xsl:choose>
  120. <xsl:when test="position() = last() and string-length(@path) &gt; 0">
  121. <xsl:value-of select="@path"/>
  122. </xsl:when>
  123. <xsl:otherwise><xsl:value-of select="concat(@path,'/')"/></xsl:otherwise>
  124. </xsl:choose>
  125. </xsl:for-each>
  126. </xsl:variable>
  127. <xsl:value-of select="$merge_path"/>
  128. </xsl:function>
  129. <xsl:function name="p5dkp:ditafiles.func.merge_path.string">
  130. <xsl:param name="map.path1"/>
  131. <xsl:param name="map.path2"/>
  132. <xsl:variable name="p5dkp:ditafiles.func.merge_path">
  133. <p5dkp:ditafiles.func.merge_path>
  134. <xsl:copy-of select="p5dkp:ditafiles.func.merge_path($map.path1,'/FAKEFILE1.FAKE',$map.path2,'/FAKEFILE2.FAKE')" copy-namespaces="no"/>
  135. </p5dkp:ditafiles.func.merge_path>
  136. </xsl:variable>
  137. <xsl:variable name="merge_path">
  138. <xsl:for-each select="$p5dkp:ditafiles.func.merge_path//result/path">
  139. <xsl:choose>
  140. <xsl:when test="position() = last()">
  141. <xsl:value-of select="@path"/>
  142. </xsl:when>
  143. <xsl:otherwise><xsl:value-of select="concat(@path,'/')"/></xsl:otherwise>
  144. </xsl:choose>
  145. </xsl:for-each>
  146. </xsl:variable>
  147. <xsl:value-of select="$merge_path"/>
  148. </xsl:function>
  149. <xsl:function name="p5dkp:ditafiles.func.merge_path">
  150. <xsl:param name="map.path2"/>
  151. <xsl:param name="href2"/>
  152. <xsl:param name="map.path1"/>
  153. <xsl:param name="href1"/>
  154. <xsl:variable name="map1" select="p5dg:filepath.clean(concat($map.path1,'/',$href1))"/>
  155. <xsl:variable name="map2" select="p5dg:filepath.clean(concat($map.path2,'/',$href2))"/>
  156. <xsl:message>[EEE]#148DDDD $map.path1 = "<xsl:value-of select="$map.path1"/>" ; "<xsl:value-of select="$href1"/>" $map.path2 = "<xsl:value-of select="$map.path2"/>" ; "<xsl:value-of select="$href2"/>" , count(<xsl:value-of select="count($map.path2)"/>); (<xsl:value-of select="count($href2)"/>)</xsl:message>
  157. <xsl:message>[EEE]#148DDDD-B $map1=<xsl:value-of select="$map1"/>; $map2=<xsl:value-of select="$map2"/>;</xsl:message>
  158. <xsl:variable name="p5dkp:ditafiles.func.merge_path">
  159. <p5dkp:ditafiles.func.merge_path>
  160. <xsl:variable name="map2.len" select="count(tokenize($map2,'/'))"/>
  161. <xsl:attribute name="p5dg:filepath.clean.1" select="$map1"/>
  162. <xsl:attribute name="p5dg:filepath.clean.2" select="$map2"/>
  163. <xsl:attribute name="map.path1" select="$map.path1"/>
  164. <xsl:attribute name="href1" select="$href1"/>
  165. <xsl:attribute name="map.path2" select="$map.path2"/>
  166. <xsl:attribute name="href2" select="$href2"/>
  167. <xsl:for-each select="tokenize($map1,'/')">
  168. <xsl:variable name="pos1" select="position()"/>
  169. <xsl:variable name="text1" select="."/>
  170. <xsl:choose>
  171. <xsl:when test="position() &gt; $map2.len">
  172. <path1 pos="{xs:integer($pos1)}">
  173. <xsl:attribute name="mismatch" select="."/>
  174. </path1>
  175. </xsl:when>
  176. <xsl:otherwise>
  177. <path1 pos="{xs:integer($pos1)}">
  178. <!--<xsl:message>#148 $map.path1 = "<xsl:value-of select="$map.path1"/>" ; "<xsl:value-of select="$href1"/>" $map.path2 = "<xsl:value-of select="$map.path2"/>" ; "<xsl:value-of select="$href2"/>" , count(<xsl:value-of select="count($map.path2)"/>); (<xsl:value-of select="count($href2)"/>)</xsl:message>-->
  179. <xsl:for-each select="tokenize($map2,'/')">
  180. <xsl:choose>
  181. <xsl:when test="position() = $pos1">
  182. <xsl:choose>
  183. <xsl:when test=". = $text1">
  184. <xsl:attribute name="same" select="$text1"/>
  185. </xsl:when>
  186. <xsl:otherwise>
  187. <xsl:attribute name="mismatch" select="$text1"/>
  188. </xsl:otherwise>
  189. </xsl:choose>
  190. </xsl:when>
  191. </xsl:choose>
  192. </xsl:for-each>
  193. </path1>
  194. </xsl:otherwise>
  195. </xsl:choose>
  196. </xsl:for-each>
  197. </p5dkp:ditafiles.func.merge_path>
  198. </xsl:variable>
  199. <xsl:variable name="p5dkp:ditafiles.func.merge_path2">
  200. <p5dkp:ditafiles.func.merge_path2>
  201. <xsl:variable name="map1.len" select="count(tokenize($map1,'/'))"/>
  202. <xsl:for-each select="tokenize($map2,'/')">
  203. <xsl:variable name="pos2" select="position()"/>
  204. <xsl:variable name="text2" select="."/>
  205. <xsl:choose>
  206. <xsl:when test="position() &gt; $map1.len">
  207. <path2 pos="{xs:integer($pos2)}">
  208. <xsl:attribute name="mismatch" select="."/>
  209. </path2>
  210. </xsl:when>
  211. <xsl:otherwise>
  212. <path2 pos="{xs:integer($pos2)}">
  213. <xsl:for-each select="tokenize($map1,'/')">
  214. <xsl:choose>
  215. <xsl:when test="position() = $pos2">
  216. <xsl:choose>
  217. <xsl:when test=". = $text2">
  218. <xsl:attribute name="same" select="$text2"/>
  219. </xsl:when>
  220. <xsl:otherwise>
  221. <xsl:attribute name="mismatch" select="$text2"/>
  222. </xsl:otherwise>
  223. </xsl:choose>
  224. </xsl:when>
  225. </xsl:choose>
  226. </xsl:for-each>
  227. </path2>
  228. </xsl:otherwise>
  229. </xsl:choose>
  230. </xsl:for-each>
  231. </p5dkp:ditafiles.func.merge_path2>
  232. </xsl:variable>
  233. <xsl:copy-of select="$p5dkp:ditafiles.func.merge_path" copy-namespaces="no"/>
  234. <xsl:copy-of select="$p5dkp:ditafiles.func.merge_path2" copy-namespaces="no"/>
  235. <xsl:variable name="min.mismatch" > <!-- select="min($p5dkp:ditafiles.func.merge_path//path1[@mismatch]/number(@pos)) cast as xs:integer " -->
  236. <xsl:choose>
  237. <xsl:when test="$p5dkp:ditafiles.func.merge_path//path1[@mismatch]/@pos">
  238. <xsl:value-of select="min($p5dkp:ditafiles.func.merge_path//path1[@mismatch]/number(@pos)) cast as xs:integer "/>
  239. </xsl:when>
  240. <xsl:otherwise>
  241. <xsl:value-of select="0"/>
  242. <xsl:message terminate="no">###273 same path?! situation path1= <xsl:copy-of select="$p5dkp:ditafiles.func.merge_path//path1"></xsl:copy-of></xsl:message>
  243. </xsl:otherwise>
  244. </xsl:choose>
  245. </xsl:variable>
  246. <xsl:variable name="max.mismatch" >
  247. <xsl:choose>
  248. <xsl:when test="not($p5dkp:ditafiles.func.merge_path//path1[@mismatch]/@pos)">
  249. <xsl:value-of select="0"/>
  250. <xsl:message>#282 same path?! WARNING </xsl:message>
  251. </xsl:when>
  252. <!--<xsl:when test="max(($p5dkp:ditafiles.func.merge_path//path1[@mismatch]/number(@pos)) ) cast as xs:integer &gt; max($p5dkp:ditafiles.func.merge_path2//path2[@mismatch]/number(@pos)) cast as xs:integer ">
  253. <xsl:value-of select="max(($p5dkp:ditafiles.func.merge_path//path1[@mismatch]/number(@pos)) ) cast as xs:integer "/>
  254. </xsl:when>-->
  255. <xsl:otherwise >
  256. <xsl:value-of select="max(($p5dkp:ditafiles.func.merge_path//path1[@mismatch]/number(@pos)) ) cast as xs:integer "/>
  257. </xsl:otherwise>
  258. <!--<xsl:otherwise>
  259. <xsl:value-of select="max($p5dkp:ditafiles.func.merge_path2//path2[@mismatch]/number(@pos)) cast as xs:integer "/>
  260. </xsl:otherwise>-->
  261. </xsl:choose>
  262. </xsl:variable>
  263. <xsl:variable name="max.mismatch.2" >
  264. <xsl:choose>
  265. <xsl:when test="not($p5dkp:ditafiles.func.merge_path2//path2[@mismatch]/@pos)">
  266. <xsl:value-of select="0"/>
  267. <xsl:message>#282 same path?! WARNING </xsl:message>
  268. </xsl:when>
  269. <!--<xsl:when test="max(($p5dkp:ditafiles.func.merge_path//path1[@mismatch]/number(@pos)) ) cast as xs:integer &gt; max($p5dkp:ditafiles.func.merge_path2//path2[@mismatch]/number(@pos)) cast as xs:integer ">
  270. <xsl:value-of select="max(($p5dkp:ditafiles.func.merge_path//path1[@mismatch]/number(@pos)) ) cast as xs:integer "/>
  271. </xsl:when>-->
  272. <xsl:otherwise >
  273. <xsl:value-of select="max(($p5dkp:ditafiles.func.merge_path2//path2[@mismatch]/number(@pos)) ) cast as xs:integer "/>
  274. </xsl:otherwise>
  275. <!--<xsl:otherwise>
  276. <xsl:value-of select="max($p5dkp:ditafiles.func.merge_path2//path2[@mismatch]/number(@pos)) cast as xs:integer "/>
  277. </xsl:otherwise>-->
  278. </xsl:choose>
  279. </xsl:variable>
  280. <xsl:variable name="map.path1.len">
  281. <xsl:choose>
  282. <xsl:when test="count(tokenize($map1,'/')) &gt; 0 " >
  283. <xsl:value-of select="count(tokenize($map1,'/')) cast as xs:string"/>
  284. </xsl:when>
  285. <xsl:otherwise><xsl:value-of select="0"/></xsl:otherwise>
  286. </xsl:choose>
  287. </xsl:variable>
  288. <xsl:variable name="map.path2.len">
  289. <xsl:choose>
  290. <xsl:when test="count(tokenize($map2,'/')) &gt; 0 " >
  291. <xsl:value-of select="count(tokenize($map2,'/')) cast as xs:string"/>
  292. </xsl:when>
  293. <xsl:otherwise><xsl:value-of select="0"/></xsl:otherwise>
  294. </xsl:choose>
  295. </xsl:variable>
  296. <xsl:variable name="max.path.len" >
  297. <xsl:for-each select="($map.path1.len,$map.path2.len)">
  298. <xsl:sort select="." order="descending" data-type="number"/>
  299. <xsl:if test="position() = 1"><xsl:value-of select=". cast as xs:integer"/></xsl:if>
  300. </xsl:for-each>
  301. </xsl:variable>
  302. <result>
  303. <xsl:attribute name="min.mismatch" select="$min.mismatch" />
  304. <xsl:attribute name="max.mismatch" select="$max.mismatch" />
  305. <xsl:attribute name="max.mismatch.2" select="$max.mismatch.2" />
  306. <xsl:attribute name="map.path1.len" select="$map.path1.len"/>
  307. <xsl:attribute name="map.path2.len" select="$map.path2.len"/>
  308. <xsl:attribute name="max.path.len" select="$max.path.len"/>
  309. <!--<xsl:message>#max.path.len = <xsl:value-of select="$max.path.len"/> ; $map.path1.len = <xsl:value-of select="$map.path1.len"/>; $map.path2.len = <xsl:value-of select="$map.path2.len"/>; </xsl:message>-->
  310. <xsl:variable name="source.file.tune">
  311. <xsl:choose>
  312. <xsl:when test="string-length($href1) &gt; 0">
  313. <xsl:value-of select="1"/>
  314. </xsl:when>
  315. <xsl:otherwise>
  316. <xsl:value-of select="1"/>
  317. </xsl:otherwise>
  318. </xsl:choose>
  319. </xsl:variable>
  320. <xsl:for-each select="$min.mismatch to ( xs:integer($max.mismatch ) - xs:integer($source.file.tune))"> <!-- - 1 -->
  321. <path>
  322. <xsl:attribute name="pos" select="position()"/>
  323. <xsl:attribute name="path" select="'..'"/>
  324. <xsl:attribute name="ind" select="."/>
  325. </path>
  326. </xsl:for-each>
  327. <xsl:for-each select="$min.mismatch to ( xs:integer($max.mismatch.2 ))">
  328. <xsl:choose>
  329. <xsl:when test="$p5dkp:ditafiles.func.merge_path2//path2[ matches(concat('III',@pos,'III'),xs:string(concat('III',current(),'III'))) ]/@mismatch">
  330. <path>
  331. <xsl:attribute name="pos" select="position()"/>
  332. <xsl:attribute name="path" select="$p5dkp:ditafiles.func.merge_path2//path2[ matches(concat('III',@pos,'III'),xs:string(concat('III',current(),'III'))) ]/@mismatch" />
  333. <xsl:attribute name="ind" select="."/>
  334. <!--<xsl:attribute name="path22" select="$p5dkp:ditafiles.func.merge_path2//path2[@pos=$min.mismatch.pos]/@mismatch"/>
  335. <xsl:attribute name="path22" select="$p5dkp:ditafiles.func.merge_path2//path2[@pos=$min.mismatch.pos]/@mismatch"/>-->
  336. </path>
  337. </xsl:when>
  338. <xsl:otherwise>
  339. <else>
  340. <xsl:attribute name="pos" select="position()"/>
  341. <xsl:attribute name="path" select="$p5dkp:ditafiles.func.merge_path2//path2[ @pos = current() ]/@mismatch" />
  342. <xsl:attribute name="ind" select="."/>
  343. </else>
  344. </xsl:otherwise>
  345. </xsl:choose>
  346. </xsl:for-each>
  347. <!--<xsl:for-each select="$p5dkp:ditafiles.func.merge_path//path[number(@pos) &lt; $min.mismatch]">
  348. </xsl:for-each>-->
  349. </result>
  350. </xsl:function>
  351. </xsl:stylesheet>