p5dkp.ditafiles.wordindex.strings.xsl 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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:include href="p5dkp.keyscope.xsl"/>-->
  17. <xsl:include href="../ant_interface/p5ant-interface.param.xsl"/>
  18. <xsl:include href="p5dkp.ditafiles.wordindex.strings.merge.t.xsl"/>
  19. <xsl:output indent="yes" />
  20. <xsl:strip-space elements="*"/>
  21. <xsl:param name="p5dkp:ditafiles.wordindex.xml.thread.count" required="yes"/> <!-- ilosc rownoleglych zapodan -->
  22. <xsl:param name="p5dkp:ditafiles.wordindex.xml.thread.no" required="yes"/> <!-- numer procesu -->
  23. <xsl:param name="p5dkp.dita_root.ditamap.dir"/>
  24. <xsl:param name="p5dkp:ditafiles.wordindex.xml.only_ditadir" /> <!-- select="true()" -->
  25. <xsl:param name="p5dkp.ditafiles.wordindex.strings.merge.xml.ignore.replace.s" required="yes"/>
  26. <!--<xsl:variable name="p5dkp.dita_root.ditamap.dir">
  27. <xsl:for-each select="tokenize($p5dkp.dita_root.ditamap.dir,'/')[ position() &lt; count(tokenize($p5dkp.dita_root.ditamap.dir,'/'))]">
  28. <xsl:value-of select="."/><xsl:if test="not(position() = last())"><xsl:text>/</xsl:text></xsl:if>
  29. </xsl:for-each>
  30. </xsl:variable>-->
  31. <xsl:param name="p5dkp:wordindex.strings.s.size" select="4"/> <!-- to analize this sizes of string phrases -->
  32. <xsl:param name="p5dkp:wordindex.strings.t.p.size" select="3"/>
  33. <xsl:param name="p5dkp.ditafiles.wordindex.strings.merge.xml.ignore.xml"/>
  34. <xsl:template match="p5dkp:ditafiles.wordindex.xml" mode="p5dkp:wordindex.strings.xml">
  35. <p5dkp:wordindex.strings.xml>
  36. <xsl:copy-of select="namespace::*"/>
  37. <xsl:apply-templates mode="p5dkp:wordindex.strings"/>
  38. </p5dkp:wordindex.strings.xml>
  39. </xsl:template>
  40. <xsl:template mode="p5dkp:wordindex.strings" match="p5dkp:ditafiles.wordindex[not(@p5dkp.dita_root.ditamap.dir.true) and p5ant-interface:param.if.istrue($p5dkp:ditafiles.wordindex.xml.only_ditadir) ]">
  41. <xsl:comment>#101 ignored due to $p5dkp:ditafiles.wordindex.xml.only_ditadir </xsl:comment>
  42. </xsl:template>
  43. <xsl:template mode="p5dkp:wordindex.strings" match="p5dkp:ditafiles.wordindex|p5ant-interface:filepath.dir|p5ant-interface:filename|p5ant-interface:dir.filename">
  44. <xsl:copy copy-namespaces="no">
  45. <xsl:copy-of select="@*"/>
  46. <xsl:copy-of select="text()"/>
  47. <xsl:apply-templates mode="#current"/>
  48. </xsl:copy>
  49. </xsl:template>
  50. <xsl:template mode="p5dkp:wordindex.strings" match="p5dkp:ditafiles.wordindex.audience|p5dkp:ditafiles.wordindex.audience.map.path">
  51. <xsl:copy-of select="." copy-namespaces="no"/>
  52. </xsl:template>
  53. <xsl:template mode="p5dkp:wordindex.strings" match="*">
  54. <!--<xsl:comment>#95 passed <xsl:value-of select="name()"/>; </xsl:comment>-->
  55. <xsl:apply-templates mode="#current"/>
  56. </xsl:template>
  57. <xsl:template mode="p5dkp:wordindex.strings" match="text()|comment()"/>
  58. <xsl:template mode="p5dkp:wordindex.strings" match="t[s]">
  59. <xsl:variable name="t">
  60. <variable>
  61. <xsl:copy copy-namespaces="no">
  62. <xsl:variable name="count.s" select="count(s)"/>
  63. <xsl:attribute name="count.s" select="$count.s"/>
  64. <xsl:variable name="count.t.p" select="count(ancestor::*[not(local-name()='ditafiles.wordindex') and not(local-name()='ditafiles.wordindex.xml')])"/>
  65. <xsl:attribute name="count.t.p" select="$count.t.p"/>
  66. <xsl:attribute name="t.p">
  67. <xsl:for-each select="ancestor::*[ not(local-name()='ditafiles.wordindex') and not(local-name()='ditafiles.wordindex.xml') ]">
  68. <xsl:value-of select="local-name()"/><xsl:text>/</xsl:text>
  69. </xsl:for-each>
  70. </xsl:attribute>
  71. <xsl:copy-of select="s" copy-namespaces="no"/>
  72. <t.p>
  73. <xsl:choose>
  74. <xsl:when test="number($count.t.p) &lt; number($p5dkp:wordindex.strings.t.p.size)">
  75. <t.p.v>
  76. <xsl:attribute name="pos" select="1"/>
  77. <xsl:attribute name="len" select="$count.t.p"/>
  78. <xsl:for-each select="ancestor::*[not(local-name()='ditafiles.wordindex') and not(local-name()='ditafiles.wordindex.xml') ]">
  79. <!--<xsl:copy-of select="@*"/>-->
  80. <xsl:value-of select="local-name()"/><xsl:if test="not(position()=last())"><xsl:text>.</xsl:text></xsl:if>
  81. </xsl:for-each>
  82. </t.p.v>
  83. </xsl:when>
  84. <xsl:otherwise>
  85. <xsl:variable name="t.p" select="."/>
  86. <xsl:for-each select="( -1 * $p5dkp:wordindex.strings.t.p.size + 1 ) to $count.t.p">
  87. <t.p.v>
  88. <xsl:attribute name="pos" select="."/>
  89. <xsl:choose>
  90. <xsl:when test="current() &lt; 0 ">
  91. <xsl:attribute name="len" select="current() + number($p5dkp:wordindex.strings.t.p.size)"/>
  92. </xsl:when>
  93. <xsl:when test="abs(current() + number($p5dkp:wordindex.strings.t.p.size) ) &lt; number($p5dkp:wordindex.strings.t.p.size)">
  94. <xsl:attribute name="len" select="current()"/>
  95. </xsl:when>
  96. <xsl:when test="abs(( current() - $count.t.p )) &lt; number($p5dkp:wordindex.strings.t.p.size)">
  97. <xsl:attribute name="len" select="abs(( current() - $count.t.p )) +1 "/>
  98. </xsl:when>
  99. <xsl:otherwise><xsl:attribute name="len" select="$p5dkp:wordindex.strings.t.p.size"/></xsl:otherwise>
  100. </xsl:choose>
  101. <xsl:variable name="pos.max" select="current() + number($p5dkp:wordindex.strings.t.p.size)"/>
  102. <xsl:for-each select="$t.p/ancestor::*[ not(local-name()='ditafiles.wordindex') and not(local-name()='ditafiles.wordindex.xml') and position() &gt;= current() and position() &lt;= $pos.max ]">
  103. <xsl:value-of select="local-name()"/><xsl:if test="not(position()=last())"><xsl:text>.</xsl:text></xsl:if>
  104. </xsl:for-each>
  105. </t.p.v>
  106. </xsl:for-each>
  107. </xsl:otherwise>
  108. </xsl:choose>
  109. </t.p>
  110. <xsl:choose>
  111. <xsl:when test="number($count.s) &lt; number($p5dkp:wordindex.strings.s.size)">
  112. <ss>
  113. <xsl:attribute name="pos" select="1"/>
  114. <xsl:attribute name="len" select="$count.s"/>
  115. <xsl:for-each select="s" >
  116. <xsl:sort select="text()"/>
  117. <xsl:value-of select="text()"/><xsl:if test="not(position()=last())"><xsl:text>/</xsl:text></xsl:if>
  118. </xsl:for-each>
  119. </ss>
  120. </xsl:when>
  121. <xsl:otherwise>
  122. <xsl:variable name="s" select="."/>
  123. <xsl:for-each select="(-1 * $p5dkp:wordindex.strings.s.size + 1) to $count.s">
  124. <ss>
  125. <xsl:attribute name="pos" select="."/>
  126. <xsl:choose>
  127. <xsl:when test="current() &lt; 0 ">
  128. <xsl:attribute name="len" select="current() + number($p5dkp:wordindex.strings.s.size)"/>
  129. </xsl:when>
  130. <xsl:when test="abs(current() + number($p5dkp:wordindex.strings.s.size) ) &lt; number($p5dkp:wordindex.strings.s.size)">
  131. <xsl:attribute name="len" select="current()"/>
  132. </xsl:when>
  133. <xsl:when test="abs(( current() - $count.s )) &lt; number($p5dkp:wordindex.strings.s.size)">
  134. <xsl:attribute name="len" select="abs(( current() - $count.s )) +1 "/>
  135. </xsl:when>
  136. <xsl:otherwise><xsl:attribute name="len" select="$p5dkp:wordindex.strings.s.size"/></xsl:otherwise>
  137. </xsl:choose>
  138. <xsl:variable name="pos.max" select="current() + number($p5dkp:wordindex.strings.s.size)"/>
  139. <xsl:for-each select="$s/s[ position() &gt;= current() and position() &lt;= $pos.max ]">
  140. <xsl:value-of select="normalize-space(text())"/><xsl:if test="not(position()=last())"><xsl:text>/</xsl:text></xsl:if>
  141. </xsl:for-each>
  142. </ss>
  143. </xsl:for-each>
  144. </xsl:otherwise>
  145. </xsl:choose>
  146. </xsl:copy>
  147. </variable>
  148. </xsl:variable>
  149. <xsl:variable name="HIT.ignore">
  150. <xsl:call-template name="p5dkp:ditafiles.wordindex.strings.merge.t">
  151. <xsl:with-param name="rem_doc" select="$p5dkp.ditafiles.wordindex.strings.merge.xml.ignore.xml"/>
  152. <xsl:with-param name="t" select="$t/variable/*"/>
  153. <xsl:with-param name="p5dkp:ditafiles.wordindex.xml.only_ditadir" select="$p5dkp:ditafiles.wordindex.xml.only_ditadir"/>
  154. </xsl:call-template>
  155. </xsl:variable>
  156. <xsl:choose>
  157. <xsl:when test="$HIT.ignore//HIT.t.p">
  158. <xsl:comment>#172 was ignored by $HIT.ignore check </xsl:comment>
  159. </xsl:when>
  160. <xsl:otherwise>
  161. <xsl:copy-of select="$t/variable/*" copy-namespaces="no"/>
  162. </xsl:otherwise>
  163. </xsl:choose>
  164. </xsl:template>
  165. </xsl:stylesheet>