diff options
author | Shaun McCance <shaunm@src.gnome.org> | 2007-05-09 16:43:49 +0000 |
---|---|---|
committer | Shaun McCance <shaunm@src.gnome.org> | 2007-05-09 16:43:49 +0000 |
commit | 503fa77fdff933f3a6109c3193b1acf3a86aa01f (patch) | |
tree | 9a144bb1273d9db08afa5478266252afb52d9d19 /xslt/docbook | |
parent | b5700ea67c0ddf7ec2b88cc2e206f86363737f58 (diff) | |
download | gnome-doc-utils-503fa77fdff933f3a6109c3193b1acf3a86aa01f.tar.gz |
- Added another line numbering continuation test
* test/testbook/testbook.xml:
- Added another line numbering continuation test
* xslt/docbook/common/db-common.xsl:
* xslt/docbook/html/db2html-block.xsl:
* xslt/docbook/html/db2html-inline.xsl:
* xslt/docbook/html/db2html-list.xsl:
- Implemented line numbering continuations
- Moved orderedlist continuation handling to db-common
- Removed hardly-used db.dingbat template
svn path=/trunk/; revision=943
Diffstat (limited to 'xslt/docbook')
-rw-r--r-- | xslt/docbook/common/db-common.xsl | 117 | ||||
-rw-r--r-- | xslt/docbook/html/db2html-block.xsl | 6 | ||||
-rw-r--r-- | xslt/docbook/html/db2html-inline.xsl | 48 | ||||
-rw-r--r-- | xslt/docbook/html/db2html-list.xsl | 36 |
4 files changed, 116 insertions, 91 deletions
diff --git a/xslt/docbook/common/db-common.xsl b/xslt/docbook/common/db-common.xsl index 0d457c7..f67d2b2 100644 --- a/xslt/docbook/common/db-common.xsl +++ b/xslt/docbook/common/db-common.xsl @@ -17,54 +17,29 @@ Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA --> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:str="http://exslt.org/strings" + exclude-result-prefixes="str" version="1.0"> <!--!!========================================================================== DocBook Common -REMARK: Describe this +This stylesheet module provides utility templates for DocBook that are +independant of the target format. --> <xsl:key name="idkey" match="*" use="@id"/> <!--**========================================================================== -db.dingbat -Outputs a character from a character name, possibly localized -$dingbat: The name of the character - -REMARK: Document the dingbats. "Logical name" sounds dumb ---> -<xsl:template name="db.dingbat"> - <xsl:param name="dingbat"/> - <xsl:choose> - <xsl:when test="$dingbat = 'copyright'"> - <!-- U+00A9 --> - <xsl:value-of select="'©'"/> - </xsl:when> - <xsl:when test="$dingbat = 'registered'"> - <!-- U+00AE --> - <xsl:value-of select="'®'"/> - </xsl:when> - <xsl:when test="$dingbat = 'trade'"> - <!-- U+2122 --> - <xsl:value-of select="'™'"/> - </xsl:when> - <xsl:when test="$dingbat = 'service'"> - <!-- U+2120 --> - <xsl:value-of select="'℠'"/> - </xsl:when> - </xsl:choose> -</xsl:template> - - -<!--**========================================================================== db.linenumbering Numbers each line in a verbatim environment $node: The verbatim element to create the line numbering for $number: The starting line number -REMARK: Document this template +This template outputs a string with line numbers for each line in a verbatim +elements. Each line number is on its own line, allowing the output string to +be placed to the side of the verbatim output. --> <xsl:template name="db.linenumbering"> <xsl:param name="node" select="."/> @@ -99,12 +74,88 @@ REMARK: Document this template <!--**========================================================================== +db.linenumbering.start +Determines the starting line number for a verbatim element +$node: The verbatim element to determine the starting line number for + +This template determines the starting line number for a verbatim element using +the #{continuation} attribute. The template finds the first preceding element +of the same name, counts its lines, and handles any #{startinglinenumber} or +#{continuation} element it finds on that element. +--> +<xsl:template name="db.linenumbering.start"> + <xsl:param name="node" select="."/> + <xsl:choose> + <xsl:when test="$node/@startinglinenumber"> + <xsl:value-of select="$node/@startinglinenumber"/> + </xsl:when> + <xsl:when test="$node/@continuation"> + <xsl:variable name="prev" select="$node/preceding::*[name(.) = name($node)][1]"/> + <xsl:choose> + <xsl:when test="count($prev) = 0">1</xsl:when> + <xsl:otherwise> + <xsl:variable name="prevcount"> + <xsl:value-of select="count(str:split(string($prev), '
'))"/> + </xsl:variable> + <xsl:variable name="prevstart"> + <xsl:call-template name="db.linenumbering.start"> + <xsl:with-param name="node" select="$prev"/> + </xsl:call-template> + </xsl:variable> + <xsl:value-of select="$prevstart + $prevcount"/> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + <xsl:otherwise>1</xsl:otherwise> + </xsl:choose> +</xsl:template> + + +<!--**========================================================================== +db.orderedlist.start +Determines the number to use for the first #{listitem} in an #{orderedlist} +$node: The #{orderedlist} element to use + +This template determines the starting number for an #{orderedlist} element using +the #{continuation} attribute. Thi template finds the first preceding #{orderedlist} +element and counts its list items. If that element also uses the #{continuation}, +this template calls itself recursively to add that element's starting line number +to its list item count. +--> +<xsl:template name="db.orderedlist.start"> + <xsl:param name="node" select="."/> + <xsl:choose> + <xsl:when test="$node/@continutation != 'continues'">1</xsl:when> + <xsl:otherwise> + <xsl:variable name="prevlist" + select="$node/preceding::orderedlist[1]"/> + <xsl:choose> + <xsl:when test="count($prevlist) = 0">1</xsl:when> + <xsl:otherwise> + <xsl:variable name="prevlength" select="count($prevlist/listitem)"/> + <xsl:variable name="prevstart"> + <xsl:call-template name="db.orderedlist.start"> + <xsl:with-param name="node" select="$prevlist"/> + </xsl:call-template> + </xsl:variable> + <xsl:value-of select="$prevstart + $prevlength"/> + </xsl:otherwise> + </xsl:choose> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + + +<!--**========================================================================== db.personname Outputs the name of a person $node: The element containing tags such as #{firstname} and #{surname} $lang: The language rules to use to construct the name -REMARK: Document this template +This template outputs the name of a person as modelled by the #{personname} +element. The #{personname} element allows authors to mark up components of +a person's name, such as the person's first name and surname. This template +assembled those into a string. --> <xsl:template name="db.personname"> <xsl:param name="node" select="."/> diff --git a/xslt/docbook/html/db2html-block.xsl b/xslt/docbook/html/db2html-block.xsl index 060fe41..35ea41d 100644 --- a/xslt/docbook/html/db2html-block.xsl +++ b/xslt/docbook/html/db2html-block.xsl @@ -235,10 +235,14 @@ is then used by the CSS for styling. <xsl:if test="$node/@linenumbering = 'numbered'"> <xsl:variable name="number"> <xsl:choose> - <!-- FIXME: continuation --> <xsl:when test="@startinglinenumber"> <xsl:value-of select="@startinglinenumber"/> </xsl:when> + <xsl:when test="@continuation"> + <xsl:call-template name="db.linenumbering.start"> + <xsl:with-param name="node" select="$node"/> + </xsl:call-template> + </xsl:when> <xsl:otherwise>1</xsl:otherwise> </xsl:choose> </xsl:variable> diff --git a/xslt/docbook/html/db2html-inline.xsl b/xslt/docbook/html/db2html-inline.xsl index 7ae78d8..94a5184 100644 --- a/xslt/docbook/html/db2html-inline.xsl +++ b/xslt/docbook/html/db2html-inline.xsl @@ -144,7 +144,8 @@ REMARK: Document this template <!-- = citation = --> <xsl:template match="citation"> - <span class="citation-punc"> + <span class="citation"> + <xsl:call-template name="db2html.anchor"/> <xsl:text>[</xsl:text> <xsl:call-template name="db2html.inline"/> <xsl:text>]</xsl:text> @@ -218,7 +219,8 @@ REMARK: Document this template <!-- = email = --> <xsl:template match="email"> - <span class="email-punc"> + <span class="email"> + <xsl:call-template name="db2html.anchor"/> <!-- FIXME: no style tags --> <tt> <xsl:text><</xsl:text> @@ -432,6 +434,7 @@ REMARK: Document this template </xsl:choose> </xsl:variable> <span class="keycombo"> + <xsl:call-template name="db2html.anchor"/> <xsl:for-each select="*"> <xsl:if test="position() != 1"> <xsl:value-of select="$joinchar"/> @@ -482,6 +485,7 @@ REMARK: Document this template <!-- = menuchoice = --> <xsl:template match="menuchoice"> <span class="menuchoice"> + <xsl:call-template name="db2html.anchor"/> <xsl:for-each select="*[local-name(.) != 'shortcut']"> <xsl:if test="position() != 1"> <xsl:text> → </xsl:text> @@ -489,7 +493,8 @@ REMARK: Document this template <xsl:apply-templates select="."/> </xsl:for-each> <xsl:if test="shortcut"> - <span class="shortcut-punc"> + <span class="shortcut"> + <xsl:call-template name="db2html.anchor"/> <xsl:text> (</xsl:text> <xsl:apply-templates select="shortcut"/> <xsl:text>)</xsl:text> @@ -519,7 +524,8 @@ REMARK: Document this template <!-- = optional = --> <xsl:template match="optional"> - <span class="optional-punc"> + <span class="optional"> + <xsl:call-template name="db2html.anchor"/> <xsl:text>[</xsl:text> <xsl:call-template name="db2html.inline"/> <xsl:text>]</xsl:text> @@ -577,13 +583,14 @@ REMARK: Document this template <!-- = productname = --> <xsl:template match="productname"> - <span class="productname-punc"> + <span class="productname"> <xsl:call-template name="db2html.inline"/> - <xsl:if test="@class"> - <xsl:call-template name="db.dingbat"> - <xsl:with-param name="dingbat" select="@class"/> - </xsl:call-template> - </xsl:if> + <xsl:choose> + <xsl:when test="@class = 'copyright'">©</xsl:when> + <xsl:when test="@class = 'registered'">®</xsl:when> + <xsl:when test="@class = 'trade'">™</xsl:when> + <xsl:when test="@class = 'service'">℠</xsl:when> + </xsl:choose> </span> </xsl:template> @@ -617,6 +624,7 @@ REMARK: Document this template <!-- = quote = --> <xsl:template match="quote"> <span class="quote"> + <xsl:call-template name="db2html.anchor"/> <xsl:call-template name="l10n.gettext"> <xsl:with-param name="msgid" select="'quote.format'"/> <xsl:with-param name="role"> @@ -799,21 +807,15 @@ REMARK: Document this template <!-- = trademark = --> <xsl:template match="trademark"> - <xsl:variable name="class"> - <xsl:choose> - <xsl:when test="@class"> - <xsl:value-of select="@class"/> - </xsl:when> - <xsl:otherwise> - <xsl:value-of select="'trade'"/> - </xsl:otherwise> - </xsl:choose> - </xsl:variable> <span class="trademark"> + <xsl:call-template name="db2html.anchor"/> <xsl:apply-templates/> - <xsl:call-template name="db.dingbat"> - <xsl:with-param name="dingbat" select="$class"/> - </xsl:call-template> + <xsl:choose> + <xsl:when test="@class = 'copyright'">©</xsl:when> + <xsl:when test="@class = 'registered'">®</xsl:when> + <xsl:when test="@class = 'service'">℠</xsl:when> + <xsl:otherwise>™</xsl:otherwise> + </xsl:choose> </span> </xsl:template> diff --git a/xslt/docbook/html/db2html-list.xsl b/xslt/docbook/html/db2html-list.xsl index 71ec2c8..e81fc7d 100644 --- a/xslt/docbook/html/db2html-list.xsl +++ b/xslt/docbook/html/db2html-list.xsl @@ -22,44 +22,12 @@ Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA <!--!!========================================================================== DocBook to HTML - Lists -:Requires: db2html-inline db2html-xref gettext +:Requires: db-common db2html-inline db2html-xref gettext REMARK: Describe this module --> -<!--**========================================================================== -db2html.orderedlist.start -Determines the number to use for the first #{listitem} in an #{orderedlist} -$node: The #{orderedlist} element to use - -REMARK: Give a good explanation talking about #{continuation}. This template -determines the number to use for the first #{listitem} in an #{orderedlist}. ---> -<xsl:template name="db2html.orderedlist.start"> - <xsl:param name="node" select="."/> - <xsl:choose> - <xsl:when test="@continutation != 'continues'">1</xsl:when> - <xsl:otherwise> - <xsl:variable name="prevlist" - select="$node/preceding::orderedlist[1]"/> - <xsl:choose> - <xsl:when test="count($prevlist) = 0">1</xsl:when> - <xsl:otherwise> - <xsl:variable name="prevlength" select="count($prevlist/listitem)"/> - <xsl:variable name="prevstart"> - <xsl:call-template name="db2html.orderedlist.start"> - <xsl:with-param name="node" select="$prevlist"/> - </xsl:call-template> - </xsl:variable> - <xsl:value-of select="$prevstart + $prevlength"/> - </xsl:otherwise> - </xsl:choose> - </xsl:otherwise> - </xsl:choose> -</xsl:template> - - <!-- == Matched Templates == --> <!-- = itemizedlist = --> @@ -127,7 +95,7 @@ determines the number to use for the first #{listitem} in an #{orderedlist}. <xsl:variable name="start"> <xsl:choose> <xsl:when test="@continuation = 'continues'"> - <xsl:call-template name="db2html.orderedlist.start"/> + <xsl:call-template name="db.orderedlist.start"/> </xsl:when> <xsl:otherwise>1</xsl:otherwise> </xsl:choose> |