[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: RE: [docbook-apps] Using <h1> for chapter titles in HTML output
Here's the customization I made to cause chapter titles to use the <h1>
element in HTML output:
It seems to work. I'm posting it so that it's available in the
archives. If what I have done here does not make sense or is poor form,
would you let me know?
Thanks.
************************************************************
<!-- Cause chapter elements to be published with h1 HTML tags -->
<xsl:template name="component.title">
<xsl:param name="node" select="."/>
<xsl:variable name="level">
<xsl:choose>
<xsl:when test="ancestor::section">
<xsl:value-of select="count(ancestor::section)+1"/>
</xsl:when>
<xsl:when test="ancestor::chapter">0</xsl:when> <!-- Added this
line - pdesj -->
<xsl:when test="ancestor::sect5">6</xsl:when>
<xsl:when test="ancestor::sect4">5</xsl:when>
<xsl:when test="ancestor::sect3">4</xsl:when>
<xsl:when test="ancestor::sect2">3</xsl:when>
<xsl:when test="ancestor::sect1">2</xsl:when>
<xsl:otherwise>1</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Let's handle the case where a component (bibliography, for
example)
occurs inside a section; will we need parameters for this? -->
<xsl:element name="h{$level+1}">
<xsl:attribute name="class">title</xsl:attribute>
<xsl:call-template name="anchor">
<xsl:with-param name="node" select="$node"/>
<xsl:with-param name="conditional" select="0"/>
</xsl:call-template>
<xsl:apply-templates select="$node" mode="object.title.markup">
<xsl:with-param name="allow-anchors" select="1"/>
</xsl:apply-templates>
</xsl:element>
</xsl:template>
************************************************************
Peter Desjardins
SupplyScape Corporation
+1 781 503 7441
http://www.supplyscape.com
> -----Original Message-----
> From: Bob Stayton [mailto:bobs@sagehill.net]
> Sent: Thursday, February 01, 2007 13:00
> To: Peter Desjardins; docbook-apps@lists.oasis-open.org
> Subject: Re: [docbook-apps] Using <h1> for chapter titles in
> HTML output
>
> Hi Peter,
> The template named 'component.title' in html/component.xsl
> handles generating the <h2> element. It computes a $level
> variable and then adds 1 to get the h heading. You'll need
> to customize that to set $level to zero for chapters.
>
> Bob Stayton
> Sagehill Enterprises
> DocBook Consulting
> bobs@sagehill.net
>
>
> ----- Original Message -----
> From: "Peter Desjardins" <pdesjardins@supplyscape.com>
> To: <docbook-apps@lists.oasis-open.org>
> Sent: Thursday, February 01, 2007 9:11 AM
> Subject: [docbook-apps] Using <h1> for chapter titles in HTML output
>
>
> I am trying to customize HTML output so that MS Word will
> open the HTML
> files in a way that produces consistent paragraph styles. In
> particular, I want chapter titles in the DocBook content to
> become <h1>
> elements so that they eventually map to the default "Heading 1"
> paragraph style in MS Word. By default, the chapter title is
> output in
> an <h2> element.
>
> My searching the docbook-apps archives, HTML parameter documentation,
> and experimenting with XSL customizations has not turned up an answer
> for me.
>
> Can anyone point me to a configuration that will cause
> chapter titles to
> appear in the HTML <h1> element?
>
> In case it matters, the DocBook content uses <section> elements rather
> than <sect1>, <sect2>, and so on. Also, I don't mind that the <book>
> title is already <h1>. Having both the book and chapter
> titles use <h1>
> is not a problem for me.
>
> Thanks for your help.
>
> Peter Desjardins
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: docbook-apps-unsubscribe@lists.oasis-open.org
> For additional commands, e-mail:
> docbook-apps-help@lists.oasis-open.org
>
>
>
>
>
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]