docbook: Thread: centering?


[<<] [<] Page 1 of 1 [>] [>>]
Subject: centering?
From: David Merrill ####@####.####
Date: 31 Jan 2002 22:05:41 -0000
Message-Id: <20020131225645.GA25733@lupercalia.net>

How can I specify that a paragraph be centered?

-- 
David C. Merrill                         http://www.lupercalia.net
Linux Documentation Project                   ####@####.####
Collection Editor & Coordinator            http://www.linuxdoc.org

You cannot avoid the interplay of politics within an orthodox religion.
This power struggle permeates the training, educating and disciplining of
the orthodox community. Because of this pressure, the leaders of such a
community inevitably must face that ultimate internal question: to succumb
to complete opportunism as the price of maintaining their rule, or risk
sacrificing themselves for the sake of the orthodox ethic.
	-- from "Muad'Dib: The Religious Issues" by the Princess Irulan
Subject: Re: centering?
From: Dan Scott ####@####.####
Date: 1 Feb 2002 00:17:45 -0000
Message-Id: <1012522687.9162.1.camel@falstaff.66broadway.com>

To be blunt, you don't. You mark up the text according to the content,
then let the stylesheets format it.

Dan

On Thu, 2002-01-31 at 17:56, David Merrill wrote:
> How can I specify that a paragraph be centered?
> 
> -- 
> David C. Merrill                         http://www.lupercalia.net
> Linux Documentation Project                   ####@####.####
> Collection Editor & Coordinator            http://www.linuxdoc.org
> 
> You cannot avoid the interplay of politics within an orthodox religion.
> This power struggle permeates the training, educating and disciplining of
> the orthodox community. Because of this pressure, the leaders of such a
> community inevitably must face that ultimate internal question: to succumb
> to complete opportunism as the price of maintaining their rule, or risk
> sacrificing themselves for the sake of the orthodox ethic.
> 	-- from "Muad'Dib: The Religious Issues" by the Princess Irulan
> 
> _________________________
> http://list.linuxdoc.org/
> 


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
[<<] [<] Page 1 of 1 [>] [>>]


  ©The Linux Documentation Project, 2014. Listserver maintained by dr Serge Victor on ibiblio.org servers. See current spam statz.