README 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. DocBook stylesheets for EPUB 3 output
  2. =============================================
  3. This directory contains XSL stylesheets
  4. for generating EPUB3 output from DocBook content.
  5. For more information on EPUB3, see:
  6. http://idpf.org/epub/30
  7. These EPUB3 stylesheets are a customization layer on
  8. top of the xhtml5/ stylesheets in this distribution, which
  9. are in turn a customization layer on top of the
  10. xhtml/ stylesheets in this distribution.
  11. Using a customization layer enables the EPUB3
  12. stylesheets to inherit all the features of the
  13. XHTML stylesheets while making the minimum changes
  14. for them to produce valid EPUB3.
  15. Usage
  16. -----------
  17. The general process for creating an EPUB3 ebook is:
  18. 1. Generate chunked XHTML5 content that validates against
  19. the EPUB3 schemas, and generate the EPUB3 package
  20. files.
  21. 2. Copy any image files into the output directory.
  22. 3. Run a zip command to create an .epub file.
  23. 4. Validate the .epub file.
  24. Following are the steps in more detail.
  25. 1. Create the XHTML5 files.
  26. -----------------------------
  27. The first step is handled by these stylesheets.
  28. To generate EPUB3-compatible XHTML5 files,
  29. use one of the following stylesheets as you would any
  30. other DocBook XSL stylesheet:
  31. epub3/chunk.xsl - Chunked output.
  32. epub3/profile-chunk.xsl - Profiled chunk output.
  33. Although the stylesheet directory contains a docbook.xsl
  34. stylesheet for single file output, that is not useful for
  35. generated EPUB3.
  36. You should set the $base.dir stylesheet param to the
  37. subdirectory that will contain the .xhtml files and
  38. the epub package files. Here is an example using xsltproc:
  39. xsltproc \
  40. --stringparam base.dir ebook1/OEBPS/ \
  41. epub3/chunk.xsl \
  42. mybook.xml
  43. After processing a document with this setting, you should find
  44. the following output:
  45. ebook1/mimetype - required mimetype file.
  46. ebook1/META-INF/container.xml - required container file
  47. ebook1/OEBPS/package.opf - required package file
  48. ebook1/OEBPS/toc.ncx - optional NCX file for backwards compatibility
  49. ebook1/OEBPS/docbook-epub.css - CSS file
  50. ebook1/OEBPS/*.xhtml - The chunked content files.
  51. 2. Copy image files
  52. ---------------------------
  53. Manually copy any image files used in the document
  54. into the corresponding locations in the $base.dir
  55. directory. For example, if your document contains:
  56. <imagedata fileref="images/caution.png"/>
  57. In this example base.dir, you would copy the file to:
  58. ebook1/OEBPS/images/caution.png
  59. You can get a list of image files from the manifest file
  60. named ebook1/OEBPS/package.opf that is created by the
  61. stylesheet. It includes references to image files for
  62. callouts and admonitions if they are used in the output.
  63. Note that the header and footer images are turned off for
  64. EPUB3 output.
  65. 3. Create the epub3 file.
  66. -----------------------------
  67. Change to the directory containing the base.dir (ebook1
  68. in this example), and run the following zip command to
  69. create the epub file:
  70. zip -r -X mybook.epub mimetype META-INF OEBPS
  71. The -r option means recursively include all directories.
  72. The -X option excludes extra file attributes (required by epub3).
  73. The "mybook.epub" in this example is the output file.
  74. The other three arguments must appear in this order.
  75. 4. Validating with epubcheck 3
  76. -----------------------------------
  77. There is a java program that can be used to check an
  78. epub3 file for conformance. It is currently available
  79. from this website:
  80. http://code.google.com/p/epubcheck/wiki/EPUBCheck30
  81. That website provides a download link, and information on
  82. how to run the command.
  83. Testing with EPUB readers
  84. ----------------------------
  85. The EPUB3 standard is not yet widely supported. The output of
  86. these stylesheets has been tested in the following readers:
  87. Apple iBooks on an iPod and iPad.
  88. - Handles videodata and audiodata.
  89. - Does not format MathML yet.
  90. - Handles SVG.
  91. Firefox browser with the EPUBReader version 1.4.10 add-on.
  92. - Formats MathML nicely.
  93. - Does not handle videodata or audiodata yet.
  94. - Handles SVG.
  95. Ibis EPUB3 preview version
  96. - Does not format MathML yet.
  97. - Does not handle videodata or audiodata yet.
  98. - Handles SVG with external viewer.
  99. EPUB metadata
  100. ========================
  101. The info child of the document's root element is used
  102. by the stylesheet to create EPUB metadata. Note that
  103. metadata is plain text, so element content is converted
  104. to text using the XSL normalize-space() function.
  105. Here is the current mapping of info elements to EPUB
  106. metadata. Any others are ignored for metadata, but
  107. may appear on the EPUB HTML titlepage, depending on the
  108. titlepage customization.
  109. NOTE: the <dc:*> elements (not attributes of meta) duplicate
  110. the meta elements for backwards compatibility, per the
  111. EPUB3 specification. They can be turned off with the
  112. $epub.include.optional.metadata.dc.elements parameter.
  113. abstract
  114. ---------
  115. The content must be converted to a text string for the
  116. OPF metadata. The stylesheet converts only title, para,
  117. formalpara, and simpara children in an abstract. All other
  118. child elements are ignored. It puts any title first.
  119. The OPF output appears as:
  120. <meta property="dcterms:description">title: abstract text</meta>
  121. <dc:description>title: abstract text</dc:description>
  122. author
  123. -------
  124. If uses a personname child, then it applies the
  125. DocBook XSL person.name template to arrange the name.
  126. Otherwise processes org or orgname into the content.
  127. Then it outputs:
  128. <meta id="meta-creator1" property="dcterms:creator">Firstname Surname</meta>
  129. <dc:creator id="pub-creator1">Firstname Surname</dc:creator>
  130. If there are multiple authors, the number in the id attribute
  131. is incremented each time.
  132. authorgroup
  133. -------------
  134. Applies templates to all of its children.
  135. bibliocoverage
  136. ---------------
  137. <meta property="dcterms:coverage">bibliocoverage text</meta>
  138. <dc:coverage>bibliocoverage text</dc:coverage>
  139. biblioid
  140. --------------
  141. This usually has @class="isbn" for the ISBN number. It is used
  142. as the EPUB3 unique-identifier. That isbn value
  143. is also output as follows:
  144. <meta id="meta-identifier" property="dcterms:identifier">urn:isbn:value</meta>
  145. <dc:identifier id="pub-identifier">urn:isbn:value</dc:identifier>
  146. A biblioid element with other class names are converted in a similar manner.
  147. bibliorelation
  148. ----------------
  149. <meta property="dcterms:relation">bibliorelation text</meta>
  150. <dc:relation>bibliorelation text</dc:relation>
  151. bibliosource
  152. ----------------
  153. <meta property="dcterms:source">bibliosource text</meta>
  154. <dc:source>bibliosource text</dc:source>
  155. collab
  156. ------------
  157. If a personname child is used, then it calls the
  158. person.name template, otherwise is uses the orgname or
  159. collabname text.
  160. <meta property="dcterms:contributor">collab text</meta>
  161. <dc:contributor>collab text</dc:contributor>
  162. copyright
  163. -------------
  164. Arranges the copyright elements into a text string with
  165. copyright symbol, dates, and holder, and then
  166. generates:
  167. <meta property="dcterms:right">Copyright text</meta>
  168. <dc:right>Copyright text</dc:right>
  169. Also, if there is no info/date element, then the copyright
  170. year is used to generate:
  171. <meta property="dcterms:date">year</meta>
  172. <dc:date>year</dc:date>
  173. corpauthor
  174. ------------
  175. <meta id="meta-creator1" property="dcterms:creator">corpauthor text</meta>
  176. <dc:creator id="pub-creator1">corpauthor text</dc:creator>
  177. corpcredit
  178. ------------
  179. <meta property="dcterms:contributor">corpcredit text</meta>
  180. <dc:contributor>corpcredit text</dc:contributor>
  181. date
  182. -------------
  183. <meta property="dcterms:date">date text</meta>
  184. <dc:date>date text</dc:date>
  185. See also: copyright.
  186. editor
  187. --------------
  188. If a personname child is used, then it calls the
  189. person.name template, otherwise is uses the orgname text.
  190. An editor can be considered as either a creator (when there
  191. is no author) or a contributor. The stylesheet parameter
  192. 'editor.property' can be set to either 'creator' or
  193. 'contributor' (default) at runtime. So the output is either:
  194. <meta property="dcterms:contributor">editor text</meta>
  195. <dc:contributor>editor text</dc:contributor>
  196. or
  197. <meta property="dcterms:creator">editor text</meta>
  198. <dc:creator>editor text</dc:creator>
  199. isbn, issn, etc.
  200. -----------------
  201. Handled like biblioid @class="isbn".
  202. keyword
  203. -----------
  204. <meta property="dcterms:subject">keyword text</meta>
  205. <dc:subject>keyword text</dc:subject>
  206. keywordset
  207. ------------
  208. Applies templates to its children.
  209. othercredit
  210. ------------
  211. Handled like collab.
  212. pubdate
  213. ------------
  214. Handled like date.
  215. publisher
  216. --------------
  217. Applies templates only to publishername.
  218. publishername
  219. ---------------
  220. <meta property="dcterms:publisher">publishername text</meta>
  221. <dc:publisher>publishername text</dc:publisher>
  222. subjectset
  223. --------------
  224. Applies templates to subject/subjecterm descendants.
  225. subjectterm
  226. ------------------
  227. <meta property="dcterms:subject">subjecterm text</meta>
  228. <dc:subject>subjecterm text</dc:subject>