Jason Zech | 19 Jul 2012 21:41
Favicon

separating chapter labels and titles

Hi all,

I am working with ns-1.77.1 stylesheets to transform to single and chunked xhtml. What I'd like to do is
produce chapter autolabels (perhaps other components later) in a different tag from the chapter titles.
Something like this:

<h1 class="chapter-label">Chapter 7</h1>
<h1 class="title">This Really Good Chapter Title</h1>

This would allow me a ton more flexibility using CSS to style my titlepages.

I've been tracing the long trip a chapter title makes through the stylesheets until my eyes are crossed and I
can't figure out where I could separate these 2 elements (especially since they are grouped together in
the gentext template).

Is this possible without a dramatic overhaul of the way titles are handled?

Thanks,

jz 
Bob Stayton | 20 Jul 2012 07:41

Re: separating chapter labels and titles

Hi Jason,
For this customization, I would suggest customizing the 'component.title' template 
from xhtml/component.xsl.  That template applies templates in 
mode="object.title.markup", which is the mechanism that uses the gentext template. 
Instead, use mode="label.markup" to generate the number, and mode="title.markup" to 
generate the title.  If you do each of those inside their own <h1> element, you can 
add your separate class attributes.  For the chapter number to say "Chapter", you will 
have to also call the template named 'gentext' as in the example below.

The component.title template is used by almost all direct children of book, though, so 
you might want to use an xsl:choose statement to apply this change only when 
local-name($node) = 'chapter', and use the default behavior otherwise.

...
<xsl:when test="local-name($node) = 'chapter'>
  <h1 class="chapter-label">
    <xsl:call-template name="gentext">
      <xsl:with-param name="key">chapter</xsl:with-param>
    </xsl:call-template>
    <xsl:text> </xsl:text>
    <xsl:apply-templates select="$node" mode="label.markup"/>
  </h1>
  <h1 class="title">
    <xsl:apply-templates select="$node" mode="title.markup"/>
  </h1>
</xsl:when>
...

Bob Stayton
Sagehill Enterprises
(Continue reading)


Gmane