p5dkp.fix-ditamap.xsl 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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:ditaarch="http://dita.oasis-open.org/architecture/2005/"
  11. exclude-result-prefixes="xs vc p5bws system_cache__appinfo p5suis p5dkp xsi ditaarch"
  12. version="2.0"> <!-- xmlns:ditaarch="http://dita.oasis-open.org/architecture/2005/" -->
  13. <xsl:output indent="yes" method="xml" standalone="no" doctype-public="-//OASIS//DTD DITA Map//EN" doctype-system="map.dtd"/>
  14. <!--<xsl:output indent="yes" />-->
  15. <xsl:strip-space elements="*"/>
  16. <!--<xsl:variable name="debug" select="99"/>-->
  17. <xsl:template mode="p5dkp:fix-ditamap.wymagania" match="glossgroup" xpath-default-namespace="" exclude-result-prefixes="ditaarch">
  18. <xsl:param name="keyscope" required="yes"/>
  19. <xsl:param name="keydef" required="yes"/>
  20. <xsl:param name="map.path" required="yes"/>
  21. <xsl:param name="href" required="yes"/>
  22. <!--<xsl:variable name="topicref.href" select="../@href"/>-->
  23. <xsl:variable name="p5dkp:fix-ditamap.wymagania">
  24. <map>
  25. <xsl:variable name="context" select="."/>
  26. <xsl:message>#321-B TO FIX TEST for $href=<xsl:value-of select="$href"/>; p5dkp:max_keyscope.get($keyscope,p5dkp:max_keyscope.pos($keyscope))=<xsl:value-of select="p5dkp:max_keyscope.get($keyscope,p5dkp:max_keyscope.pos($keyscope))"/> <xsl:value-of select=".//@*"/> </xsl:message>
  27. <xsl:apply-templates mode="p5dkp:fix-ditamap.wymagania.child" select="$keydef" xpath-default-namespace="">
  28. <xsl:with-param name="keyscope" select="$keyscope"/>
  29. <xsl:with-param name="keydef" select="$keydef"/>
  30. <xsl:with-param name="context" select="$context"/>
  31. <xsl:with-param name="href" select="$href"/>
  32. </xsl:apply-templates>
  33. <!--<xsl:for-each select="$keydef">
  34. <xsl:variable name="keydef.keys" select="@keys"/>
  35. <xsl:message>#324-B checking $keydef.keys=<xsl:value-of select="$keydef.keys"/>; if is set $keydef <xsl:copy-of select="." copy-namespaces="no"/> in glossentry at $keyscope = <xsl:value-of select="$keyscope"/>;</xsl:message>
  36. <xsl:apply-templates mode="p5dkp:fix-ditamap.wymagania.child" select=".">
  37. <xsl:with-param name="keyscope" select="$keyscope"/>
  38. <xsl:with-param name="keydef" select="$keydef"/>
  39. <xsl:with-param name="context" select="$context"/>
  40. <xsl:with-param name="href" select="$href"/>
  41. </xsl:apply-templates>
  42. </xsl:for-each>-->
  43. </map>
  44. </xsl:variable>
  45. <xsl:choose>
  46. <xsl:when test="$p5dkp:fix-ditamap.wymagania//comment()">
  47. <xsl:message>#68 dita- adding fixed ditamap to <xsl:value-of select="$map.path"/>/<xsl:value-of select="$href"/>.ditamap.fixedgg ;</xsl:message>
  48. <xsl:choose>
  49. <xsl:when test="doc-available(concat($map.path,'/',$href,'.ditamap.fixedgg'))">
  50. <xsl:message>#123 DOCUMENT EXISTS - should bbefore go clean! <xsl:value-of select="$href"/>.ditamap.fixedgg !</xsl:message>
  51. <xsl:message>#124 count of previous hits of $href <!--<xsl:value-of select="document-uri(current())"/>-->
  52. <xsl:copy-of select="$keyscope" copy-namespaces="no"/>
  53. </xsl:message>
  54. </xsl:when>
  55. <xsl:otherwise>
  56. <xsl:result-document href="{$map.path}/{$href}.ditamap.fixedgg" doctype-public="-//OASIS//DTD DITA Map//EN" doctype-system="map.dtd" ><!-- doctype-public="-//OASIS//DTD DITA Glossary Group//EN" doctype-system="glossgroup.dtd" -->
  57. <xsl:copy-of select="$p5dkp:fix-ditamap.wymagania"/>
  58. </xsl:result-document>
  59. </xsl:otherwise>
  60. </xsl:choose>
  61. </xsl:when>
  62. <xsl:otherwise>
  63. <xsl:message>#68-B not fixing ditamap</xsl:message>
  64. </xsl:otherwise>
  65. </xsl:choose>
  66. </xsl:template>
  67. <xsl:template mode="p5dkp:fix-ditamap.wymagania.child" match="text()|comment()">
  68. <xsl:copy-of select="."/>
  69. </xsl:template>
  70. <xsl:template mode="p5dkp:fix-ditamap.wymagania.child" match="*" xpath-default-namespace="">
  71. <xsl:param name="keyscope" required="yes"/>
  72. <xsl:param name="keydef" required="yes"/>
  73. <xsl:param name="context" required="yes"/>
  74. <xsl:param name="href" required="yes"/>
  75. <xsl:choose>
  76. <xsl:when test="local-name()='keydef'">
  77. <xsl:message terminate="yes">#85 uncorrect matched <xsl:value-of select="local-name()"/> - <xsl:copy-of select="." copy-namespaces="no"/></xsl:message>
  78. </xsl:when>
  79. </xsl:choose>
  80. <xsl:copy copy-namespaces="no">
  81. <xsl:copy-of select="@*"/>
  82. <xsl:apply-templates mode="p5dkp:fix-ditamap.wymagania.child" xpath-default-namespace="">
  83. <xsl:with-param name="keyscope" select="$keyscope"/>
  84. <xsl:with-param name="keydef" select="$keydef"/>
  85. <xsl:with-param name="context" select="$context"/>
  86. <xsl:with-param name="href" select="$href"/>
  87. </xsl:apply-templates>
  88. </xsl:copy>
  89. </xsl:template>
  90. <xsl:template mode="p5dkp:fix-ditamap.wymagania.child" match="*[ local-name()='keydef']" xpath-default-namespace="" exclude-result-prefixes="ditaarch" priority="9">
  91. <xsl:param name="keyscope" required="yes"/>
  92. <xsl:param name="keydef" required="yes"/>
  93. <xsl:param name="context" required="yes"/>
  94. <xsl:param name="href" required="yes"/>
  95. <xsl:variable name="keydef.keys" select="@keys"/>
  96. <xsl:copy copy-namespaces="no">
  97. <xsl:copy-of select="@*"/>
  98. <xsl:choose>
  99. <xsl:when test="@href and $context//*[@id = substring-after(current()/@href,'#')] or 1=2">
  100. <xsl:message>#243 @href is probably ok <xsl:value-of select="@href"/>; todo check for #</xsl:message>
  101. <xsl:apply-templates mode="p5dkp:fix-ditamap.wymagania.child">
  102. <xsl:with-param name="keyscope" select="$keyscope"/>
  103. <xsl:with-param name="keydef" select="$keydef"/>
  104. <xsl:with-param name="context" select="$context"/>
  105. <xsl:with-param name="href" select="$href"/>
  106. </xsl:apply-templates>
  107. </xsl:when>
  108. <!--<xsl:when test="$context/.//*[@keyref = concat($keyscope,'.',$keydef.keys)]">
  109. <xsl:message>#347-B OK is set $context/.//*[@keyref $keydef.keys]]</xsl:message>
  110. </xsl:when>-->
  111. <xsl:otherwise>
  112. <xsl:message terminate="no">#333-B not set in ditamap or @href and $context//*[@id = substring-after(current(@href,'#'))] = <xsl:value-of select="substring-after(current()/@href,'#')"/></xsl:message>
  113. <xsl:message>#389 adding missing ditamap <xsl:copy-of select="." copy-namespaces="no"/> after all nodes</xsl:message>
  114. <!--<xsl:comment>#389 adding missing $keydef.keys = <xsl:value-of select="$keydef.keys"/> - test1=<xsl:value-of select="count($context/.//*[@keyref = $keydef.keys])"/>; test2=<xsl:value-of select="count($context/.//*[@keyref = $keydef.keys])" xpath-default-namespace=""/> after all nodes</xsl:comment>-->
  115. <xsl:copy-of select="@*"/>
  116. <xsl:attribute name="href" select="concat($href,'#',$keydef.keys)"/>
  117. <xsl:comment> #392-B Wymagania uzupełnione automatycznie</xsl:comment>
  118. <xsl:apply-templates mode="p5dkp:fix-ditamap.wymagania.child">
  119. <xsl:with-param name="keyscope" select="$keyscope"/>
  120. <xsl:with-param name="keydef" select="$keydef"/>
  121. <xsl:with-param name="context" select="$context"/>
  122. <xsl:with-param name="href" select="$href"/>
  123. </xsl:apply-templates>
  124. </xsl:otherwise>
  125. </xsl:choose>
  126. </xsl:copy>
  127. </xsl:template>
  128. </xsl:stylesheet>