p5dkp.ditafiles.wordindex.strings.merge.t.xsl 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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:p5ant-interface="http://biuro.biall-net.pl/xmlschema_procesy5/WPS_Functions/ant_interface/ant_interface.xsd"
  14. exclude-result-prefixes="xs ditaarch"
  15. version="2.0">
  16. <xsl:import href="../ant_interface/p5ant-interface.param.xsl"/>
  17. <xsl:include href="p5dkp.ditafiles.wordindex.strings.merge.maximize.xsl"/>
  18. <xsl:include href="p5dkp.ditafiles.func.xsl"/>
  19. <xsl:output indent="yes" />
  20. <xsl:strip-space elements="*"/>
  21. <xsl:template name="p5dkp.ditafiles.wordindex.strings.merge.t.test">
  22. <p5dkp.ditafiles.wordindex.strings.merge.t.test>
  23. <xsl:variable name="t">
  24. <variable>
  25. <t count.s="1"
  26. count.t.p="7"
  27. t.p="topic/body/table/tgroup/tbody/row/entry/">
  28. <s>Namespace</s>
  29. <t.p>
  30. <t.p.v pos="-2" len="1">entry</t.p.v>
  31. <t.p.v pos="-1" len="2">row.entry</t.p.v>
  32. <t.p.v pos="0" len="3">tbody.row.entry</t.p.v>
  33. <t.p.v pos="1" len="3">tgroup.tbody.row.entry</t.p.v>
  34. <t.p.v pos="2" len="3">table.tgroup.tbody.row</t.p.v>
  35. <t.p.v pos="3" len="3">body.table.tgroup.tbody</t.p.v>
  36. <t.p.v pos="4" len="3">topic.body.table.tgroup</t.p.v>
  37. <t.p.v pos="5" len="3">topic.body.table</t.p.v>
  38. <t.p.v pos="6" len="2">topic.body</t.p.v>
  39. <t.p.v pos="7" len="1">topic</t.p.v>
  40. </t.p>
  41. <ss pos="1" len="1">Namespace</ss>
  42. </t>
  43. </variable>
  44. </xsl:variable>
  45. <xsl:call-template name="p5dkp:ditafiles.wordindex.strings.merge.t">
  46. <xsl:with-param name="t" select="$t//t"/>
  47. <xsl:with-param name="rem_doc" select="'/Users/a.binder/Documents/xmlschema_procesy5/src-xmlschema/public_html/WPS_Functions/dita_kosztorys_projektowy/p5dkp.ditafiles.wordindex.strings.merge.xml.ignore.xml'"/>
  48. </xsl:call-template>
  49. </p5dkp.ditafiles.wordindex.strings.merge.t.test>
  50. </xsl:template>
  51. <xsl:template name="p5dkp:ditafiles.wordindex.strings.merge.t">
  52. <xsl:param name="rem_doc" required="yes"/>
  53. <xsl:param name="local_doc" select="''"/>
  54. <xsl:param name="t" required="yes"/>
  55. <xsl:param name="p5dkp:ditafiles.wordindex.xml.only_ditadir"/>
  56. <xsl:for-each select="$t">
  57. <xsl:variable name="remote.t" select="."/>
  58. <!--<xsl:message>#60 foreach t <xsl:value-of select="name()"/> ; $rem_doc = <xsl:value-of select="doc($rem_doc)//@p5dkp.dita_root.ditamap.dir.true"/></xsl:message>-->
  59. <xsl:for-each select="doc($rem_doc)//p5dkp:ditafiles.wordindex[ not(p5ant-interface:dir.filename[ text() = $local_doc ]) and ( @p5dkp.dita_root.ditamap.dir.true or not(p5ant-interface:param.if.istrue($p5dkp:ditafiles.wordindex.xml.only_ditadir)) )]"> <!-- [ not(p5ant-interface:dir.filename[ text() = $local_doc ]) and ( @p5dkp.dita_root.ditamap.dir.true or not(p5ant-interface:param.if.istrue($p5dkp:ditafiles.wordindex.xml.only_ditadir)) )] --> <!-- [ @p5dkp.dita_root.ditamap.dir.true or not($p5dkp:ditafiles.wordindex.xml.only_ditadir)] -->
  60. <!--<xsl:message>#62 foreach doc() <xsl:value-of select="name()"/></xsl:message>-->
  61. <xsl:apply-templates mode="p5dkp:ditafiles.wordindex.strings.merge.t">
  62. <xsl:with-param name="remote.t" select="$remote.t"/>
  63. <xsl:with-param name="rem_doc.file_from_fullpath" select="p5dkp:ditafiles.file_from_fullpath($rem_doc)"/>
  64. <xsl:with-param name="local_doc.file_from_fullpath" select="p5dkp:ditafiles.file_from_fullpath($local_doc)"/>
  65. <xsl:with-param name="p5ant-interface:dir.filename" select="@p5ant-interface:dir.filename"/>
  66. </xsl:apply-templates>
  67. </xsl:for-each>
  68. </xsl:for-each>
  69. </xsl:template>
  70. <xsl:template mode="p5dkp:ditafiles.wordindex.strings.merge.t" match="text()|comment()|*"/>
  71. <xsl:template mode="p5dkp:ditafiles.wordindex.strings.merge.t" match="t">
  72. <xsl:param name="remote.t" required="yes"/>
  73. <xsl:param name="rem_doc.file_from_fullpath"/>
  74. <xsl:param name="local_doc.file_from_fullpath"/>
  75. <xsl:param name="p5ant-interface:dir.filename"/>
  76. <xsl:variable name="local.t" select="."/>
  77. <xsl:variable name="HIT_ss">
  78. <HIT_ss>
  79. <xsl:for-each select="$local.t/ss">
  80. <xsl:variable name="local.ss" select="."/>
  81. <xsl:for-each select="$remote.t/ss">
  82. <xsl:choose>
  83. <xsl:when test="$local.t/number(@count.s) &lt; 2"/>
  84. <xsl:when test="number(@len) &lt; 2 "/>
  85. <xsl:when test="string-length(text()) &lt; 4"/>
  86. <xsl:when test=" text() = $local.ss/text()">
  87. <HIT.ss>
  88. <xsl:copy-of select="@*"/>
  89. <xsl:attribute name="local.t__count.s" select="$local.t/@count.s"/>
  90. <!--<xsl:attribute name="p5ant-interface:local.dir.filename" select="$local.t/../p5ant-interface:dir.filename/text()"/>-->
  91. <!--<xsl:attribute name="remote.p5ant-interface:dir.filename" select="../../p5ant-interface:dir.filename/text()"/>-->
  92. <xsl:value-of select="text()"/>
  93. </HIT.ss>
  94. </xsl:when>
  95. </xsl:choose>
  96. </xsl:for-each>
  97. </xsl:for-each>
  98. <xsl:for-each select="$local.t/s">
  99. <xsl:variable name="local.s" select="."/>
  100. <xsl:for-each select="$remote.t/s">
  101. <xsl:choose>
  102. <xsl:when test="string-length(text()) &lt; 3"/>
  103. <xsl:when test=" text() = $local.s/text()">
  104. <HIT.s>
  105. <xsl:attribute name="pos" select="position()"/>
  106. <!--<xsl:attribute name="p5ant-interface:local.dir.filename" select="$local.t/../p5ant-interface:dir.filename/text()"/>-->
  107. <!--<xsl:attribute name="remote.p5ant-interface:dir.filename" select="../../p5ant-interface:dir.filename/text()"/>-->
  108. <xsl:value-of select="text()"/>
  109. </HIT.s>
  110. </xsl:when>
  111. </xsl:choose>
  112. </xsl:for-each>
  113. </xsl:for-each>
  114. </HIT_ss>
  115. </xsl:variable>
  116. <xsl:choose>
  117. <xsl:when test="$HIT_ss//(HIT.ss | HIT.s)">
  118. <HIT>
  119. <xsl:attribute name="p5ant-interface:dir.filename.remote" select="$local.t/../p5ant-interface:dir.filename/text()"/>
  120. <xsl:copy-of select="$local.t/@*"/>
  121. <xsl:copy-of select="$HIT_ss//HIT.s" copy-namespaces="no"/>
  122. <!--<xsl:message>#154 hit for count s=<xsl:value-of select="count($HIT_ss//HIT.s)"/>; or HIT.ss/@len=<xsl:value-of select="$HIT_ss//HIT.ss/@len"/></xsl:message>-->
  123. <!--<HHIIIT><xsl:copy-of select="$HIT_ss" copy-namespaces="no"/></HHIIIT>-->
  124. <xsl:for-each select="$HIT_ss//HIT.ss">
  125. <xsl:sort order="descending" select="number(@len)"/>
  126. <xsl:if test="position() &lt; 3 and number(@len) &gt; 1 ">
  127. <HIT.ss>
  128. <xsl:copy-of select="@*"/>
  129. <xsl:copy-of select="text()"/>
  130. </HIT.ss>
  131. </xsl:if>
  132. </xsl:for-each>
  133. <xsl:variable name="HIT_t">
  134. <HIT_t>
  135. <xsl:for-each select="$local.t/t.p/t.p.v">
  136. <xsl:variable name="local.t_t.p_t.p.v" select="."/>
  137. <xsl:for-each select="$remote.t/t.p/t.p.v">
  138. <xsl:choose>
  139. <xsl:when test=" text() = $local.t_t.p_t.p.v/text()">
  140. <HIT.t.p>
  141. <xsl:copy-of select="@*"/>
  142. <!--<xsl:attribute name="p5ant-interface:local.dir.filename" select="$local.t/../p5ant-interface:dir.filename/text()"/>-->
  143. <!--<xsl:attribute name="remote.p5ant-interface:dir.filename" select="../../p5ant-interface:dir.filename/text()"/>-->
  144. <xsl:value-of select="text()"/>
  145. </HIT.t.p>
  146. </xsl:when>
  147. </xsl:choose>
  148. </xsl:for-each>
  149. </xsl:for-each>
  150. </HIT_t>
  151. </xsl:variable>
  152. <xsl:choose>
  153. <xsl:when test="$HIT_t//HIT.t.p">
  154. <xsl:for-each select="$HIT_t//HIT.t.p">
  155. <xsl:sort order="descending" select="number(@len)"/>
  156. <xsl:if test="position() &lt; 2 and number(@len) &gt; 1">
  157. <HIT.t.p>
  158. <xsl:copy-of select="@*"/>
  159. <xsl:copy-of select="text()"/>
  160. </HIT.t.p>
  161. </xsl:if>
  162. </xsl:for-each>
  163. </xsl:when>
  164. <xsl:otherwise>
  165. <NOT_HIT.t.p>
  166. <xsl:for-each select="$local.t/t.p/t.p.v[1]">
  167. <xsl:sort select="number(@len)" order="descending"/>
  168. <xsl:copy-of select="."/>
  169. </xsl:for-each>
  170. </NOT_HIT.t.p>
  171. </xsl:otherwise>
  172. </xsl:choose>
  173. </HIT>
  174. <xsl:apply-templates mode="p5dkp:ditafiles.wordindex.strings.merge.xml.maximize.s" select="$HIT_ss">
  175. <xsl:with-param name="rem_doc.file_from_fullpath" select="$rem_doc.file_from_fullpath"/>
  176. <xsl:with-param name="local_doc.file_from_fullpath" select="$local_doc.file_from_fullpath"/>
  177. <xsl:with-param name="p5ant-interface:dir.filename.remote" select="$local.t/../p5ant-interface:dir.filename/text()"/>
  178. <xsl:with-param name="p5ant-interface:dir.filename" select="$p5ant-interface:dir.filename"/>
  179. </xsl:apply-templates>
  180. </xsl:when>
  181. </xsl:choose>
  182. <!--<xsl:copy-of select="$HIT_ss" copy-namespaces="no"/>-->
  183. </xsl:template>
  184. </xsl:stylesheet>