<?xml version="1.0"?>
<zprava jazyk="en" cislo="3/2006">
  <nazev>Annotating XML Schemas with reStructuredText</nazev>
  <autor>Ladislav Lhotka</autor>
  <datum>19.6.2006</datum>
  <p><b>Keywords:</b> XML, RELAX NG, reStructuredText, XSLT</p>
  <h1>Abstract</h1>
  <p>This technical report describes a method for annotating XML
schemas expressed in the RELAX NG language. The annotations use a
natural text markup of reStructuredText (reST). The annotated
schema is a valid RELAX NG XML document that can transformed into
a reST document via an XSLT stylesheet. Consequently, the schema
can be easily presented as HTML or LaTeX with added value of
bidirectional hyperlinks between RELAX NG definitions and their
references.</p>
  <h1 id="introduction">Introduction</h1>
  <p>Extensible Markup Language (XML) is increasingly used as a flexible
format for representing various structured data in networking and
other software applications, even if the data is intended to be parsed
by machines. The concrete data model can be defined by
means of a special language known as <i>XML schema</i>. The base XML 1.0
specification <cite href="XML"/> offers the DTD (Document Type Definition)
language for this purpose. However, this language has a number of
deficiencies:</p>
  <ul>
    <li>
      <p>DTD itself is not an XML document</p>
    </li>
    <li>
      <p>DTD does not allow to use elements with identical names in different
contexts</p>
    </li>
    <li>
      <p>Namespaces are not supported</p>
    </li>
  </ul>
  <p>The W3C consortium thus prepared a much more sophisticated language
with a rather unfortunate name~-- <i>XML Schema</i> <cite href="XSch1"/>, <cite href="XSch2"/>~-- as
if it was supposed to be <i>the</i> ultimate XML schema. As it turns out,
it is a typical consortium-driven specification: very complex and in
certain places even unclear and ambiguous. An interesting alternative
with approximately the same expressive power is <i>RELAX NG</i> <cite href="RNG"/>. It
is based on a sound mathematical basis of the tree automaton theory and
in general is easier to use than W3C XML Schema.</p>
  <p>Any XML schema is primarily used for validating XML documents: a
validating XML parser is able to verify whether an XML document
conforms to the given schema. However, an XML schema can also serve as
<i>authoritative documentation</i> of the data model. This documentation
role of an XML schema can be further improved by interspersing the
schema with annotations. This can be realised either via XML
comments analogical to comments in the source code of programs, or by
using extra markup, for example special XML elements. RELAX
NG specification <cite href="RNG"/> requires the parsers to ignore elements in
foreign namespaces that are included in the schema document, so
annotations can be quite naturally enclosed in elements whose
namespace is different from that of RELAX NG schema itself
(<tt>http://relaxng.org/ns/structure/1.0</tt>).</p>
  <p>This technical report presents a method for annotating RELAX NG
schemas and an XSLT stylesheet that allows to convert a RELAX NG
schema augmented with annotations to common presentation forms such as
HTML or LaTeX. The annotations use the simple and effective markup
of <a href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> (reST). The XSLT stylesheet mentioned above is
then able to transform the annotated RELAX NG schema into a valid reST
document that essentially combines RELAX NG mechanisms (pattern
definitions and references) with reST features such as hyperlinks. The
result closely resembles <i>literate programs</i> <cite href="Knu92"/>.</p>
  <p>This work was inspired by a similar XSLT stylesheet written by Zdeněk
Wagner <cite href="Wag05"/>. However, the present approach is slightly more
general, thanks to the flexibility of reST as opposed to HTML, which
is the result of Wagner's stylesheet. Also, my stylesheet uses only
XSLT 1.0 and can thus be used with virtually any XSLT processor.</p>
  <p>The listing of the entire stylesheet can be found in the
<a href="#appendix-xslt-stylesheet-rngrest-xsl">appendix</a>. It is also available <a href="http://staff.cesnet.cz/~lhotka/rngrest.tar.gz">online</a>.</p>
  <h1 id="adding-annotations">Adding annotations</h1>
  <p>The annotation system introduces just a single new XML element:
rest. Its namespace is
<tt>http://www.cesnet.cz/ns/rngrest-annotations/1.0</tt>. In other words,
annotations are usually included as follows:</p>
  <pre>&lt;a:rest&gt; ... &lt;/a:rest&gt;</pre>
  <p>where the namespace prefix <tt>a</tt> must be properly defined as an
abbreviation of the above URL, typically in the grammar element.</p>
  <p>Any number of rest elements can be created as direct children of the
following RELAX NG elements: grammar, start and define. As a
matter of fact, they may appear in other places as well but will be
ignored there by the XSLT stylesheet.</p>
  <p>Any valid reStructuredText is allowed inside the rest element~--
multiple paragraphs with tables, figures, hyperlinks etc. Sections
should be used with care. If used, the section titles must not be
underlined with exclamation marks <tt>!</tt> as these are used internally
for automatic sections that the stylesheet creates for each define
element in the schema.</p>
  <p>The following example is a simple annotated RELAX NG schema:</p>
  <pre>&lt;?xml version="1.0"?&gt;

&lt;grammar ns="http://www.cesnet.org/ns/football/1.0"
  xmlns="http://relaxng.org/ns/structure/1.0"
  xmlns:a="http://www.cesnet.cz/ns/rngrest-annotations/1.0"&gt;

  &lt;a:rest&gt;
Example: Annotated RELAX NG Schema
==================================

:Author: Ladislav Lhotka
:Contact: lhotka@cesnet.cz

.. contents::

This is an example of a RELAX NG schema annotated with
reStructuredText. Every annotation consists of one or more paragraphs
and may contain text in *italics*, **boldface** or ``monospace font``,
numbered or bulleted lists, hyperlinks etc.

We use a simple data model of a football_ team.

.. _football: http://en.wikipedia.org/wiki/Football

  &lt;/a:rest&gt;

  &lt;start&gt;
    &lt;a:rest&gt;
The root element is `football-team`. It contains any number of
players.
    &lt;/a:rest&gt;
    &lt;element name="football-team"&gt;
      &lt;zeroOrMore&gt;
        &lt;element name="player"&gt;
          &lt;ref name="player-content"/&gt;
        &lt;/element&gt;
      &lt;/zeroOrMore&gt;
    &lt;/element&gt;
  &lt;/start&gt;

  &lt;define name="player-content"&gt;
    &lt;a:rest&gt;
Each player has the attribute `role` with one of the four choices
below, and element `name` which is supposed to contain full name of
the player.
    &lt;/a:rest&gt;
    &lt;attribute name="role"&gt;
      &lt;choice&gt;
        &lt;value&gt;goalkeeper&lt;/value&gt;
        &lt;value&gt;defender&lt;/value&gt;
        &lt;value&gt;midfielder&lt;/value&gt;
        &lt;value&gt;striker&lt;/value&gt;
      &lt;/choice&gt;
    &lt;/attribute&gt;
    &lt;element name="name"&gt;
      &lt;text/&gt;
    &lt;/element&gt;
  &lt;/define&gt;

&lt;/grammar&gt;</pre>
  <p>Several thing are worth pointing out here:</p>
  <ul>
    <li>
      <p>The annotations must be indented strictly according to the rules of
reST so that, for example, normal paragraph text starts at
column~1. This slightly breaks the canonical indentation structure
of XML documents, but there is no easy way around this problem, as
reST is very fussy about indentation.</p>
    </li>
    <li>
      <p>One has to be careful when including characters that are not allowed
in XML documents: <tt>&lt;</tt>, <tt>&gt;</tt> or <tt>&amp;</tt>. XML entity references such
as <tt>&amp;lt;</tt> do not work here because the reST parser does not
interpret them. The solution is to use the <tt>unicode</tt> directive of
reST, for example</p>
      <pre>.. |lt| unicode:: U+003C</pre>
      <p>The <tt>&lt;</tt> character can then be represented as <tt>|lt|</tt> in
annotations.</p>
    </li>
    <li>
      <p>A special case of the previous issue are XML element names inside
annotations. Should the autor wish to write them with the <tt>&lt;</tt> and
<tt>&gt;</tt> delimiters~-- and I generally recommend not to~-- then he or she
might consider creating a new <i>interpreted text role</i>, see
<cite href="Goo05"/>. An XML element could then be conveniently written as, for
example, <tt>:xml:`football-team`</tt>.</p>
    </li>
    <li>
      <p>The <tt>.. contents::</tt> directive offers an easy way for generating an
index of all RELAX NG pattern definitions used in the schema.</p>
    </li>
  </ul>
  <h1 id="transformations">Transformations</h1>
  <p>An annotated RELAX NG schema can be converted to reStructuredText by
means of an XSLT processor and the XSLT stylesheet <tt>rngrest.xsl</tt>
shown in the <a href="#appendix-xslt-stylesheet-rngrest-xsl">appendix</a>. The following command uses the <a href="http://xmlsoft.org/XSLT/xsltproc2.html">xsltproc</a>
processor:</p>
  <pre>$ xsltproc --output example.rest rngrest.xsl example.rng</pre>
  <p>When applied to the example schema shown above, this command gives the
following reST file as output:</p>
  <pre>Example: Annotated RELAX NG Schema
==================================

:Author: Ladislav Lhotka
:Contact: lhotka@cesnet.cz

.. contents::

This is an example of a RELAX NG schema annotated with
reStructuredText. Every annotation consists of one or more paragraphs
and may contain text in *italics*, **boldface** or ``monospace font``,
numbered or bulleted lists, hyperlinks etc.

We use a simple data model of a football_ team.

.. _football: http://en.wikipedia.org/wiki/Football

::

    &lt;grammar
        ns="http://www.cesnet.org/ns/football/1.0"
        xmlns:a="http://www.cesnet.cz/ns/rngrest-annotations/1.0"
        xmlns="http://relaxng.org/ns/structure/1.0"&gt;

start
!!!!!

The root element is `football-team`. It contains any number of
players.

.. parsed-literal::

    &lt;start&gt;
      &lt;element name="football-team"&gt;
        &lt;zeroOrMore&gt;
          &lt;element name="player"&gt;
            &lt;ref name="player-content_"/&gt;
          &lt;/element&gt;
        &lt;/zeroOrMore&gt;
      &lt;/element&gt;
    &lt;/start&gt;

player-content
!!!!!!!!!!!!!!

Each player has the attribute `role` with one of the four choices
below, and element `name` which is supposed to contain full name of
the player.

The pattern is referenced by:

* start_

.. parsed-literal::

    &lt;define name="player-content"&gt;
      &lt;attribute name="role"&gt;
        &lt;choice&gt;
          &lt;value&gt;goalkeeper&lt;/value&gt;
          &lt;value&gt;defender&lt;/value&gt;
          &lt;value&gt;midfielder&lt;/value&gt;
          &lt;value&gt;striker&lt;/value&gt;
        &lt;/choice&gt;
      &lt;/attribute&gt;
      &lt;element name="name"&gt;
        &lt;text/&gt;
      &lt;/element&gt;
    &lt;/define&gt;</pre>
  <p>Comparing it to the original annotated schema, we see that the
annotation of the grammar element became the introductory part of
the reST file. The annotations of the other elements~-- start and
define~-- were moved before their parent elements and also received
automatically generated titles. These titles serve as targets for
hyperlinks from the corresponding RELAX NG ref elements as well as
from the lists of referring definitions that are also automatically
created (note the underline characters at the end of the referenced
element names).</p>
  <p>The reST file is then converted to the desired presentation format
(HTML, LaTeX or XML) by the standard <a href="http://docutils.sourceforge.net/">docutils</a> tools. For example,
to convert our example reST file to HTML, use the following command:</p>
  <pre>$ rest2html example.rest example.html</pre>
  <p>Part of the result rendered by Firefox is shown in Figure 1.</p>
  <obr src="browser">Our example annotated RELAX NG schema rendered as HTML.</obr>
  <h1 id="conclusions">Conclusions</h1>
  <p>This technical report describes a simple yet flexible way of
annotating RELAX NG schemas. The annotations use the plain text markup
of <a href="http://docutils.sourceforge.net/rst.html">reStructuredText</a>, which means, in the first place, that the
annotated schema is easily readable even in the source form. In
addition, XSLT stylesheet <tt>rngrest.xsl</tt> in <a href="#appendix-xslt-stylesheet-rngrest-xsl">appendix</a> (also
available <a href="http://staff.cesnet.cz/~lhotka/rngrest.tar.gz">online</a>)
transforms the annotated schema into a valid reST document that can be
in turn converted to HTML, LaTeX or XML with the additional benefits
of bidirectional links between RELAX NG pattern definitions and their
references and, optionally, a listing of all definitions.</p>
  <p>A more complex schema annotated using the method described in this
report is the data model for FlowMon probe configuration <cite href="Lho06"/>.</p>
  <h1 id="appendix-xslt-stylesheet-rngrest-xsl">Appendix. XSLT Stylesheet <tt>rngrest.xsl</tt></h1>
  <pre>&lt;?xml version="1.0"?&gt;

&lt;!--

Program name: rngrest.xsl
Description: This style sheet converts annotated RELAX NG schemas
             into reStructuredText documents
Author: Ladislav Lhotka &lt;Lhotka@cesnet.cz&gt;

Copyright (C) 2006 CESNET

This program is free software; you can redistribute it and/or
modify it under the terms of version 2 of the GNU General Public
License as published by the Free Software Foundation.

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.

$Id: rngrest.xsl,v 1.4 2006/05/05 17:59:44 lhotka Exp $
--&gt;

&lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:rng="http://relaxng.org/ns/structure/1.0"
                xmlns:a="http://www.cesnet.cz/ns/rngrest-annotations/1.0"
                version="1.0"&gt;

  &lt;xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/&gt;
  &lt;xsl:strip-space elements="rng:start rng:define"/&gt;

  &lt;xsl:variable name="NL"&gt;
    &lt;xsl:text&gt;
&lt;/xsl:text&gt;
  &lt;/xsl:variable&gt;

  &lt;xsl:variable name="NLI"&gt;
    &lt;xsl:text&gt;
    &lt;/xsl:text&gt;
  &lt;/xsl:variable&gt;

  &lt;xsl:variable name="NLNL"&gt;
    &lt;xsl:value-of select="$NL"/&gt;
    &lt;xsl:value-of select="$NL"/&gt;
  &lt;/xsl:variable&gt;

  &lt;xsl:variable name="IND"&gt;
    &lt;xsl:text&gt;    &lt;/xsl:text&gt;
  &lt;/xsl:variable&gt;

  &lt;xsl:template name="underline"&gt;
    &lt;xsl:param name="str"/&gt;
    &lt;xsl:text&gt;!&lt;/xsl:text&gt;
    &lt;xsl:if test="string-length($str)&amp;gt;1"&gt;
      &lt;xsl:call-template name="underline"&gt;
        &lt;xsl:with-param name="str"&gt;
          &lt;xsl:value-of select="substring($str,2)"/&gt;
        &lt;/xsl:with-param&gt;
      &lt;/xsl:call-template&gt;
    &lt;/xsl:if&gt;
  &lt;/xsl:template&gt;

  &lt;!-- The root element --&gt;

  &lt;xsl:template match="rng:grammar"&gt;
    &lt;xsl:apply-templates select="a:rest"/&gt;
    &lt;xsl:value-of select="$NLNL"/&gt;
    &lt;xsl:text&gt;::&lt;/xsl:text&gt;
    &lt;xsl:value-of select="$NLNL"/&gt;
    &lt;xsl:text disable-output-escaping="yes"&gt;    &amp;lt;grammar&lt;/xsl:text&gt;
    &lt;xsl:for-each select="@*"&gt;
      &lt;xsl:value-of select="$NLI"/&gt;
      &lt;xsl:text&gt;    &lt;/xsl:text&gt;
      &lt;xsl:value-of select="name()"/&gt;
      &lt;xsl:text&gt;="&lt;/xsl:text&gt;
      &lt;xsl:value-of select="."/&gt;
      &lt;xsl:text&gt;"&lt;/xsl:text&gt;
    &lt;/xsl:for-each&gt;
    &lt;xsl:for-each select="namespace::*"&gt;
      &lt;xsl:if test="name()!='xml'"&gt;
        &lt;xsl:value-of select="$NLI"/&gt;
        &lt;xsl:text&gt;    xmlns&lt;/xsl:text&gt;
        &lt;xsl:if test="name()!=''"&gt;
          &lt;xsl:text&gt;:&lt;/xsl:text&gt;
          &lt;xsl:value-of select="name()"/&gt;
        &lt;/xsl:if&gt;
        &lt;xsl:text&gt;="&lt;/xsl:text&gt;
        &lt;xsl:value-of select="."/&gt;
        &lt;xsl:text&gt;"&lt;/xsl:text&gt;
      &lt;/xsl:if&gt;
    &lt;/xsl:for-each&gt;
    &lt;xsl:text disable-output-escaping="yes"&gt;&amp;gt;&lt;/xsl:text&gt;
    &lt;xsl:value-of select="$NLNL"/&gt;
    &lt;xsl:apply-templates select="rng:*" mode="listing"/&gt;
  &lt;/xsl:template&gt;

  &lt;xsl:template match="rng:start" mode="listing"&gt;
    &lt;xsl:value-of select="$NL"/&gt;
    &lt;xsl:text&gt;start&lt;/xsl:text&gt;
    &lt;xsl:value-of select="$NL"/&gt;
    &lt;xsl:text&gt;!!!!!&lt;/xsl:text&gt;
    &lt;xsl:value-of select="$NLNL"/&gt;
    &lt;xsl:apply-templates select="a:rest"/&gt;
    &lt;xsl:value-of select="$NLNL"/&gt;
    &lt;xsl:text&gt;.. parsed-literal::&lt;/xsl:text&gt;
    &lt;xsl:value-of select="$NLNL"/&gt;
    &lt;xsl:text disable-output-escaping="yes"&gt;    &amp;lt;&lt;/xsl:text&gt;
    &lt;xsl:value-of select="name()"/&gt;
    &lt;xsl:apply-templates select="@*"/&gt;
    &lt;xsl:text disable-output-escaping="yes"&gt;&amp;gt;&lt;/xsl:text&gt;
    &lt;xsl:apply-templates mode="listing"/&gt;
    &lt;xsl:value-of select="$NLI"/&gt;
    &lt;xsl:text disable-output-escaping="yes"&gt;&amp;lt;/&lt;/xsl:text&gt;
    &lt;xsl:value-of select="name()"/&gt;
    &lt;xsl:text disable-output-escaping="yes"&gt;&amp;gt;&lt;/xsl:text&gt;
    &lt;xsl:value-of select="$NL"/&gt;
  &lt;/xsl:template&gt;

  &lt;xsl:template match="rng:define" mode="listing"&gt;
    &lt;xsl:value-of select="$NL"/&gt;
    &lt;xsl:variable name="elname" select="@name"/&gt;
    &lt;xsl:value-of select="$elname"/&gt;
    &lt;xsl:value-of select="$NL"/&gt;
    &lt;xsl:call-template name="underline"&gt;
      &lt;xsl:with-param name="str" select="$elname"/&gt;
    &lt;/xsl:call-template&gt;
    &lt;xsl:value-of select="$NLNL"/&gt;
    &lt;xsl:apply-templates select="a:rest"/&gt;
    &lt;xsl:value-of select="$NLNL"/&gt;
    &lt;xsl:variable name="refs"
                  select="//rng:define[descendant::rng:ref/@name=$elname]"/&gt;
    &lt;xsl:if test="count($refs)!=0 or //rng:start//rng:ref[@name=$elname]"&gt;
      &lt;xsl:text&gt;
The pattern is referenced by:
      &lt;/xsl:text&gt;
      &lt;xsl:value-of select="$NL"/&gt;
      &lt;xsl:if test="//rng:start//rng:ref[@name=$elname]"&gt;
        &lt;xsl:text&gt;* start_&lt;/xsl:text&gt;
        &lt;xsl:value-of select="$NLNL"/&gt;
      &lt;/xsl:if&gt;
      &lt;xsl:for-each select="$refs"&gt;
        &lt;xsl:text&gt;* &lt;/xsl:text&gt;
        &lt;xsl:value-of select="@name"/&gt;
        &lt;xsl:text&gt;_&lt;/xsl:text&gt;
        &lt;xsl:value-of select="$NLNL"/&gt;
      &lt;/xsl:for-each&gt;
      &lt;xsl:value-of select="$NL"/&gt;
    &lt;/xsl:if&gt;
    &lt;xsl:text&gt;.. parsed-literal::&lt;/xsl:text&gt;
    &lt;xsl:value-of select="$NLNL"/&gt;
    &lt;xsl:text disable-output-escaping="yes"&gt;    &amp;lt;&lt;/xsl:text&gt;
    &lt;xsl:value-of select="name()"/&gt;
    &lt;xsl:apply-templates select="@*"/&gt;
    &lt;xsl:text disable-output-escaping="yes"&gt;&amp;gt;&lt;/xsl:text&gt;
    &lt;xsl:apply-templates mode="listing"/&gt;
    &lt;xsl:value-of select="$NLI"/&gt;
    &lt;xsl:text disable-output-escaping="yes"&gt;&amp;lt;/&lt;/xsl:text&gt;
    &lt;xsl:value-of select="name()"/&gt;
    &lt;xsl:text disable-output-escaping="yes"&gt;&amp;gt;&lt;/xsl:text&gt;
    &lt;xsl:value-of select="$NL"/&gt;
  &lt;/xsl:template&gt;

  &lt;xsl:template match="rng:*" mode="listing"&gt;
    &lt;xsl:if test="name(..)='define' or name(..)='start'"&gt;
      &lt;xsl:value-of select="$NLI"/&gt;
    &lt;/xsl:if&gt;
    &lt;xsl:text disable-output-escaping="yes"&gt;  &amp;lt;&lt;/xsl:text&gt;
    &lt;xsl:value-of select="name()"/&gt;
    &lt;xsl:apply-templates select="@*"/&gt;
    &lt;xsl:choose&gt;
      &lt;xsl:when test="count(*)=0"&gt;
    &lt;xsl:choose&gt;
      &lt;xsl:when test="count(text())=0"&gt;
        &lt;xsl:text&gt;/&lt;/xsl:text&gt;
      &lt;/xsl:when&gt;
      &lt;xsl:otherwise&gt;
        &lt;xsl:text disable-output-escaping="yes"&gt;&amp;gt;&lt;/xsl:text&gt;
        &lt;xsl:apply-templates/&gt;
        &lt;xsl:text disable-output-escaping="yes"&gt;&amp;lt;/&lt;/xsl:text&gt;
        &lt;xsl:value-of select="name()"/&gt;
      &lt;/xsl:otherwise&gt;
    &lt;/xsl:choose&gt;
      &lt;/xsl:when&gt;
      &lt;xsl:otherwise&gt;
    &lt;xsl:text disable-output-escaping="yes"&gt;&amp;gt;&lt;/xsl:text&gt;
    &lt;xsl:apply-templates mode="listing"/&gt;
    &lt;xsl:text disable-output-escaping="yes"&gt;  &amp;lt;/&lt;/xsl:text&gt;
    &lt;xsl:value-of select="name()"/&gt;
      &lt;/xsl:otherwise&gt;
    &lt;/xsl:choose&gt;
    &lt;xsl:text disable-output-escaping="yes"&gt;&amp;gt;&lt;/xsl:text&gt;
  &lt;/xsl:template&gt;

  &lt;xsl:template match="a:rest"&gt;
    &lt;xsl:value-of select="."/&gt;
  &lt;/xsl:template&gt;

  &lt;xsl:template match="a:rest" mode="listing"/&gt;

  &lt;xsl:template match="@*"&gt;
    &lt;xsl:text&gt; &lt;/xsl:text&gt;
    &lt;xsl:value-of select="name()"/&gt;
    &lt;xsl:text&gt;="&lt;/xsl:text&gt;
    &lt;xsl:value-of select="."/&gt;
    &lt;xsl:text&gt;"&lt;/xsl:text&gt;
  &lt;/xsl:template&gt;

  &lt;xsl:template match="@*"&gt;
    &lt;xsl:text&gt; &lt;/xsl:text&gt;
    &lt;xsl:value-of select="name()"/&gt;
    &lt;xsl:text&gt;="&lt;/xsl:text&gt;
    &lt;xsl:value-of select="."/&gt;
    &lt;xsl:if test="name(..)='ref' and name()='name'"&gt;
      &lt;xsl:text&gt;_&lt;/xsl:text&gt;
    &lt;/xsl:if&gt;
    &lt;xsl:text&gt;"&lt;/xsl:text&gt;
  &lt;/xsl:template&gt;

&lt;/xsl:stylesheet&gt;</pre>
  <seznamknih>
    <kniha id="Goo05">Goodger, D. <i>Creating reStructuredText Interpreted Text
Roles</i>. Developer documentation of reST, 2005. Available <a href="http://docutils.sourceforge.net/docs/howto/rst-roles.html">online</a>.</kniha>
    <kniha id="Knu92">Knuth D.E. <i>Literate Programming</i>. Stanford, California:
Center for the Study of Language and Information, 1992. 368pp. ISBN
0-937073-80-6.</kniha>
    <kniha id="Lho06">Lhotka L. <i>XML Schema of FlowMon Configuration
Data</i>. Available <a href="http://www.flowmon.org/flowmon-probe/devel/config/flowmon-rng.rest/">online</a>.</kniha>
    <kniha id="RNG">Clark J. and Murata M. (Editors). <i>RELAX NG
Specification</i>. OASIS Consortium, 2001. Available <a href="http://www.oasis-open.org/committees/relax-ng/spec-20011203.html">online</a>.</kniha>
    <kniha id="Wag05">Wagner Z. <i>Tool for Annotation of Relax NG
Schemas</i>. IceBearSoft, 2005. Available <a href="http://icebearsoft.euweb.cz/xmltools/rngdoc-en.php">online</a>.</kniha>
    <kniha id="XML">Bray T., Paoli J., Sperberg-McQueen C.M., Maler E. and
Yergeau, F. (Editors). <i>Extensible Markup Language (XML) 1.0.</i> Third
edition. W3C Consortium, 2004. Available online
&lt;http://www.w3.org/TR/2004/REC-xml-20040204/&gt;.</kniha>
    <kniha id="XSch1">Thompson H.S., Beech D., Maloney M. and Mendelsohn
N. (Editors). <i>XML Schema Part 1: Structures.</i> Second edition. W3C
Consortium, 2004. Available <a href="http://www.w3.org/TR/xmlschema-1/">online</a>.</kniha>
    <kniha id="XSch2">Biron P.V. and Malhotra A. (Editors). <i>XML
Schema Part 2: Datatypes.</i> Second edition. W3C Consortium,
2004. Available <a href="http://www.w3.org/TR/xmlschema-2/">online</a>.</kniha>
  </seznamknih>
</zprava>
