olinktest/ 0000775 0034577 0033635 00000000000 07445604342 0013572 5 ustar 00docadmin doc 0016777 0000001 olinktest/userguide.xml 0000644 0034577 0033635 00000010015 07445551421 0016302 0 ustar 00docadmin doc 0016777 0000001
]>
Publishing DocBook Documents
Creating and editing SGML/XML documents is usually only half the
battle. After you've composed your document, you'll want to publish
it. Publishing, for our purposes, means either print or web
publishing. For SGML and XML documents, this is usually
accomplished with some kind of stylesheet. In
the (not too distant) future, you may be able to publish an XML
document on the Web by simply putting it online with a stylesheet, but
for now you'll probably have to translate your document into HTML.
Try an olink with content to
css stylesheet
to see how it will work, and another olink without content to
so we can see it can fill in the text.
Finally, let's create a failing olink
to see what that looks like.
There are many ways, using both free and commercial tools, to publish
SGML documents. In this chapter, we're going to survey a number of
possibilities.
DocBook XSL Architecture
DocBook stylesheets are modular files that pulled into a complete
stylesheet by a driver file.
XSL is a template language, not a procedural
language. That means a stylesheet specifies a sample of the
output, not a sequence of programming steps to generate it.
A stylesheet consists of a mixture of output samples with
instructions of what to put in each sample. Each bit of
output sample and instructions is called
a template.
In general, you write a template for each element
type in your document. That lets you concentrate on
handling just one element at a time, and keeps a stylesheet
modular. The power of XSL comes from processing the
templates recursively. That is, each template handles the
processing of its own element, and then calls other
templates to process its children, and so on. Since an XML
document is always a single root element at the top level
that contains all of the nested descendent elements, the
XSL templates also start at the top and work their way down
through the hierarchy of elements.
Take the
DocBook <para> paragraph element as
an example. To convert this to HTML, you want to wrap the
paragraph content with the HTML
tags <p> and </p>.
But a DocBook <para> can contain
any number of in-line DocBook elements marking up the text.
Fortunately, you can let other templates take care of those
elements, so your XSL template
for <para> can be quite
simple:
<xsl:template match="para">
<p>
<xsl:apply-templates/>
</p>
</xsl:template>
The <xsl:template> element
starts a new template, and
its match attribute indicates where to
apply the template, in this case to
any <para> elements. The template
says to output a literal <p> string
and then execute
the <xsl:apply-templates/> instruction.
This tells the XSL processor to look among all the
templates in the stylesheet for any that should be applied
to the content of the paragraph. If each template in the
stylesheet includes
an <xsl:apply-templates/> instruction,
then all descendents will eventually be processed. When it
is through recursively applying templates to the paragraph
content, it outputs the </p> closing
tag.
;xsl:apply-templates/> instruction.
This tells the XSL processor to look among all the
templates in the stylesheet for any that should be applied
to the content of the paragraph. If each template in the
stylesheet includes
an <xsl:apply-templates/> instruction,
then all descendents will eventually be processed. When it
is through recursively applying templates to the paragraph
content, it outputs the </p> closing
tag.