README 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. DocBook Assembly Stylesheets
  2. ==============================
  3. bobs@sagehill.net
  4. This directory provides XSL stylesheets for working with
  5. DocBook assemblies. It is intended to enable working with
  6. <topic> and <assembly> elements, as defined in DocBook 5.1
  7. and later.
  8. This kit currently supports most features of an assembly.
  9. See the "Unsupported Features" section below for details
  10. of what is not currently supported. These more advanced
  11. features will be supported as it is further developed.
  12. Content of this directory:
  13. --------------------------
  14. topic-maker-chunk.xsl - stylesheet to modularize an existing DB5 document.
  15. topic-maker.xsl - imported by topic-maker-chunk.xsl.
  16. assemble.xsl - stylesheet to process an <assembly> into a document.
  17. The toolkit consists of an assemble.xsl XSL stylesheet
  18. to process a DocBook <assembly> element to convert it
  19. to an assembled DocBook 5 document ready to be formatted.
  20. This stylesheet will enable users to structure a book from
  21. modular files.
  22. To make it easy to initially create a modular book, this
  23. kit also includes a topic-maker-chunk.xsl XSL stylesheet
  24. to break apart an existing DocBook 5 book into modular
  25. files, and also create the associated <assembly> document.
  26. Then you can run the assemble.xsl stylesheet to put it
  27. back together as a single DocBook document.
  28. To create an assembly and topic files from a book or article document
  29. =======================================================================
  30. If you have an existing DocBook 5 book or article document,
  31. you can convert it to an assembly and a collection of
  32. modular topic files. If you want to convert a DocBook 4
  33. document, you must first convert it to version 5.
  34. For example, to disassemble a DocBook 5 book document named book.xml:
  35. xsltproc --xinclude \
  36. --stringparam assembly.filename myassembly.xml \
  37. --stringparam base.dir topics/ \
  38. topic-maker-chunk.xsl \
  39. mybook.xml
  40. This command will result in a master assembly file named
  41. 'myassembly.xml' with a root element of <assembly>, containing
  42. a single <structure> element. It will also break up the
  43. content of the book into modular chunks that are output
  44. to the 'topics/' subdirectory as specified in the 'base.dir'
  45. parameter.
  46. Options
  47. ----------
  48. The name of the assembly file is set by the stylesheet param
  49. named 'assembly.filename', which should include the filename suffix.
  50. Modular files are output to the directory location specified
  51. by the 'base.dir' parameter. If you want them in the current
  52. directory, then don't set that param.
  53. By default the assembly element is output to the current
  54. directory, *not* into base.dir with the modular files.
  55. The <resources> element in the assembly has its xml:base
  56. attribute set to the value of 'base.dir', so that it is
  57. added to the paths to the modular files when processed.
  58. If you set the stylesheet param 'manifest.in.base.dir'
  59. to 1, then the assembly file is created in the base.dir
  60. directory and the xml:base attribute is omitted (since
  61. they are together in the same directory).
  62. If you want the assembly file in 'base.dir' instead of
  63. the current directory, then set the stylesheet param
  64. 'manifest.in.base.dir' to 1.
  65. The stylesheet chunks a document into modules at the
  66. same boundaries as the chunking XHTML stylesheet, because
  67. it reuses many of the chunking stylesheet templates.
  68. You can alter the chunking behavior with the same options
  69. as for XHTML chunking.
  70. For example, the stylesheet will chunk sections into topics
  71. down to section level 3 by default. To change that level,
  72. change the stylesheet param 'chunk.section.depth' to
  73. another value.
  74. Finer control of chunking can be achieved by using
  75. the <?dbhtml stop-chunking?> processing instruction in
  76. the source file.
  77. Many modular elements retain their original element name,
  78. such as glossary, bibliography, index, and such. By default, the
  79. stylesheet converts chapter, article, preface and section elements
  80. into <topic> modules. To change that list of
  81. converted element names, alter the stylesheet param named
  82. 'topic.elements'. If that param is empty, then no elements
  83. will be converted to <topic>, so they will all retain their
  84. original element names.
  85. Modular filenames use the same naming scheme as the chunking
  86. XHTML stylesheet, and supports the same file naming options such as
  87. the param 'use.id.as.filename', which is set to 1 by default.
  88. Note that the stylesheet param 'html.ext' is set to '.xml'
  89. because it is producing modular XML files, not HTML files.
  90. Root element conversion
  91. ------------------------
  92. By default, the root element of the original document is
  93. also converted to a module, and <structure> gets a resourceref
  94. attribute to reference it. If you set the stylesheet
  95. param 'root.as.resourceref' to zero, then the root element
  96. is handled differently, as described as follows.
  97. If the structure element does not have a resourcref
  98. attribute, the root element is constructed rather
  99. than copied from a resource. The structure element must
  100. have a renderas attribute (or its child output element must
  101. have such) to select the output root element name.
  102. Any content between the root element start tag and the
  103. first module is put into a resource with the original
  104. root element. To pull this content in, the first
  105. module in the structure points to this resource but
  106. uses a contentonly="yes" attribute. The effect of
  107. that attribute is to pull in all content *except*
  108. the root element of that resource.
  109. In general, if you have content that does not logically
  110. have its own container element, you can put the content
  111. into a suitable container element and then deselect the
  112. container element upon assembly with the contentonly="yes"
  113. attribute. That attribute can also be used to avoid
  114. pulling in a resource's xml:id when you want to change it.
  115. To process an <assembly> into an assembled DocBook document
  116. ==============================================================
  117. To convert an <assembly> and its associated modular
  118. files into a single DocBook document, process
  119. your assembly document with the assemble.xsl stylesheet.
  120. You should then be able to process the resulting
  121. document with a DocBook XSL formatting stylesheet.
  122. Useful params in assemble.xsl
  123. -----------------------------
  124. The $root.default.renderas param sets the name of the
  125. root element of the assembled document, if it is not
  126. otherwise specified with @renderas. Its default value
  127. is 'book'.
  128. The $topic.default.renderas param sets the name of the
  129. output element for any topic element included in the
  130. assembly, if it is not otherwise specified with
  131. @renderas. It's default value is 'section'.
  132. The $structure.id param lets you specify at runtime
  133. the id value of the structure you want to reassemble.
  134. This is only necessary if you have more than one
  135. structure element in your assembly.
  136. The $output.type param also lets you specify at runtime
  137. which structure element to process. In this case,
  138. the value should match on an @type attribute on
  139. the structure element.
  140. The $output.format param lets you specify at runtime
  141. which of several possible output formats are being generated.
  142. The param value is compared to the @format
  143. attribute on <output> elements to select specific properties
  144. for a module.
  145. Unsupported Features
  146. -----------------------
  147. The transforms and transform elements are currently ignored
  148. by the assembly stylesheet.
  149. The relationships and relationship elements are currently
  150. ignored by the assembly stylesheet.
  151. The filterin and filterout elements are not currently
  152. supported.