oldchunker.xsl 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  2. xmlns:saxon="http://icl.com/saxon"
  3. xmlns:lxslt="http://xml.apache.org/xslt"
  4. xmlns:redirect="http://xml.apache.org/xalan/redirect"
  5. xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
  6. version="1.1"
  7. exclude-result-prefixes="doc"
  8. extension-element-prefixes="saxon redirect lxslt">
  9. <!-- ********************************************************************
  10. $Id: oldchunker.xsl 6910 2007-06-28 23:23:30Z xmldoc $
  11. ********************************************************************
  12. This file is part of the XSL DocBook Stylesheet distribution.
  13. See ../README or http://docbook.sf.net/release/xsl/current/ for
  14. copyright and other information.
  15. ******************************************************************** -->
  16. <!-- ==================================================================== -->
  17. <!-- This stylesheet works with Saxon and Xalan; for XT use xtchunker.xsl -->
  18. <!-- ==================================================================== -->
  19. <xsl:param name="default.encoding" select="'ISO-8859-1'" doc:type='string'/>
  20. <doc:param name="default.encoding" xmlns="">
  21. <refpurpose>Encoding used in generated HTML pages</refpurpose>
  22. <refdescription>
  23. <para>This encoding is used in files generated by chunking stylesheet. Currently
  24. only Saxon is able to change output encoding.
  25. </para>
  26. </refdescription>
  27. </doc:param>
  28. <!-- ==================================================================== -->
  29. <xsl:param name="saxon.character.representation" select="'entity;decimal'" doc:type='string'/>
  30. <doc:param name="saxon.character.representation" xmlns="">
  31. <refpurpose>Saxon character representation used in generated HTML pages</refpurpose>
  32. <refdescription>
  33. <para>This character representation is used in files generated by chunking stylesheet. If
  34. you want to suppress entity references for characters with direct representation
  35. in default.encoding, set this parameter to value <literal>native</literal>.
  36. </para>
  37. </refdescription>
  38. </doc:param>
  39. <!-- ==================================================================== -->
  40. <xsl:template name="make-relative-filename">
  41. <xsl:param name="base.dir" select="'./'"/>
  42. <xsl:param name="base.name" select="''"/>
  43. <xsl:variable name="vendor" select="system-property('xsl:vendor')"/>
  44. <xsl:choose>
  45. <xsl:when test="contains($vendor, 'SAXON')">
  46. <!-- Saxon doesn't make the chunks relative -->
  47. <xsl:value-of select="concat($base.dir,$base.name)"/>
  48. </xsl:when>
  49. <xsl:when test="contains($vendor, 'Apache')">
  50. <!-- Xalan doesn't make the chunks relative -->
  51. <xsl:value-of select="concat($base.dir,$base.name)"/>
  52. </xsl:when>
  53. <xsl:otherwise>
  54. <xsl:message terminate="yes">
  55. <xsl:text>Chunking isn't supported with </xsl:text>
  56. <xsl:value-of select="$vendor"/>
  57. </xsl:message>
  58. </xsl:otherwise>
  59. </xsl:choose>
  60. </xsl:template>
  61. <xsl:template name="write.chunk">
  62. <xsl:param name="filename" select="''"/>
  63. <xsl:param name="method" select="'html'"/>
  64. <xsl:param name="encoding" select="$default.encoding"/>
  65. <xsl:param name="indent" select="'no'"/>
  66. <xsl:param name="content" select="''"/>
  67. <xsl:message>
  68. <xsl:text>Writing </xsl:text>
  69. <xsl:value-of select="$filename"/>
  70. <xsl:if test="name(.) != ''">
  71. <xsl:text> for </xsl:text>
  72. <xsl:value-of select="name(.)"/>
  73. <xsl:if test="@id">
  74. <xsl:text>(</xsl:text>
  75. <xsl:value-of select="@id"/>
  76. <xsl:text>)</xsl:text>
  77. </xsl:if>
  78. </xsl:if>
  79. </xsl:message>
  80. <xsl:variable name="vendor" select="system-property('xsl:vendor')"/>
  81. <xsl:choose>
  82. <xsl:when test="contains($vendor, 'SAXON 6.2')">
  83. <!-- Saxon 6.2.x uses xsl:document -->
  84. <xsl:document href="{$filename}"
  85. method="{$method}"
  86. encoding="{$encoding}"
  87. indent="{$indent}"
  88. saxon:character-representation="{$saxon.character.representation}">
  89. <xsl:copy-of select="$content"/>
  90. </xsl:document>
  91. </xsl:when>
  92. <xsl:when test="contains($vendor, 'SAXON')">
  93. <!-- Saxon uses saxon:output -->
  94. <saxon:output file="{$filename}"
  95. href="{$filename}"
  96. method="{$method}"
  97. encoding="{$encoding}"
  98. indent="{$indent}"
  99. saxon:character-representation="{$saxon.character.representation}">
  100. <xsl:copy-of select="$content"/>
  101. </saxon:output>
  102. </xsl:when>
  103. <xsl:when test="contains($vendor, 'Apache')">
  104. <!-- Xalan uses redirect -->
  105. <redirect:write file="{$filename}">
  106. <xsl:copy-of select="$content"/>
  107. </redirect:write>
  108. </xsl:when>
  109. <xsl:otherwise>
  110. <!-- it doesn't matter since we won't be making chunks... -->
  111. <xsl:message terminate="yes">
  112. <xsl:text>Can't make chunks with </xsl:text>
  113. <xsl:value-of select="$vendor"/>
  114. <xsl:text>'s processor.</xsl:text>
  115. </xsl:message>
  116. </xsl:otherwise>
  117. </xsl:choose>
  118. </xsl:template>
  119. <xsl:template name="write.chunk.with.doctype">
  120. <xsl:param name="filename" select="''"/>
  121. <xsl:param name="method" select="'html'"/>
  122. <xsl:param name="encoding" select="$default.encoding"/>
  123. <xsl:param name="indent" select="'no'"/>
  124. <xsl:param name="doctype-public" select="''"/>
  125. <xsl:param name="doctype-system" select="''"/>
  126. <xsl:param name="content" select="''"/>
  127. <xsl:message>
  128. <xsl:text>Writing </xsl:text>
  129. <xsl:value-of select="$filename"/>
  130. <xsl:if test="name(.) != ''">
  131. <xsl:text> for </xsl:text>
  132. <xsl:value-of select="name(.)"/>
  133. </xsl:if>
  134. </xsl:message>
  135. <xsl:variable name="vendor" select="system-property('xsl:vendor')"/>
  136. <xsl:choose>
  137. <xsl:when test="contains($vendor, 'SAXON 6.2')">
  138. <!-- Saxon 6.2.x uses xsl:document -->
  139. <xsl:document href="{$filename}"
  140. method="{$method}"
  141. encoding="{$encoding}"
  142. indent="{$indent}"
  143. doctype-public="{$doctype-public}"
  144. doctype-system="{$doctype-system}"
  145. saxon:character-representation="{$saxon.character.representation}">
  146. <xsl:copy-of select="$content"/>
  147. </xsl:document>
  148. </xsl:when>
  149. <xsl:when test="contains($vendor, 'SAXON')">
  150. <!-- Saxon uses saxon:output -->
  151. <saxon:output file="{$filename}"
  152. href="{$filename}"
  153. method="{$method}"
  154. encoding="{$encoding}"
  155. indent="{$indent}"
  156. doctype-public="{$doctype-public}"
  157. doctype-system="{$doctype-system}"
  158. saxon:character-representation="{$saxon.character.representation}">
  159. <xsl:copy-of select="$content"/>
  160. </saxon:output>
  161. </xsl:when>
  162. <xsl:when test="contains($vendor, 'Apache')">
  163. <!-- Xalan uses redirect -->
  164. <redirect:write file="{$filename}">
  165. <xsl:copy-of select="$content"/>
  166. </redirect:write>
  167. </xsl:when>
  168. <xsl:otherwise>
  169. <!-- it doesn't matter since we won't be making chunks... -->
  170. <xsl:message terminate="yes">
  171. <xsl:text>Can't make chunks with </xsl:text>
  172. <xsl:value-of select="$vendor"/>
  173. <xsl:text>'s processor.</xsl:text>
  174. </xsl:message>
  175. </xsl:otherwise>
  176. </xsl:choose>
  177. </xsl:template>
  178. </xsl:stylesheet>