[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: Re: [docbook-apps] Novice questions (repost)
Bob Stayton
Sagehill Enterprises
DocBook Consulting
bobs@sagehill.net
----- Original Message -----
From: "Mads Ipsen" <mpi@osc.kiku.dk>
To: <docbook-apps@lists.oasis-open.org>
Sent: Monday, January 15, 2007 6:21 AM
Subject: [docbook-apps] Novice questions (repost)
> Dear DocBook users,
>
> This is my second attempt at posting these questions; I believe that
> my first attempt ended up as a reply to a previous posting.
>
> If you believe that this forum is out-of-scope for the questions I
> raise, please let me know, and I'll try to find help elsewhere.
>
> First of all, these are real novice questions, but I hope some of you
> will have the time to provide some feedback to my questions:
>
> 1. Using the style sheet
>
> /usr/share/xml/docbook/stylesheet/nwalsh/xhtml/docbook.xsl
>
> DocBook generates html files where the whole string ass. with a
> figure title gets formatted in bold. I prefer: Figure + number in
> bold and the caption text in roman, eg.
>
> <b>Figure 1</b>: Blah. blah.
>
> Here's my approach for dealing with this from a user supplied style
> sheet:
>
> <xsl:template name="formal.object.heading">
> ...
> <p class="title">
> <xsl:choose>
> <xsl:when test="contains($title,'Figure')">
> <b>
> <xsl:value-of select="substring-before($title,'.')"/>
> </b>:
> <xsl:value-of select="substring-after($title,'.')"/>
> </xsl:when>
> <xsl:otherwise>
> <xsl:value-of select="$title"/>
> </xsl:otherwise>
> </xsl:choose>
> </p>
> </xsl:template>
>
> It works, but I am starting to choose a wrong track here?
>
This is a bit hazardous for two reasons: it selects the text based on the
".", but a figure number might be 3.2., in which case it doesn't get it
right. Also, using xsl:value-of removes any markup in the processed $title,
so you could lose any subscript/superscript markup, internal italic, etc.
The object.title.markup mode used in formal.object.heading gets a gentext
template from the locale collection and fills in the number and title. I
would suggest customizing the gentext string for figure title to remove the
title, and then using mode="title.markup" in this template to restore the
title outside the <b>. Something like this:
This part customizes the gentext template:
<xsl:param name="local.l10n.xml" select="document('')"/>
<l:i18n xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0">
<l:l10n language="en">
<l:context name="title">
<l:template name="figure" text="Figure %n. "/>
</l:context>
</l:l10n>
</l:i18n>
This is the customized formal.object.heading:
<xsl:template name="formal.object.heading">
<xsl:param name="object" select="."/>
<xsl:param name="title">
<xsl:apply-templates select="$object" mode="object.title.markup">
<xsl:with-param name="allow-anchors" select="1"/>
</xsl:apply-templates>
</xsl:param>
<p class="title">
<xsl:choose>
<xsl:when test="self::figure">
<b>
<xsl:copy-of select="$title"/>
</b>
<xsl:apply-templates select="." mode="title.markup"/>
</xsl:when>
<xsl:otherwise>
<b>
<xsl:copy-of select="$title"/>
</b>
</xsl:otherwise>
</xsl:choose>
</p>
</xsl:template>
> 2. For the html representation of my documentation, I need to insert
> a graphical header and the beginning and end of each sect1 <div>
> to achive a rounded appearance of the block. Something along the
> lines:
>
> <div class="sect1" lang="en" xml:lang="en">
> <div id="contentUpper">
> <img src="images/main_center_header_660px.png" alt="" />
> </div>
> ...
> <div id="contentLower">
> <img src="images/main_center_footer_660px.png" alt="" />
> </div>
> </div>
>
> It took me 5 min. to write a Python script that uses regular
> expression for matching and inserting these items - but are there
> a cleaner style sheet based solution? I tried fiddling with
>
> <xsl:template match="sect1">
>
> but that completely messes up the chunking.
Customizing the template for sect1 is the right way to go, but you need to
pay careful attention to the sequence of xsl:imports used. There are
actually two templates matching on sect1. The original template in
sections.xsl formats the section content. The extra template in
chunk-code.xsl handles putting the formatted content into a chunked file.
Your customization messes up the latter process without affecting the
former. This reference describes how to set up a two-stage import process
so you can change the formatting template without affecting the chunking
template:
http://www.sagehill.net/docbookxsl/ChunkingCustomization.html
>
> 3. At some time soon, I will have to start caring about print as
> well, i.e. PDF reps. Do you have any suggestions of the
> postprocessors that I should use (commercial or free). Its
> imperative that they can handle MathML.
>
> Thanks for taking your time to read this. If you have any feedback,
> please let me know.
>
> Best, Mads
>
>
> ---------------------------------------------------------------------
> 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]