bug-patches and created some new ones in the stylesheets.
Also tweaked some files to structure the xml properly.
The FAQ and the Quick-Start are now 'articles' inside a book-wrapper,
which is as it should be.
FAQ.xml
- due to various passivetex bug fixes, the faq is now a properly
structured xml qandaset document
quick-start-guide.xml:
manual.xml
- Fixed some passivetex-workaround kludges:
legalnotice -> author
manual-core.xml:
For readability, added '<command>' to varlistentry items
since passivetex (sigh) will no longer indent the para text.
index.xml:
- loads of white-space readability tweaks here and there.
tech-docs.xml
dist-docs.xml
manual.xml
- additional entries to <bookinfo> for compatability with
the rest of the docs.
/docs/Makefile.am
- added stuff to use the new vg-faq2txt.xsl stylesheet
/docs/lib/Makefile.am
- updated to reflect current contents of /docs/lib/
- removed refs to vg-html-single as is never ever used
/docs/lib/vg-fo.xsl
- massively updated to reflect losing old bugs and gaining new ones
/docs/lib/vg-common.xsl
- deleted as only contained two lines common to html and fo,
so not worth the bother of hauling around
/docs/lib/vg-html-chunk.xsl
- added what was in vg-common.xsl
/docs/lib/line-wrap.xsl
/docs/lib/faq2text.xsl
- two new stylesheet files for transforming FAQ.xml to FAQ.txt
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5234
# stylesheets
XSL_HTML_CHUNK_STYLE = $(mylibdir)/vg-html-chunk.xsl
-XSL_HTML_SINGLE_STYLE = $(mylibdir)/vg-html-single.xsl
XSL_FO_STYLE = $(mylibdir)/vg-fo.xsl
+XSL_TEXT_STYLE = $(mylibdir)/vg-faq2txt.xsl
all-docs: FAQ.txt html-docs print-docs
$(XMLLINT) $(XMLLINT_FLAGS) $(myxmldir)/index.xml
# The text version of the FAQ.
-FAQ.txt: $(myxmldir)/FAQ.xml $(myxmldir)/vg-entities.xml $(mylibdir)/*.xslt
- $(XSLTPROC) $(XSLTPROC_FLAGS) $(mylibdir)/untag-inline.xslt $(myxmldir)/FAQ.xml | \
- $(XSLTPROC) $(XSLTPROC_FLAGS) $(mylibdir)/docbook2text.xslt - > FAQ.txt
-
+FAQ.txt:
+ @echo "Generating the text version of the FAQ ..."
+ export XML_CATALOG_FILES=$(XML_CATALOG_FILES) && \
+ $(XSLTPROC) $(XSLTPROC_FLAGS) -o ./FAQ.txt $(XSL_TEXT_STYLE) $(myxmldir)/FAQ.xml
-# chunked html
+# chunked html, on a chapter-by-chapter basis
html-docs:
@echo "Generating html files..."
export XML_CATALOG_FILES=$(XML_CATALOG_FILES) && \
-EXTRA_DIST = \
- README_XML2TXT.txt \
- copy.xslt \
- text.justify.xslt \
- docbook2text.xslt \
- text.wrap.xslt \
- str.dup.xslt \
- untag-inline.xslt \
- str.find-last.xslt \
- vg-common.xsl \
- vg-fo.xsl \
+EXTRA_DIST = \
+ vg-fo.xsl \
vg-html-chunk.xsl \
- vg-html-single.xsl \
+ vg-faq2txt.xsl \
+ line-wrap.xsl \
vg_basic.css
-
-
+++ /dev/null
-README.txt file for the FAQ.xml to FAQ.txt transformer.
-=======================================================
-
-In valgrind-3.1.SVN, file docs/README contains, under the heading
-"TODO CRUCIAL", the item "Need to generate text FAQ from the
-valgrind/docs/xml/FAQ.xml (done at 'make dist' time along with the
-HTML docs using the 'dist-hook'), and remove the old text FAQ which is
-in valgrind/." This is an attempt to resolve this item using xsltproc
-and a number of xml style sheets. It is a hack in the sense that it
-does not support all of docbook, but only the subset currently used by
-file docs/xml/FAQ.xml.
-
-The transformation is done in two stages:
-
-1. Inline elements (literal, computeroutput and ulink) are replaced
- with the corresponding text by stylesheet untag-inline.xslt. This
- stylesheet uses copy.xslt to handle the non-inline elements.
-
-2. The actual formatting is done by stylesheet docbook2text.xslt. It
- uses stylesheets str.dup.xslt, str.find-last.xslt,
- text.justify.xslt and text.wrap.xslt to handle the formatting of
- the text into a column with the approproate width and indentation.
-
-Stylesheets untag-inline.xslt and docbook2text.xslt are original
-work. Stylesheets copy.xslt, str.dup.xslt, str.find-last.xslt,
-text.justify.xslt and text.wrap.xslt are copied with some adaptations
-from the examples supplied with the XSLT Cookbook by Sal Mangano, (C)
-2003 O'Reilly & Associates, ISBN 0-596-00372-2. The O'Reilly Policy on
-Re-Use of Code Examples from Books
-<http://www.oreilly.com/pub/a/oreilly/ask_tim/2001/codepolicy.html>
-allows the use of these style sheets in valgrind for this purpose.
-
-The tarball contains:
-
-- File README.txt (this file).
-
-- the stylesheets copy.xslt, docbook2text.xslt, str.dup.xslt,
- str.find-last.xslt, text.justify.xslt, text.wrap.xslt and
- untag-inline.xslt.
-
-- File faq.txt.patch adds the generation of FAQ.txt to file
- docs/Makefile.am. It is based on the assumptions that
- * file FAQ.txt will be generated in directory docs.
- * the stylesheets will be stored in directory docs/lib.
- If a different output width is required (e.g. 80), you can use
- command
- $(XSLTPROC) $(XSLTPROC_FLAGS) $(libdir)/untag-inline.xslt $(xmldir)/FAQ.xml | \
- $(XSLTPROC) $(XSLTPROC_FLAGS) --stringparam width 80 $(libdir)/docbook2text.xslt - > FAQ.txt
-
-- File FAQ.txt as generated on my system (Debian 3.1).
-
-Software used:
-xsltproc was compiled against libxml 20616, libxslt 10112 and libexslt 810
-libxslt 10112 was compiled against libxml 20616
-libexslt 810 was compiled against libxml 20616
-
-
-Copyright 2005 Jeroen N. Witmond, jnw@xs4all.nl
-GNU GENERAL PUBLIC LICENSE Version 2, June 1991 applies.
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-
-<!-- This file was copied with some adaptations from the examples
-supplied with the XSLT Cookbook by Sal Mangano, (C) 2003 O'Reilly &
-Associates, ISBN 0-596-00372-2. -->
-
-<xsl:output method="xml"/>
-
-<xsl:template match="/ | node() | @* | comment() | processing-instruction()">
- <xsl:copy>
- <xsl:apply-templates select="node() | @*"/>
- </xsl:copy>
-</xsl:template>
-
-</xsl:stylesheet>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?> <!-- -*- sgml -*- -->
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:text="http://www.ora.com/XSLTCookbook/namespaces/text"
- xmlns:str="http://www.ora.com/XSLTCookbook/namespaces/strings">
-
-<xsl:include href="text.wrap.xslt"/>
-
-<xsl:strip-space elements="*"/>
-<xsl:preserve-space elements="screen programlisting"/>
-<xsl:output method="text"/>
-
-<!-- Transform a subset of docbook/xml into plain text. This -->
-<!-- stylesheet assumes that all elements that are to be formatted -->
-<!-- inline already have been handled by untag-inline.xslt. -->
-
-<!-- Maximum number of characters on one line. -->
-<xsl:param name="width" select="72"/>
-
-<!-- This stylesheet uses two named templates. The template named -->
-<!-- "header" writes its input, followed by a line of '~'s of -->
-<!-- the same length. The template named "ruler" produces a line of -->
-<!-- $width '-'s. They are implemented at the bottom of this file. -->
-
-<xsl:template match="/">
- <!-- Title 'page' stuff. -->
- <xsl:call-template name="header">
- <xsl:with-param name="input" select="book/title"/>
- </xsl:call-template>
-
- <xsl:call-template name="header">
- <xsl:with-param name="input" select="book/bookinfo/releaseinfo"/>
- </xsl:call-template>
- <xsl:text>
</xsl:text>
-
- <!-- List of sections. -->
- <xsl:text>Table of Contents
</xsl:text>
- <xsl:apply-templates select="book/sect1" mode="toc"/>
- <xsl:text>
</xsl:text>
-
- <!-- Contents. -->
- <xsl:apply-templates select="book/sect1"/>
-</xsl:template>
-
-<xsl:template match="sect1" mode="toc">
- <xsl:value-of select="position()"/>
- <xsl:text>. </xsl:text>
- <xsl:value-of select="title"/>
- <xsl:text>
</xsl:text>
-</xsl:template>
-
-<!-- Processing of the contents starts here. -->
-
-<xsl:template match="sect1">
- <!-- The FAQ contains two types of sect1: those containing a
- qandaset (actually an unspecified number), and those containing a
- sequence of paras. To get the number of blank lines right, these
- must be treated separately. -->
-
- <xsl:variable name="sectno" select="position()"/>
-
- <xsl:call-template name="ruler"/>
- <xsl:value-of select="$sectno"/>
- <xsl:text>. </xsl:text>
- <xsl:value-of select="title"/>
- <xsl:text>
</xsl:text>
- <xsl:call-template name="ruler"/>
- <xsl:text>
</xsl:text>
-
- <xsl:choose>
- <xsl:when test="qandaset">
- <xsl:apply-templates select="qandaset|para">
- <xsl:with-param name="sectno" select="$sectno"/>
- </xsl:apply-templates>
- </xsl:when>
-
- <xsl:when test="para">
- <xsl:for-each select="para|screen|programlisting|itemizedlist|orderedlist">
- <xsl:apply-templates select="."/>
-
- <xsl:if test="position() != last()">
- <xsl:text>
</xsl:text>
- </xsl:if>
- </xsl:for-each>
- </xsl:when>
-
- <!-- Oops. sect1 contains elements we do not yet handle. -->
- <xsl:otherwise>
- <xsl:message>template match="sect1": Encountered
- <<xsl:value-of select="name(.)"/>>.</xsl:message>
- </xsl:otherwise>
- </xsl:choose>
-
- <xsl:text>
</xsl:text>
-</xsl:template>
-
-<xsl:template match="qandaset">
- <xsl:param name="sectno"/>
-
- <xsl:apply-templates select="qandaentry">
- <xsl:with-param name="sectno" select="$sectno"/>
- </xsl:apply-templates>
-</xsl:template>
-
-<xsl:template match="qandaentry">
- <xsl:param name="sectno"/>
-
- <xsl:variable name="questno" select="position()"/>
-
- <xsl:variable name="prefix">
- <xsl:value-of select="$sectno"/>
- <xsl:text>.</xsl:text>
- <xsl:value-of select="$questno"/>
- <xsl:text>. </xsl:text>
- </xsl:variable>
- <xsl:variable name="prefix-length" select="string-length($prefix)"/>
-
- <xsl:if test="$questno > 1">
- <xsl:text>
</xsl:text>
- <xsl:call-template name="ruler"/>
- <xsl:text>
</xsl:text>
- </xsl:if>
-
- <xsl:apply-templates select="question">
- <xsl:with-param name="prefix" select="$prefix"/>
- <xsl:with-param name="indent" select="$prefix-length"/>
- </xsl:apply-templates>
-
- <xsl:text>
</xsl:text>
-
- <xsl:apply-templates select="answer"/>
-</xsl:template>
-
-<xsl:template match="question">
- <xsl:param name="prefix"/>
- <xsl:param name="indent" select="0"/>
-
- <xsl:for-each select="para|screen|programlisting">
- <xsl:choose>
- <xsl:when test="position() = 1 and $prefix">
- <xsl:value-of select="$prefix"/>
- <xsl:apply-templates select=".">
- <xsl:with-param name="indent" select="$indent"/>
- <xsl:with-param name="dofirst" select="0"/>
- </xsl:apply-templates>
- </xsl:when>
- <xsl:otherwise>
- <xsl:apply-templates select=".">
- <xsl:with-param name="indent" select="$indent"/>
- </xsl:apply-templates>
- </xsl:otherwise>
- </xsl:choose>
-
- <xsl:if test="position() != last()">
- <xsl:text>
</xsl:text>
- </xsl:if>
- </xsl:for-each>
-</xsl:template>
-
-<xsl:template match="answer">
- <xsl:param name="indent" select="0"/>
-
- <xsl:for-each select="para|screen|programlisting|itemizedlist|orderedlist">
- <xsl:apply-templates select=".">
- <xsl:with-param name="indent" select="$indent"/>
- </xsl:apply-templates>
-
- <xsl:if test="position() != last()">
- <xsl:text>
</xsl:text>
- </xsl:if>
- </xsl:for-each>
-</xsl:template>
-
-<xsl:template match="para">
- <xsl:param name="indent" select="0"/>
- <xsl:param name="dofirst" select="1"/>
-
- <xsl:for-each select="node()">
- <xsl:choose>
- <!-- Lists and blocks as children. -->
- <xsl:when test="self::screen|self::programlisting|
- self::itemizedlist|self::orderedlist">
- <xsl:apply-templates select=".">
- <xsl:with-param name="indent" select="$indent"/>
- </xsl:apply-templates>
-
- <xsl:if test="position() != last()">
- <xsl:text>
</xsl:text>
- </xsl:if>
- </xsl:when>
-
- <!-- Text. Inline elements have been flattened by
- untag-inline.xslt. -->
- <xsl:when test="self::text()">
- <xsl:choose>
- <xsl:when test="position() = 1 and $dofirst = 0">
- <xsl:apply-templates select="." mode="text:wrap">
- <xsl:with-param name="width" select="$width"/>
- <xsl:with-param name="indent" select="$indent"/>
- <xsl:with-param name="dofirst" select="0"/>
- </xsl:apply-templates>
- </xsl:when>
- <xsl:otherwise>
- <xsl:apply-templates select="." mode="text:wrap">
- <xsl:with-param name="width" select="$width"/>
- <xsl:with-param name="indent" select="$indent"/>
- </xsl:apply-templates>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
-
- <!-- Oops. para contains elements we do not yet handle. -->
- <xsl:otherwise>
- <xsl:message>template match="para": Encountered
- <<xsl:value-of select="name(.)"/>>.</xsl:message>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:for-each>
-</xsl:template>
-
-<xsl:template match="screen|programlisting">
- <xsl:param name="indent" select="0"/>
- <xsl:param name="dofirst" select="1"/><!-- ignored. -->
-
- <xsl:variable name="myindent" select=" $indent + 2 " />
-
- <xsl:apply-templates select="." mode="text:dump">
- <xsl:with-param name="input" select="text()"/>
- <xsl:with-param name="indent" select="$myindent"/>
- </xsl:apply-templates>
-</xsl:template>
-
-<xsl:template match="itemizedlist">
- <xsl:param name="indent" select="0"/>
-
- <xsl:variable name="prefix" select=" '* ' "/>
- <xsl:variable name="prefix-length" select="string-length($prefix)"/>
-
- <xsl:for-each select="listitem">
- <xsl:apply-templates select=".">
- <xsl:with-param name="prefix" select="$prefix"/>
- <xsl:with-param name="indent" select="$prefix-length"/>
- </xsl:apply-templates>
-
- <xsl:if test="position() != last()">
- <xsl:text>
</xsl:text>
- </xsl:if>
- </xsl:for-each>
-</xsl:template>
-
-<xsl:template match="orderedlist">
- <xsl:param name="indent" select="0"/>
-
- <xsl:for-each select="listitem">
- <xsl:variable name="prefix">
- <xsl:value-of select="position()"/>
- <xsl:text>. </xsl:text>
- </xsl:variable>
- <xsl:variable name="prefix-length" select="string-length($prefix)"/>
-
- <xsl:apply-templates select=".">
- <xsl:with-param name="prefix" select="$prefix"/>
- <xsl:with-param name="indent" select="$prefix-length"/>
- </xsl:apply-templates>
-
- <xsl:if test="position() != last()">
- <xsl:text>
</xsl:text>
- </xsl:if>
- </xsl:for-each>
-</xsl:template>
-
-<xsl:template match="listitem">
- <xsl:param name="prefix"/>
- <xsl:param name="indent" select="0"/>
-
- <xsl:for-each select="para|screen|programlisting">
- <xsl:choose>
- <xsl:when test="position() = 1 and $prefix">
- <xsl:value-of select="$prefix"/>
- <xsl:apply-templates select=".">
- <xsl:with-param name="indent" select="$indent"/>
- <xsl:with-param name="dofirst" select="0"/>
- </xsl:apply-templates>
- </xsl:when>
- <xsl:otherwise>
- <xsl:apply-templates select=".">
- <xsl:with-param name="indent" select="$indent"/>
- </xsl:apply-templates>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:for-each>
-</xsl:template>
-
-<!-- Named utility templates. -->
-
-<xsl:template name="header">
- <xsl:param name="input" select="0"/>
- <xsl:variable name="input-length" select="string-length($input)"/>
-
- <xsl:value-of select="$input"/>
- <xsl:text>
</xsl:text>
-
- <xsl:call-template name="str:dup">
- <xsl:with-param name="input" select=" '~' "/>
- <xsl:with-param name="count" select="$input-length"/>
- </xsl:call-template>
- <xsl:text>
</xsl:text>
-</xsl:template>
-
-<xsl:template name="ruler">
- <xsl:call-template name="str:dup">
- <xsl:with-param name="input" select=" '-' "/>
- <xsl:with-param name="count" select="$width"/>
- </xsl:call-template>
- <xsl:text>
</xsl:text>
-</xsl:template>
-
-</xsl:stylesheet>
--- /dev/null
+<?xml version="1.0" encoding="ISO-8859-1"?> <!-- -*- sgml -*- -->
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:ext="http://exslt.org/common"
+ xmlns:str-split2lines-func="f:str-split2lines-func"
+ exclude-result-prefixes="xsl ext str-split2lines-func">
+
+
+<!-- how much do I love haskell ... -->
+<xsl:template name="str-foldl">
+ <xsl:param name="pFunc" select="/.."/>
+ <xsl:param name="pA0"/>
+ <xsl:param name="pStr"/>
+
+ <xsl:choose>
+ <xsl:when test="not(string($pStr))">
+ <xsl:copy-of select="$pA0"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:variable name="vFunResult">
+ <xsl:apply-templates select="$pFunc[1]">
+ <xsl:with-param name="arg0" select="$pFunc[position() > 1]"/>
+ <xsl:with-param name="arg1" select="$pA0"/>
+ <xsl:with-param name="arg2" select="substring($pStr,1,1)"/>
+ </xsl:apply-templates>
+ </xsl:variable>
+
+ <xsl:call-template name="str-foldl">
+ <xsl:with-param name="pFunc" select="$pFunc"/>
+ <xsl:with-param name="pStr" select="substring($pStr,2)"/>
+ <xsl:with-param name="pA0" select="ext:node-set($vFunResult)"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+
+</xsl:template>
+
+
+<str-split2lines-func:str-split2lines-func/>
+
+<xsl:template name="str-split-to-lines">
+ <xsl:param name="pStr"/>
+ <xsl:param name="pLineLength" select="60"/>
+ <xsl:param name="pDelimiters" select="' 
'"/>
+ <xsl:variable name="vsplit2linesFun"
+ select="document('')/*/str-split2lines-func:*[1]"/>
+
+ <xsl:variable name="vrtfParams">
+ <delimiters><xsl:value-of select="$pDelimiters"/></delimiters>
+ <lineLength><xsl:copy-of select="$pLineLength"/></lineLength>
+ </xsl:variable>
+
+ <xsl:variable name="vResult">
+ <xsl:call-template name="str-foldl">
+ <xsl:with-param name="pFunc" select="$vsplit2linesFun"/>
+ <xsl:with-param name="pStr" select="$pStr"/>
+
+ <xsl:with-param name="pA0" select="ext:node-set($vrtfParams)"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:for-each select="ext:node-set($vResult)/line">
+ <xsl:for-each select="word">
+ <xsl:value-of select="concat(., ' ')"/>
+ </xsl:for-each>
+ <xsl:value-of select="'
'"/>
+ </xsl:for-each>
+</xsl:template>
+
+
+<xsl:template match="str-split2lines-func:*">
+ <xsl:param name="arg1" select="/.."/>
+ <xsl:param name="arg2"/>
+
+ <xsl:copy-of select="$arg1/*[position() < 3]"/>
+ <xsl:copy-of select="$arg1/line[position() != last()]"/>
+
+ <xsl:choose>
+ <xsl:when test="contains($arg1/*[1], $arg2)">
+ <xsl:if test="string($arg1/word)">
+ <xsl:call-template name="fillLine">
+ <xsl:with-param name="pLine" select="$arg1/line[last()]"/>
+ <xsl:with-param name="pWord" select="$arg1/word"/>
+ <xsl:with-param name="pLineLength" select="$arg1/*[2]"/>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:copy-of select="$arg1/line[last()]"/>
+ <word><xsl:value-of select="concat($arg1/word, $arg2)"/></word>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+
+<!-- This template recognises every new word and accumulates the result, -->
+<!-- which is a list of 'line' elements, each having a list of 'word' -->
+<!-- children. After the last 'line' element there's a single 'word', in -->
+<!-- which the 'current word; is being accumulated. Whenever the current -->
+<!--- character is one of the specified delimiters, this signals the -->
+<!-- formation of a new word. This word is either added to the last line -->
+<!-- (if the total line length will not exceed the specified line-length), -->
+<!-- or a new line is started and this word becomes the 1st in the new line -->
+<xsl:template name="fillLine">
+ <xsl:param name="pLine" select="/.."/>
+ <xsl:param name="pWord" select="/.."/>
+ <xsl:param name="pLineLength" />
+
+ <xsl:variable name="vnWordsInLine" select="count($pLine/word)"/>
+ <xsl:variable name="vLineLength"
+ select="string-length($pLine) + $vnWordsInLine"/>
+
+ <xsl:choose>
+ <xsl:when test="not($vLineLength + string-length($pWord) > $pLineLength)">
+ <line>
+ <xsl:copy-of select="$pLine/*"/>
+ <xsl:copy-of select="$pWord"/>
+ </line>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:copy-of select="$pLine"/>
+ <line>
+ <xsl:copy-of select="$pWord"/>
+ </line>
+ <word/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+
+</xsl:stylesheet>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:str="http://www.ora.com/XSLTCookbook/namespaces/strings">
-
-<!-- This file was copied with some adaptations from the examples
-supplied with the XSLT Cookbook by Sal Mangano, (C) 2003 O'Reilly &
-Associates, ISBN 0-596-00372-2. -->
-
- <xsl:template name="str:dup">
- <xsl:param name="input"/>
- <xsl:param name="count" select="1"/>
-
- <xsl:choose>
- <xsl:when test="not($count) or not($input)"/>
- <xsl:when test="$count = 1">
- <xsl:value-of select="$input"/>
- </xsl:when>
- <xsl:otherwise>
- <!-- If $count is odd append an extra copy of input -->
- <xsl:if test="$count mod 2">
- <xsl:value-of select="$input"/>
- </xsl:if>
- <!-- Recursively apply template after doubling input and
- halving count -->
- <xsl:call-template name="str:dup">
- <xsl:with-param name="input" select="concat($input,$input)"/>
- <xsl:with-param name="count" select="floor($count div 2)"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-</xsl:stylesheet>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" id="str.find-last"
- xmlns:str="http://www.ora.com/XSLTCookbook/namespaces/strings" extension-element-prefixes="str">
-
-<!-- This file was copied with some adaptations from the examples
-supplied with the XSLT Cookbook by Sal Mangano, (C) 2003 O'Reilly &
-Associates, ISBN 0-596-00372-2. -->
-
-<xsl:template name="str:substring-before-last">
- <xsl:param name="input"/>
- <xsl:param name="substr"/>
-
- <xsl:if test="$substr and contains($input, $substr)">
- <xsl:variable name="temp" select="substring-after($input, $substr)" />
- <xsl:value-of select="substring-before($input, $substr)" />
- <xsl:if test="contains($temp, $substr)">
- <xsl:value-of select="$substr" />
- <xsl:call-template name="str:substring-before-last">
- <xsl:with-param name="input" select="$temp" />
- <xsl:with-param name="substr" select="$substr" />
- </xsl:call-template>
- </xsl:if>
- </xsl:if>
-
-</xsl:template>
-
-
-<xsl:template name="str:substring-after-last">
- <xsl:param name="input"/>
- <xsl:param name="substr"/>
-
- <!-- Extract the string which comes after the first occurence -->
- <xsl:variable name="temp" select="substring-after($input,$substr)"/>
-
- <xsl:choose>
- <xsl:when test="$substr and contains($temp,$substr)">
- <xsl:call-template name="str:substring-after-last">
- <xsl:with-param name="input" select="$temp"/>
- <xsl:with-param name="substr" select="$substr"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$temp"/>
- </xsl:otherwise>
- </xsl:choose>
-</xsl:template>
-
-
-<xsl:template match="xsl:stylesheet[@id='str.find-last'] | xsl:include[@href='str.find-last.xslt'] " >
-<tests>
-
-<!-- before -->
- <test name="str:substring-before-last with no occurences of yes">
- <xsl:call-template name="str:substring-before-last">
- <xsl:with-param name="input" select=" 'No occurences' "/>
- <xsl:with-param name="substr" select=" 'yes' "/>
- </xsl:call-template>
- </test>
-
- <test name="str:substring-before-last starts with yes">
- <xsl:call-template name="str:substring-before-last">
- <xsl:with-param name="input" select=" 'yes occurences' "/>
- <xsl:with-param name="substr" select=" 'yes' "/>
- </xsl:call-template>
- </test>
-
- <test name="str:substring-before-last starts with yes and ends with yes">
- <xsl:call-template name="str:substring-before-last">
- <xsl:with-param name="input" select=" 'yes occurences yes' "/>
- <xsl:with-param name="substr" select=" 'yes' "/>
- </xsl:call-template>
- </test>
-
- <test name="str:substring-before-last 3 yes">
- <xsl:call-template name="str:substring-before-last">
- <xsl:with-param name="input" select=" 'yesyesyes' "/>
- <xsl:with-param name="substr" select=" 'yes' "/>
- </xsl:call-template>
- </test>
- <test name="str:substring-before-last empty input">
- <xsl:call-template name="str:substring-before-last">
- <xsl:with-param name="substr" select=" 'yes' "/>
- </xsl:call-template>
- </test>
-
- <test name="str:substring-before-last empty search">
- <xsl:call-template name="str:substring-before-last">
- <xsl:with-param name="input" select=" 'No occurences' "/>
- </xsl:call-template>
-
- </test>
-
- <test name="str:substring-before-last large">
- <xsl:call-template name="str:substring-before-last">
- <xsl:with-param name="input" select=" 'yesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyes' "/>
- <xsl:with-param name="substr" select=" 'yes' "/>
- </xsl:call-template>
-
-
- </test>
-
-<!-- after -->
-
- <test name="str:substring-after-last with no occurences of yes">
- <xsl:call-template name="str:substring-after-last">
- <xsl:with-param name="input" select=" 'No occurences' "/>
- <xsl:with-param name="substr" select=" 'yes' "/>
- </xsl:call-template>
- </test>
-
- <test name="str:substring-after-last starts with yes">
- <xsl:call-template name="str:substring-after-last">
- <xsl:with-param name="input" select=" 'yes occurences' "/>
- <xsl:with-param name="substr" select=" 'yes' "/>
- </xsl:call-template>
- </test>
-
- <test name="str:substring-after-last starts with yes and ends with yes">
- <xsl:call-template name="str:substring-after-last">
- <xsl:with-param name="input" select=" 'yes occurences yes' "/>
- <xsl:with-param name="substr" select=" 'yes' "/>
- </xsl:call-template>
- </test>
-
- <test name="str:substring-after-last 3 yes">
- <xsl:call-template name="str:substring-after-last">
- <xsl:with-param name="input" select=" 'yesyesyes' "/>
- <xsl:with-param name="substr" select=" 'yes' "/>
- </xsl:call-template>
- </test>
-
- <test name="str:substring-after-last 3 yes then no">
- <xsl:call-template name="str:substring-after-last">
- <xsl:with-param name="input" select=" 'yesyesyesno' "/>
- <xsl:with-param name="substr" select=" 'yes' "/>
- </xsl:call-template>
- </test>
-
- <test name="str:substring-after-last empty input">
- <xsl:call-template name="str:substring-after-last">
- <xsl:with-param name="substr" select=" 'yes' "/>
- </xsl:call-template>
- </test>
-
- <test name="str:substring-after-last empty search">
- <xsl:call-template name="str:substring-after-last">
- <xsl:with-param name="input" select=" 'No occurences' "/>
- </xsl:call-template>
-
- </test>
-
-</tests>
-</xsl:template>
-
- <xsl:template match="text()"/>
-
-</xsl:stylesheet>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:str="http://www.ora.com/XSLTCookbook/namespaces/strings"
- xmlns:text="http://www.ora.com/XSLTCookbook/namespaces/text" extension-element-prefixes="text">
-
-<!-- This file was copied with some adaptations from the examples
-supplied with the XSLT Cookbook by Sal Mangano, (C) 2003 O'Reilly &
-Associates, ISBN 0-596-00372-2. -->
-
-<xsl:include href="str.dup.xslt"/>
-
-<xsl:template name="text:justify">
- <xsl:param name="value" />
- <xsl:param name="width" select="10"/>
- <xsl:param name="align" select=" 'left' "/>
-
- <!-- Truncate if too long -->
- <xsl:variable name="output" select="substring($value,1,$width)"/>
-
- <xsl:choose>
- <xsl:when test="$align = 'left'">
- <xsl:value-of select="$output"/>
- <xsl:call-template name="str:dup">
- <xsl:with-param name="input" select=" ' ' "/>
- <xsl:with-param name="count" select="$width - string-length($output)"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:when test="$align = 'right'">
- <xsl:call-template name="str:dup">
- <xsl:with-param name="input" select=" ' ' "/>
- <xsl:with-param name="count" select="$width - string-length($output)"/>
- </xsl:call-template>
- <xsl:value-of select="$output"/>
- </xsl:when>
- <xsl:when test="$align = 'center'">
- <xsl:call-template name="str:dup">
- <xsl:with-param name="input" select=" ' ' "/>
- <xsl:with-param name="count" select="floor(($width - string-length($output)) div 2)"/>
- </xsl:call-template>
- <xsl:value-of select="$output"/>
- <xsl:call-template name="str:dup">
- <xsl:with-param name="input" select=" ' ' "/>
- <xsl:with-param name="count" select="ceiling(($width - string-length($output)) div 2)"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>INVALID ALIGN</xsl:otherwise>
- </xsl:choose>
-</xsl:template>
-
-</xsl:stylesheet>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" id="text.wrap"
- xmlns:str="http://www.ora.com/XSLTCookbook/namespaces/strings"
- xmlns:text="http://www.ora.com/XSLTCookbook/namespaces/text" exclude-result-prefixes="text">
-
-<!-- This file was copied with some adaptations from the examples
-supplied with the XSLT Cookbook by Sal Mangano, (C) 2003 O'Reilly &
-Associates, ISBN 0-596-00372-2. -->
-
-<xsl:include href="str.find-last.xslt"/>
-<xsl:include href="text.justify.xslt"/>
-
-<xsl:template match="node() | @*" mode="text:wrap" name="text:wrap">
- <xsl:param name="input" select="normalize-space()"/>
- <xsl:param name="width" select="70"/>
- <xsl:param name="indent" select="0"/>
- <xsl:param name="dofirst" select="1"/>
- <xsl:param name="align" select=" 'left' "/>
-
- <xsl:variable name="effective" select="$width - $indent"/>
-
- <xsl:if test="$input">
- <xsl:variable name="line">
- <xsl:choose>
- <xsl:when test="string-length($input) > $effective">
- <xsl:variable name="candidate-line" select="substring($input,1,$effective)"/>
- <xsl:choose>
- <xsl:when test="contains($candidate-line,' ')">
- <xsl:call-template name="str:substring-before-last">
- <xsl:with-param name="input" select="$candidate-line"/>
- <xsl:with-param name="substr" select=" ' ' "/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$candidate-line"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$input"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <xsl:if test="$line">
- <xsl:if test="$dofirst">
- <xsl:call-template name="str:dup">
- <xsl:with-param name="input" select=" ' ' "/>
- <xsl:with-param name="count" select="$indent"/>
- </xsl:call-template>
- </xsl:if>
-
- <xsl:call-template name="text:justify">
- <xsl:with-param name="value" select="$line"/>
- <xsl:with-param name="width" select="$effective"/>
- <xsl:with-param name="align" select="$align"/>
- </xsl:call-template>
- <xsl:text>
</xsl:text>
- </xsl:if>
-
- <xsl:call-template name="text:wrap">
- <xsl:with-param name="input" select="substring($input, string-length($line) + 2)"/>
- <xsl:with-param name="width" select="$width"/>
- <xsl:with-param name="indent" select="$indent"/>
- <xsl:with-param name="align" select="$align"/>
- </xsl:call-template>
- </xsl:if>
-</xsl:template>
-
-<xsl:template match="node() | @*" mode="text:dump" name="text:dump">
- <xsl:param name="input" select="text()"/>
- <xsl:param name="indent" select="0"/>
-
- <xsl:if test="$input">
- <xsl:variable name="line">
- <xsl:choose>
- <xsl:when test="contains($input, '
')">
- <xsl:value-of select="substring-before($input, '
')"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$input"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <xsl:if test="$line">
- <xsl:call-template name="str:dup">
- <xsl:with-param name="input" select=" ' ' "/>
- <xsl:with-param name="count" select="$indent"/>
- </xsl:call-template>
- <xsl:value-of select="$line"/>
- <xsl:text>
</xsl:text>
- </xsl:if>
-
- <xsl:call-template name="text:dump">
- <xsl:with-param name="input" select="substring-after($input, '
')"/>
- <xsl:with-param name="indent" select="$indent"/>
- </xsl:call-template>
- </xsl:if>
-</xsl:template>
-
-</xsl:stylesheet>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?> <!-- -*- sgml -*- -->
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-
-<xsl:include href="copy.xslt"/>
-
-<xsl:strip-space elements="*"/>
-
-<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
-
-<!-- Preprocess a docbook/xml file, replacing elements that are to be -->
-<!-- formatted inline with the corresponding text. -->
-
-<xsl:template match="literal|computeroutput">
- <xsl:value-of select="text()"/>
-</xsl:template>
-
-<xsl:template match="ulink">
- <xsl:variable name="url" select="normalize-space(@url)"/>
- <xsl:variable name="text" select="normalize-space(text())"/>
-
- <xsl:if test="$text and $text != $url">
- <xsl:text>'</xsl:text><xsl:value-of select="$text"/><xsl:text>' </xsl:text>
- </xsl:if>
- <xsl:text><</xsl:text><xsl:value-of select="$url"/><xsl:text>></xsl:text>
-</xsl:template>
-
-</xsl:stylesheet>
+++ /dev/null
-<?xml version="1.0"?> <!-- -*- sgml -*- -->
-<xsl:stylesheet
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
-
-<!-- we like '1.2 Title' -->
-<xsl:param name="section.autolabel" select="'1'"/>
-<xsl:param name="section.label.includes.component.label" select="'1'"/>
-
-<!-- Do not put 'Chapter' at the start of eg 'Chapter 1. Doing This' -->
-<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-numbered">
- <l:template name="chapter" text="%n. %t"/>
- </l:context>
- </l:l10n>
-</l:i18n>
-
-<!-- do not generate sub-tocs for qanda sets -->
-<xsl:param name="generate.toc">
-set toc,title
-book toc,title,figure,table,example,equation
-chapter toc,title
-section toc
-sect1 toc
-sect2 toc
-sect3 toc
-sect4 nop
-sect5 nop
-qandaset toc
-qandadiv nop
-appendix toc,title
-article/appendix nop
-<!-- article toc,title -->
-article nop
-preface toc,title
-reference toc,title
-</xsl:param>
-
-<!-- center everything at the top of a titlepage -->
-<xsl:attribute-set name="set.titlepage.recto.style">
- <xsl:attribute name="align">center</xsl:attribute>
-</xsl:attribute-set>
-
-<!-- per Bob Stayton: turn off xml:base processing pro tem -->
-<!-- should hopefully be fixed in next docbook stylesheets release (1.70) -->
-<xsl:template match="@fileref">
- <xsl:value-of select="."/>
-</xsl:template>
-
-</xsl:stylesheet>
--- /dev/null
+<?xml version="1.0" encoding="ISO-8859-1"?> <!-- -*- sgml -*- -->
+<!DOCTYPE xsl:stylesheet [
+ <!ENTITY nl "
">
+ <!ENTITY line-len "72">
+ <!ENTITY indent " ">
+ <!-- we always output the same-length rule, so just define it as an entity -->
+ <!ENTITY rule "------------------------------------------------------------------------">
+]>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<xsl:import href="http://docbook.sourceforge.net/release/xsl/current/fo/docbook.xsl"/>
+
+
+<!-- line-wrapping stuff -->
+<xsl:import href="line-wrap.xsl"/>
+
+<!-- dump all white-space only nodes -->
+<xsl:strip-space elements="*"/>
+
+
+<xsl:output method="text" encoding="ISO-8859-1"
+ indent="yes" omit-xml-declaration="yes"/>
+
+<xsl:param name="generate.toc">
+book nop
+article nop
+qandaset toc
+qandadiv nop
+</xsl:param>
+
+
+<!-- top-level place to start -->
+<xsl:template match="*" mode="process.root">
+ <xsl:text>&nl;</xsl:text>
+ <xsl:apply-templates select="."/>
+</xsl:template>
+
+
+<!-- book templates -->
+<xsl:template match="book">
+ <xsl:call-template name="book.titlepage"/>
+ <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template name="book.titlepage">
+ <xsl:text>&nl;</xsl:text>
+ <xsl:variable name="recto.content">
+ <xsl:apply-templates mode="book.titlepage.recto.auto.mode"
+ select="bookinfo/title"/>
+ <xsl:apply-templates mode="book.titlepage.recto.auto.mode"
+ select="bookinfo/releaseinfo"/>
+ <xsl:apply-templates mode="book.titlepage.recto.auto.mode"
+ select="bookinfo/copyright"/>
+ <xsl:apply-templates mode="book.titlepage.recto.auto.mode"
+ select="bookinfo/author"/>
+ </xsl:variable>
+ <xsl:copy-of select="$recto.content"/>
+
+</xsl:template>
+
+<xsl:template match="title" mode="book.titlepage.recto.auto.mode">
+ <xsl:value-of select="."/>
+ <xsl:text>&nl;</xsl:text>
+</xsl:template>
+
+<xsl:template match="releaseinfo" mode="book.titlepage.recto.auto.mode">
+ <xsl:value-of select="."/>
+ <xsl:text>&nl;</xsl:text>
+
+ <xsl:call-template name="ruler">
+ <xsl:with-param name="char" select="'~'"/>
+ <xsl:with-param name="len" select="string-length(.)"/>
+ </xsl:call-template>
+
+ <xsl:text>&nl;</xsl:text>
+</xsl:template>
+
+<!-- noop -->
+<xsl:template match="copyright" mode="book.titlepage.recto.auto.mode"/>
+<!-- noop -->
+<xsl:template match="author" mode="book.titlepage.recto.auto.mode"/>
+
+
+<!-- article templates -->
+<xsl:template match="article">
+ <xsl:call-template name="article.titlepage"/>
+ <xsl:apply-templates/>
+</xsl:template>
+
+<!-- noop -->
+<xsl:template name="article.titlepage"/>
+<!-- noop -->
+<xsl:template match="article/title" mode="titlepage.mode"/>
+
+
+
+<!-- qandaset / qandadiv / qandaentry templates -->
+<xsl:template match="qandaset">
+ <xsl:variable name="title" select="(title)[1]"/>
+ <xsl:text>Table of Contents</xsl:text>
+ <xsl:apply-templates select="$title"/>
+ <xsl:call-template name="process.qanda.toc"/>
+ <xsl:text>&nl;</xsl:text>
+ <!-- do the thang -->
+ <xsl:apply-templates select="qandaentry|qandadiv"/>
+</xsl:template>
+
+<xsl:template match="qandadiv/title">
+ <xsl:variable name="qalevel">
+ <xsl:call-template name="qandadiv.section.level"/>
+ </xsl:variable>
+
+ <xsl:text>&nl;&rule;&nl;</xsl:text>
+ <xsl:apply-templates select="parent::qandadiv" mode="label.markup"/>
+ <xsl:text>. </xsl:text>
+ <xsl:apply-templates/>
+ <xsl:text>&nl;&rule;&nl;&nl;</xsl:text>
+</xsl:template>
+
+<xsl:template name="process.qanda.toc">
+ <xsl:apply-templates select="qandadiv" mode="qandatoc.mode"/>
+</xsl:template>
+
+<xsl:template match="qandadiv" mode="qandatoc.mode">
+ <xsl:apply-templates select="title" mode="qandatoc.mode"/>
+ <xsl:call-template name="process.qanda.toc"/>
+</xsl:template>
+
+<xsl:template match="qandadiv/title" mode="qandatoc.mode">
+ <xsl:variable name="qalevel">
+ <xsl:call-template name="qandadiv.section.level"/>
+ </xsl:variable>
+
+ <xsl:text>&nl;</xsl:text>
+ <xsl:apply-templates select="parent::qandadiv" mode="label.markup"/>
+ <xsl:text>. </xsl:text>
+
+ <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="qandadiv">
+ <xsl:apply-templates select="(title)[1]"/>
+ <xsl:apply-templates select="qandadiv|qandaentry"/>
+</xsl:template>
+
+<!-- if this qandaentry is not the first child in the parent qandadiv, -->
+<!-- then output a separator line -->
+<xsl:template match="qandaentry">
+ <xsl:if test="position() > 1">
+ <xsl:text>&rule;&nl;&nl;</xsl:text>
+ </xsl:if>
+ <xsl:apply-templates/>
+</xsl:template>
+
+
+
+<!-- TODO: implement indenting of subsequent lines in question para -->
+<!-- maybe pass a var 'indent' along to foldl ... ... -->
+<xsl:template match="question">
+ <xsl:variable name="qnum">
+ <xsl:apply-templates select="." mode="label.markup"/>
+ </xsl:variable>
+
+ <xsl:for-each select="para|screen|programlisting|itemizedlist|orderedlist">
+ <xsl:choose>
+ <!-- glue $qnum onto the front of the first question para -->
+ <xsl:when test="local-name() = 'para' and position() = 1">
+ <xsl:apply-templates select=".">
+ <xsl:with-param name="prefix" select="concat($qnum, '. ')"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select=".">
+ <xsl:with-param name="prefix" select="zzzz"/>
+ </xsl:apply-templates>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
+
+</xsl:template>
+
+
+<xsl:template match="answer">
+ <xsl:apply-templates select="*[name(.) != 'label']"/>
+</xsl:template>
+
+
+<xsl:template match="para">
+ <xsl:param name="prefix" select="''"/>
+
+ <!-- reformat any ulinks found -->
+ <xsl:variable name="text">
+ <xsl:choose>
+ <xsl:when test="descendant-or-self::ulink">
+ <xsl:apply-templates name="ulink"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="."/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <!-- the input to str-split-to-lines must be delim'd by either -->
+ <!-- a space or a newline. since we need a newline at the end of -->
+ <!-- every para anyway, stick it on now -->
+ <xsl:variable name="pLine"
+ select="concat($prefix, normalize-space($text), '&nl;')"/>
+
+ <xsl:choose>
+ <xsl:when test="string-length($pLine) < &line-len;">
+ <xsl:value-of select="$pLine"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <!-- TODO: this is where an 'indent' param should be sent -->
+ <xsl:call-template name="str-split-to-lines">
+ <xsl:with-param name="pStr" select="$pLine"/>
+ <xsl:with-param name="pLineLength" select="&line-len;"/>
+ <xsl:with-param name="pDelimiters" select="' &nl;'"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:text>&nl;</xsl:text>
+</xsl:template>
+
+
+<!-- always indent the contents of screen / programlisting -->
+<xsl:template match="screen|programlisting">
+ <xsl:call-template name="indent.me">
+ <xsl:with-param name="first" select="'1'"/>
+ </xsl:call-template>
+ <xsl:text>&nl;</xsl:text>
+</xsl:template>
+
+
+<xsl:template match="itemizedlist">
+ <xsl:apply-templates select="listitem"/>
+</xsl:template>
+
+<xsl:template match="itemizedlist/listitem">
+ <xsl:apply-templates>
+ <xsl:with-param name="prefix" select="'* '"/>
+ </xsl:apply-templates>
+</xsl:template>
+
+
+<xsl:template match="orderedlist">
+ <xsl:apply-templates select="listitem"/>
+</xsl:template>
+
+<xsl:template match="orderedlist/listitem">
+ <xsl:apply-templates>
+ <xsl:with-param name="prefix" select="concat(position(), '. ' )"/>
+ </xsl:apply-templates>
+</xsl:template>
+
+
+<xsl:template match="ulink" name="ulink">
+ <xsl:variable name="url" select="normalize-space(@url)"/>
+
+ <xsl:value-of select="concat(text(), ': ')"/>
+
+ <xsl:text><</xsl:text>
+ <xsl:choose>
+ <xsl:when test="starts-with($url, 'mailto:')">
+ <xsl:value-of select="substring-after($url, ':')"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$url"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:text>></xsl:text>
+
+</xsl:template>
+
+
+<!-- indent a string -->
+<xsl:template name="indent.me">
+ <xsl:param name="text" select="."/>
+ <xsl:param name="first" select="'0'"/>
+ <xsl:choose>
+ <xsl:when test="contains($text, '
')">
+ <xsl:value-of select="substring-before($text, '
')"/>
+ <xsl:if test="$first = 0">
+ <xsl:text>&nl;</xsl:text>
+ </xsl:if>
+ <xsl:text>&indent;</xsl:text>
+ <xsl:call-template name="indent.me">
+ <xsl:with-param name="text" select="substring-after($text, '
')"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:if test="not(string-length($text) = 0)">
+ <xsl:text>&indent;</xsl:text>
+ <xsl:value-of select="$text"/>
+ <xsl:text>&nl;</xsl:text>
+ </xsl:if>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+
+<!-- Repeat the character 'char' 'len' times -->
+<xsl:template name="ruler">
+ <xsl:param name="char"/>
+ <xsl:param name="len"/>
+ <xsl:param name="line"/>
+ <xsl:choose>
+ <xsl:when test="$len = 0">
+ <xsl:value-of select="$line"/>
+ <xsl:text>&nl;</xsl:text>
+ </xsl:when>
+ <xsl:when test="$len mod 2 = 1">
+ <xsl:call-template name="ruler">
+ <xsl:with-param name="char" select="concat($char,$char)"/>
+ <xsl:with-param name="len" select="($len - 1) div 2"/>
+ <xsl:with-param name="line" select="concat($line,$char)"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="ruler">
+ <xsl:with-param name="char" select="concat($char,$char)"/>
+ <xsl:with-param name="len" select="$len div 2"/>
+ <xsl:with-param name="line" select="$line"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+
+</xsl:stylesheet>
+
xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.0">
<xsl:import href="http://docbook.sourceforge.net/release/xsl/current/fo/docbook.xsl"/>
-<xsl:import href="vg-common.xsl"/>
<!-- set indent = yes while debugging, then change to NO -->
<xsl:output method="xml" indent="no"/>
-<!-- ensure only passivetex extensions are on -->
-<xsl:param name="stylesheet.result.type" select="'fo'"/>
-<!-- fo extensions: PDF bookmarks and index terms -->
+
+<!-- passivetex fo extensions: PDF bookmarks and index terms -->
<xsl:param name="use.extensions" select="'1'"/>
-<xsl:param name="xep.extensions" select="0"/>
-<xsl:param name="fop.extensions" select="0"/>
-<xsl:param name="saxon.extensions" select="0"/>
<xsl:param name="passivetex.extensions" select="1"/>
-<xsl:param name="tablecolumns.extension" select="'1'"/>
-
-<!-- ensure we are using single sided -->
+<!-- turn draft mode off -->
+<xsl:param name="draft.mode" select="'no'"></xsl:param>
+<!-- be extra sure we are using single sided -->
<xsl:param name="double.sided" select="'0'"/>
+<!-- output in 'block' mode -->
+<xsl:param name="variablelist.as.blocks" select="1"/>
+<!-- don't show url separately in ulinks -->
+<xsl:param name="ulink.show" select="0"/>
+<!-- control generation of tocs -->
+<xsl:param name="generate.toc">
+set toc,title
+book toc,title
+part toc,title
+chapter nop,title
+section nop
+sect1 nop
+sect2 nop
+sect3 nop
+sect4 nop
+sect5 nop
+article nop
+book/article nop
+article/sect1 nop
+appendix toc,title
+preface toc,title
+reference toc,title
+qandadiv toc
+qandaset toc
+</xsl:param>
-<!-- insert cross references to page numbers -->
-<xsl:param name="insert.xref.page.number" select="1"/>
+<!-- properties common to html + fo -->
+<!-- we like '1.2 Title' -->
+<xsl:param name="section.autolabel" select="'1'"/>
+<xsl:param name="section.label.includes.component.label" select="'1'"/>
+<!-- Do not put 'Chapter' at the start of eg 'Chapter 1. Doing This' -->
+<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-numbered">
+ <l:template name="chapter" text="%n. %t"/>
+ </l:context>
+ </l:l10n>
+</l:i18n>
-<!-- <?custom-pagebreak?> inserts a page break at this point -->
-<xsl:template match="processing-instruction('custom-pagebreak')">
- <fo:block break-before='page'/>
-</xsl:template>
-
-<!-- show links in color -->
-<xsl:attribute-set name="xref.properties">
- <xsl:attribute name="color">blue</xsl:attribute>
-</xsl:attribute-set>
<!-- Bug-fix for Suse 10 PassiveTex version -->
-<!-- Precompute attribute values; PassiveTex is too stupid: -->
+<!-- Precompute attribute values 'cos PassiveTex is too stupid: -->
<xsl:attribute-set name="component.title.properties">
- <xsl:attribute
- name="keep-with-next.within-column">always</xsl:attribute>
+ <xsl:attribute name="keep-with-next.within-column">always</xsl:attribute>
<xsl:attribute name="space-before.optimum">
<xsl:value-of select="concat($body.font.master, 'pt')"/>
</xsl:attribute>
<xsl:attribute name="hyphenate">false</xsl:attribute>
</xsl:attribute-set>
-<!-- make pre listings indented a bit + a bg colour -->
-<xsl:template match="programlisting | screen">
- <fo:block start-indent="0.25in" wrap-option="no-wrap"
- white-space-collapse="false" text-align="start"
- font-family="monospace" background-color="#f2f2f9"
- linefeed-treatment="preserve"
- xsl:use-attribute-sets="normal.para.spacing">
- <xsl:apply-templates/>
- </fo:block>
+<!-- per Bob Stayton: turn off xml:base processing pro tem -->
+<!-- should hopefully be fixed in next docbook stylesheets release (1.70) -->
+<!-- ensures correct source paths, eg. images/my_img.png -->
+<xsl:template match="@fileref">
+ <xsl:value-of select="."/>
</xsl:template>
-<!-- workaround bug in passivetex fo output for itemizedlist -->
-<xsl:template match="itemizedlist/listitem">
- <xsl:variable name="id">
- <xsl:call-template name="object.id"/></xsl:variable>
- <xsl:variable name="itemsymbol">
- <xsl:call-template name="list.itemsymbol">
- <xsl:with-param name="node" select="parent::itemizedlist"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:variable name="item.contents">
- <fo:list-item-label end-indent="label-end()">
- <fo:block>
- <xsl:choose>
- <xsl:when test="$itemsymbol='disc'">•</xsl:when>
- <xsl:when test="$itemsymbol='bullet'">•</xsl:when>
- <xsl:otherwise>•</xsl:otherwise>
- </xsl:choose>
- </fo:block>
- </fo:list-item-label>
- <fo:list-item-body start-indent="body-start()">
- <xsl:apply-templates/> <!-- removed extra block wrapper -->
- </fo:list-item-body>
+<!-- show links in color -->
+<xsl:attribute-set name="xref.properties">
+ <xsl:attribute name="color">blue</xsl:attribute>
+</xsl:attribute-set>
+
+<!-- colored background for programlisting and screen -->
+<!-- setting param shade.verbatim=1 screws up literallayout -->
+<!-- something chronic, so have to go this route -->
+<xsl:template match="programlisting|screen|synopsis">
+ <xsl:param name="suppress-numbers" select="'0'"/>
+ <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
+ <xsl:variable name="content">
+ <xsl:choose>
+ <xsl:when test="$suppress-numbers = '0'
+ and @linenumbering = 'numbered'
+ and $use.extensions != '0'
+ and $linenumbering.extension != '0'">
+ <xsl:call-template name="number.rtf.lines">
+ <xsl:with-param name="rtf">
+ <xsl:apply-templates/>
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates/>
+ </xsl:otherwise>
+ </xsl:choose>
</xsl:variable>
- <xsl:choose>
- <xsl:when test="parent::*/@spacing = 'compact'">
- <fo:list-item id="{$id}"
- xsl:use-attribute-sets="compact.list.item.spacing">
- <xsl:copy-of select="$item.contents"/>
- </fo:list-item>
- </xsl:when>
- <xsl:otherwise>
- <fo:list-item id="{$id}" xsl:use-attribute-sets="list.item.spacing">
- <xsl:copy-of select="$item.contents"/>
- </fo:list-item>
- </xsl:otherwise>
- </xsl:choose>
+ <fo:block id="{$id}" white-space-collapse='false' white-space-treatment='preserve'
+ linefeed-treatment="preserve" background-color="#f2f2f9"
+ xsl:use-attribute-sets="monospace.verbatim.properties">
+ <xsl:choose>
+ <xsl:when test="$hyphenate.verbatim != 0
+ and function-available('exsl:node-set')">
+ <xsl:apply-templates select="exsl:node-set($content)"
+ mode="hyphenate.verbatim"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:copy-of select="$content"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </fo:block>
</xsl:template>
-<!-- workaround bug in passivetex fo output for orderedlist -->
-<xsl:template match="orderedlist/listitem">
- <xsl:variable name="id">
- <xsl:call-template name="object.id"/></xsl:variable>
- <xsl:variable name="item.contents">
- <fo:list-item-label end-indent="label-end()">
+
+<!-- customised set title-page template -->
+<xsl:template name="set.titlepage">
+ <fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format">
+ <xsl:variable name="recto.content">
+ <xsl:apply-templates mode="set.titlepage.recto.auto.mode"
+ select="setinfo/title"/>
+ <xsl:apply-templates mode="set.titlepage.recto.auto.mode"
+ select="setinfo/releaseinfo"/>
+ <xsl:apply-templates mode="set.titlepage.recto.auto.mode"
+ select="setinfo/copyright"/>
+ <xsl:apply-templates mode="set.titlepage.recto.auto.mode"
+ select="setinfo/legalnotice"/>
+ </xsl:variable>
+ <xsl:variable name="recto.elements.count" select="1"/>
<fo:block>
- <xsl:apply-templates select="." mode="item-number"/>
+ <xsl:copy-of select="$recto.content"/>
</fo:block>
- </fo:list-item-label>
- <fo:list-item-body start-indent="body-start()">
- <xsl:apply-templates/> <!-- removed extra block wrapper -->
- </fo:list-item-body>
- </xsl:variable>
- <xsl:choose>
- <xsl:when test="parent::*/@spacing = 'compact'">
- <fo:list-item id="{$id}"
- xsl:use-attribute-sets="compact.list.item.spacing">
- <xsl:copy-of select="$item.contents"/>
- </fo:list-item>
- </xsl:when>
- <xsl:otherwise>
- <fo:list-item id="{$id}" xsl:use-attribute-sets="list.item.spacing">
- <xsl:copy-of select="$item.contents"/>
- </fo:list-item>
- </xsl:otherwise>
- </xsl:choose>
+ <xsl:call-template name="set.titlepage.separator"/>
+ </fo:block>
</xsl:template>
-<!-- workaround bug in passivetex fo output for variablelist -->
-<xsl:param name="variablelist.as.blocks" select="1"/>
-<xsl:template match="varlistentry" mode="vl.as.blocks">
- <xsl:variable name="id">
- <xsl:call-template name="object.id"/></xsl:variable>
- <fo:block id="{$id}" xsl:use-attribute-sets="list.item.spacing"
- keep-together.within-column="always"
- keep-with-next.within-column="always">
- <xsl:apply-templates select="term"/>
+<!-- put some extra space after the set title -->
+<xsl:template match="title" mode="set.titlepage.recto.auto.mode">
+ <fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format"
+ xsl:use-attribute-sets="set.titlepage.recto.style"
+ text-align="center" font-size="24.8832pt" space-before="18.6624pt"
+ space-after="18.6624pt" font-weight="bold" font-family="{$title.fontset}">
+ <xsl:call-template name="division.title">
+ <xsl:with-param name="node" select="ancestor-or-self::set[1]"/>
+ </xsl:call-template>
+ </fo:block>
+</xsl:template>
+
+<!-- put release-info + copyright centered and bold -->
+<xsl:template match="releaseinfo" mode="set.titlepage.recto.auto.mode">
+ <fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format" text-align="center"
+ font-size="14pt" font-weight="bold" font-family="{$title.fontset}">
+ <xsl:apply-templates select="." mode="set.titlepage.recto.mode"/>
+ </fo:block>
+</xsl:template>
+
+<xsl:template match="copyright" mode="set.titlepage.recto.auto.mode">
+ <fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format" text-align="center"
+ font-size="12pt" font-weight="bold" font-family="{$title.fontset}">
+ <xsl:apply-templates select="." mode="set.titlepage.recto.mode"/>
</fo:block>
- <fo:block start-indent="0.5in" end-indent="0in"
- space-after.minimum="0.2em"
- space-after.optimum="0.4em"
- space-after.maximum="0.6em">
+</xsl:template>
+
+
+<!-- customised book title-page template -->
+<xsl:template name="book.titlepage">
+ <fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format">
+ <xsl:variable name="recto.content">
+ <xsl:apply-templates mode="book.titlepage.recto.auto.mode"
+ select="bookinfo/title"/>
+ <xsl:apply-templates mode="book.titlepage.recto.auto.mode"
+ select="bookinfo/subtitle"/>
+ <xsl:apply-templates mode="book.titlepage.recto.auto.mode"
+ select="bookinfo/releaseinfo"/>
+ <xsl:apply-templates mode="book.titlepage.recto.auto.mode"
+ select="bookinfo/copyright"/>
+ <xsl:apply-templates mode="book.titlepage.recto.auto.mode"
+ select="bookinfo/author"/>
+ <xsl:apply-templates mode="book.titlepage.recto.auto.mode"
+ select="bookinfo/legalnotice"/>
+ </xsl:variable>
+ <xsl:variable name="recto.elements.count" select="1"/>
<fo:block>
- <xsl:apply-templates select="listitem"/>
+ <xsl:copy-of select="$recto.content"/>
</fo:block>
+ <xsl:call-template name="book.titlepage.separator"/>
+ </fo:block>
+</xsl:template>
+
+<!-- put some extra space after the book title -->
+<xsl:template match="title" mode="book.titlepage.recto.auto.mode">
+ <fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format"
+ xsl:use-attribute-sets="book.titlepage.recto.style"
+ text-align="center" font-size="24.8832pt" space-before="18.6624pt"
+ space-after="18.6624pt" font-weight="bold" font-family="{$title.fontset}">
+ <xsl:call-template name="division.title">
+ <xsl:with-param name="node" select="ancestor-or-self::book[1]"/>
+ </xsl:call-template>
+ </fo:block>
+</xsl:template>
+
+<!-- center subtitles -->
+<xsl:template match="subtitle" mode="book.titlepage.recto.auto.mode">
+ <fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format" text-align="center"
+ font-size="14pt" font-weight="bold" font-family="{$title.fontset}">
+ <xsl:apply-templates select="." mode="book.titlepage.recto.mode"/>
+ </fo:block>
+</xsl:template>
+
+<!-- no docbook template for bookinfo/releaseinfo, so make one -->
+<xsl:template match="releaseinfo" mode="book.titlepage.recto.auto.mode">
+ <fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format" text-align="center"
+ font-size="12pt" font-weight="bold" font-family="{$title.fontset}">
+ <xsl:apply-templates select="." mode="book.titlepage.recto.mode"/>
+ </fo:block>
+</xsl:template>
+
+<!-- no docbook recto template for bookinfo/copyright, so make one -->
+<xsl:template match="copyright" mode="book.titlepage.recto.auto.mode">
+ <fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format" text-align="center"
+ font-size="11pt" font-weight="bold" font-family="{$title.fontset}">
+ <xsl:apply-templates select="." mode="book.titlepage.recto.mode"/>
+ </fo:block>
+</xsl:template>
+
+<!-- customised email for titlepages -->
+<xsl:template match="author" mode="book.titlepage.recto.auto.mode">
+ <fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format" text-align="center"
+ font-size="10pt" font-family="{$title.fontset}">
+ <xsl:if test="email">
+ <xsl:text>Email: </xsl:text>
+ <xsl:apply-templates select="(email)[1]"/>
+ </xsl:if>
</fo:block>
</xsl:template>
-<!-- workaround bug in passivetext fo output for revhistory -->
-<xsl:template match="revhistory" mode="titlepage.mode">
- <fo:block space-before="1.0em">
- <fo:table table-layout="fixed" width="100%">
- <fo:table-column column-number="1" column-width="33%"/>
- <fo:table-column column-number="2" column-width="33%"/>
- <fo:table-column column-number="3" column-width="34%"/>
+
+<!-- show only book titles in the top-level set toc -->
+<xsl:template match="book|setindex" mode="toc">
+ <xsl:param name="toc-context" select="."/>
+ <xsl:variable name="id">
+ <xsl:call-template name="object.id"/>
+ </xsl:variable>
+ <xsl:variable name="cid">
+ <xsl:call-template name="object.id">
+ <xsl:with-param name="object" select="$toc-context"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:call-template name="toc.line"/>
+ <xsl:variable name="nodes" select="glossary|bibliography|preface|chapter
+ |reference|part|article|appendix|index"/>
+ <xsl:variable name="depth.from.context"
+ select="count(ancestor::*)-count($toc-context/ancestor::*)"/>
+ <xsl:if test="$toc.section.depth > 0 and not($toc-context/self::set)
+ and $toc.max.depth > $depth.from.context and $nodes">
+ <fo:block id="toc.{$cid}.{$id}">
+ <xsl:attribute name="margin-left">
+ <xsl:call-template name="set.toc.indent"/>
+ </xsl:attribute>
+ <xsl:apply-templates select="$nodes" mode="toc">
+ <xsl:with-param name="toc-context" select="$toc-context"/>
+ </xsl:apply-templates>
+ </fo:block>
+ </xsl:if>
+</xsl:template>
+
+
+<!-- TODO: don`t generate a TOC at all for Quick-Start and FAQ -->
+
+
+
+<!-- page headers: -->
+<xsl:template name="header.table">
+ <xsl:param name="pageclass" select="''"/>
+ <xsl:param name="sequence" select="''"/>
+ <xsl:param name="gentext-key" select="''"/>
+ <xsl:variable name="candidate">
+ <fo:table table-layout="fixed" width="100%" border-bottom-width="0.5pt" border-bottom-style="solid" border-bottom-color="black">
+ <fo:table-column column-number="1" column-width="100%"/>
<fo:table-body>
- <fo:table-row>
- <fo:table-cell number-columns-spanned="3" text-align="left">
+ <fo:table-row height="14pt">
+ <fo:table-cell text-align="right" display-align="before" relative-align="baseline">
<fo:block>
- <xsl:call-template name="gentext">
- <xsl:with-param name="key" select="'RevHistory'"/>
- </xsl:call-template>
+ <xsl:apply-templates select="." mode="titleabbrev.markup"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
- <xsl:apply-templates mode="titlepage.mode"/>
</fo:table-body>
- </fo:table>
- </fo:block>
+ </fo:table>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="$pageclass='titlepage' or $sequence='blank'
+ or ($sequence='first' and $gentext-key='chapter')">
+ <!-- noop on titlepages, first chapter page or blank pages -->
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:copy-of select="$candidate"/>
+ </xsl:otherwise>
+ </xsl:choose>
</xsl:template>
-<xsl:template match="revhistory/revision" mode="titlepage.mode">
- <xsl:variable name="revnumber" select=".//revnumber"/>
- <xsl:variable name="revdate" select=".//date"/>
- <xsl:variable name="revauthor" select=".//authorinitials"/>
- <xsl:variable name="revremark" select=".//revremark"/>
- <fo:table-row>
- <fo:table-cell text-align="left">
- <fo:block>
- <xsl:if test="$revnumber">
- <xsl:call-template name="gentext">
- <xsl:with-param name="key" select="'Revision'"/>
- </xsl:call-template>
- <xsl:call-template name="gentext.space"/>
- <xsl:apply-templates select="$revnumber[1]" mode="titlepage.mode"/>
- </xsl:if>
- </fo:block>
- </fo:table-cell>
- <fo:table-cell text-align="left">
- <fo:block>
- <xsl:apply-templates select="$revdate[1]" mode="titlepage.mode"/>
- </fo:block>
- </fo:table-cell>
- <fo:table-cell text-align="left">
- <fo:block>
- <xsl:apply-templates select="$revauthor[1]" mode="titlepage.mode"/>
- </fo:block>
- </fo:table-cell>
- </fo:table-row>
- <xsl:if test="$revremark">
- <fo:table-row>
- <fo:table-cell number-columns-spanned="3" text-align="left">
- <fo:block>
- <xsl:apply-templates select="$revremark[1]" mode="titlepage.mode"/>
- </fo:block>
- </fo:table-cell>
- </fo:table-row>
- </xsl:if>
-</xsl:template>
-<!-- workaround bug in footers: force right-align w/two 80|30 cols -->
+<!-- page footers: two 80|20 cols w/right-aligned page numbers -->
<xsl:template name="footer.table">
<xsl:param name="pageclass" select="''"/>
<xsl:param name="sequence" select="''"/>
<xsl:param name="gentext-key" select="''"/>
- <xsl:choose>
- <xsl:when test="$pageclass = 'index'">
- <xsl:attribute name="margin-left">0pt</xsl:attribute>
- </xsl:when>
- </xsl:choose>
<xsl:variable name="candidate">
<fo:table table-layout="fixed" width="100%">
- <fo:table-column column-number="1" column-width="80%"/>
- <fo:table-column column-number="2" column-width="20%"/>
- <fo:table-body>
- <fo:table-row height="14pt">
- <fo:table-cell text-align="left" display-align="after">
- <xsl:attribute name="relative-align">baseline</xsl:attribute>
- <fo:block>
- <fo:block> </fo:block><!-- empty cell -->
- </fo:block>
- </fo:table-cell>
- <fo:table-cell text-align="center" display-align="after">
- <xsl:attribute name="relative-align">baseline</xsl:attribute>
- <fo:block>
- <xsl:call-template name="footer.content">
- <xsl:with-param name="pageclass" select="$pageclass"/>
- <xsl:with-param name="sequence" select="$sequence"/>
- <xsl:with-param name="position" select="'center'"/>
- <xsl:with-param name="gentext-key" select="$gentext-key"/>
- </xsl:call-template>
- </fo:block>
- </fo:table-cell>
- </fo:table-row>
- </fo:table-body>
+ <fo:table-column column-number="1" column-width="80%"/>
+ <fo:table-column column-number="2" column-width="20%"/>
+ <fo:table-body>
+ <fo:table-row height="14pt">
+ <fo:table-cell text-align="left" display-align="after"
+ relative-align="baseline">
+ <fo:block/>
+<!--
+ <fo:block>
+ <xsl:text>Pageclass: </xsl:text>
+ <xsl:value-of select="$pageclass"/>
+ <xsl:text> Sequence: </xsl:text>
+ <xsl:value-of select="$sequence"/>
+ <xsl:text> Gentext-Key: </xsl:text>
+ <xsl:value-of select="$gentext-key"/>
+ </fo:block>
+-->
+ </fo:table-cell>
+ <fo:table-cell text-align="right" display-align="after"
+ relative-align="baseline">
+ <fo:block>
+ <fo:page-number/>
+ </fo:block>
+ </fo:table-cell>
+ </fo:table-row>
+ </fo:table-body>
</fo:table>
</xsl:variable>
- <!-- Really output a footer? -->
<xsl:choose>
- <xsl:when test="$pageclass='titlepage' and $gentext-key='book'
- and $sequence='first'">
- <!-- no, book titlepages have no footers at all -->
- </xsl:when>
- <xsl:when test="$sequence = 'blank' and $footers.on.blank.pages = 0">
- <!-- no output -->
+ <xsl:when test="$pageclass='titlepage' or $sequence='blank'">
+ <!-- noop on titlepages or blank pages -->
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="$candidate"/>
</xsl:template>
-<!-- fix bug in headers: force right-align w/two 40|60 cols -->
-<xsl:template name="header.table">
- <xsl:param name="pageclass" select="''"/>
- <xsl:param name="sequence" select="''"/>
- <xsl:param name="gentext-key" select="''"/>
+<!-- workaround bug in passivetex fo output for itemizedlist -->
+<xsl:template match="itemizedlist/listitem">
+ <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
+ <xsl:variable name="item.contents">
+ <fo:list-item-label end-indent="label-end()">
+ <fo:block>
+ <xsl:call-template name="itemizedlist.label.markup">
+ <xsl:with-param name="itemsymbol">
+ <xsl:call-template name="list.itemsymbol">
+ <xsl:with-param name="node" select="parent::itemizedlist"/>
+ </xsl:call-template>
+ </xsl:with-param>
+ </xsl:call-template>
+ </fo:block>
+ </fo:list-item-label>
+ <fo:list-item-body start-indent="body-start()">
+ <xsl:apply-templates/> <!-- removed extra block wrapper -->
+ </fo:list-item-body>
+ </xsl:variable>
<xsl:choose>
- <xsl:when test="$pageclass = 'index'">
- <xsl:attribute name="margin-left">0pt</xsl:attribute>
+ <xsl:when test="parent::*/@spacing = 'compact'">
+ <fo:list-item id="{$id}" xsl:use-attribute-sets="compact.list.item.spacing">
+ <xsl:copy-of select="$item.contents"/>
+ </fo:list-item>
</xsl:when>
+ <xsl:otherwise>
+ <fo:list-item id="{$id}" xsl:use-attribute-sets="list.item.spacing">
+ <xsl:copy-of select="$item.contents"/>
+ </fo:list-item>
+ </xsl:otherwise>
</xsl:choose>
- <xsl:variable name="candidate">
- <fo:table table-layout="fixed" width="100%">
- <xsl:call-template name="head.sep.rule">
- <xsl:with-param name="pageclass" select="$pageclass"/>
- <xsl:with-param name="sequence" select="$sequence"/>
- <xsl:with-param name="gentext-key" select="$gentext-key"/>
- </xsl:call-template>
- <fo:table-column column-number="1" column-width="40%"/>
- <fo:table-column column-number="2" column-width="60%"/>
- <fo:table-body>
- <fo:table-row height="14pt">
- <fo:table-cell text-align="left" display-align="before">
- <xsl:attribute name="relative-align">baseline</xsl:attribute>
- <fo:block>
- <fo:block> </fo:block><!-- empty cell -->
- </fo:block>
- </fo:table-cell>
- <fo:table-cell text-align="center" display-align="before">
- <xsl:attribute name="relative-align">baseline</xsl:attribute>
- <fo:block>
- <xsl:call-template name="header.content">
- <xsl:with-param name="pageclass" select="$pageclass"/>
- <xsl:with-param name="sequence" select="$sequence"/>
- <xsl:with-param name="position" select="'center'"/>
- <xsl:with-param name="gentext-key" select="$gentext-key"/>
- </xsl:call-template>
- </fo:block>
- </fo:table-cell>
- </fo:table-row>
- </fo:table-body>
- </fo:table>
+</xsl:template>
+
+<!-- workaround bug in passivetex fo output for orderedlist -->
+<xsl:template match="orderedlist/listitem">
+ <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
+ <xsl:variable name="item.contents">
+ <fo:list-item-label end-indent="label-end()">
+ <fo:block>
+ <xsl:apply-templates select="." mode="item-number"/>
+ </fo:block>
+ </fo:list-item-label>
+ <fo:list-item-body start-indent="body-start()">
+ <xsl:apply-templates/> <!-- removed extra block wrapper -->
+ </fo:list-item-body>
</xsl:variable>
- <!-- Really output a header? -->
<xsl:choose>
- <xsl:when test="$pageclass = 'titlepage' and $gentext-key = 'book'
- and $sequence='first'">
- <!-- no, book titlepages have no headers at all -->
- </xsl:when>
- <xsl:when test="$sequence = 'blank' and $headers.on.blank.pages = 0">
- <!-- no output -->
+ <xsl:when test="parent::*/@spacing = 'compact'">
+ <fo:list-item id="{$id}" xsl:use-attribute-sets="compact.list.item.spacing">
+ <xsl:copy-of select="$item.contents"/>
+ </fo:list-item>
</xsl:when>
<xsl:otherwise>
- <xsl:copy-of select="$candidate"/>
+ <fo:list-item id="{$id}" xsl:use-attribute-sets="list.item.spacing">
+ <xsl:copy-of select="$item.contents"/>
+ </fo:list-item>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
-
-<!--
-pagebreaks in fo output:
-- http://www.dpawson.co.uk/docbook/styling/fo.html#d1408e636
-http://www.dpawson.co.uk/docbook/styling/fo.html
-http://docbook.sourceforge.net/release/xsl/current/doc/fo/variablelist.as.blocks.html
-alt. book to oreilly:
-- http://www.ravelgrane.com/ER/doc/lx/book.html
-tex memory:
-- http://www.dpawson.co.uk/docbook/tools.html#d4e191
--->
<?xml version="1.0"?> <!-- -*- sgml -*- -->
-<xsl:stylesheet
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:import href="http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl"/>
<xsl:import href="http://docbook.sourceforge.net/release/xsl/current/html/chunk-common.xsl"/>
<xsl:import href="http://docbook.sourceforge.net/release/xsl/current/html/manifest.xsl"/>
<xsl:import href="http://docbook.sourceforge.net/release/xsl/current/html/chunk-code.xsl"/>
-<xsl:import href="vg-common.xsl"/>
+
<!-- use 8859-1 encoding -->
<xsl:output method="html" encoding="ISO-8859-1" indent="yes"/>
+<!-- set various parameters -->
<xsl:param name="use.id.as.filename" select="'1'"/>
<xsl:param name="chunker.output.indent" select="'yes'"/>
<!-- use our custom html stylesheet -->
<xsl:param name="html.stylesheet" select="'vg_basic.css'"/>
<!-- set chunking at the chapter level only -->
<xsl:param name="chunk.section.depth" select="'0'"/>
+<!-- do not generate sub-tocs for qanda sets -->
+<xsl:param name="generate.toc">
+set toc,title
+book toc,title,figure,table,example,equation
+chapter toc,title
+section toc
+sect1 toc
+sect2 toc
+sect3 toc
+sect4 nop
+sect5 nop
+qandaset toc
+qandadiv toc
+appendix toc,title
+article/appendix nop
+article nop
+preface toc,title
+reference toc,title
+</xsl:param>
+
+
+<!-- properties common to html + fo -->
+<!-- we like '1.2 Title' -->
+<xsl:param name="section.autolabel" select="'1'"/>
+<xsl:param name="section.label.includes.component.label" select="'1'"/>
+
+<!-- Do not put 'Chapter' at the start of eg 'Chapter 1. Doing This' -->
+<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-numbered">
+ <l:template name="chapter" text="%n. %t"/>
+ </l:context>
+ </l:l10n>
+</l:i18n>
+
+<!-- per Bob Stayton: turn off xml:base processing pro tem -->
+<!-- should hopefully be fixed in next docbook stylesheets release (1.70) -->
+<xsl:template match="@fileref">
+ <xsl:value-of select="."/>
+</xsl:template>
+
+
+<!-- center everything at the top of a titlepage -->
+<xsl:attribute-set name="set.titlepage.recto.style">
+ <xsl:attribute name="align">center</xsl:attribute>
+</xsl:attribute-set>
+
<!-- use our custom header -->
<xsl:template name="header.navigation">
+++ /dev/null
-<?xml version="1.0"?> <!-- -*- sgml -*- -->
-<!DOCTYPE xsl:stylesheet [ <!ENTITY vg-css SYSTEM "vg_basic.css"> ]>
-
-<xsl:stylesheet
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
-
-<xsl:import href="http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl"/>
-<xsl:import href="vg-common.xsl"/>
-
-<!-- use 8859-1 encoding -->
-<xsl:output method="html" encoding="ISO-8859-1" indent="yes"/>
-
-<!-- we include the css directly when generating one large file -->
-<xsl:template name="user.head.content">
- <style type="text/css" media="screen">
- <xsl:text>&vg-css;</xsl:text>
- </style>
-</xsl:template>
-
-<!-- We don't like tables with borders -->
-<xsl:template match="revhistory" mode="titlepage.mode">
- <xsl:variable name="numcols">
- <xsl:choose>
- <xsl:when test="//authorinitials">3</xsl:when>
- <xsl:otherwise>2</xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <table width="100%" border="0" summary="Revision history">
- <tr>
- <th align="left" colspan="{$numcols}">
- <h4>Revision History</h4>
- </th>
- </tr>
- <xsl:apply-templates mode="titlepage.mode">
- <xsl:with-param name="numcols" select="$numcols"/>
- </xsl:apply-templates>
- </table>
-</xsl:template>
-
-<!-- question and answer set mods -->
-<xsl:template match="answer">
- <xsl:variable name="deflabel">
- <xsl:choose>
- <xsl:when test="ancestor-or-self::*[@defaultlabel]">
- <xsl:value-of select="(ancestor-or-self::*[@defaultlabel])[last()]
- /@defaultlabel"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$qanda.defaultlabel"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <tr class="{name(.)}">
- <td><xsl:text> </xsl:text></td>
- <td align="left" valign="top">
- <xsl:apply-templates select="*[name(.) != 'label']"/>
- </td>
- </tr>
- <tr><td colspan="2"><xsl:text> </xsl:text></td></tr>
-</xsl:template>
-
-</xsl:stylesheet>
-
<bookinfo>
<title>Valgrind FAQ</title>
- <subtitle>Valgrind Frequently Asked Questions</subtitle>
<releaseinfo>&rel-type; &rel-version; &rel-date;</releaseinfo>
- <copyright>
- <year>&vg-lifespan;</year>
- <holder><ulink url="&vg-developers;">Valgrind Developers</ulink></holder>
- </copyright>
- <legalnotice>
- <para>Email: <ulink url="mailto:&vg-vemail;">&vg-vemail;</ulink></para>
- </legalnotice>
+ <copyright>
+ <year>&vg-lifespan;</year>
+ <holder><ulink url="&vg-developers;">Valgrind Developers</ulink></holder>
+ </copyright>
+ <author>
+ <email><ulink url="mailto:&vg-vemail;">&vg-vemail;</ulink></email>
+ </author>
</bookinfo>
-<sect1 id="faq.background" xreflabel="Background">
-<title>Background</title>
+<article>
+<title>Valgrind Frequently Asked Questions</title>
+
+
+<!-- FAQ starts here -->
+<qandaset>
-<qandaset id="qset.background">
+
+<!-- Background -->
+<qandadiv id="faq.background" xreflabel="Background">
+<title>Background</title>
<qandaentry id="faq.pronounce">
- <question>
+ <question id="q-pronounce">
<para>How do you pronounce "Valgrind"?</para>
</question>
- <answer>
+ <answer id="a-pronounce">
<para>The "Val" as in the world "value". The "grind" is
pronounced with a short 'i' -- ie. "grinned" (rhymes with
"tinned") rather than "grined" (rhymes with "find").</para>
</qandaentry>
<qandaentry id="faq.whence">
- <question>
+ <question id="q-whence">
<para>Where does the name "Valgrind" come from?</para>
</question>
- <answer>
+ <answer id="a-whence">
<para>From Nordic mythology. Originally (before release) the
project was named Heimdall, after the watchman of the Nordic
gods. He could "see a hundred miles by day or night, hear the
</answer>
</qandaentry>
-</qandaset>
+</qandadiv>
-</sect1>
-<sect1 id="faq.installing"
- xreflabel="Compiling, installing and configuring">
+<!-- Compiling, Installing and Configuring -->
+<qandadiv id="faq.installing" xreflabel="Compiling, installing and configuring">
<title>Compiling, installing and configuring</title>
-<qandaset id="qset.installing">
<qandaentry id="faq.make_dies">
- <question>
+ <question id="q-make_dies">
<para>When I trying building Valgrind, 'make' dies partway with
- an assertion failure, something like this:
+ an assertion failure, something like this:</para>
<screen>
% make: expand.c:489: allocated_variable_append:
Assertion 'current_variable_set_list->next != 0' failed.
</screen>
- </para>
</question>
- <answer>
+ <answer id="a-make_dies">
<para>It's probably a bug in 'make'. Some, but not all,
instances of version 3.79.1 have this bug, see
www.mail-archive.com/bug-make@gnu.org/msg01658.html. Try
</answer>
</qandaentry>
-</qandaset>
-</sect1>
+</qandadiv>
-<sect1 id="faq.abort"
- xreflabel="Valgrind aborts unexpectedly">
+<!-- Valgrind aborts unexpectedly -->
+<qandadiv id="faq.abort" xreflabel="Valgrind aborts unexpectedly">
<title>Valgrind aborts unexpectedly</title>
-<qandaset id="qset.abort">
<qandaentry id="faq.exit_errors">
- <question>
+ <question id="q-exit_errors">
<para>Programs run OK on Valgrind, but at exit produce a bunch
of errors involving <literal>__libc_freeres()</literal>
and then die with a segmentation fault.</para>
</question>
- <answer>
- <para>When the program exits, Valgrind runs the procedure
- <literal>__libc_freeres()</literal> in glibc. This is a hook
- for memory debuggers, so they can ask glibc to free up any
- memory it has used. Doing that is needed to ensure that
- Valgrind doesn't incorrectly report space leaks in glibc.</para>
- <para>Problem is that running
- <literal>__libc_freeres()</literal> in older glibc versions
- causes this crash.</para> <para>WORKAROUND FOR 1.1.X and later
- versions of Valgrind: use the
- <literal>--run-libc-freeres=no</literal> flag. You may then get
- space leak reports for glibc-allocations (please _don't_ report
- these to the glibc people, since they are not real leaks), but
- at least the program runs.</para>
+ <answer id="a-exit_errors">
+ <para>When the program exits, Valgrind runs the procedure
+ <literal>__libc_freeres()</literal> in glibc. This is a hook
+ for memory debuggers, so they can ask glibc to free up any
+ memory it has used. Doing that is needed to ensure that
+ Valgrind doesn't incorrectly report space leaks in glibc.</para>
+ <para>Problem is that running
+ <literal>__libc_freeres()</literal> in older glibc versions
+ causes this crash.</para> <para>WORKAROUND FOR 1.1.X and later
+ versions of Valgrind: use the
+ <literal>--run-libc-freeres=no</literal> flag. You may then get
+ space leak reports for glibc-allocations (please _don't_ report
+ these to the glibc people, since they are not real leaks), but
+ at least the program runs.</para>
</answer>
</qandaentry>
<qandaentry id="faq.bugdeath">
- <question>
+ <question id="q-bugdeath">
<para>My (buggy) program dies like this:</para>
- <screen>
-% valgrind: vg_malloc2.c:442 (bszW_to_pszW): Assertion 'pszW >= 0' failed.
-</screen>
-
+<screen>% valgrind: vg_malloc2.c:442 (bszW_to_pszW): Assertion 'pszW >= 0' failed.</screen>
</question>
- <answer>
+ <answer id="a-bugdeath">
<para>If Memcheck (the memory checker) shows any invalid reads,
invalid writes and invalid frees in your program, the above may
happen. Reason is that your program may trash Valgrind's
</qandaentry>
<qandaentry id="faq.msgdeath">
- <question>
+ <question id="q-msgdeath">
<para>My program dies, printing a message like this along the
way:</para>
-<screen>
-% disInstr: unhandled instruction bytes: 0x66 0xF 0x2E 0x5
-</screen>
-
+<screen>% disInstr: unhandled instruction bytes: 0x66 0xF 0x2E 0x5</screen>
</question>
- <answer>
+ <answer id="a-msgdeath">
<para>Older versions did not support some x86 instructions,
particularly SSE/SSE2 instructions. Try a newer Valgrind; we
now support almost all instructions. If it still happens with
</qandaentry>
<qandaentry id="faq.java">
- <question>
+ <question id="q-java">
<para>I tried running a Java program (or another program that uses a
- just-in-time compiler) under Valgrind but something went wrong.
- Does Valgrind handle such programs?
- </para>
+ just-in-time compiler) under Valgrind but something went wrong.
+ Does Valgrind handle such programs?</para>
</question>
- <answer>
+ <answer id="a-java">
<para>Valgrind can handle dynamically generated code, so long as none
- of the generated code is later overwritten by other generated code.
- If this happens, though, things will go wrong as Valgrind will continue
- running its translations of the old code (this is true on x86 and AMD64,
- on PPC32 there are explicit cache flush instructions which Valgrind
- detects). You should try running with
- <computeroutput>--smc-check=all</computeroutput> in this case; Valgrind
- will run much more slowly, but should detect the use of the out-of-date
- code.</para>
+ of the generated code is later overwritten by other generated code.
+ If this happens, though, things will go wrong as Valgrind will continue
+ running its translations of the old code (this is true on x86 and AMD64,
+ on PPC32 there are explicit cache flush instructions which Valgrind
+ detects). You should try running with
+ <computeroutput>--smc-check=all</computeroutput> in this case; Valgrind
+ will run much more slowly, but should detect the use of the out-of-date
+ code.</para>
<para>Alternativaly, if you have the source code to the JIT compiler you
- can insert calls to the
- <computeroutput>VALGRIND_DISCARD_TRANSLATIONS</computeroutput> client
- request to mark out-of-date code, saving you from using
- <computeroutput>--smc-check=all</computeroutput>.</para>
+ can insert calls to the
+ <computeroutput>VALGRIND_DISCARD_TRANSLATIONS</computeroutput> client
+ request to mark out-of-date code, saving you from using
+ <computeroutput>--smc-check=all</computeroutput>.</para>
<para>Apart from this, in theory Valgrind can run any Java program just
- fine, even those that use JNI and are partially implemented in other
- languages like C and C++. In practice, Java implementations tend to do
- nasty things that most programs do not, and Valgrind sometimes falls
- over these corner cases.</para>
+ fine, even those that use JNI and are partially implemented in other
+ languages like C and C++. In practice, Java implementations tend to do
+ nasty things that most programs do not, and Valgrind sometimes falls
+ over these corner cases.</para>
<para>If your Java programs do not run under Valgrind, even with
- <computeroutput>--smc-check=all</computeroutput>, please file a bug
- report and hopefully we'll be able to fix the problem.</para>
+ <computeroutput>--smc-check=all</computeroutput>, please file a bug
+ report and hopefully we'll be able to fix the problem.</para>
</answer>
</qandaentry>
-</qandaset>
-</sect1>
+</qandadiv>
-<sect1 id="faq.unexpected"
- xreflabel="Valgrind behaves unexpectedly">
+<!-- Valgrind behaves unexpectedly -->
+<qandadiv id="faq.unexpected" xreflabel="Valgrind behaves unexpectedly">
<title>Valgrind behaves unexpectedly</title>
-<qandaset id="qset.unexpected">
<qandaentry id="faq.reports">
- <question>
+ <question id="q-reports">
<para>My program uses the C++ STL and string classes. Valgrind
reports 'still reachable' memory leaks involving these classes
at the exit of the program, but there should be none.</para>
</question>
- <answer>
+ <answer id="a-reports">
<para>First of all: relax, it's probably not a bug, but a
feature. Many implementations of the C++ standard libraries
use their own memory pool allocators. Memory for quite a
<qandaentry id="faq.unhelpful">
- <question>
+ <question id="q-unhelpful">
<para>The stack traces given by Memcheck (or another tool)
aren't helpful. How can I improve them?</para>
</question>
- <answer>
+ <answer id="a-unhelpful">
<para>If they're not long enough, use
<literal>--num-callers</literal> to make them longer.</para>
<para>If they're not detailed enough, make sure you are
</qandaentry>
<qandaentry id="faq.aliases">
- <question>
+ <question id="q-aliases">
<para>The stack traces given by Memcheck (or another tool) seem to
have the wrong function name in them. What's happening?</para>
</question>
- <answer>
+ <answer id="a-aliases">
<para>Occasionally Valgrind stack traces get the wrong function names.
This is caused by glibc using aliases to effectively give one function two
names. Most of the time Valgrind chooses a suitable name, but very
occasionally it gets it wrong.
-
Examples we know of are printing 'bcmp' instead of 'memcmp', 'index'
instead of 'strchr', and 'rindex' instead of 'strrchr'.</para>
</answer>
</qandaentry>
-</qandaset>
-</sect1>
+</qandadiv>
+
-<sect1 id="faq.notfound" xreflabel="Memcheck doesn't find my bug">
+<!-- Memcheck doesn't find my bug -->
+<qandadiv id="faq.notfound" xreflabel="Memcheck doesn't find my bug">
<title>Memcheck doesn't find my bug</title>
-<qandaset id="qset.notfound">
<qandaentry id="faq.hiddenbug">
- <question>
+ <question id="q-hiddenbug">
<para>I try running "valgrind --tool=memcheck my_program" and
get Valgrind's startup message, but I don't get any errors and
I know my program has errors.</para>
</question>
- <answer>
+ <answer id="a-hiddenbug">
<para>There are two possible causes of this.</para>
<para>First, by default, Valgrind only traces the top-level process.
<qandaentry id="faq.overruns">
- <question>
+ <question id="q-overruns">
<para>Why doesn't Memcheck find the array overruns in this program?</para>
<programlisting>
int static[5];
}
</programlisting>
</question>
- <answer>
+ <answer id="a-overruns">
<para>Unfortunately, Memcheck doesn't do bounds checking on
static or stack arrays. We'd like to, but it's just not
possible to do in a reasonable way that fits with how Memcheck
</answer>
</qandaentry>
+</qandadiv>
-</qandaset>
-</sect1>
-<sect1 id="faq.misc"
- xreflabel="Miscellaneous">
+<!-- Miscellaneous -->
+<qandadiv id="faq.misc" xreflabel="Miscellaneous">
<title>Miscellaneous</title>
-<qandaset id="qset.misc">
<qandaentry id="faq.writesupp">
- <question>
+ <question id="q-writesupp">
<para>I tried writing a suppression but it didn't work. Can
you write my suppression for me?</para>
</question>
- <answer>
+ <answer id="a-writesupp">
<para>Yes! Use the
<computeroutput>--gen-suppressions=yes</computeroutput> feature
to spit out suppressions automatically for you. You can then
<qandaentry id="faq.deflost">
- <question>
+ <question id="q=deflost">
<para>With Memcheck/Addrcheck's memory leak detector, what's
the difference between "definitely lost", "possibly lost",
"still reachable", and "suppressed"?</para>
</question>
- <answer>
+ <answer id="a-deflost">
<para>The details are in the Memcheck section of the user manual.</para>
<para>In short:</para>
suppression files. You can ignore suppressed errors.</para>
</listitem>
</itemizedlist>
- </answer>
+ </answer>
</qandaentry>
+</qandadiv>
-</qandaset>
-</sect1>
-<!-- template
-<sect1 id="faq."
- xreflabel="xx">
-<title>xx</title>
-<qandaset id="qset.">
+<!-- Further Assistance -->
+<qandadiv id="faq.help" xreflabel="How To Get Further Assistance">
+<title>How To Get Further Assistance</title>
-<qandaentry id="faq.deflost">
- <question>
- <para></para>
- </question>
- <answer>
- <para></para>
- </answer>
-</qandaentry>
+<qandaentry id="e-help">
-</qandaset>
-</sect1>
--->
+ <answer id="a-help">
+ <para>Please read all of this section before posting.</para>
+ <para>If you think an answer is incomplete or inaccurate, please
+ e-mail <ulink url="mailto:&vg-vemail;">&vg-vemail;</ulink>.</para>
+ <para>Read the appropriate section(s) of the
+ <ulink url="http://www.valgrind.org/docs/manual.html">Valgrind
+ Documentation</ulink>.</para>
-<sect1 id="faq.help" xreflabel="How To Get Further Assistance">
-<title>How To Get Further Assistance</title>
+ <para>Read the <ulink url="http://www.valgrind.org/docs/dist.html">Distribution Documents</ulink>.</para>
+ <para><ulink url="http://search.gmane.org">Search</ulink> the
+ <ulink url="http://news.gmane.org/gmane.comp.debugging.valgrind">valgrind-users</ulink> mailing list archives, using the group name
+ <computeroutput>gmane.comp.debugging.valgrind</computeroutput>.</para>
-<para>Please read all of this section before posting.</para>
+ <para>Only when you have tried all of these things and are still stuck,
+ should you post to the <ulink url="&vg-users-list;">valgrind-users
+ mailing list</ulink>. In which case, please read the following
+ carefully. Making a complete posting will greatly increase the chances
+ that an expert or fellow user reading it will have enough information
+ and motivation to reply.</para>
-<para>If you think an answer is incomplete or inaccurate, please
-e-mail <ulink url="mailto:&vg-vemail;">&vg-vemail;</ulink>.</para>
+ <para>Make sure you give full details of the problem,
+ including the full output of <computeroutput>valgrind -v</computeroutput>,
+ if applicable. Also which Linux distribution you're using (Red Hat, Debian, etc)
+ and its version number.</para>
-<para>Read the appropriate section(s) of the Manual(s):
-<ulink url="http://www.valgrind.org/docs/">Valgrind
-Documentation</ulink>.</para>
+ <para>You are in little danger of making your posting too long
+ unless you include large chunks of valgrind's (unsuppressed)
+ output, so err on the side of giving too much information.</para>
-<para>Read the <ulink url="http://www.valgrind.org/docs/">Distribution Documents</ulink>.</para>
+ <para>Clearly written subject lines and message bodies are appreciated,
+ too.</para>
-<para><ulink url="http://search.gmane.org">Search</ulink> the
-<ulink url="http://news.gmane.org/gmane.comp.debugging.valgrind">valgrind-users</ulink> mailing list archives, using the group name
-<computeroutput>gmane.comp.debugging.valgrind</computeroutput>.</para>
+ <para>Finally, remember that, despite the fact that most of the
+ community are very helpful and responsive to emailed questions,
+ you are probably requesting help from unpaid volunteers, so you
+ have no guarantee of receiving an answer.</para>
+</answer>
-<para>Only when you have tried all of these things and are still stuck,
-should you post to the <ulink url="&vg-users-list;">valgrind-users
-mailing list</ulink>. In which case, please read the following
-carefully. Making a complete posting will greatly increase the chances
-that an expert or fellow user reading it will have enough information
-and motivation to reply.</para>
+</qandaentry>
+</qandadiv>
-<para>Make sure you give full details of the problem,
-including the full output of <computeroutput>valgrind
--v</computeroutput>, if applicable. Also which Linux distribution
-you're using (Red Hat, Debian, etc) and its version number.</para>
-<para>You are in little danger of making your posting too long
-unless you include large chunks of valgrind's (unsuppressed)
-output, so err on the side of giving too much information.</para>
+<!-- FAQ ends here -->
+</qandaset>
+
-<para>Clearly written subject lines and message bodies are appreciated,
-too.</para>
-<para>Finally, remember that, despite the fact that most of the
-community are very helpful and responsive to emailed questions,
-you are probably requesting help from unpaid volunteers, so you
-have no guarantee of receiving an answer.</para>
+<!-- template
+<qandadiv id="faq.installing" xreflabel="Installing">
+<title>Installing</title>
+
+<qandaentry id="faq.problem">
+ <question id="q-problem">
+ <para></para>
+ </question>
+ <answer id="a-problem">
+ <para></para>
+ </answer>
+</qandaentry>
-</sect1>
+</qandadiv>
+-->
+</article>
</book>
<?xml version="1.0"?> <!-- -*- sgml -*- -->
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
- "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
+ "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"
+[ <!ENTITY % vg-entities SYSTEM "vg-entities.xml"> %vg-entities; ]>
<book id="dist" xreflabel="Distribution Documents">
<bookinfo>
- <title>Distribution Documents</title>
+ <title>Valgrind Distribution Documents</title>
+ <releaseinfo>&rel-type; &rel-version; &rel-date;</releaseinfo>
+ <copyright>
+ <year>&vg-lifespan;</year>
+ <holder><ulink url="&vg-developers;">Valgrind Developers</ulink></holder>
+ </copyright>
+ <author>
+ <email><ulink url="mailto:&vg-vemail;">&vg-vemail;</ulink></email>
+ </author>
</bookinfo>
<!-- Nb: because these are all text files, we have to wrap them in suitable
<copyright>
<year>&vg-lifespan;</year>
<holder>
- <link linkend="dist.authors" endterm="dist.authors.title"></link>
+ <link linkend="dist.authors" endterm="dist.authors.title"></link>
</holder>
</copyright>
<variablelist>
<varlistentry>
- <term><computeroutput>RUNNING_ON_VALGRIND</computeroutput>:</term>
+ <term><command><computeroutput>RUNNING_ON_VALGRIND</computeroutput></command>:</term>
<listitem>
<para>returns 1 if running on Valgrind, 0 if running on the
real CPU. If you are running Valgrind on itself, it will return the
</varlistentry>
<varlistentry>
- <term><computeroutput>VALGRIND_DISCARD_TRANSLATIONS</computeroutput>:</term>
+ <term><command><computeroutput>VALGRIND_DISCARD_TRANSLATIONS</computeroutput>:</command></term>
<listitem>
<para>discard translations of code in the specified address
range. Useful if you are debugging a JITter or some other
</varlistentry>
<varlistentry>
- <term><computeroutput>VALGRIND_COUNT_ERRORS</computeroutput>:</term>
+ <term><command><computeroutput>VALGRIND_COUNT_ERRORS</computeroutput>:</command></term>
<listitem>
<para>returns the number of errors found so far by Valgrind.
Can be useful in test harness code when combined with the
</varlistentry>
<varlistentry>
- <term><computeroutput>VALGRIND_MALLOCLIKE_BLOCK</computeroutput>:</term>
+ <term><command><computeroutput>VALGRIND_MALLOCLIKE_BLOCK</computeroutput>:</command></term>
<listitem>
<para>If your program manages its own memory instead of using
the standard <computeroutput>malloc()</computeroutput> /
</varlistentry>
<varlistentry>
- <term><computeroutput>VALGRIND_FREELIKE_BLOCK</computeroutput>:</term>
+ <term><command><computeroutput>VALGRIND_FREELIKE_BLOCK</computeroutput>:</command></term>
<listitem>
<para>This should be used in conjunction with
<computeroutput>VALGRIND_MALLOCLIKE_BLOCK</computeroutput>.
</varlistentry>
<varlistentry>
- <term><computeroutput>VALGRIND_CREATE_MEMPOOL</computeroutput>:</term>
+ <term><command><computeroutput>VALGRIND_CREATE_MEMPOOL</computeroutput>:</command></term>
<listitem>
<para>This is similar to
<computeroutput>VALGRIND_MALLOCLIKE_BLOCK</computeroutput>,
</varlistentry>
<varlistentry>
- <term><computeroutput>VALGRIND_DESTROY_MEMPOOL</computeroutput>:</term>
+ <term><command><computeroutput>VALGRIND_DESTROY_MEMPOOL</computeroutput>:</command></term>
<listitem>
<para>This should be used in conjunction with
<computeroutput>VALGRIND_CREATE_MEMPOOL</computeroutput>
</varlistentry>
<varlistentry>
- <term><computeroutput>VALGRIND_MEMPOOL_ALLOC</computeroutput>:</term>
+ <term><command><computeroutput>VALGRIND_MEMPOOL_ALLOC</computeroutput>:</command></term>
<listitem>
<para>This should be used in conjunction with
<computeroutput>VALGRIND_CREATE_MEMPOOL</computeroutput>
</varlistentry>
<varlistentry>
- <term><computeroutput>VALGRIND_MEMPOOL_FREE</computeroutput>:</term>
+ <term><command><computeroutput>VALGRIND_MEMPOOL_FREE</computeroutput>:</command></term>
<listitem>
<para>This should be used in conjunction with
<computeroutput>VALGRIND_CREATE_MEMPOOL</computeroutput>
</varlistentry>
<varlistentry>
- <term><computeroutput>VALGRIND_NON_SIMD_CALL[0123]</computeroutput>:</term>
+ <term><command><computeroutput>VALGRIND_NON_SIMD_CALL[0123]</computeroutput>:</command></term>
<listitem>
<para>executes a function of 0, 1, 2 or 3 args in the client
program on the <emphasis>real</emphasis> CPU, not the virtual
</varlistentry>
<varlistentry>
- <term><computeroutput>VALGRIND_PRINTF(format, ...)</computeroutput>:</term>
+ <term><command><computeroutput>VALGRIND_PRINTF(format, ...)</computeroutput>:</command></term>
<listitem>
<para>printf a message to the log file when running under
Valgrind. Nothing is output if not running under Valgrind.
</varlistentry>
<varlistentry>
- <term><computeroutput>VALGRIND_PRINTF_BACKTRACE(format, ...)</computeroutput>:</term>
+ <term><command><computeroutput>VALGRIND_PRINTF_BACKTRACE(format, ...)</computeroutput>:</command></term>
<listitem>
<para>printf a message to the log file along with a stack
backtrace when running under Valgrind. Nothing is output if
</varlistentry>
<varlistentry>
- <term><computeroutput>VALGRIND_STACK_REGISTER(start, end)</computeroutput>:</term>
+ <term><command><computeroutput>VALGRIND_STACK_REGISTER(start, end)</computeroutput>:</command></term>
<listitem>
<para>Register a new stack. Informs Valgrind that the memory range
between start and end is a unique stack. Returns a stack identifier
</varlistentry>
<varlistentry>
- <term><computeroutput>VALGRIND_STACK_DEREGISTER(id)</computeroutput>:</term>
+ <term><command><computeroutput>VALGRIND_STACK_DEREGISTER(id)</computeroutput>:</command></term>
<listitem>
<para>Deregister a previously registered stack. Informs
Valgrind that previously registered memory range with stack id
</varlistentry>
<varlistentry>
- <term><computeroutput>VALGRIND_STACK_CHANGE(id, start, end)</computeroutput>:</term>
+ <term><command><computeroutput>VALGRIND_STACK_CHANGE(id, start, end)</computeroutput>:</command></term>
<listitem>
<para>Change a previously registered stack. Informs
Valgrind that the previously registerer stack with stack id
</itemizedlist>
</sect1>
+
</chapter>
<book id="manual" xreflabel="Valgrind User Manual">
<bookinfo>
- <title>Valgrind User Manual</title>
- <releaseinfo>&rel-type; &rel-version; &rel-date;</releaseinfo>
- <copyright>
- <year>&vg-lifespan;</year>
- <holder><ulink url="&vg-developers;">Valgrind Developers</ulink></holder>
- </copyright>
- <legalnotice>
- <para>Email: <ulink url="mailto:&vg-vemail;">&vg-vemail;</ulink></para>
- </legalnotice>
+ <title>Valgrind User Manual</title>
+ <releaseinfo>&rel-type; &rel-version; &rel-date;</releaseinfo>
+ <copyright>
+ <year>&vg-lifespan;</year>
+ <holder><ulink url="&vg-developers;">Valgrind Developers</ulink></holder>
+ </copyright>
+ <author>
+ <email><ulink url="mailto:&vg-vemail;">&vg-vemail;</ulink></email>
+ </author>
</bookinfo>
<xi:include href="manual-intro.xml" parse="xml"
<book id="quick-start" xreflabel="Valgrind Quick Start Guide">
<bookinfo>
- <title>Valgrind Quick Start Guide</title>
- <releaseinfo>&rel-type; &rel-version; &rel-date;</releaseinfo>
- <copyright>
- <year>&vg-lifespan;</year>
- <holder><ulink url="&vg-developers;">Valgrind Developers</ulink></holder>
- </copyright>
- <legalnotice>
- <para>Email: <ulink url="mailto:&vg-vemail;">&vg-vemail;</ulink></para>
- </legalnotice>
+ <title>The Valgrind Quick Start Guide</title>
+ <releaseinfo>&rel-type; &rel-version; &rel-date;</releaseinfo>
+ <copyright>
+ <year>&vg-lifespan;</year>
+ <holder><ulink url="&vg-developers;">Valgrind Developers</ulink></holder>
+ </copyright>
+ <author>
+ <email><ulink url="mailto:&vg-vemail;">&vg-vemail;</ulink></email>
+ </author>
</bookinfo>
-<title>Valgrind Quick Start Guide</title>
+<article>
+<title>The Valgrind Quick Start Guide</title>
+
+
+<sect1 id="quick-start.intro" xreflabel="Introduction">
+<title>Introduction</title>
<para>The Valgrind distribution has multiple tools. The most popular is the
memory checking tool (called Memcheck) which can detect many common memory
-errors such as:
-</para>
+errors such as:</para>
<itemizedlist>
<listitem><para>touching memory you shouldn't (eg. overrunning heap block
to Valgrind version 2.4.0 and later; some of the information is not quite
right for earlier versions.</para>
-<sect1 id="quick-start.prepare"
- xreflabel="Preparing your program">
+</sect1>
+
+
+<sect1 id="quick-start.prepare" xreflabel="Preparing your program">
<title>Preparing your program</title>
+
<para>Compile your program with <computeroutput>-g</computeroutput> to include
debugging information so that Memcheck's error messages include exact line
numbers. Using <computeroutput>-O0</computeroutput> is also a good idea, if
errors which don't really exist.</para>
</sect1>
-<sect1 id="quick-start.mcrun"
- xreflabel="Running your program under Memcheck">
+
+<sect1 id="quick-start.mcrun" xreflabel="Running your program under Memcheck">
<title>Running your program under Memcheck</title>
+
<para>If you normally run your program like this:
<programlisting>
and leaks that it detects.</para>
</sect1>
+
<sect1 id="quick-start.interpret"
xreflabel="Interpreting Memcheck's output">
<title>Interpreting Memcheck's output</title>
examples of all the error messages Memcheck produces.</para>
</sect1>
+
<sect1 id="quick-start.caveats" xreflabel="Caveats">
<title>Caveats</title>
+
<para>Memcheck is not perfect; it occasionally produces false positives,
and there are mechanisms for suppressing these (see
<xref linkend="manual-core.suppress"/> in the <xref linkend="manual"/>).
could crash your program (eg. cause a segmentation fault).</para>
</sect1>
+
<sect1 id="quick-start.info" xreflabel="More Information">
<title>More information</title>
+
<para>Please consult the <xref linkend="FAQ"/> and the
<xref linkend="manual"/>, which have much more information. Note that the
other tools in the Valgrind distribution can be invoked with the
<computeroutput>--tool</computeroutput> option.</para>
</sect1>
+
+</article>
</book>
<?xml version="1.0"?> <!-- -*- sgml -*- -->
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
- "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
+ "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"
+[ <!ENTITY % vg-entities SYSTEM "vg-entities.xml"> %vg-entities; ]>
<book id="tech-docs" xreflabel="Valgrind Technical Documentation">
<bookinfo>
<title>Valgrind Technical Documentation</title>
+ <releaseinfo>&rel-type; &rel-version; &rel-date;</releaseinfo>
+ <copyright>
+ <year>&vg-lifespan;</year>
+ <holder><ulink url="&vg-developers;">Valgrind Developers</ulink></holder>
+ </copyright>
+ <author>
+ <email><ulink url="mailto:&vg-vemail;">&vg-vemail;</ulink></email>
+ </author>
</bookinfo>
<xi:include href="../../memcheck/docs/mc-tech-docs.xml" parse="xml"