docbook: centering?
Subject:
Re: centering?
From:
Dan York ####@####.####
Date:
6 Feb 2002 16:43:10 -0000
Message-Id: <20020206113620.M30743@e-smith.com>
David,
> How can I specify that a paragraph be centered?
As mentioned, this is a stylesheet issue. Completely off the top of
my head, I'll make a suggestion on how to do it using XSLT (sorry,
don't know DSSSL well enough).
First, I'll make the assumption that you want to center simply
a paragraph inside of a <para> element. If you want to center a
<sect1> or something else, the hack I'm going below would be similar.
1. So, first I would go into your DocBook XML file and add a 'role'
attribute (hmmm... maybe it would be better as 'align'). So the
resulting XML looks like:
<para role="center">This text will be centered</para>
<para>This text will not.</para>
2. Go into the DocBook XSLT stylesheets, in the 'html' directory, and
find the XSLT file that contains the template for the DocBook element
whose style you want to modify. In the case of <para>, it is in
'block.xsl' and looks like:
<xsl:template match="para">
<p>
<xsl:if test="position() = 1 and parent::listitem">
<xsl:call-template name="anchor">
<xsl:with-param name="node" select="parent::listitem"/>
</xsl:call-template>
</xsl:if>
<xsl:call-template name="anchor"/>
<xsl:apply-templates/>
</p>
</xsl:template>
3. Copy this to your XSLT customization layer and modify it to add
the HTML 'align' attribute to the first <p> based on whether the role
attribute exists and is set to 'center'. It would probably be this:
<xsl:template match="para">
<xsl:choose>
<xsl:when test="(@role='center')">
<p align="center">
</xsl:when>
<xsl:otherwise>
<p>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="position() = 1 and parent::listitem">
<xsl:call-template name="anchor">
<xsl:with-param name="node" select="parent::listitem"/>
</xsl:call-template>
</xsl:if>
<xsl:call-template name="anchor"/>
<xsl:apply-templates/>
</p>
</xsl:template>
I think that would do it... haven't tried it, but that is my guess.
Regards,
Dan