<chapter id="customize">
<?html-filename custom.html>
<docinfo>
<pubdate role=rcs>$Date: 2004/09/18 10:31:25 $</pubdate>
</docinfo>
<title>Customizing the Stylesheets</title>
<sect1>
<title>Deriving Your Own Stylesheet</title>
<para>The best way to customize the stylesheets is to write your own &ldquo;driver&rdquo;
file; this is a document which contains your local modifications to the stylesheet
and then includes the stylesheet from the standard distribution by reference.
This allows you to make local changes and extensions without modifying the
distributed files, which makes upgrading to the next release much, much simpler.
</para>
<para>The basic driver file looks like this:<screen>&lt;!DOCTYPE style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN" [
&lt;!ENTITY dbstyle SYSTEM "docbook.dsl" CDATA DSSSL>
]>

&lt;style-sheet>
&lt;style-specification use="docbook">
&lt;style-specification-body>

;; your stuff goes here...

&lt;/style-specification-body>
&lt;/style-specification>
&lt;external-specification id="docbook" document="dbstyle">
&lt;/style-sheet>

</screen></para>
<para>Make sure that you specify, in the system identifier, the full path
to the <filename>docbook.dsl</filename> file that you want to customize; for
example, <filename>\docbook\print\docbook.dsl</filename>.</para>
<note><para>The next stylesheet release will probably use public identifiers
to locate the stylesheets, which will simplify this problem a bit (at the
cost, naturally, of a little more complexity elsewhere; sigh).</para>
</note>
<para>You can add your own definitions, or redefinitions, of stylesheet rules
and parameters where<screen>;; your stuff goes here...</screen> occurs in
the example above.</para>
<para>The <filename>plain.dsl</filename> stylesheet in the <filename>docbook/print
</filename> directory is a customization of the <filename>docbook.dsl</filename>
print stylesheet. It turns off title page and TOC generation.</para>
</sect1>

<sect1>
<title>A Single Stylesheet for Both Print and HTML</title>
<para>A DSSSL <sgmltag>style-sheet</sgmltag> consists of one or more <sgmltag>
style-specification</sgmltag>s. This allows one to build a single stylesheet
that can format with either the print or HTML backends.</para>
<para>All you need is a customization skeleton that looks like this:</para>
<screen>&lt;!DOCTYPE style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN" [
&lt;!ENTITY % html "IGNORE">
&lt;![%html;[
&lt;!ENTITY % print "IGNORE">
&lt;!ENTITY docbook.dsl PUBLIC "-//Norman Walsh//DOCUMENT DocBook HTML Stylesheet//EN" CDATA dsssl>
]]&#62;
&lt;!ENTITY % print "INCLUDE">
&lt;![%print;[
&lt;!ENTITY docbook.dsl PUBLIC "-//Norman Walsh//DOCUMENT DocBook Print Stylesheet//EN" CDATA dsssl>
]]&#62;
]>
&lt;style-sheet>
&lt;style-specification id="print" use="docbook">
&lt;style-specification-body> 

;; customize the print stylesheet

&lt;/style-specification-body>
&lt;/style-specification>
&lt;style-specification id="html" use="docbook">
&lt;style-specification-body> 

;; customize the html stylesheet

&lt;/style-specification-body>
&lt;/style-specification>
&lt;external-specification id="docbook" document="docbook.dsl">
&lt;/style-sheet></screen>
<para>If this is <filename>both.dsl</filename>, I can format my document using
the print stylesheet by running<screen>jade -t rtf -d both.dsl#print file.sgm
</screen>and using the HTML stylesheet by running<screen>jade -t sgml -i html -d both.dsl#html file.sgm
</screen>which is kindof neat. (I've built some additional machinery on top
of this to make the selection automatic from within <ulink url="http://www.arbortext.com/">
ADEPT</ulink> and a shell script that I use.)</para>
<para>
An alternative method for doing this is simply to use marked sections
in the stylesheet, like this:
<screen>&lt;!DOCTYPE style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN" [
&lt;!ENTITY % html "IGNORE">
&lt;![%html;[
&lt;!ENTITY % print "IGNORE">
&lt;!ENTITY docbook.dsl PUBLIC "-//Norman Walsh//DOCUMENT DocBook HTML Stylesheet//EN" CDATA dsssl>
]]&#62;
&lt;!ENTITY % print "INCLUDE">
&lt;![%print;[
&lt;!ENTITY docbook.dsl PUBLIC "-//Norman Walsh//DOCUMENT DocBook Print Stylesheet//EN" CDATA dsssl>
]]&#62;
]>
&lt;style-sheet>
&lt;style-specification use="docbook">
&lt;style-specification-body> 

;; common customization can go here

&lt;![%print;[

;; customize the print stylesheet here

]]&gt;

&lt;![%html;[

;; customize the html stylesheet here

]]&gt;

&lt;/style-specification-body>
&lt;/style-specification>
&lt;external-specification id="docbook" document="docbook.dsl">
&lt;/style-sheet></screen></para>
</sect1>
<sect1>
<title>Customizing the Title Page</title>
<para>Titlepages are controlled by several variables:<variablelist>
<varlistentry>
<term><literal>%generate-<replaceable>element</replaceable>-titlepage%</literal></term>
<listitem><para>Controls whether or not a titlepage is generated. If, for
example, <literal>%generate-book-titlepage%</literal> is true, a titlepage
will be generated for <sgmltag>Book</sgmltag>s.</para>
</listitem></varlistentry>
<varlistentry>
<term><literal><replaceable>element</replaceable>-titlepage-recto-elements
</literal></term><listitem><para>Specifies the elements which should occur
on the titlepage recto. This variable is a list of GIs. For example, if <literal>
book-titlepage-recto-elements</literal> is <literal>'("TITLE" "SUBTITLE" "AUTHOR")
</literal>, then the <sgmltag>Title</sgmltag>, <sgmltag>SubTitle</sgmltag>,
and <sgmltag>Author</sgmltag> elements in the division or component's <sgmltag>
*Info</sgmltag> element will appear on the <sgmltag>Book</sgmltag>'s titlepage
recto.</para>
</listitem></varlistentry>
<varlistentry>
<term><literal><replaceable>element</replaceable>-titlepage-verso-elements
</literal></term><listitem><para>Specifies the elements which should occur
on the titlepage verso.</para>
</listitem></varlistentry>
<varlistentry>
<term><literal>%titlepage-in-info-order%</literal></term><listitem><para>
The content of the titlepage is drawn from the <sgmltag>*Info</sgmltag> element
at the beginning of a division or component. If <literal>%titlepage-in-info-order%
</literal> is true, the elements on the titlepage will occur in the order
in which they appear in the <sgmltag>*Info</sgmltag> element. Otherwise, the
elements occur in a fixed order given by the <literal><replaceable>element
</replaceable>-titlepage-<replaceable>side</replaceable>-elemnts</literal>.
</para>
</listitem></varlistentry>
<varlistentry>
<term><literal>%generate-<replaceable>element</replaceable>-toc-on-titlepage%
</literal></term><listitem><para>For some elements, such as <sgmltag>Part
</sgmltag>s, it may make sense to place the TOC for that element (if it is
generated) on the same page sequence as the titlepage. If <literal>%generate-<replaceable>
element</replaceable>-toc-on-titlepage%</literal> is true, that's what will
be done.</para>
</listitem></varlistentry>
<varlistentry>
<term><literal>%generate-partintro-on-titlepage%</literal></term><listitem>
<para><sgmltag>Part</sgmltag>s and <sgmltag>Reference</sgmltag>s can begin
with a <sgmltag>PartIntro</sgmltag>. If <literal>%generate-partintro-on-titlepage%
</literal> is true, the content of the <sgmltag>PartIntro</sgmltag> will occur
on the same page sequence as the titlepage.</para>
</listitem></varlistentry>
</variablelist></para>
<para>The most common customization is probably setting <literal>%generate-<replaceable>
element</replaceable>-titlepage%</literal> to true and changing the list of
elements in <literal><replaceable>element</replaceable>-titlepage-recto-elements
</literal> and <literal><replaceable>element</replaceable>-titlepage-verso-elements
</literal></para>
<para>There are a few other functions that you may wish to change:<variablelist>
<varlistentry>
<term><literal>(<replaceable>element</replaceable>-titlepage-before node side)
</literal></term><listitem><para>This function is called before each new type
of element on the titlepage (before the first <sgmltag>Title</sgmltag>, before
the first <sgmltag>SubTitle</sgmltag>, etc.). The <literal>node</literal>
will contain the element that will appear on the titlepage next and <literal>
side</literal> will be either <literal>'recto</literal> or <literal>'verso
</literal>.</para>
</listitem></varlistentry>
<varlistentry>
<term><literal>(<replaceable>element</replaceable>-titlepage-<replaceable>
component</replaceable> node side)</literal></term><listitem><para>This function
is called for each element on the titlepage. For example, the <sgmltag>Abstract
</sgmltag> on a <sgmltag>Book</sgmltag> titlepage is printed by the <literal>
book-titlepage-abstract</literal> function.</para>
</listitem></varlistentry>
</variablelist></para>
</sect1>
<sect1>
<title>Using the Stylesheets with XML</title>
<para>This is just a placeholder. This needs to be written. Basically, you
just need to use <filename>catalog</filename> files to make sure that the
XML instances and the stylesheets get parsed with the correct declarations.
</para>
</sect1>
</chapter>


