Hi,
in {xhtml,html}/docbook.xsl there is the head.content template. The
head.content does a lot of things: It creates a title, some CSS stylesheets
references, and meta tags.
Unfortunately, customizing is a bit inconvenient: You have to copy *all* the
content, although you just want to change the <style> element, for example.
Same for meta information.
As this is one "central" piece when generating HTML, wouldn't it be more user
friendly to split it into smaller pieces allowing easier customization?
I've added a small patch which moves some elements into separate templates.
That makes it a lot easier to customize just the necessary parts without
touching head.content. I've named them header.content.<PURPOSE>:
* head.content.base
Creates <base href="{$html.base}"/>
* head.content.link.made
Creates <link rev="made" href="{$link.mailto.url}"/>
* head.content.generator
<meta name="generator" content="DocBook {$DistroTitle} V{$VERSION}"/>
* head.content.abstract
Creates a <meta name="description"> tag and adds all the content from an
abstract element
* head.content.style
Creates a <style type="text/css"> to support draft mode
The first three might be debatable as all three create just one element. The
question is, is there are a need to customize, e.g., a <base/> element? Or to
create a generator meta element directly?
Apart from the first three, the head.content.abstract and head.content.style
templates are useful. People might want to customize what should go inside an
meta description. Or change the content of <style> for the draft mode.
What do you think? Comments, suggestions, ideas? :-)
Thanks!
--
Gruß/Regards
Thomas Schraitle
--- docbook.xsl.bak 2012-09-12 19:54:11.939057473 +0200
+++ docbook.xsl 2012-09-12 20:01:09.045387110 +0200
@@ -125,6 +125,69 @@
</xsl:if>
</xsl:template>
+<xsl:template name="head.content.base">
+ <xsl:param name="node" select="."/>
+ <base href="{$html.base}"/>
+</xsl:template>
+
+<xsl:template name="head.content.abstract">
+ <xsl:param name="node" select="."/>
+ <xsl:variable name="info" select="(articleinfo
+ |bookinfo
+ |prefaceinfo
+ |chapterinfo
+ |appendixinfo
+ |sectioninfo
+ |sect1info
+ |sect2info
+ |sect3info
+ |sect4info
+ |sect5info
+ |referenceinfo
+ |refentryinfo
+ |partinfo
+ |info
+ |docinfo)[1]"/>
+ <xsl:if test="$info and $info/abstract">
+ <meta name="description">
+ <xsl:attribute name="content">
+ <xsl:for-each select="$info/abstract[1]/*">
+ <xsl:value-of select="normalize-space(.)"/>
+ <xsl:if test="position() < last()">
+ <xsl:text> </xsl:text>
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:attribute>
+ </meta>
+ </xsl:if>
+</xsl:template>
+
+<xsl:template name="head.content.link.made">
+ <xsl:param name="node" select="."/>
+
+ <link rev="made" href="{$link.mailto.url}"/>
+</xsl:template>
+
+<xsl:template name="head.content.generator">
+ <xsl:param name="node" select="."/>
+ <meta name="generator" content="DocBook {$DistroTitle} V{$VERSION}"/>
+</xsl:template>
+
+<xsl:template name="head.content.style">
+ <xsl:param name="node" select="."/>
+ <style type="text/css"><xsl:text>
+body { background-image: url('</xsl:text>
+<xsl:value-of select="$draft.watermark.image"/><xsl:text>');
+ background-repeat: no-repeat;
+ background-position: top left;
+ /* The following properties make the watermark "fixed" on the page. */
+ /* I think that's just a bit too distracting for the reader... */
+ /* background-attachment: fixed; */
+ /* background-position: center center; */
+ }</xsl:text>
+ </style>
+</xsl:template>
+
<xsl:template name="head.content">
<xsl:param name="node" select="."/>
<xsl:param name="title">
@@ -137,7 +200,9 @@
</xsl:call-template>
<xsl:if test="$html.base != ''">
- <base href="{$html.base}"/>
+ <xsl:call-template name="head.content.base">
+ <xsl:with-param name="node" select="$node"/>
+ </xsl:call-template>
</xsl:if>
<!-- Insert links to CSS files or insert literal style elements -->
@@ -156,58 +221,28 @@
</xsl:if>
<xsl:if test="$link.mailto.url != ''">
- <link rev="made"
- href="{$link.mailto.url}"/>
+ <xsl:call-template name="head.content.link.made">
+ <xsl:with-param name="node" select="$node"/>
+ </xsl:call-template>
</xsl:if>
- <meta name="generator" content="DocBook {$DistroTitle} V{$VERSION}"/>
+ <xsl:call-template name="head.content.generator">
+ <xsl:with-param name="node" select="$node"/>
+ </xsl:call-template>
<xsl:if test="$generate.meta.abstract != 0">
- <xsl:variable name="info" select="(articleinfo
- |bookinfo
- |prefaceinfo
- |chapterinfo
- |appendixinfo
- |sectioninfo
- |sect1info
- |sect2info
- |sect3info
- |sect4info
- |sect5info
- |referenceinfo
- |refentryinfo
- |partinfo
- |info
- |docinfo)[1]"/>
- <xsl:if test="$info and $info/abstract">
- <meta name="description">
- <xsl:attribute name="content">
- <xsl:for-each select="$info/abstract[1]/*">
- <xsl:value-of select="normalize-space(.)"/>
- <xsl:if test="position() < last()">
- <xsl:text> </xsl:text>
- </xsl:if>
- </xsl:for-each>
- </xsl:attribute>
- </meta>
- </xsl:if>
+ <xsl:call-template name="head.content.abstract">
+ <xsl:with-param name="node" select="$node"/>
+ </xsl:call-template>
</xsl:if>
<xsl:if test="($draft.mode = 'yes' or
($draft.mode = 'maybe' and
ancestor-or-self::*[@status][1]/@status = 'draft'))
and $draft.watermark.image != ''">
- <style type="text/css"><xsl:text>
-body { background-image: url('</xsl:text>
-<xsl:value-of select="$draft.watermark.image"/><xsl:text>');
- background-repeat: no-repeat;
- background-position: top left;
- /* The following properties make the watermark "fixed" on the page. */
- /* I think that's just a bit too distracting for the reader... */
- /* background-attachment: fixed; */
- /* background-position: center center; */
- }</xsl:text>
- </style>
+ <xsl:call-template name="head.content.style">
+ <xsl:with-param name="node" select="$node"/>
+ </xsl:call-template>
</xsl:if>
<xsl:apply-templates select="." mode="head.keywords.content"/>
</xsl:template>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]