Commits

smerten  committed 98e440f

Renamed package `xml2rst` to `xml2rstlib`.

  • Participants
  • Parent commits 379c188

Comments (0)

Files changed (22)

File sandbox/xml2rst/MANIFEST.in

 include tests.tgz
 include version.py
-include xml2rst/*.xsl
+include xml2rstlib/*.xsl

File sandbox/xml2rst/README

 
 1. ``xml2rst.py``
 
-   This script uses ``xml2rst/xml2rst.xsl`` through the XSLT_ engine
+   This script uses ``xml2rstlib/xml2rst.xsl`` through the XSLT_ engine
    available through the lxml_ package [#deb-lxml]_. It also uses
    Python callbacks for some advanced functionality.
 
 
    Run ``xml2rst --help`` for information on how to run it.
 
-2. ``xml2rst/xml2rst-nopy.xsl``
+2. ``xml2rstlib/xml2rst-nopy.xsl``
 
    This is the core XSLT_ script without using Python. It uses EXSLT_
    and therefore needs an EXSLT_ capable XSLT_ processors such as
    .. [#deb-xsltproc] Under Debian based operating systems try
       ``apt-get install xsltproc``.
 
-   Run ``perldoc xml2rst/xml2rst-nopy.xsl`` for information on how to
+   Run ``perldoc xml2rstlib/xml2rst-nopy.xsl`` for information on how to
    run it.
 
-3. ``xml2rst/xml2rst-noexslt.xsl``
+3. ``xml2rstlib/xml2rst-noexslt.xsl``
 
    This version can be processed with every XSLT_ processor like
    Xalan_ [#deb-xalan]_.
    .. [#deb-xalan] Under Debian based operating systems try ``apt-get
       install xalan``.
 
-   Run ``perldoc xml2rst/xml2rst-noexslt.xsl`` for information on how
+   Run ``perldoc xml2rstlib/xml2rst-noexslt.xsl`` for information on how
    to run it.
 
 Availability

File sandbox/xml2rst/global.log

+**************************************
+Date: Mon Dec  3 12:24:00 CET 2012
+Author: stefan
+Tag: xml2rst_1_226
+
+--------------------------------------
+Update of /home/stefan/vault/sm/xml2rst
+In directory theowa:/home/stefan/free/xml2rst
+
+Modified Files:
+	Makefile README setup.py xml2rst.py 
+
+--------------------------------------
+Update of /home/stefan/vault/sm/xml2rst/tests.xalan
+In directory theowa:/home/stefan/free/xml2rst/tests.xalan
+
+Modified Files:
+	common.cfg 
+
+--------------------------------------
+Update of /home/stefan/vault/sm/xml2rst/tests.xsltproc
+In directory theowa:/home/stefan/free/xml2rst/tests.xsltproc
+
+Modified Files:
+	common.cfg 
+
+--------------------------------------
+Update of /home/stefan/vault/sm/xml2rst/tests.xsltproc/options
+In directory theowa:/home/stefan/free/xml2rst/tests.xsltproc/options
+
+Modified Files:
+	filterunit.cfg 
+
+--------------------------------------
+Update of /home/stefan/vault/sm/xml2rst/xml2rstlib
+In directory theowa:/home/stefan/free/xml2rst/xml2rstlib
+
+Modified Files:
+	rst_xslt.py 
+
+--------------------------------------
+Log Message:
+Renamed package to `xml2rstlib` to work in installation.
 **************************************
 Date: Mon Dec  3 10:54:11 CET 2012
 Author: stefan

File sandbox/xml2rst/setup.py

       license='GPL 2',
       requires=[ 'docutils', 'lxml' ],
       scripts=[ 'xml2rst.py' ],
-      packages=[ 'xml2rst' ],
-      package_data={ 'xml2rst': [ 'xml2rst.xsl',
-                                  'xml2rst-nopy.xsl',
-                                  'xml2rst-noexslt.xsl' ], },
+      packages=[ 'xml2rstlib' ],
+      package_data={ 'xml2rstlib': [ 'xml2rst.xsl',
+                                     'xml2rst-nopy.xsl',
+                                     'xml2rst-noexslt.xsl' ], },
      )

File sandbox/xml2rst/tag.log

-xml2rst_1_225
+xml2rst_1_226

File sandbox/xml2rst/tests.xalan/common.cfg

 expectedExtension = .rst
 
 command = xalan
-options = -qc -xsl ../../xml2rst/xml2rst-noexslt.xsl
+options = -qc -xsl ../../xml2rstlib/xml2rst-noexslt.xsl

File sandbox/xml2rst/tests.xsltproc/common.cfg

 expectedExtension = .rst
 
 command = xsltproc
-arguments = ../../xml2rst/xml2rst-nopy.xsl -
+arguments = ../../xml2rstlib/xml2rst-nopy.xsl -

File sandbox/xml2rst/tests.xsltproc/options/filterunit.cfg

 inputExtension = .xml
 optionExtension = .xsltproc
 expectedExtension = .rst
-arguments = ../../xml2rst/xml2rst-nopy.xsl -
+arguments = ../../xml2rstlib/xml2rst-nopy.xsl -
 
 command = xsltproc

File sandbox/xml2rst/version.py

-version = '1.0.3'
+version = '1.1.0'

File sandbox/xml2rst/xml2rst.py

 
 from optparse import OptionParser, OptionGroup, OptionValueError, Option
 
-from xml2rst import rst_xslt
+from xml2rstlib import rst_xslt
 
 ###############################################################################
 ###############################################################################

File sandbox/xml2rst/xml2rst/__init__.py

Empty file removed.

File sandbox/xml2rst/xml2rst/markup.py

-"""
-Python based conversion.
-"""
-
-###############################################################################
-###############################################################################
-# Import
-
-import re
-import docutils
-import docutils.parsers.rst.states
-
-__docformat__ = 'reStructuredText'
-
-###############################################################################
-###############################################################################
-# Classes
-
-class Inliner(docutils.parsers.rst.states.Inliner):
-    """
-    Recognizer for inline markup. Derive this from the original inline
-    markup parser for best results.
-    """
-
-    def quoteInline(self, text):
-        """
-        `text`: ``str``
-          Return `text` with inline markup quoted.
-        """
-        # Method inspired by `docutils.parsers.rst.states.Inliner.parse`
-        self.document = docutils.utils.new_document("<string>")
-        self.document.settings.trim_footnote_reference_space = False
-        self.reporter = self.document.reporter
-        self.reporter.stream = None
-        self.language = None
-        self.parent = self.document
-        remaining = docutils.utils.escape2null(text)
-        checked = ""
-        processed = []
-        unprocessed = []
-        messages = []
-        while remaining:
-            original = remaining
-            match = self.patterns.initial.search(remaining)
-            if match:
-                groups = match.groupdict()
-                method = self.dispatch[groups['start'] or groups['backquote']
-                                       or groups['refend'] or groups['fnend']]
-                ( before, inlines, remaining, sysmessages,
-                  ) = method(self, match, 0)
-                checked += before
-                if inlines:
-                    assert len(inlines) == 1, "More than one inline found"
-                    inline = original[len(before)
-                                      :len(original) - len(remaining)]
-                    rolePfx = re.search("^:" + self.simplename + ":(?=`)",
-                                        inline)
-                    refSfx = re.search("_+$", inline)
-                    if rolePfx:
-                        # Prefixed roles need to be quoted in the middle
-                        checked += (inline[:rolePfx.end()] + "\\"
-                                    + inline[rolePfx.end():])
-                    elif refSfx and not re.search("^`", inline):
-                        # Pure reference markup needs to be quoted at the end
-                        checked += (inline[:refSfx.start()] + "\\"
-                                    + inline[refSfx.start():])
-                    else:
-                        # Quote other inlines by prefixing
-                        checked += "\\" + inline
-            else:
-                checked += remaining
-                break
-        # Quote all original backslashes
-        checked = re.sub('\x00', "\\\x00", checked)
-        return docutils.utils.unescape(checked, 1)
-
-###############################################################################
-
-class Text():
-    """
-    Functions for computing valid reStructuredText plain text.
-    """
-
-    inliner = Inliner()
-
-    @staticmethod
-    def plain(text, indent, literal):
-        """
-        Return a plain text preventing further interpretation by
-        reStructuredText. Text may contain linefeeds.
-
-        `text`: ``str``
-          The string to turn into output text.
-
-        `indent`: ``str``
-          The string to use for indent in case of internal linefeeds.
-
-        `literal`: ``bool``
-          Output literal instead of quoting.
-        """
-        sep = "\n" + indent
-        if literal:
-            quoted = text
-        else:
-            quoted = Text.inliner.quoteInline(text)
-        return sep.join(quoted.split("\n"))
-
-#print(Text.plain("Some \\ back\slashes", ""))
-
-# indent
-# directive
-# field_names
-# substitution
-# inline markup
-# token
-# label
-# start_delimiter
-# end_delimiter
-# target_definition

File sandbox/xml2rst/xml2rst/rst_xslt.py

-"""
-Glue code for XSLT and Python based conversion.
-"""
-
-###############################################################################
-###############################################################################
-# Import
-
-import os.path
-import sys
-
-try:
-    from lxml import etree
-except ImportError:
-    raise Exception("""
-Python package 'lxml' is not available.
-You may try to use an older version of 'xml2rst.xsl' with a standalone
-XSLT processor like 'xalan' or 'xsltproc'""")
-
-from xml2rst import markup
-
-__docformat__ = 'reStructuredText'
-
-###############################################################################
-###############################################################################
-# Constants
-
-MainXsltNm = 'xml2rst.xsl'
-"""
-`MainXsltNm`: ``str``
-   Name of the main XSLT source file.
-"""
-
-###############################################################################
-###############################################################################
-# Classes
-
-class XPathExtension():
-    """
-    Abstract class for XPath extension functions.
-    """
-
-    namespace = "http://www.merten-home.de/xml2rst"
-    """
-    `namespace`: ``str``
-      Namespace for these XSLT extension functions.
-    """
-
-    def _stringParameter(self, string):
-        """
-        Return the normalized string parameter from an XPath
-        parameter.
-
-        `string`: ``lxml.etree._ElementStringResult`` | ``[ lxml.etree._ElementStringResult, ]`` | ``[ ]``
-          Original XPath string parameter.
-        """
-        if isinstance(string, list):
-            if len(string) == 0:
-                return ""
-            else:
-                assert len(string) == 1, "Encountered an XPath string parameter with more than one element"
-                return string[0]
-        else:
-            return string
-
-    def _boolParameter(self, boolean):
-        """
-        Return the normalized bool parameter from an XPath parameter.
-
-        `boolean`: ``bool``
-          Original XPath bool parameter.
-        """
-        return boolean
-
-###############################################################################
-
-class RstText(XPathExtension):
-    """
-    XPath extension functions for computing valid reStructuredText
-    markup for plain text.
-    """
-
-    def plain(self, context, string, indent, literal):
-        """
-        Output a plain text preventing further interpretation by
-        reStructuredText. Text may contain linefeeds.
-
-        `context`: ``lxml.etree._XSLTContext``
-          The evaluation context.
-
-          `context.context_node`: ``Element``
-            The context node.
-
-          `contect.eval_context`: ``dict``
-            A dictionary to store state.
-
-        `string`:
-          The (smart) string to turn into output text.
-
-        `indent`:
-          The (smart) string to use for indent in case of internal
-          linefeeds.
-
-        `literal`:
-          The (smart) string to use for indent in case of internal
-          linefeeds.
-        """
-        return markup.Text.plain(self._stringParameter(string),
-                                 self._stringParameter(indent),
-                                 self._boolParameter(literal))
-
-    # indent
-    # directive
-    # field_names
-    # substitution
-    # inline markup
-    # token
-    # label
-    # start_delimiter
-    # end_delimiter
-    # target_definition
-
-###############################################################################
-###############################################################################
-# Specialized functions
-
-def convert(inNm, outNm, settings):
-    """
-    Do the conversion.
-
-    `inNm`: ``str``
-      Filename of input file.
-
-    `outNm`: ``str`` | None
-      Filename of output file or None for stdout.
-
-    `settings`: ``optparse.Values``
-      Options from command line.
-    """
-    try:
-        inF = open(inNm)
-    except IOError, e:
-        raise Exception("Can't open input file %r: %s" % ( inNm, e, ))
-
-    # Find XSLT
-    modP = os.path.dirname(__file__)
-    mainXsltNm = os.path.join(modP, MainXsltNm)
-    try:
-        mainXsltF = open(mainXsltNm)
-    except IOError, e:
-        raise Exception("Can't open main XSLT file %r: %s" % ( mainXsltNm, e, ))
-
-    # Parse and prepare XSLT and extensions
-    xsltParser = etree.XMLParser()
-    try:
-        mainXsltDoc = etree.parse(mainXsltF, xsltParser)
-    except Exception, e:
-        raise Exception("Error parsing main XSLT file %r: %s"
-                        % ( mainXsltNm, e, ))
-    mainXsltF.close()
-
-    rstText = RstText()
-    extensions = etree.Extension(rstText, ns=rstText.namespace)
-    mainXslt = etree.XSLT(mainXsltDoc, extensions=extensions)
-
-    # Parse input file
-    inParser = etree.XMLParser()
-    try:
-        inDoc = etree.parse(inF, inParser)
-    except Exception, e:
-        raise Exception("Error parsing input file %r: %s" % ( inNm, e, ))
-    inF.close()
-
-    # Process input
-    xsltParams = { }
-    if settings.fold is not None:
-        xsltParams['fold'] = str(settings.fold)
-    if settings.adornment is not None:
-        xsltParams['adornment'] = "'" + settings.adornment + "'"
-    try:
-        result = mainXslt(inDoc, **xsltParams)
-    except Exception, e:
-        raise Exception("Error transforming input file %r: %s" % ( inNm, e, ))
-    outS = str(result)
-    if outNm:
-        try:
-            outF = open(outNm, "w")
-        except IOError, e:
-            raise Exception("Can't open output file %r: %s" % ( outNm, e, ))
-        outF.write(outS)
-        outF.close()
-    else:
-        sys.stdout.write(outS)

File sandbox/xml2rst/xml2rst/xml2rst-noexslt.xsl

-<?xml version="1.0" encoding="utf-8"?>
-<!DOCTYPE xsl:stylesheet [
-<!ENTITY CR "&#x0A;">
-<!-- "xml:space='preserve'" is needed for use with libxslt -->
-<!-- "xmlns:xsl='http://www.w3.org/1999/XSL/Transform'" is needed for
-     use with xsltproc -->
-<!-- Used to create a blank line -->
-<!ENTITY tCR "<xsl:text xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xml:space='preserve'>&CR;</xsl:text>">
-<!-- Used when the line before must be ended -->
-<!ENTITY tEOL "<xsl:text xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xml:space='preserve'>&CR;</xsl:text>">
-<!ENTITY tSP "<xsl:text xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xml:space='preserve'> </xsl:text>">
-]>
-
-<!--
-     Copyright (C) 2005, 2006, 2009 Stefan Merten, David Priest
-
-     xml2rst.xsl is free software; you can redistribute it and/or modify
-     it under the terms of the GNU General Public License as published
-     by the Free Software Foundation; either version 2 of the License,
-     or (at your option) any later version.
-
-     This program is distributed in the hope that it will be useful,
-     but WITHOUT ANY WARRANTY; without even the implied warranty of
-     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-     General Public License for more details.
-
-     You should have received a copy of the GNU General Public License
-     along with this program; if not, write to the Free Software
-     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-     02111-1307, USA.
--->
-
-<!-- ********************************************************************** -->
-<!-- ********************************************************************** -->
-
-<!-- These elements in the DTD need support:
-
-     - ``colspec`` has attribute "stub %yesorno; #IMPLIED"
-
-     - ``document`` has attribute "title CDATA #IMPLIED"
-
-       Probably rendered by the `.. title::` directive
-
-     -->
-
-<!--
-Set namespace extensions. These are used as [shortname]:[tag] throughout the 
-XSL-FO files.
-xsl: eXtensible Stylesheet Language
-u: user extensions (indicates utility 'call-template' routines defined in 
-these XSL files)
-data: Data elements used by the stylesheet
--->
-<xsl:stylesheet
-    version="1.0"
-    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-    xmlns:u="u"
-    xmlns:data="a"
-    exclude-result-prefixes="data">
-
-  <xsl:output
-      method="text"
-      omit-xml-declaration="yes"
-      indent="no"/>
-
-  <!-- ******************************************************************** -->
-  <!-- ******************************************************************** -->
-
-  <!-- Parameter to configure title markup; see manual page for description -->
-  <xsl:param
-      name="adornment"
-      select="'o=o-u=u-u~u`u,u.'"/>
-
-  <!-- Parameter for folding long lines; see manual page for description -->
-  <xsl:param
-      name="fold"
-      select="0"/>
-
-  <!-- ******************************************************************** -->
-  <!-- ******************************************************************** -->
-
-  <xsl:variable
-      name="apos"
-      select='"&apos;"'/>
-
-  <xsl:variable
-      name="structural_elements"
-      select="'*document*section*topic*sidebar*'"/>
-
-  <xsl:variable
-      name="structural_subelements"
-      select="'*title*subtitle*docinfo*decoration*transition*'"/>
-
-  <xsl:variable
-      name="bibliographic_elements"
-      select="'*address*author*authors*contact*copyright*date*field*organization*revision*status*version*'"/>
-
-  <xsl:variable
-      name="decorative_elements"
-      select="'*footer*header*'"/>
-
-  <xsl:variable
-      name="simple_body_elements_no_substitution"
-      select="'*comment*doctest_block*image*literal_block*paragraph*pending*raw*rubric*target*'"/>
-
-  <xsl:variable
-      name="folding_elements"
-      select="concat('*comment*paragraph*rubric*attribution*caption*line*', substring-after($bibliographic_elements, '*'))"/>
-
-  <xsl:variable
-      name="simple_body_elements"
-      select="concat($simple_body_elements_no_substitution, 'substitution_definition*')"/>
-
-  <xsl:variable
-      name="compound_body_elements"
-      select="'*admonition*attention*block_quote*bullet_list*caution*citation*compound*danger*definition_list*enumerated_list*error*field_list*figure*footnote*hint*important*line_block*note*option_list*system_message*table*tip*warning*container*'"/>
-
-  <xsl:variable
-      name="body_elements"
-      select="concat($simple_body_elements, substring-after($compound_body_elements, '*'))"/>
-
-  <xsl:variable
-      name="admonitions"
-      select="'*admonition*attention*caution*danger*error*hint*important*note*tip*warning*'"/>
-
-  <xsl:variable
-      name="simple_body_subelements"
-      select="'*attribution*caption*classifier*colspec*field_name*label*line*option_argument*option_string*term*'"/>
-
-  <xsl:variable
-      name="compound_body_subelements"
-      select="'*definition*definition_list_item*description*entry*field*field_body*legend*list_item*option*option_group*option_list_item*row*tbody*tgroup*thead*'"/>
-
-  <xsl:variable
-      name="inline_elements"
-      select="'*abbreviation*acronym*citation_reference*emphasis*footnote_reference*generated*image*inline*literal*problematic*reference*strong*subscript*substitution_reference*superscript*target*title_reference*raw*'"/>
-
-  <xsl:variable
-      name="inline_containers"
-      select="concat($simple_body_elements_no_substitution, substring-after($inline_elements, '*'))"/>
-
-  <xsl:variable
-      name="directives"
-      select="'*admonition*attention*caution*comment*danger*error*footnote*hint*important*note*tip*warning*image*figure*topic*sidebar*rubric*meta*raw*citation*compound*substitution_definition*container*'"/>
-
-  <xsl:variable
-      name="titled_elements"
-      select="'*sidebar*topic*admonition*'"/>
-
-  <xsl:variable
-      name="blank_after"
-      select="concat($structural_elements, substring-after($structural_subelements, '*'), substring-after($body_elements, '*'))"/>
-
-  <xsl:variable
-      name="adornment_characters"
-      select="concat($apos, '!&quot;#$%&amp;()*+,-./:;&lt;=&gt;?@[\]^_`{|}~')"/>
-
-  <!-- ******************************************************************** -->
-  <!-- ******************************************************************** -->
-
-  <!--
-  Content Model: ((title, subtitle?)?, docinfo?, decoration?,
-  %structure.model;)
-
-  Attributes:    The document element contains only the common attributes: ids,
-  names, dupnames, source, and classes.
-
-  Depending on the source of the data and the stage of processing, the 
-  "document" may not initially contain a "title". A document title is not 
-  directly representable in reStructuredText. Instead, a lone top-level section
-  may have its title promoted to become the document title, and similarly for a
-  lone second-level (sub)section's title to become the document subtitle. The 
-  "docinfo" may be transformed from an initial field_list, and "decoration" is 
-  usually constructed programmatically.
-  -->
-  <!-- == structural_element -->
-  <xsl:template
-      match="document">
-    <xsl:if
-	test="//generated[@classes = 'sectnum']">
-      <xsl:text>.. section-numbering::</xsl:text>
-      &tEOL;
-      &tCR;
-    </xsl:if>
-    <xsl:call-template
-	name="u:outputClass">
-      <xsl:with-param
-	  name="blankAfter"
-	  select="true()"/>
-    </xsl:call-template>
-    <xsl:apply-templates/>
-  </xsl:template>
-
-  <!-- ******************************************************************** -->
-
-  <!--
-  Content Model: (title, %structure.model;)
-  Attributes:    The section element contains only the common attributes: ids,
-  names, dupnames, source, and classes.
-  -->
-  <!-- == structural_element -->
-  <xsl:template
-      match="section">
-    <xsl:call-template
-	name="u:outputClass"/>
-    <xsl:call-template
-	name="u:blank"/>
-    <xsl:apply-templates/>
-  </xsl:template>
-
-  <!-- == structural_element -->
-  <xsl:template
-      match="section[@classes = 'system-messages']"/>
-  <!-- Ignore system messages completely -->
-  <!-- This should be really in `generated' -->
-
-  <!-- ******************************************************************** -->
-
-  <!--
-  Content Model: (title, subtitle?, (%body.elements;)+)
-  Attributes:    The sidebar element contains only the common attributes: ids,
-  names, dupnames, source, and classes.
-  -->
-  <!-- == structural_element == directive -->
-  <xsl:template
-      match="sidebar">
-    <xsl:call-template
-	name="u:BandI"/>
-    <xsl:text>.. sidebar:: </xsl:text>
-    <xsl:value-of
-	select="title"/>
-    &tEOL;
-    <xsl:if
-	test="subtitle">
-      <xsl:call-template
-	  name="u:param">
-	<xsl:with-param
-	    name="name"
-	    select="'subtitle'"/>
-	<xsl:with-param
-	    name="value"
-	    select="subtitle"/>
-	<xsl:with-param
-	    name="ancestors"
-	    select="ancestor-or-self::*"/>
-      </xsl:call-template>
-    </xsl:if>
-    <xsl:call-template
-	name="u:params"/>
-    <!-- Always blank line after parameter block -->
-    &tCR;
-    <xsl:apply-templates
-	select="*[not(self::title) and not(self::subtitle)]"/>
-  </xsl:template>
-
-  <!-- ******************************************************************** -->
-
-  <!--
-  Content Model: (title?, (%body.elements;)+)
-  Attributes:    The topic element contains only the common attributes: ids,
-  names, dupnames, source, and classes.
-  -->
-  <!-- == structural_element == directive -->
-  <xsl:template
-      match="topic">
-    <xsl:call-template
-	name="u:BandI"/>
-    <xsl:text>.. topic:: </xsl:text>
-    <xsl:value-of
-	select="title"/>
-    &tEOL;
-    <xsl:call-template
-	name="u:params"/>
-    <xsl:apply-templates
-	select="*[not(self::title)]"/>
-  </xsl:template>
-
-  <!-- == structural_element == directive -->
-  <xsl:template
-      match="topic[starts-with(@classes, 'contents')]">
-    <xsl:call-template
-	name="u:BandI"/>
-    <xsl:text>.. contents:: </xsl:text>
-    <xsl:apply-templates
-	select="title"/>
-    &tEOL;
-    <xsl:call-template
-	name="u:params">
-      <xsl:with-param
-	  name="params"
-	  select="@*[name() != 'ids' and name() != 'names' and name() != 'classes']"/>
-    </xsl:call-template>
-    <xsl:variable
-	name="isLocal"
-	select="substring-before(@classes, ' local')"/>
-    <xsl:variable
-	name="realClassesLocal"
-	select="normalize-space(substring-after(@classes, 'contents'))"/>
-    <xsl:variable
-	name="realClassesNode">
-      <xsl:choose>
-	<xsl:when
-	    test="$isLocal">
-	  <xsl:value-of
-	      select="normalize-space(substring-before($realClassesLocal, 'local'))"/>
-	</xsl:when>
-	<xsl:otherwise>
-	  <xsl:value-of
-	      select="$realClassesLocal"/>
-	</xsl:otherwise>
-      </xsl:choose>
-    </xsl:variable>
-    <xsl:variable
-	name="realClasses"
-	select="string($realClassesNode)"/>
-    <xsl:if
-	test="$isLocal">
-      <xsl:call-template
-	  name="u:param">
-	<xsl:with-param
-	    name="name"
-	    select="'local'"/>
-	<xsl:with-param
-	    name="value"
-	    select="''"/>
-	<xsl:with-param
-	    name="ancestors"
-	    select="ancestor-or-self::*"/>
-      </xsl:call-template>
-    </xsl:if>
-    <xsl:if
-	test="$realClasses">
-      <xsl:call-template
-	  name="u:param">
-	<xsl:with-param
-	    name="name"
-	    select="'class'"/>
-	<xsl:with-param
-	    name="value"
-	    select="$realClasses"/>
-        <xsl:with-param
-	    name="ancestors"
-	    select="ancestor-or-self::*"/>
-      </xsl:call-template>
-    </xsl:if>
-    <!-- Autogenerated content is discarded -->
-    &tCR;
-  </xsl:template>
-
-  <!-- == structural_element == directive -->
-  <xsl:template
-      match="topic[@classes='dedication' or @classes='abstract']">
-    <xsl:call-template
-	name="u:BandI"/>
-    <xsl:text>:</xsl:text>
-    <xsl:apply-templates
-	select="title"/>
-    <xsl:text>: </xsl:text>
-    &tEOL;
-    <xsl:apply-templates
-	select="*[not(self::title)]"/>
-  </xsl:template>
-
-  <!-- ******************************************************************** -->
-
-  <!--
-  Content Model: (title, (%body.elements;)+)
-  Attributes:    The admonition element contains only the common attributes:
-  ids, names, dupnames, source, and classes.
-  -->
-  <!-- == compound_body_element == directive -->
-  <xsl:template
-      match="admonition">
-    <xsl:call-template
-	name="u:BandI"/>
-    <xsl:text>.. admonition:: </xsl:text>
-    <xsl:apply-templates
-	select="title"/>
-    &tEOL;
-    <xsl:call-template
-	name="u:params">
-      <xsl:with-param
-	  name="params"
-	  select="@*[name() != 'classes' or not(starts-with(., 'admonition-'))]"/>
-    </xsl:call-template>
-    <xsl:call-template
-	name="u:indent"/>
-    <xsl:apply-templates
-	select="*[not(self::title)]"/>
-  </xsl:template>
-
-  <!-- ******************************************************************** -->
-
-  <!--
-  Content Model: (%body.elements;)+
-  Attributes:    The note element contains only the common attributes: ids,
-  names, dupnames, source, and classes.
-  -->
-  <!-- == compound_body_element == directive -->
-  <xsl:template
-      match="attention | caution | danger | error | hint | important | note | tip | warning">
-    <xsl:call-template
-	name="u:outputClass"/>
-    <xsl:call-template
-	name="u:BandI"/>
-    <xsl:text>.. </xsl:text>
-    <xsl:value-of
-	select="name()"/>
-    <xsl:text>:: </xsl:text>
-    <xsl:call-template
-	name="u:params">
-      <xsl:with-param
-	  name="params"
-	  select="@*[name() != 'classes']"/>
-    </xsl:call-template>
-    <xsl:apply-templates/>
-  </xsl:template>
-
-  <!-- ******************************************************************** -->
-
-  <!--
-  Content Model: (header?, footer?)
-  Attributes:    The decoration element contains only the common attributes:
-  ids, names, dupnames, source, and classes.
-
-  Although the content model doesn't specifically require contents, no empty 
-  decoration elements are ever created.
-  -->
-  <!-- == structural_subelement -->
-  <xsl:template
-      match="//document/decoration">
-    <xsl:apply-templates/>
-  </xsl:template>
-
-  <!-- TODO To be rendered as `.. header::` directive -->
-  <!-- == decorative_element -->
-  <xsl:template
-      match="//document/decoration/header">
-    <xsl:apply-templates/>
-  </xsl:template>
-
-  <!-- TODO To be rendered as `.. footer::` directive -->
-  <!-- == decorative_element -->
-  <xsl:template
-      match="//document/decoration/footer">
-    <xsl:apply-templates/>
-  </xsl:template>
-
-  <!-- ******************************************************************** -->
-
-  <!--
-  Content Model: (%bibliographic.elements;)+
-  Attributes:    The docinfo element contains only the common attributes: ids,
-  names, dupnames, source, and classes.
-  -->
-  <!-- == structural_subelement -->
-  <xsl:template
-      match="docinfo">
-    <xsl:call-template
-	name="u:outputClass"/>
-    <xsl:call-template
-	name="u:blank"/>
-    <xsl:apply-templates/>
-    <xsl:call-template
-	name="u:blank"/>
-  </xsl:template>
-
-  <!-- ******************************************************************** -->
-
-  <!--
-  Content Model: ((author, organization?, address?, contact?)+)
-  Attributes:    The authors element contains only the common attributes: ids,
-  names, dupnames, source, and classes.
-
-  In reStructuredText, multiple author's names are separated with semicolons 
-  (";") or commas (","); semicolons take precedence. There is currently no way 
-  to represent the author's organization, address, or contact in a 
-  reStructuredText "Authors" field.
-  -->
-  <!-- == bibliographic_element == folding_element -->
-  <xsl:template
-      match="docinfo/authors">
-    <xsl:call-template
-	name="u:outputFolding">
-      <xsl:with-param
-	  name="prefix">
-	<xsl:text>:</xsl:text>
-	<xsl:value-of
-	    select="name()"/>
-	<xsl:text>: </xsl:text>
-      </xsl:with-param>
-    </xsl:call-template>
-  </xsl:template>
-
-  <!--
-  Content Model: %text.model;
-  Attributes:    All docinfo elements contains the common attributes (ids,
-  names, dupnames, source, and classes)
-	      Some docinfo elements also have xml:space.
-  -->
-  <xsl:template
-      match="docinfo/authors/*">
-    <xsl:apply-templates/>
-    <!-- no semicolon after final author -->
-    <xsl:if
-	test="generate-id(current()) != generate-id(../*[last()])">
-      <xsl:text>; </xsl:text>
-    </xsl:if>
-  </xsl:template>
-
-  <!--
-  Content Model: (field_name, field_body)
-  Attributes:    The field element contains only the common attributes: ids,
-  names, dupnames, source, and classes.
-  -->
-  <!-- == bibliographic_element -->
-  <xsl:template
-      match="docinfo/field">
-    <!-- contents handled by ordinary field lists -->
-    <xsl:apply-templates/>
-    <!-- Supply an EOL because following elements do not recognize this -->
-    &tEOL;
-  </xsl:template>
-
-  <!--
-  Content Model: %text.model;
-  Attributes:    All docinfo elements contains the common attributes (ids,
-  names, dupnames, source, and classes)
-	      Some docinfo elements also have xml:space.
-  -->
-  <!-- == bibliographic_element == folding_element -->
-  <xsl:template
-      match="docinfo/*[name()!='authors' and name()!='field']">
-    <xsl:call-template
-	name="u:outputFolding">
-      <xsl:with-param
-	  name="prefix">
-	<xsl:text>:</xsl:text>
-	<xsl:value-of
-	    select="name()"/>
-	<xsl:text>: </xsl:text>
-      </xsl:with-param>
-    </xsl:call-template>
-  </xsl:template>
-
-  <!-- ******************************************************************** -->
-
-  <!--
-  Content Model: EMPTY
-  Attributes:    The transition element contains only the common attributes:
-  ids, names, dupnames, source, and classes.
-  -->
-  <!-- == structural_subelement -->
-  <xsl:template
-      match="transition">
-    <xsl:call-template
-	name="u:outputClass"/>
-    &tCR; <!-- req: blank line before -->
-    <xsl:text>-----</xsl:text>
-    &tEOL;
-    <!-- Add a required blank line after unless class follows immediately -->
-    <xsl:if
-	test="not(following-sibling::*[1]/@classes)">
-      &tCR;
-    </xsl:if>
-  </xsl:template>
-
-  <!-- ******************************************************************** -->
-  <!-- ******************************************************************** -->
-
-  <!--
-  IFF there is a /document/title element, it is the publication's title.  All 
-  other titles will appear within sections.
-
-  Content Model: %text.model;
-  Attributes:    The title element contains the common attributes (ids, names, 
-  dupnames, source, and classes), plus refid and auto.
-      refid is used as a backlink to a table of contents entry.
-      auto is used to indicate (with value "1") that the title has been
-  numbered automatically.
-  -->
-  <!-- == structural_subelement -->
-  <xsl:template
-      match="//document/title">
-    <xsl:call-template
-	name="u:outputClass"/>
-    <xsl:variable
-	name="textWS">
-      <!-- Catch the title text as it is rendered so its length can be
-           determined -->    
-      <xsl:apply-templates/>
-    </xsl:variable>
-    <xsl:variable
-	name="text"
-	select="normalize-space($textWS)"/>
-    <xsl:variable
-	name="length"
-	select="string-length($text)"/>
-    <xsl:call-template
-	name="u:overline">
-      <xsl:with-param
-	  name="length"
-	  select="$length"/>
-      <xsl:with-param
-	  name="depth"
-	  select="1"/>
-    </xsl:call-template>
-    <xsl:value-of
-	select="$text"/>
-    &tEOL;    
-    <xsl:call-template
-	name="u:underline">
-      <xsl:with-param
-	  name="length"
-	  select="$length"/>
-      <xsl:with-param
-	  name="depth"
-	  select="1"/>
-    </xsl:call-template>
-  </xsl:template>
-
-  <!-- ******************************************************************** -->
-
-  <!--
-  Title Underlines are defined by their position within the tree.
-
-  Content Model: %text.model;
-  Attributes:    The title element contains the common attributes (ids, names, 
-  dupnames, source, and classes), plus refid and auto.
-      refid is used as a backlink to a table of contents entry.
-      auto is used to indicate (with value "1") that the title has been
-  numbered automatically.
-  -->
-  <!-- == structural_subelement -->
-  <xsl:template
-      match="section/title">
-    <xsl:call-template
-	name="u:outputClass"/>
-    <xsl:variable
-	name="textWS">
-      <!-- catch the title text as it is rendered -->    
-      <xsl:apply-templates/>
-    </xsl:variable>
-    <xsl:variable
-	name="text"
-	select="normalize-space($textWS)"/>
-    <xsl:variable
-	name="length"
-	select="string-length($text)"/>
-    <xsl:variable
-	name="depth"
-	select="count(ancestor::section)"/>
-    <xsl:call-template
-	name="u:overline">
-      <xsl:with-param
-	  name="length"
-	  select="$length"/>
-      <xsl:with-param
-	  name="depth"
-	  select="$depth + 2"/>
-    </xsl:call-template>
-    <xsl:value-of
-	select="$text"/>
-    &tEOL;    
-    <xsl:call-template
-	name="u:underline">
-      <xsl:with-param
-	  name="length"
-	  select="$length"/>
-      <xsl:with-param
-	  name="depth"
-	  select="$depth + 2"/>
-    </xsl:call-template>
-    <!-- Add a blank line after unless structure follows immediately -->
-    <xsl:if
-	test="not(contains(concat($structural_elements, $compound_body_elements), concat('*', name(following-sibling::*[1]), '*')) or following-sibling::*[1]/@classes)">
-      &tCR;
-    </xsl:if>
-  </xsl:template>
-
-  <!-- ******************************************************************** -->
-
-  <!--
-  Content Model: %text.model;
-  Attributes:    The title element contains the common attributes (ids, names, 
-  dupnames, source, and classes), plus refid and auto.
-      refid is used as a backlink to a table of contents entry.
-      auto is used to indicate (with value "1") that the title has been
-  numbered automatically.
-  -->
-  <!-- == structural_subelement -->
-  <xsl:template
-      match="title">
-    <xsl:call-template
-	name="u:outputClass">
-      <xsl:with-param
-	  name="alreadyBlanked"
-	  select="true()"/>
-    </xsl:call-template>
-    <!-- blank line provided by parent -->
-    <xsl:apply-templates/>
-    <!-- no EOL: provided by parent -->
-  </xsl:template>
-
-  <!-- ******************************************************************** -->
-
-  <!--
-  IFF there is a /document/title element, it is the publication's title.  All 
-  other titles will appear within sections.
-
-  Content Model: %text.model;
-  Attributes:    The subtitle element contains only the common attributes:
-  ids, names, dupnames, source, and classes.
-  -->
-  <!-- == structural_subelement -->
-  <xsl:template
-      match="//document/subtitle">
-    <xsl:call-template
-	name="u:outputClass"/>
-    <xsl:variable
-	name="textWS">
-      <!-- Catch the title text as it is rendered -->    
-      <xsl:apply-templates/>
-    </xsl:variable>
-    <xsl:variable
-	name="text"
-	select="normalize-space($textWS)"/>
-    <xsl:variable
-	name="length"
-	select="string-length($text)"/>
-
-    <!-- always a blank line above -->
-    &tCR;
-    <xsl:call-template
-	name="u:overline">
-      <xsl:with-param
-	  name="length"
-	  select="$length"/>
-      <xsl:with-param
-	  name="depth"
-	  select="2"/>
-    </xsl:call-template>
-    <xsl:value-of
-	select="$text"/>
-    &tEOL;    
-    <xsl:call-template
-	name="u:underline">
-      <xsl:with-param
-	  name="length"
-	  select="$length"/>
-      <xsl:with-param
-	  name="depth"
-	  select="2"/>
-    </xsl:call-template>
-  </xsl:template>
-
-  <!-- ******************************************************************** -->
-
-  <!--
-  Content Model: %text.model;
-  Attributes:    The subtitle element contains only the common attributes: ids,
-  names, dupnames, source, and classes.
-  -->
-  <!-- == structural_subelement -->
-  <xsl:template
-      match="sidebar/subtitle">
-    <xsl:call-template
-	name="u:outputClass"/>
-    <xsl:call-template
-	name="u:indent"/>
-    <xsl:apply-templates/>
-    &tEOL;
-    &tCR;
-  </xsl:template>
-
-  <!-- ******************************************************************** -->
-  <!-- ******************************************************************** -->
-
-  <!--
-  Content Model: %text.model;
-  Attributes:    The comment element contains only the common attributes: ids,
-  names, dupnames, source, and classes.
-  -->
-  <!-- == simple_body_element == folding_element == directive -->
-  <xsl:template
-      match="comment">
-    <xsl:call-template
-	name="u:BandI"/>
-    <xsl:call-template
-	name="u:outputFolding">
-      <xsl:with-param
-	  name="prefix">
-	<xsl:text>.. </xsl:text>
-      </xsl:with-param>
-    </xsl:call-template>
-  </xsl:template>
-
-  <!-- ******************************************************************** -->
-
-  <!--
-  Content Model: %text.model;
-  Attributes:    The doctest_block element contains the common attributes (ids,
-  names, dupnames, source, and classes), plus xml:space.
-  -->
-  <!-- == simple_body_element -->
-  <xsl:template
-      match="doctest_block">
-    <xsl:call-template
-	name="u:outputClass"/>
-    <xsl:call-template
-	name="u:BandI"/>
-    <xsl:apply-templates/>
-    &tEOL;
-  </xsl:template>
-
-  <!-- ******************************************************************** -->
-
-  <!-- An image element can have various roles; they are all covered here -->
-  <!-- == simple_body_element == inline_element == directive -->
-  <xsl:template
-      match="image">
-    <xsl:choose>
-      <xsl:when
-	  test="contains($inline_containers, concat('*', name(..), '*')) and @alt">
-	<!-- An inline image with an `@alt' - must be a substitution
-             reference -->
-	<xsl:text>|</xsl:text>
-	<!-- Original text is lost - use what we have -->
-	<xsl:value-of
-	    select="@alt"/>
-	<xsl:text>|</xsl:text>
-      </xsl:when>
-      <xsl:otherwise>
-	<!-- A directive -->
-	<xsl:if
-	    test="not(parent::figure)">
-	  <xsl:if
-	      test="not(parent::substitution_definition)">
-	    <xsl:call-template
-		name="u:BandI"/>
-	    <xsl:text>.. </xsl:text>
-	  </xsl:if>
-	  <xsl:text>image:: </xsl:text>
-	</xsl:if>
-	<xsl:value-of
-	    select="@uri"/>
-	&tEOL;
-	<xsl:choose>
-	  <xsl:when
-	      test="parent::figure">
-	    <!-- `@classes' is special because it is in the parent -->
-	    <xsl:if
-		test="../@classes">
-	      <xsl:call-template
-		  name="u:param">
-		<xsl:with-param
-		    name="name"
-		    select="'figclass'"/>
-		<xsl:with-param
-		    name="value"
-		    select="../@classes"/>
-		<xsl:with-param
-		    name="ancestors"
-		    select="ancestor::*"/>
-	      </xsl:call-template>
-	    </xsl:if>
-	    <!-- `@align' is special because it is in the parent -->
-	    <xsl:if
-		test="../@align">
-	      <xsl:call-template
-		  name="u:param">
-		<xsl:with-param
-		    name="name"
-		    select="'align'"/>
-		<xsl:with-param
-		    name="value"
-		    select="../@align"/>
-		<xsl:with-param
-		    name="ancestors"
-		    select="ancestor::*"/>
-	      </xsl:call-template>
-	    </xsl:if>
-	    <xsl:call-template
-		name="u:params">
-	      <!-- `figure' would add one level of indentation --> 
-	      <xsl:with-param
-		  name="ancestors"
-		  select="ancestor::*"/>
-	    </xsl:call-template>
-	  </xsl:when>
-	  <xsl:when
-	      test="parent::substitution_definition">
-	    <xsl:call-template
-		name="u:params">
-	      <!-- `@alt' only for the real images --> 
-	      <xsl:with-param
-		  name="params"
-		  select="@*[name() != 'alt']"/>
-	    </xsl:call-template>
-	  </xsl:when>
-	  <xsl:otherwise>
-	    <xsl:call-template
-		name="u:params">
-	      <xsl:with-param
-		  name="params"
-		  select="@*[name() != 'ids' and name() != 'names']"/>
-	    </xsl:call-template>
-	  </xsl:otherwise>
-	</xsl:choose>
-	<xsl:if
-	    test="parent::reference">
-	  <!-- A clickable image -->
-	  <xsl:call-template
-	      name="u:param">
-	    <xsl:with-param
-		name="name"
-		select="'target'"/>
-	    <xsl:with-param
-		name="value">
-	      <xsl:choose>
-		<xsl:when
-		    test="../@name">
-		  <!-- An internal link -->
-		  <xsl:call-template
-		      name="u:inlineReference">
-		    <xsl:with-param
-			name="text"
-			select="../@refid"/>
-		  </xsl:call-template>
-		</xsl:when>
-		<xsl:otherwise>
-		  <!-- An external link -->
-		  <xsl:value-of
-		      select="../@refuri"/>
-		</xsl:otherwise>
-	      </xsl:choose>
-	    </xsl:with-param>
-	    <xsl:with-param
-		name="ancestors"
-		select="ancestor-or-self::*"/>
-	  </xsl:call-template>
-	</xsl:if>
-	<!-- Always blank line after parameter block -->
-	&tCR;
-      </xsl:otherwise>
-    </xsl:choose>
-  </xsl:template>
-
-  <!-- ******************************************************************** -->
-
-  <!--
-  Content Model: (line_block | line)+
-  Attributes:    The line_block element contains the common attributes (ids, 
-  names, dupnames, source, and classes), plus xml:space.
-  -->
-  <!-- == compound_body_element -->
-  <xsl:template
-      match="line_block">
-    <xsl:call-template
-	name="u:outputClass"/>
-    <xsl:variable
-	name="isEmbedded"
-	select="name(..) = 'line_block'"/>
-    <xsl:if
-	test="not($isEmbedded)">
-      <xsl:call-template
-	  name="u:blank"/>
-    </xsl:if>
-    <xsl:apply-templates/>
-  </xsl:template>
-
-  <!-- ******************************************************************** -->
-
-  <!--
-  Content Model: %text.model;
-  Attributes:    The line element contains the common attributes (ids, 
-  names, dupnames, source, and classes).
-  -->
-  <!-- == simple_body_subelement == folding_element -->
-  <xsl:template
-      match="line">
-    <xsl:call-template
-	name="u:outputClass"/>
-    <xsl:variable
-	name="indent">
-      <xsl:call-template
-	  name="u:indent"/>
-    </xsl:variable>
-    <xsl:value-of
-	select="$indent"/>
-    <xsl:choose>
-      <xsl:when
-	  test="node()">
-	<!-- Only for non-empty lines -->
-	<xsl:variable
-	    name="lineBlockIndent">
-	  <!-- Very special indendation for nested `line_block's -->
-	  <xsl:for-each
-	      select="ancestor::line_block[position() > 1]">
-	    <xsl:call-template
-		name="u:repeat">
-	      <xsl:with-param
-		  name="length"
-		  select="4"/>
-	    </xsl:call-template>
-	  </xsl:for-each>
-	</xsl:variable>
-	<xsl:call-template
-	    name="u:outputFolding">
-	  <xsl:with-param
-	      name="prefix">
-	    <xsl:text>| </xsl:text>
-	    <xsl:value-of
-		select="$lineBlockIndent"/>
-	  </xsl:with-param>
-	  <xsl:with-param
-	      name="indent"
-	      select="concat($indent, '  ', $lineBlockIndent)"/>
-	</xsl:call-template>
-      </xsl:when>
-      <xsl:otherwise>
-	<xsl:text>|</xsl:text>
-	&tEOL;
-      </xsl:otherwise>
-    </xsl:choose>
-  </xsl:template>
-
-  <!-- ******************************************************************** -->
-
-  <!--
-  Content Model: %text.model;
-  Attributes:    The literal_block element contains the common attributes (ids,
-  names, dupnames, source, and classes), plus xml:space.
-  -->
-  <!-- == simple_body_element == directive -->
-  <xsl:template
-      match="literal_block">
-    <xsl:choose>
-      <xsl:when
-	  test=".//*[contains($inline_elements, concat('*', name(), '*'))]">
-	<!-- If it contains inline elements this is a parsed-literal -->
-	<xsl:call-template
-	    name="u:BandI"/>
-	<xsl:text>.. parsed-literal::</xsl:text>
-	&tEOL;
-	<xsl:call-template
-	    name="u:params"/>
-	&tCR;
-      </xsl:when>
-      <xsl:otherwise>
-	<xsl:call-template
-	    name="u:outputClass"/>
-	<!-- TODO Support for the (fully) minimized style would be nice but
-	          is difficult to accomplish because there is a linefeed
-	          already when we arrive here :-( -->
-	<xsl:call-template
-	    name="u:BandI"/>
-	<xsl:text>::</xsl:text>
-	&tEOL;
-	&tCR;
-      </xsl:otherwise>
-    </xsl:choose>
-    <xsl:variable
-	name="isQuotedLiteral">
-      <xsl:call-template
-	  name="u:isQuotedLiteral"/>
-    </xsl:variable>
-    <!-- Indent correctly depending on quoted literal or not -->
-    <xsl:choose>
-      <xsl:when
-	  test="string-length($isQuotedLiteral)">
-	<xsl:call-template
-	    name="u:indent">
-	  <xsl:with-param
-	      name="ancestors"
-	      select="ancestor::*"/>
-	</xsl:call-template>
-	<xsl:apply-templates
-	    mode="quotedLiteral"/>
-      </xsl:when>
-      <xsl:otherwise>
-	<xsl:call-template
-	    name="u:indent">
-	  <xsl:with-param
-	      name="ancestors"
-	      select="ancestor-or-self::*"/>
-	</xsl:call-template>
-	<xsl:apply-templates/>
-      </xsl:otherwise>
-    </xsl:choose>
-    &tEOL;
-  </xsl:template>
-
-  <!-- Indent a text of a quoted literal containing line feeds correctly -->
-  <xsl:template
-      match="text()"
-      mode="quotedLiteral">
-    <xsl:call-template
-	name="u:indentLF">
-      <xsl:with-param
-	  name="indent">
-	<xsl:call-template
-	    name="u:indent">
-	  <xsl:with-param
-	      name="ancestors"
-	      select="ancestor::*[position() > 1]"/>
-	</xsl:call-template>
-      </xsl:with-param>
-    </xsl:call-template>
-  </xsl:template>
-
-  <!-- Determine whether `$text' is a quoted literal and return the quote
-       character if so -->
-  <xsl:template
-      name="u:isQuotedLiteral">
-    <xsl:param
-	name="text"
-	select="text()"/>
-    <xsl:param
-	name="quote"
-	select="substring($text, 1, 1)"/>
-    <xsl:if
-	test="contains($adornment_characters, $quote) and substring($text, 1, 1) = $quote">
-      <!-- Given quote is an adornment character and first character is this
-           quote -->
-      <xsl:choose>
-	<xsl:when
-	    test="contains($text, '&#xA;')">
-	  <!-- Test the remaining lines -->
-	  <xsl:call-template
-	      name="u:isQuotedLiteral">
-	    <xsl:with-param
-		name="text"
-		select="substring-after($text, '&#xA;')"/>
-	    <xsl:with-param
-		name="quote"
-		select="$quote"/>
-	  </xsl:call-template>
-	</xsl:when>
-	<xsl:otherwise>
-	  <!-- No more lines to test so this is a quoted literal -->
-	  <xsl:value-of
-	      select="$quote"/>
-	</xsl:otherwise>
-      </xsl:choose>
-    </xsl:if>
-  </xsl:template>
-
-  <!-- ******************************************************************** -->
-
-  <!--
-  Content Model: %text.model;
-  Attributes:    The paragraph element contains only the common attributes:
-  ids, names, dupnames, source, and classes.
-  -->
-  <!-- == simple_body_element == folding_element -->
-  <xsl:template
-      match="paragraph">
-    <xsl:variable
-	name="previous"
-	select="preceding-sibling::*[1]"/>
-    <!-- Do indent except first element in some compound elements -->
-    <xsl:variable
-	name="needsIndent"
-	select="($previous or not(parent::list_item or parent::field_body or contains($admonitions, concat('*', name(..), '*')))) and name($previous) != 'label'"/>
-    <!-- Blank line in front if following a body element, except first
-         elements in some compound elements -->
-    <xsl:variable
-	name="needsBlank"
-	select="($previous or not(parent::list_item or ../parent::option_list_item or parent::field_body or parent::document or contains($admonitions, concat('*', name(..), '*')))) and (not($previous) or contains($body_elements, concat('*', name($previous), '*')) or name($previous) = 'title' and contains($titled_elements, concat('*', name(..), '*')) or name($previous) = 'docinfo')"/>
-    <xsl:if
-	test="$needsBlank">
-      &tCR;
-    </xsl:if>
-    <xsl:if
-	test="$needsIndent">
-      <xsl:call-template
-	  name="u:indent"/>
-    </xsl:if>
-    <xsl:if
-	test="@classes">
-      <!-- This paragraph has a classes attribute - always needs newline and
-           indent -->
-      <xsl:call-template
-	  name="u:outputClass">
-	<xsl:with-param
-	    name="alreadyBlanked"
-	    select="$needsBlank"/>
-	<xsl:with-param
-	    name="alreadyIndented"
-	    select="$needsIndent"/>
-      </xsl:call-template>
-      <xsl:call-template
-	  name="u:BandI"/>
-    </xsl:if>
-    <xsl:call-template
-	name="u:outputFolding"/>
-  </xsl:template>
-
-  <!-- ******************************************************************** -->
-
-  <!-- == simple_body_element -->
-  <xsl:template
-      match="pending">
-    <xsl:call-template
-	name="u:notSupported"/>
-  </xsl:template>
-
-  <!-- ******************************************************************** -->
-
-  <!-- == simple_body_element == inline_element == directive -->
-  <xsl:template
-      match="raw">
-    <xsl:choose>
-      <xsl:when
-	  test="contains($inline_containers, concat('*', name(..), '*'))">
-	<!-- Used as a custom role -->
-	<!-- TODO `role' directives must be generated for user-defined raw
-	          roles. -->
-	<!-- The name of the custom role is not contained in the input -->
-	<xsl:text>:RAW-ROLE:`</xsl:text>
-	<xsl:apply-templates/>
-	<xsl:text>`</xsl:text>
-      </xsl:when>
-      <xsl:otherwise>
-	<!-- A directive -->
-	<xsl:call-template
-	    name="u:outputClass"/>
-	<xsl:call-template
-	    name="u:BandI"/>
-	<xsl:text>.. raw:: </xsl:text>
-	<xsl:value-of
-	    select="@format"/>
-	&tEOL;
-	<xsl:call-template
-	    name="u:params">
-	  <xsl:with-param
-	      name="params"
-	      select="@*[name() != 'format' and name() != 'classes']"/>
-	</xsl:call-template>
-	&tCR;
-	<xsl:call-template
-	    name="u:indent">
-	  <xsl:with-param
-	      name="ancestors"
-	      select="ancestor-or-self::*"/>
-	</xsl:call-template>
-	<xsl:apply-templates/>
-	&tEOL;
-      </xsl:otherwise>
-    </xsl:choose>
-  </xsl:template>
-
-  <!-- ******************************************************************** -->
-
-  <!-- == simple_body_element == folding_element == directive -->
-  <xsl:template
-      match="rubric">
-    <xsl:call-template
-	name="u:BandI"/>
-    <xsl:call-template
-	name="u:outputFolding">
-      <xsl:with-param
-	  name="prefix">
-	<xsl:text>.. rubric:: </xsl:text>
-      </xsl:with-param>
-    </xsl:call-template>
-    <xsl:call-template
-	name="u:params"/>
-  </xsl:template>
-
-  <!-- ******************************************************************** -->
-
-  <!-- == compound_body_element == directive -->
-  <xsl:template
-      match="compound">
-    <xsl:call-template
-	name="u:BandI"/>
-    <xsl:text>.. compound::</xsl:text>
-    &tEOL;
-    <xsl:call-template
-	name="u:params"/>
-    <xsl:apply-templates/>
-  </xsl:template>
-
-  <!-- ******************************************************************** -->
-
-  <!-- == compound_body_element == directive -->
-  <xsl:template
-      match="container">
-    <xsl:call-template
-	name="u:BandI"/>
-    <xsl:text>.. container::</xsl:text>
-    <xsl:if
-	test="@classes">
-      &tSP;
-      <xsl:value-of
-	  select="@classes"/>
-    </xsl:if>
-    &tEOL;
-    <xsl:apply-templates/>
-  </xsl:template>
-
-  <!-- ******************************************************************** -->
-
-  <!-- == simple_body_element == directive -->
-  <xsl:template
-      match="substitution_definition">
-    <!-- More than one child or not a directive is a replacement text -->
-    <xsl:variable
-	name="isReplace"
-	select="not(* and count(node()) = 1 and contains($directives, concat('*', name(*[1]), '*')))"/>
-    <xsl:call-template
-	name="u:BandI"/>
-    <xsl:variable
-	name="prefix">
-      <xsl:text>.. |</xsl:text>
-      <xsl:call-template
-	  name="u:outputNames"/>
-      <xsl:text>| </xsl:text>
-    </xsl:variable>
-    <xsl:choose>
-      <xsl:when
-	  test="$isReplace">
-      <!-- TODO Substitution references for replace can not be found because
-	        they are not marked as such; embedding them in `generated'
-                would be nice -->
-	<xsl:call-template
-	    name="u:outputFolding">
-	  <xsl:with-param
-	      name="prefix">
-	    <xsl:value-of
-		select="$prefix"/>
-	    <xsl:text>replace:: </xsl:text>
-	  </xsl:with-param>
-	</xsl:call-template>
-      </xsl:when>
-      <xsl:otherwise>
-	<xsl:value-of
-	    select="$prefix"/>
-	<xsl:apply-templates/>
-      </xsl:otherwise>
-    </xsl:choose>
-  </xsl:template>
-
-  <!-- ******************************************************************** -->
-
-  <!--
-  Content Model: ((%body.elements;)+, attribution?)
-  Attributes:    The block_quote element contains only the common attributes:
-  ids, names, dupnames, source, and classes.
-  -->
-  <!-- == compound_body_element -->
-  <xsl:template
-      match="block_quote">
-    <xsl:if
-	test="@classes = 'epigraph' or @classes = 'highlights' or @classes = 'pull-quote'">
-      <xsl:call-template
-	  name="u:BandI"/>
-      <xsl:text>.. </xsl:text>
-      <xsl:value-of
-	  select="@classes"/>
-      <xsl:text>::</xsl:text>
-      &tEOL;
-      <xsl:call-template
-	  name="u:params"/>
-    </xsl:if>
-    <xsl:apply-templates/>
-  </xsl:template>
-
-  <!-- ******************************************************************** -->
-
-  <!-- == simple_body_subelement == folding_element -->
-  <xsl:template
-      match="attribution">
-    <xsl:call-template
-	name="u:outputClass"/>
-    <!-- blank line between quote and attribution -->
-    &tCR;
-    <xsl:call-template
-	name="u:indent"/>
-    <xsl:call-template
-	name="u:outputFolding">
-      <xsl:with-param
-	  name="prefix">
-	<xsl:text>-- </xsl:text>
-      </xsl:with-param>
-    </xsl:call-template>
-  </xsl:template>
-
-  <!-- ******************************************************************** -->
-
-  <!-- == compound_body_element == directive -->
-  <xsl:template
-      match="citation">
-    <xsl:call-template
-	name="u:outputClass"/>
-    <xsl:call-template
-	name="u:BandI"/>
-    <xsl:text>.. [</xsl:text>
-    <xsl:value-of
-	select="label"/>
-    <xsl:text>] </xsl:text>
-    <xsl:apply-templates
-	select="*[not(self::label)]"/>
-  </xsl:template>
-
-  <!-- == simple_body_subelement -->
-  <xsl:template
-      match="citation/label">
-    <xsl:apply-templates/>
-  </xsl:template>
-
-  <!-- ******************************************************************** -->
-
-  <!-- == compound_body_element == directive -->
-  <xsl:template
-      match="figure">
-    <xsl:call-template
-	name="u:BandI"/>
-    <xsl:text>.. figure:: </xsl:text>
-    <xsl:apply-templates/>
-  </xsl:template>
-
-  <!-- ******************************************************************** -->
-
-  <!-- == simple_body_subelement == folding_element -->
-  <xsl:template
-      match="caption">
-    <xsl:call-template
-	name="u:indent"/>
-    <xsl:call-template
-	name="u:outputFolding"/>
-  </xsl:template>
-
-  <!-- ******************************************************************** -->
-
-  <!-- == compound_body_subelement -->
-  <xsl:template
-      match="legend">
-    <xsl:apply-templates/>
-  </xsl:template>
-
-  <!-- ******************************************************************** -->
-
-  <!-- TODO Footnotes should continue on line of definition -->
-
-  <!-- user-numbered footnotes lack @auto -->
-  <!-- == compound_body_element == directive -->
-  <xsl:template
-      match="footnote[not(@auto)]">
-    <xsl:call-template
-	name="u:outputClass"/>
-    <xsl:call-template
-	name="u:BandI"/>
-    <xsl:text>.. [</xsl:text>
-    <xsl:apply-templates
-	select="label"/>
-    <xsl:text>] </xsl:text>
-    <xsl:apply-templates
-	select="*[not(self::label)]"/>
-  </xsl:template>
-
-  <!-- autonumbered footnotes have @auto -->
-  <!-- if the target footnote_reference@names matches its label, it was not a
-       numbered-name footnote -->
-  <!-- == compound_body_element == directive -->
-  <xsl:template
-      match="footnote[@auto='1']">
-    <xsl:call-template