Author: mcbrown
Date: 2006-08-15 13:16:23 +0200 (Tue, 15 Aug 2006)
New Revision: 3022
Log:
Fixed Q&A sections so that a <programlisting> is not incorporated into a
<emphasis>; this is achieved by <emphasis> blocks around everything *but*
programlisting
Also did a reformat to improve readability, and checked that nothing has been broken ;)
Modified:
trunk/xsl.d/dbk-prep.xsl
Modified: trunk/xsl.d/dbk-prep.xsl
===================================================================
--- trunk/xsl.d/dbk-prep.xsl 2006-08-15 08:33:45 UTC (rev 3021)
+++ trunk/xsl.d/dbk-prep.xsl 2006-08-15 11:16:23 UTC (rev 3022)
Changed blocks: 5, Lines Added: 212, Lines Deleted: 197; 15382 bytes
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<!--
+ <!--
dbk-prep.xsl - prep a DocBook document for formatting
This is an identity transform, with the following exceptions:
@@ -45,22 +45,17 @@
Other whitespace is preserved.
-->
-<xsl:output
- method="xml"
- version="1.0"
- encoding="utf-8"
- standalone="no"
+ <xsl:output method="xml" version="1.0" encoding="utf-8" standalone="no"
doctype-public="-//OASIS//DTD DocBook XML V4.3//EN"
- doctype-system="http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd"
-/>
+ doctype-system="http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd"/>
-<!-- include refentry-mapping templates -->
+ <!-- include refentry-mapping templates -->
-<xsl:include href="map-refentry.xsl"/>
+ <xsl:include href="map-refentry.xsl"/>
-<xsl:preserve-space elements="*"/>
+ <xsl:preserve-space elements="*"/>
-<!--
+ <!--
Repository revision number. Default: empty (unknown)
If not empty and there is a <remark role="repository-revision"/>
element present, insert text that says what the revision number is.
@@ -68,27 +63,27 @@
attribute can be supplied with the correct text.
-->
-<xsl:param name="repository.revision" select="''"/>
+ <xsl:param name="repository.revision" select="''"/>
-<xsl:template match="remark[@role='repository.revision']">
- <xsl:if test="$repository.revision != ''">
- <xsl:text>(</xsl:text>
- <!-- use @condition attribute or "revision" if @condition not present -->
- <xsl:choose>
- <xsl:when test="@condition != ''">
- <xsl:value-of select="@condition"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>revision</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:text>: </xsl:text>
- <xsl:value-of select="$repository.revision"/>
- <xsl:text>)</xsl:text>
- </xsl:if>
-</xsl:template>
+ <xsl:template match="remark[@role='repository.revision']">
+ <xsl:if test="$repository.revision != ''">
+ <xsl:text>(</xsl:text>
+ <!-- use @condition attribute or "revision" if @condition not present -->
+ <xsl:choose>
+ <xsl:when test="@condition != ''">
+ <xsl:value-of select="@condition"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>revision</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:text>: </xsl:text>
+ <xsl:value-of select="$repository.revision"/>
+ <xsl:text>)</xsl:text>
+ </xsl:if>
+ </xsl:template>
-<!--
+ <!--
For other remarks: If $map.remark.to.para is non-zero, turn them into
<para> elements so that they show up in final output. (Most output
processors after the prepping stage normally strip them otherwise.)
@@ -105,58 +100,59 @@
No @role, or a @role of note, todo.
-->
-<xsl:param name="map.remark.to.para" select="0"/>
+ <xsl:param name="map.remark.to.para" select="0"/>
-<xsl:template match="remark[not(@role)]
+ <xsl:template
+ match="remark[not(@role)]
|remark[@role='note']
|remark[@role='todo']
">
- <xsl:choose>
- <xsl:when test="$map.remark.to.para = 0">
- <!-- pass remark through unchanged -->
- <remark>
- <xsl:copy-of select="@*"/>
- <xsl:apply-templates/>
- </remark>
- </xsl:when>
- <xsl:otherwise>
- <!-- set up prefix to add to remark to make it stand out -->
- <xsl:variable name="prefix">
+ <xsl:choose>
+ <xsl:when test="$map.remark.to.para = 0">
+ <!-- pass remark through unchanged -->
+ <remark>
+ <xsl:copy-of select="@*"/>
+ <xsl:apply-templates/>
+ </remark>
+ </xsl:when>
+ <xsl:otherwise>
+ <!-- set up prefix to add to remark to make it stand out -->
+ <xsl:variable name="prefix">
+ <xsl:choose>
+ <xsl:when test="@role = 'note'">
+ <xsl:text>NOTE</xsl:text>
+ </xsl:when>
+ <xsl:when test="@role = 'todo'">
+ <xsl:text>TODO</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>REMARK</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
<xsl:choose>
- <xsl:when test="@role = 'note'">
- <xsl:text>NOTE</xsl:text>
+ <!-- map remark to para, adding para tags only if not present -->
+ <xsl:when test="parent::para">
+ <xsl:text>[</xsl:text>
+ <xsl:value-of select="$prefix"/>
+ <xsl:text>:</xsl:text>
+ <xsl:apply-templates/>
+ <xsl:text>]</xsl:text>
</xsl:when>
- <xsl:when test="@role = 'todo'">
- <xsl:text>TODO</xsl:text>
- </xsl:when>
<xsl:otherwise>
- <xsl:text>REMARK</xsl:text>
+ <para>
+ <xsl:text>[</xsl:text>
+ <xsl:value-of select="$prefix"/>
+ <xsl:text>]</xsl:text>
+ <xsl:apply-templates/>
+ </para>
</xsl:otherwise>
</xsl:choose>
- </xsl:variable>
- <xsl:choose>
- <!-- map remark to para, adding para tags only if not present -->
- <xsl:when test="parent::para">
- <xsl:text>[</xsl:text>
- <xsl:value-of select="$prefix"/>
- <xsl:text>:</xsl:text>
- <xsl:apply-templates/>
- <xsl:text>]</xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <para>
- <xsl:text>[</xsl:text>
- <xsl:value-of select="$prefix"/>
- <xsl:text>]</xsl:text>
- <xsl:apply-templates/>
- </para>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
-</xsl:template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
-<!--
+ <!--
Map <qanda> elements to paragraphs
The handling here is substandard. It's a quick job simply to keep
@@ -164,167 +160,186 @@
for example.
-->
-<xsl:template match="qandaset">
-<para><emphasis role="bold">Questions</emphasis></para>
-<itemizedlist>
- <xsl:apply-templates select="qandadiv/qandaentry/question
- |qandaentry/question" mode="toc"/>
-</itemizedlist>
-<para><emphasis role="bold">Questions and
Answers</emphasis></para>
- <xsl:apply-templates select="qandadiv/qandaentry/question
+ <xsl:template match="qandaset">
+ <para>
+ <emphasis role="bold">Questions</emphasis>
+ </para>
+ <itemizedlist>
+ <xsl:apply-templates
+ select="qandadiv/qandaentry/question
+ |qandaentry/question"
+ mode="toc"/>
+ </itemizedlist>
+ <para>
+ <emphasis role="bold">Questions and Answers</emphasis>
+ </para>
+ <xsl:apply-templates
+ select="qandadiv/qandaentry/question
|qandaentry/question
|qandadiv/qandaentry/answer
- |qandaentry/answer"/>
-</xsl:template>
+ |qandaentry/answer"
+ />
+ </xsl:template>
-<xsl:template match="question" mode="toc">
-<listitem>
-<simpara>
-<link>
-<xsl:attribute name="linkend">
-<xsl:text>qandaitem-</xsl:text>
-<xsl:number
-
count="chapter|appendix|preface|section|sect1[@id]|sect2[@id]|sect3[@id]|sect4[@id]|sect5[@id]|qandaentry"
- level="multiple"
- format="1-1-1-1-1-1"
- />
-</xsl:attribute>
- <xsl:number
-
count="chapter|appendix|preface|section|sect1[@id]|sect2[@id]|sect3[@id]|sect4[@id]|sect5[@id]|qandaentry"
- level="multiple"
- format="1.1.1.1.1.1"
- />:<xsl:text> </xsl:text><xsl:for-each
select="*"><xsl:choose><xsl:when test="name() =
'para'"><xsl:apply-templates/></xsl:when><xsl:otherwise><xsl:apply-templates
select="."/></xsl:otherwise></xsl:choose></xsl:for-each>
-</link>
-</simpara>
-</listitem>
-</xsl:template>
+ <xsl:template match="question" mode="toc">
+ <listitem>
+ <simpara>
+ <link>
+ <xsl:attribute name="linkend">
+ <xsl:text>qandaitem-</xsl:text>
+ <xsl:number
+
count="chapter|appendix|preface|section|sect1[@id]|sect2[@id]|sect3[@id]|sect4[@id]|sect5[@id]|qandaentry"
+ level="multiple" format="1-1-1-1-1-1"/>
+ </xsl:attribute>
+ <xsl:number
+
count="chapter|appendix|preface|section|sect1[@id]|sect2[@id]|sect3[@id]|sect4[@id]|sect5[@id]|qandaentry"
+ level="multiple" format="1.1.1.1.1.1"
+ />:<xsl:text> </xsl:text><xsl:for-each select="*">
+ <xsl:choose>
+ <xsl:when test="name() = 'para'">
+ <xsl:apply-templates/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="."/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
+ </link>
+ </simpara>
+ </listitem>
+ </xsl:template>
-<xsl:template match="question">
- <para>
-<xsl:attribute name="id">
-<xsl:text>qandaitem-</xsl:text>
-<xsl:number
-
count="chapter|appendix|preface|section|sect1[@id]|sect2[@id]|sect3[@id]|sect4[@id]|sect5[@id]|qandaentry"
- level="multiple"
- format="1-1-1-1-1-1"
- />
-</xsl:attribute>
- <emphasis role="bold">
- <xsl:number
-
count="chapter|appendix|preface|section|sect1[@id]|sect2[@id]|sect3[@id]|sect4[@id]|sect5[@id]|qandaentry"
- level="multiple"
- format="1.1.1.1.1.1"
- />:<xsl:text> </xsl:text><xsl:for-each
select="*"><xsl:choose><xsl:when test="name() =
'para'"><xsl:apply-templates/></xsl:when><xsl:otherwise><xsl:apply-templates
select="."/></xsl:otherwise></xsl:choose></xsl:for-each>
- </emphasis>
- </para>
-</xsl:template>
+ <xsl:template match="question">
+ <para>
+ <xsl:attribute name="id">
+ <xsl:text>qandaitem-</xsl:text>
+ <xsl:number
+
count="chapter|appendix|preface|section|sect1[@id]|sect2[@id]|sect3[@id]|sect4[@id]|sect5[@id]|qandaentry"
+ level="multiple" format="1-1-1-1-1-1"/>
+ </xsl:attribute>
+ <emphasis role="bold">
+ <xsl:number
+
count="chapter|appendix|preface|section|sect1[@id]|sect2[@id]|sect3[@id]|sect4[@id]|sect5[@id]|qandaentry"
+ level="multiple" format="1.1.1.1.1.1"/>:<xsl:text>
</xsl:text></emphasis>
+ <xsl:for-each select="*">
+ <xsl:choose>
+ <xsl:when test="name() = 'para'">
+ <emphasis role="bold"><xsl:apply-templates/></emphasis>
+ </xsl:when>
+ <xsl:when test="name() = 'programlisting'">
+ <xsl:apply-templates select="."/>
+ </xsl:when>
+ <xsl:otherwise>
+ <emphasis role="bold"><xsl:apply-templates
select="."/></emphasis>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
+ </para>
+ </xsl:template>
-<xsl:template match="answer">
- <xsl:apply-templates/>
-</xsl:template>
+ <xsl:template match="answer">
+ <xsl:apply-templates/>
+ </xsl:template>
-<!--
+ <!--
Map glossary tags to variable list
-->
-<!-- glossary becomes appendix -->
+ <!-- glossary becomes appendix -->
-<xsl:template match="glossary">
- <appendix>
- <xsl:copy-of select="@*"/>
- <xsl:apply-templates/>
- </appendix>
-</xsl:template>
+ <xsl:template match="glossary">
+ <appendix>
+ <xsl:copy-of select="@*"/>
+ <xsl:apply-templates/>
+ </appendix>
+ </xsl:template>
-<!-- glossdiv becomes variablelist -->
+ <!-- glossdiv becomes variablelist -->
-<xsl:template match="glossdiv">
- <variablelist>
- <xsl:apply-templates/>
- </variablelist>
-</xsl:template>
+ <xsl:template match="glossdiv">
+ <variablelist>
+ <xsl:apply-templates/>
+ </variablelist>
+ </xsl:template>
-<!-- glossentry elements become items within variablelist -->
+ <!-- glossentry elements become items within variablelist -->
-<xsl:template match="glossentry">
- <varlistentry>
- <xsl:copy-of select="@*"/>
- <xsl:apply-templates/>
- </varlistentry>
-</xsl:template>
+ <xsl:template match="glossentry">
+ <varlistentry>
+ <xsl:copy-of select="@*"/>
+ <xsl:apply-templates/>
+ </varlistentry>
+ </xsl:template>
-<xsl:template match="glossterm">
- <term>
- <xsl:apply-templates/>
- </term>
-</xsl:template>
+ <xsl:template match="glossterm">
+ <term>
+ <xsl:apply-templates/>
+ </term>
+ </xsl:template>
-<xsl:template match="glossdef">
- <listitem>
- <xsl:apply-templates/>
- </listitem>
-</xsl:template>
+ <xsl:template match="glossdef">
+ <listitem>
+ <xsl:apply-templates/>
+ </listitem>
+ </xsl:template>
-<!-- glossseealso becomes para with a cross-reference -->
+ <!-- glossseealso becomes para with a cross-reference -->
-<xsl:template match="glossseealso">
- <para>
- See also
- <xref>
- <xsl:attribute name="linkend">
- <xsl:value-of select="@otherterm"/>
- </xsl:attribute>
- <xsl:apply-templates/>
- </xref>.
- </para>
-</xsl:template>
+ <xsl:template match="glossseealso">
+ <para> See also <xref>
+ <xsl:attribute name="linkend">
+ <xsl:value-of select="@otherterm"/>
+ </xsl:attribute>
+ <xsl:apply-templates/>
+ </xref>. </para>
+ </xsl:template>
-<!--
+ <!--
Match text elements that are the first child of <programlisting>
and chop any leading newline.
-->
-<xsl:template match="text()[1][parent::programlisting]">
- <xsl:choose>
- <xsl:when test="starts-with(., '
')">
- <xsl:value-of select="substring(.,2)"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="."/>
- </xsl:otherwise>
- </xsl:choose>
-</xsl:template>
+ <xsl:template match="text()[1][parent::programlisting]">
+ <xsl:choose>
+ <xsl:when test="starts-with(., '
')">
+ <xsl:value-of select="substring(.,2)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="."/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
-<!--
+ <!--
Match text nodes that follow a comment. If the text begins with a
newline, remove the newline.
Matching rule uses node(), not *, because * does not include comment().
-->
-<xsl:template match="text()[preceding-sibling::node()[1][self::comment()]]">
- <xsl:choose>
- <xsl:when test="starts-with(., '
')">
- <xsl:value-of select="substring(.,2)"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="."/>
- </xsl:otherwise>
- </xsl:choose>
-</xsl:template>
+ <xsl:template match="text()[preceding-sibling::node()[1][self::comment()]]">
+ <xsl:choose>
+ <xsl:when test="starts-with(., '
')">
+ <xsl:value-of select="substring(.,2)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="."/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
-<!--
+ <!--
Copy everything else.
Matching rules use * and text(), not node(), because node() includes
comment().
-->
-<xsl:template match="/ | * | text() | @* | processing-instruction()">
- <xsl:copy>
- <xsl:apply-templates select="* | text() | @* | processing-instruction()"/>
- </xsl:copy>
-</xsl:template>
+ <xsl:template match="/ | * | text() | @* | processing-instruction()">
+ <xsl:copy>
+ <xsl:apply-templates select="* | text() | @* | processing-instruction()"/>
+ </xsl:copy>
+ </xsl:template>
</xsl:stylesheet>
| Thread |
|---|
| • svn commit - mysqldoc@docsrva: r3022 - trunk/xsl.d | mcbrown | 15 Aug |