This is the mail archive of the
docbook-apps@lists.oasis-open.org
mailing list .
Re: how to recognize depth of section for CSS
- From: Bob Stayton <bobs at caldera dot com>
- To: abx at abx dot art dot pl, docbook-apps at lists dot oasis-open dot org
- Date: Fri, 06 Dec 2002 09:08:05 -0800
- Subject: Re: DOCBOOK-APPS: how to recognize depth of section for CSS
- References: <dtv0vugepf7ijmvhsl2nf8fbp3rsi291r3@4ax.com>
On Fri, Dec 06, 2002 at 11:59:29AM +0100, ABX wrote:
> Whe I apply any of xhtml outputs from XSL 1.58 to the sections then they are
> outputed into file as
>
> <div class="section">....</div>
>
> I want then apply intendation to this rendering with
>
> div.section {
> margin-left:20px;
> }
>
> This cause that every next level section level has larger margin. It works
> nice. Now I want to customize it so margin would increase for sections at
> <h1>, <h2> and <h3> level but for <h4> and deeper it should be the same as for
> <h3>. I suppose I could do it using sect1, sect2, sect3... but there is a
> problem. We move content from time to time and change level of section. It
> could be hard to modify sect numbering each time we move content. Much usefull
> it could be if XSL templates could investigate section level and output it as:
>
> <div class="section_1">
> <h1>title1</h1>
> <div class="section_2">
> <h2>title2</h2>
> <div class="section_3">
> <h3>title3</h3>
> <div class="section_4">
> <h3>title4</h4>
> </div>
> </div>
> </div>
> </div>
>
> Any advice how to customize XSL for such output ?
Copy the template <xsl:template match="section" from
html/sections.xsl to your customization layer, and
change the top of it from:
<xsl:template match="section">
<xsl:variable name="depth" select="count(ancestor::section)+1"/>
<div class="{name(.)}">
to:
<xsl:template match="section">
<xsl:variable name="depth" select="count(ancestor::section)+1"/>
<div class="{name(.)}_{$depth}">
--
Bob Stayton 400 Encinal Street
Publications Architect Santa Cruz, CA 95060
Technical Publications voice: (831) 427-7796
The SCO Group fax: (831) 429-1887
email: bobs@sco.com