oldchunker.xsl 7.1 KB

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