You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ch05.html 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <html><head>
  2. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  3. <title>Chapter 5. The Template System</title><link rel="stylesheet" href="reference.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V2"><link rel="home" href="index.html" title="DocBook XSL Stylesheet Documentation"><link rel="up" href="index.html" title="DocBook XSL Stylesheet Documentation"><link rel="previous" href="ch04.html" title="Chapter 4. Reference Documentation"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 5. The Template System</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch04.html">Prev</a>&nbsp;</td><th width="60%" align="center">&nbsp;</th><td width="20%" align="right">&nbsp;</td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><h2 class="title"><a name="d0e982"></a>Chapter 5. The Template System</h2></div><div><h3 class="author">Norman Walsh</h3></div><div><p class="releaseinfo">
  4. $Id: ch05.html,v 1.1 2002/05/15 17:22:23 isberg Exp $
  5. </p></div><div><p class="copyright">Copyright &copy; 2000 Norman Walsh</p></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><a href="ch05.html#d0e1006">Changing the Article Title Page</a></dt></dl></div><p>Some parts of the DocBook XSL Stylesheets are actually generated
  6. using XSL Stylesheets. In particular, the formatting of title pages
  7. is generated using a special template system. The same template system
  8. will eventually allow you to easily customize bibliography entries and
  9. perhaps other parts of the system as well.</p><p>FIXME: there needs to be more introductory/explanatory text
  10. here!</p><div class="section"><a name="d0e1006"></a><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="d0e1006"></a>Changing the Article Title Page</h2></div></div><p>In order to demonstrate how this system works, let's consider
  11. how we can use it to change the format of article title pages.</p><p>By default, the stylesheets print the following elements on the
  12. article title page, in this order: <span class="simplelist"><tt>title</tt>, <tt>subtitle</tt>, <tt>corpauthor</tt>, <tt>authorgroup</tt>, <tt>author</tt>, <tt>releaseinfo</tt>, <tt>copyright</tt>, <tt>legalnotice</tt>, <tt>pubdate</tt>, <tt>revision</tt>, <tt>revhistory</tt>, <tt>abstract</tt></span>. Suppose we want to put only the
  13. <tt>title</tt>, <tt>author</tt>, and
  14. <tt>edition</tt> elements on the title page, in the order
  15. that they appear in the <tt>articleinfo</tt>.
  16. </p><p>The hard (and wrong!) way to do it would be to
  17. edit <tt>titlepage.templates.xsl</tt> and make the changes
  18. by hand.</p><p>The easy and right way is to construct a template document that
  19. describes the order and sequence of elements that you want:</p><pre class="screen">
  20. &lt;t:templates xmlns:t="http://nwalsh.com/docbook/xsl/template/1.0"
  21. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  22. base-stylesheet="/path/to/html/docbook.xsl"&gt;
  23. &lt;t:titlepage element="article" wrapper="div" class="titlepage"&gt;
  24. &lt;t:titlepage-content side="recto" order="document"&gt;
  25. &lt;title predicate="[1]"/&gt;
  26. &lt;author/&gt;
  27. &lt;edition/&gt;
  28. &lt;/t:titlepage-content&gt;
  29. &lt;/t:titlepage&gt;
  30. &lt;/t:templates&gt;
  31. </pre><p>Then process this document with the
  32. <tt>template/titlepage.xsl</tt> stylesheet. This will
  33. produce the following somewhat cryptic stylesheet:</p><pre class="screen">
  34. &lt;?xml version="1.0" encoding="utf-8"?&gt;
  35. &lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"&gt;
  36. &lt;!-- This stylesheet was created by titlepage.xsl; do not edit it by hand. --&gt;
  37. &lt;xsl:import href="/path/to/html/docbook.xsl"/&gt;
  38. &lt;xsl:template name="article.titlepage.recto"&gt;&lt;xsl:apply-templates mode="article.titlepage.recto.mode" select="(articleinfo/title|artheader/title|title)[1]|articleinfo/author|artheader/author|articleinfo/edition|artheader/edition"/&gt;
  39. &lt;/xsl:template&gt;
  40. &lt;xsl:template name="article.titlepage"&gt;
  41. &lt;div class="titlepage"&gt;
  42. &lt;xsl:call-template name="article.titlepage.before.recto"/&gt;
  43. &lt;xsl:call-template name="article.titlepage.recto"/&gt;
  44. &lt;xsl:call-template name="article.titlepage.before.verso"/&gt;
  45. &lt;xsl:call-template name="article.titlepage.verso"/&gt;
  46. &lt;xsl:call-template name="article.titlepage.separator"/&gt;
  47. &lt;/div&gt;
  48. &lt;/xsl:template&gt;
  49. &lt;/xsl:stylesheet&gt;
  50. </pre><p>Despite its cryptic appearance, it has the desired result.
  51. If you want to change <span class="emphasis"><i>how</i></span> the titlepage elements
  52. are formatted (as opposed to which ones are formatted), you have to
  53. write your own customization layer that overrides the template for
  54. the element in question in the titlepage.mode mode.</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch04.html">Prev</a>&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right">&nbsp;</td></tr><tr><td width="40%" align="left">Chapter 4. Reference Documentation&nbsp;</td><td width="20%" align="center"><a accesskey="u" href="index.html">Up</a></td><td width="40%" align="right">&nbsp;</td></tr></table></div></body></html>