|
From: <smi...@us...> - 2004-01-02 00:39:39
|
Update of /cvsroot/devil-linux/build/docs/documentation/stylesheets/doc/lib
In directory sc8-pr-cvs1:/tmp/cvs-serv17796/stylesheets/doc/lib
Added Files:
ChangeLog lib.html
Log Message:
so that's hopefully it, with the new stylesheets
--- NEW FILE: ChangeLog ---
2002-03-25 Norman Walsh <nw...@us...>
* Makefile: Update documentation build to reflect use of lib.xweb
2002-03-09 Jirka Kosek <ko...@us...>
* Makefile: Removed hardcoded reference for XSLT processor as it is already set in Makefile.incl. Fixed typo in DocBook DTD URI.
2001-08-06 Norman Walsh <nw...@us...>
* Makefile: Documentation and documentation generation tweaks
2001-06-20 Norman Walsh <nw...@us...>
* Makefile: Use XT again (neither Saxon nor Xalan work)
2001-04-03 Norman Walsh <nw...@us...>
* .cvsignore, Makefile: New file.
--- NEW FILE: lib.html ---
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>XSL Library Template Reference</title><meta name="generator" content="DocBook XSL Stylesheets V0.00+"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="book"><div class="titlepage"><div><h1 class="title"><a name="d0e3"></a>XSL Library Template Reference</h1></div><div><h3 class="corpauthor">DocBook Open Repository Team</h3></div><div><p class="releaseinfo">$Id: lib.html,v 1.1 2004/01/02 00:39:30 smiley73 Exp $
</p></div><div><p class="copyright">Copyright © 1999, 2000, 2001, 2002 Norman Walsh</p></div><hr></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><a href="#d0e22">Introduction</a></dt><dt>I. <a href="#d0e37">General Library Templates</a></dt><dd><dl><dt><a href="#dot.count">dot.count</a> - Returns the number of . characters in a string</dt><dt><a href="#copy-string">copy-string</a> - Returns count copies of a string</dt><dt><a href="#string.subst">string.subst</a> - Substitute one text string for another in a string</dt><dt><a href="#xpointer.idref">xpointer.idref</a> - Extract IDREF from an XPointer</dt><dt><a href="#length-magnitude">length-magnitude</a> - Return the unqualified dimension from a length specification</dt><dt><a href="#length-units">length-units</a> - Return the units from a length specification</dt><dt><a href="#length-spec">length-spec</a> - Return a fully qualified length specification</dt><dt><a href="#length-in-points">length-in-points</a> - Returns the size, in points, of a specified length</dt><dt><a href="#pi-attribute">pi-attribute</a> - Extract a pseudo-attribute from a PI</dt><dt><a href="#lookup.key">lookup.key</a> - Retrieve the value associated with a particular key in a table</dt><dt><a href="#xpath.location">xpath.location</a> - Calculate the XPath child-sequence to the current node</dt><dt><a href="#comment-escape-string">comment-escape-string</a> - Prepare a string for inclusion in an XML comment</dt><dt><a href="#comment-escape-string.recursive">comment-escape-string.recursive</a> - Internal function used by comment-escape-string</dt></dl></dd><dt>II. <a href="#d0e331">Relative URI Functions</a></dt><dd><dl><dt><a href="#count.uri.path.depth">count.uri.path.depth</a> - Count the number of path components in a relative URI</dt><dt><a href="#trim.common.uri.paths">trim.common.uri.paths</a> - Trim common leading path components from a relative URI</dt></dl></dd><dt>A. <a href="#d0e385">The Stylesheet</a></dt></dl></div><div class="preface"><div class="titlepage"><div><h2 class="title"><a name="d0e22"></a>Introduction</h2></div></div><p>This is technical reference documentation for the DocBook XSL
Stylesheets; it documents (some of) the parameters, templates, and
other elements of the stylesheets.</p><p>This is not intended to be “user” documentation.
It is provided for developers writing customization layers for the
stylesheets, and for anyone who's interested in “how it
works”.</p><p>Although I am trying to be thorough, this documentation is known
to be incomplete. Don't forget to read the source, too :-)</p></div><div class="reference"><a name="d0e37"></a><div class="titlepage"><div><h1 class="title"><a name="d0e37"></a>General Library Templates</h1></div><hr></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><a href="#dot.count">dot.count</a> - Returns the number of . characters in a string</dt><dt><a href="#copy-string">copy-string</a> - Returns count copies of a string</dt><dt><a href="#string.subst">string.subst</a> - Substitute one text string for another in a string</dt><dt><a href="#xpointer.idref">xpointer.idref</a> - Extract IDREF from an XPointer</dt><dt><a href="#length-magnitude">length-magnitude</a> - Return the unqualified dimension from a length specification</dt><dt><a href="#length-units">length-units</a> - Return the units from a length specification</dt><dt><a href="#length-spec">length-spec</a> - Return a fully qualified length specification</dt><dt><a href="#length-in-points">length-in-points</a> - Returns the size, in points, of a specified length</dt><dt><a href="#pi-attribute">pi-attribute</a> - Extract a pseudo-attribute from a PI</dt><dt><a href="#lookup.key">lookup.key</a> - Retrieve the value associated with a particular key in a table</dt><dt><a href="#xpath.location">xpath.location</a> - Calculate the XPath child-sequence to the current node</dt><dt><a href="#comment-escape-string">comment-escape-string</a> - Prepare a string for inclusion in an XML comment</dt><dt><a href="#comment-escape-string.recursive">comment-escape-string.recursive</a> - Internal function used by comment-escape-string</dt></dl></div><div class="refentry"><a name="dot.count"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>dot.count — Returns the number of “.” characters in a string</p></div><div class="refsect1"><h2>Description</h2><pre class="programlisting"><a name="dot.count.frag"></a><table border="1" width="100%"><tr><td><p><b>§1</b>: <a href="#top">§16</a></p></td></tr><tr><td><pre class="src:fragment"> 1| <xsl:template name="dot.count">
| <!-- Returns the number of "." characters in a string -->
| <xsl:param name="string"/>
| <xsl:param name="count"
5| select="0"/>
| <xsl:choose>
| <xsl:when test="contains($string, '.')">
| <xsl:call-template name="dot.count">
| <xsl:with-param name="string"
10| select="substring-after($string, '.')"/>
| <xsl:with-param name="count"
| select="$count+1"/>
| </xsl:call-template>
| </xsl:when>
15| <xsl:otherwise>
| <xsl:value-of select="$count"/>
| </xsl:otherwise>
| </xsl:choose>
| </xsl:template></pre></td></tr></table></pre></div></div><div class="refentry"><div class="refentry.separator"><hr></div><a name="copy-string"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>copy-string — Returns “count” copies of a string</p></div><div class="refsect1"><h2>Description</h2><pre class="programlisting"><a name="copy-string.frag"></a><table border="1" width="100%"><tr><td><p><b>§2</b>: <a href="#top">§16</a></p></td></tr><tr><td><pre class="src:fragment"> 1| <xsl:template name="copy-string">
| <!-- returns 'count' copies of 'string' -->
| <xsl:param name="string"/>
| <xsl:param name="count"
5| select="0"/>
| <xsl:param name="result"/>
|
| <xsl:choose>
| <xsl:when test="$count>0">
10| <xsl:call-template name="copy-string">
| <xsl:with-param name="string"
| select="$string"/>
| <xsl:with-param name="count"
| select="$count - 1"/>
15| <xsl:with-param name="result">
| <xsl:value-of select="$result"/>
| <xsl:value-of select="$string"/>
| </xsl:with-param>
| </xsl:call-template>
20| </xsl:when>
| <xsl:otherwise>
| <xsl:value-of select="$result"/>
| </xsl:otherwise>
| </xsl:choose>
25| </xsl:template></pre></td></tr></table></pre></div></div><div class="refentry"><div class="refentry.separator"><hr></div><a name="string.subst"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>string.subst — Substitute one text string for another in a string</p></div><div class="refsect1"><h2>Description</h2><p>The <tt>string.subst</tt> template replaces all
occurances of <i><tt>target</tt></i> in <i><tt>string</tt></i>
with <i><tt>replacement</tt></i> and returns the result.
</p><pre class="programlisting"><a name="string.subst.frag"></a><table border="1" width="100%"><tr><td><p><b>§3</b>: <a href="#top">§16</a></p></td></tr><tr><td><pre class="src:fragment"> 1| <xsl:template name="string.subst">
| <xsl:param name="string"/>
| <xsl:param name="target"/>
| <xsl:param name="replacement"/>
5|
| <xsl:choose>
| <xsl:when test="contains($string, $target)">
| <xsl:variable name="rest">
| <xsl:call-template name="string.subst">
10| <xsl:with-param name="string"
| select="substring-after($string, $target)"/>
| <xsl:with-param name="target"
| select="$target"/>
| <xsl:with-param name="replacement"
15| select="$replacement"/>
| </xsl:call-template>
| </xsl:variable>
| <xsl:value-of select="concat(substring-before($string, $target), $replacement, $rest)"/>
| </xsl:when>
20| <xsl:otherwise>
| <xsl:value-of select="$string"/>
| </xsl:otherwise>
| </xsl:choose>
| </xsl:template></pre></td></tr></table></pre></div></div><div class="refentry"><div class="refentry.separator"><hr></div><a name="xpointer.idref"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>xpointer.idref — Extract IDREF from an XPointer</p></div><div class="refsect1"><h2>Description</h2><p>The <tt>xpointer.idref</tt> template returns the
ID portion of an XPointer which is a pointer to an ID within the current
document, or the empty string if it is not.</p><p>In other words, <tt>xpointer.idref</tt> returns
“foo” when passed either <tt>#foo</tt>
or <tt>#xpointer(id('foo'))</tt>, otherwise it returns
the empty string.</p><pre class="programlisting"><a name="xpointer.idref.frag"></a><table border="1" width="100%"><tr><td><p><b>§4</b>: <a href="#top">§16</a></p></td></tr><tr><td><pre class="src:fragment"> 1| <xsl:template name="xpointer.idref">
| <xsl:param name="xpointer">http://...</xsl:param>
| <xsl:choose>
| <xsl:when test="starts-with($xpointer, '#xpointer(id(')">
5| <xsl:variable name="rest"
| select="substring-after($xpointer, '#xpointer(id(')"/>
| <xsl:variable name="quote"
| select="substring($rest, 1, 1)"/>
| <xsl:value-of select="substring-before(substring-after($xpointer, $quote), $quote)"/>
10| </xsl:when>
| <xsl:when test="starts-with($xpointer, '#')">
| <xsl:value-of select="substring-after($xpointer, '#')"/>
| </xsl:when>
| <!-- otherwise it's a pointer to some other document -->
15| </xsl:choose>
| </xsl:template></pre></td></tr></table></pre></div></div><div class="refentry"><div class="refentry.separator"><hr></div><a name="length-magnitude"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>length-magnitude — Return the unqualified dimension from a length specification</p></div><div class="refsect1"><h2>Description</h2><p>The <tt>length-magnitude</tt> template returns the
unqualified length ("20" for "20pt") from a dimension.
</p><pre class="programlisting"><a name="length-magnitude.frag"></a><table border="1" width="100%"><tr><td><p><b>§5</b>: <a href="#top">§16</a></p></td></tr><tr><td><pre class="src:fragment"> 1| <xsl:template name="length-magnitude">
| <xsl:param name="length"
| select="'0pt'"/>
|
5| <xsl:choose>
| <xsl:when test="string-length($length) = 0"/>
| <xsl:when test="substring($length,1,1) = '0' or substring($length,1,1) = '1' or substring($length,1,1) = '2' or substring($length,1,1) = '3' or substring($length,1,1) = '4' or substring($length,1,1) = '5' or substring($length,1,1) = '6' or substring($length,1,1) = '7' or substring($length,1,1) = '8' or substring($length,1,1) = '9' or substring($length,1,1) = '.'">
| <xsl:value-of select="substring($length,1,1)"/>
| <xsl:call-template name="length-magnitude">
10| <xsl:with-param name="length"
| select="substring($length,2)"/>
| </xsl:call-template>
| </xsl:when>
| </xsl:choose>
15| </xsl:template></pre></td></tr></table></pre></div></div><div class="refentry"><div class="refentry.separator"><hr></div><a name="length-units"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>length-units — Return the units from a length specification</p></div><div class="refsect1"><h2>Description</h2><p>The <tt>length-units</tt> template returns the
units ("pt" for "20pt") from a length. If no units are supplied on the
length, the <i><tt>defauilt.units</tt></i> are returned.</p><pre class="programlisting"><a name="length-units.frag"></a><table border="1" width="100%"><tr><td><p><b>§6</b>: <a href="#top">§16</a></p></td></tr><tr><td><pre class="src:fragment"> 1| <xsl:template name="length-units">
| <xsl:param name="length"
| select="'0pt'"/>
| <xsl:param name="default.units"
5| select="'px'"/>
| <xsl:variable name="magnitude">
| <xsl:call-template name="length-magnitude">
| <xsl:with-param name="length"
| select="$length"/>
10| </xsl:call-template>
| </xsl:variable>
|
| <xsl:variable name="units">
| <xsl:value-of select="substring($length, string-length($magnitude)+1)"/>
15| </xsl:variable>
|
| <xsl:choose>
| <xsl:when test="$units = ''">
| <xsl:value-of select="$default.units"/>
20| </xsl:when>
| <xsl:otherwise>
| <xsl:value-of select="$units"/>
| </xsl:otherwise>
| </xsl:choose>
25| </xsl:template></pre></td></tr></table></pre></div></div><div class="refentry"><div class="refentry.separator"><hr></div><a name="length-spec"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>length-spec — Return a fully qualified length specification</p></div><div class="refsect1"><h2>Description</h2><p>The <tt>length-spec</tt> template returns the
qualified length from a dimension. If an unqualified length is given,
the <i><tt>default.units</tt></i> will be added to it.
</p><pre class="programlisting"><a name="length-spec.frag"></a><table border="1" width="100%"><tr><td><p><b>§7</b>: <a href="#top">§16</a></p></td></tr><tr><td><pre class="src:fragment"> 1| <xsl:template name="length-spec">
| <xsl:param name="length"
| select="'0pt'"/>
| <xsl:param name="default.units"
5| select="'px'"/>
|
| <xsl:variable name="magnitude">
| <xsl:call-template name="length-magnitude">
| <xsl:with-param name="length"
10| select="$length"/>
| </xsl:call-template>
| </xsl:variable>
|
| <xsl:variable name="units">
15| <xsl:value-of select="substring($length, string-length($magnitude)+1)"/>
| </xsl:variable>
|
| <xsl:value-of select="$magnitude"/>
| <xsl:choose>
20| <xsl:when test="$units='cm' or $units='mm' or $units='in' or $units='pt' or $units='pc' or $units='px' or $units='em'">
| <xsl:value-of select="$units"/>
| </xsl:when>
| <xsl:when test="$units = ''">
| <xsl:value-of select="$default.units"/>
25| </xsl:when>
| <xsl:otherwise>
| <xsl:message>
| <xsl:text>Unrecognized unit of measure: </xsl:text>
| <xsl:value-of select="$units"/>
30| <xsl:text>.</xsl:text>
| </xsl:message>
| </xsl:otherwise>
| </xsl:choose>
| </xsl:template></pre></td></tr></table></pre></div></div><div class="refentry"><div class="refentry.separator"><hr></div><a name="length-in-points"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>length-in-points — Returns the size, in points, of a specified length</p></div><div class="refsect1"><h2>Description</h2><p>The <tt>length-in-points</tt> template converts a length
specification to points and returns that value as an unqualified
number.
</p><div class="caution" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Caution</h3><p>There is no way for the template to infer the size of an
<tt>em</tt>. It relies on the default <i><tt>em.size</tt></i>
which is initially <tt>10</tt> (for 10pt).</p><p>Similarly, converting pixesl to points relies on the
<i><tt>pixels.per.inch</tt></i> parameter which is initially
<tt>90</tt>.
</p></div><pre class="programlisting"><a name="length-in-points.frag"></a><table border="1" width="100%"><tr><td><p><b>§8</b>: <a href="#top">§16</a></p></td></tr><tr><td><pre class="src:fragment"> 1| <xsl:template name="length-in-points">
| <xsl:param name="length"
| select="'0pt'"/>
| <xsl:param name="em.size"
5| select="10"/>
| <xsl:param name="pixels.per.inch"
| select="90"/>
|
| <xsl:variable name="magnitude">
10| <xsl:call-template name="length-magnitude">
| <xsl:with-param name="length"
| select="$length"/>
| </xsl:call-template>
| </xsl:variable>
15|
| <xsl:variable name="units">
| <xsl:value-of select="substring($length, string-length($magnitude)+1)"/>
| </xsl:variable>
|
20| <xsl:choose>
| <xsl:when test="$units = 'pt'">
| <xsl:value-of select="$magnitude"/>
| </xsl:when>
| <xsl:when test="$units = 'cm'">
25| <xsl:value-of select="$magnitude div 2.54 * 72.0"/>
| </xsl:when>
| <xsl:when test="$units = 'mm'">
| <xsl:value-of select="$magnitude div 25.4 * 72.0"/>
| </xsl:when>
30| <xsl:when test="$units = 'in'">
| <xsl:value-of select="$magnitude * 72.0"/>
| </xsl:when>
| <xsl:when test="$units = 'pc'">
| <xsl:value-of select="$magnitude div 6.0 * 72.0"/>
35| </xsl:when>
| <xsl:when test="$units = 'px'">
| <xsl:value-of select="$magnitude div $pixels.per.inch * 72.0"/>
| </xsl:when>
| <xsl:when test="$units = 'em'">
40| <xsl:value-of select="$magnitude * $em.size"/>
| </xsl:when>
| <xsl:otherwise>
| <xsl:message>
| <xsl:text>Unrecognized unit of measure: </xsl:text>
45| <xsl:value-of select="$units"/>
| <xsl:text>.</xsl:text>
| </xsl:message>
| </xsl:otherwise>
| </xsl:choose>
50| </xsl:template></pre></td></tr></table></pre></div></div><div class="refentry"><div class="refentry.separator"><hr></div><a name="pi-attribute"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>pi-attribute — Extract a pseudo-attribute from a PI</p></div><div class="refsect1"><h2>Description</h2><p>The <tt>pi-attribute</tt> template extracts a pseudo-attribute
from a processing instruction. For example, given the PI
“<tt><?foo bar="1" baz='red'?></tt>”,</p><pre class="programlisting"><xsl:call-template name="pi-attribute">
<xsl:with-param name="pis" select="processing-instruction('foo')"/>
<xsl:with-param name="attribute" select="'baz'"/>
</xsl:call-template></pre><p>will return “red”. This template returns the first matching
attribute that it finds. Presented with processing instructions that
contain badly formed pseudo-attributes (missing or unbalanced quotes,
for example), the template may silently return erroneous results.</p><pre class="programlisting"><a name="pi-attribute.frag"></a><table border="1" width="100%"><tr><td><p><b>§9</b>: <a href="#top">§16</a></p></td></tr><tr><td><pre class="src:fragment"> 1| <xsl:template name="pi-attribute">
| <xsl:param name="pis"
| select="processing-instruction('')"/>
| <xsl:param name="attribute">filename</xsl:param>
5| <xsl:param name="count">1</xsl:param>
|
| <xsl:choose>
| <xsl:when test="$count>count($pis)">
| <!-- not found -->
10| </xsl:when>
| <xsl:otherwise>
| <xsl:variable name="pi">
| <xsl:value-of select="$pis[$count]"/>
| </xsl:variable>
15| <xsl:choose>
| <xsl:when test="contains($pi,concat($attribute, '='))">
| <xsl:variable name="rest"
| select="substring-after($pi,concat($attribute,'='))"/>
| <xsl:variable name="quote"
20| select="substring($rest,1,1)"/>
| <xsl:value-of select="substring-before(substring($rest,2),$quote)"/>
| </xsl:when>
| <xsl:otherwise>
| <xsl:call-template name="pi-attribute">
25| <xsl:with-param name="pis"
| select="$pis"/>
| <xsl:with-param name="attribute"
| select="$attribute"/>
| <xsl:with-param name="count"
30| select="$count + 1"/>
| </xsl:call-template>
| </xsl:otherwise>
| </xsl:choose>
| </xsl:otherwise>
35| </xsl:choose>
| </xsl:template></pre></td></tr></table></pre></div></div><div class="refentry"><div class="refentry.separator"><hr></div><a name="lookup.key"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>lookup.key — Retrieve the value associated with a particular key in a table</p></div><div class="refsect1"><h2>Description</h2><p>Given a table of space-delimited key/value pairs,
the <tt>lookup.key</tt> template extracts the value associated
with a particular key.</p><pre class="programlisting"><a name="lookup.key.frag"></a><table border="1" width="100%"><tr><td><p><b>§10</b>: <a href="#top">§16</a></p></td></tr><tr><td><pre class="src:fragment"> 1| <xsl:template name="lookup.key">
| <xsl:param name="key"
| select="''"/>
| <xsl:param name="table"
5| select="''"/>
|
| <xsl:if test="contains($table, ' ')">
| <xsl:choose>
| <xsl:when test="substring-before($table, ' ') = $key">
10| <xsl:variable name="rest"
| select="substring-after($table, ' ')"/>
| <xsl:choose>
| <xsl:when test="contains($rest, ' ')">
| <xsl:value-of select="substring-before($rest, ' ')"/>
15| </xsl:when>
| <xsl:otherwise>
| <xsl:value-of select="$rest"/>
| </xsl:otherwise>
| </xsl:choose>
20| </xsl:when>
| <xsl:otherwise>
| <xsl:call-template name="lookup.key">
| <xsl:with-param name="key"
| select="$key"/>
25| <xsl:with-param name="table"
| select="substring-after(substring-after($table,' '), ' ')"/>
| </xsl:call-template>
| </xsl:otherwise>
| </xsl:choose>
30| </xsl:if>
| </xsl:template></pre></td></tr></table></pre></div></div><div class="refentry"><div class="refentry.separator"><hr></div><a name="xpath.location"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>xpath.location — Calculate the XPath child-sequence to the current node</p></div><div class="refsect1"><h2>Description</h2><p>The <tt>xpath.location</tt> template calculates the
absolute path from the root of the tree to the current element node.
</p><pre class="programlisting"><a name="xpath.location.frag"></a><table border="1" width="100%"><tr><td><p><b>§11</b>: <a href="#top">§16</a></p></td></tr><tr><td><pre class="src:fragment"> 1| <xsl:template name="xpath.location">
| <xsl:param name="node"
| select="."/>
| <xsl:param name="path"
5| select="''"/>
|
| <xsl:variable name="next.path">
| <xsl:value-of select="local-name($node)"/>
| <xsl:if test="$path != ''">/</xsl:if>
10| <xsl:value-of select="$path"/>
| </xsl:variable>
|
| <xsl:choose>
| <xsl:when test="$node/parent::*">
15| <xsl:call-template name="xpath.location">
| <xsl:with-param name="node"
| select="$node/parent::*"/>
| <xsl:with-param name="path"
| select="$next.path"/>
20| </xsl:call-template>
| </xsl:when>
| <xsl:otherwise>
| <xsl:text>/</xsl:text>
| <xsl:value-of select="$next.path"/>
25| </xsl:otherwise>
| </xsl:choose>
| </xsl:template></pre></td></tr></table></pre></div></div><div class="refentry"><div class="refentry.separator"><hr></div><a name="comment-escape-string"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>comment-escape-string — Prepare a string for inclusion in an XML comment</p></div><div class="refsect1"><h2>Description</h2><p>The <tt>comment-escape-string</tt> template returns a string
that has been transformed so that it can safely be output as an XML comment.
Internal occurrences of "--" will be replaced with "- -" and a leading and/or
trailing space will be added to the string, if necessary.</p><pre class="programlisting"><a name="comment-escape-string"></a><table border="1" width="100%"><tr><td><p><b>§12</b>: <a href="#top">§16</a></p></td></tr><tr><td><pre class="src:fragment"> 1| <xsl:template name="comment-escape-string">
| <xsl:param name="string"
| select="''"/>
|
5| <xsl:if test="starts-with($string, '-')">
| <xsl:text> </xsl:text>
| </xsl:if>
|
| <xsl:call-template name="comment-escape-string.recursive">
10| <xsl:with-param name="string"
| select="$string"/>
| </xsl:call-template>
|
| <xsl:if test="substring($string, string-length($string), 1) = '-'">
15| <xsl:text> </xsl:text>
| </xsl:if>
| </xsl:template></pre></td></tr></table></pre></div></div><div class="refentry"><div class="refentry.separator"><hr></div><a name="comment-escape-string.recursive"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>comment-escape-string.recursive — Internal function used by comment-escape-string</p></div><div class="refsect1"><h2>Description</h2><p>The <tt>comment-escape-string.recursive</tt> template is used
by <tt>comment-escape-string</tt>.</p><pre class="programlisting"><a name="comment-escape-string.recursive"></a><table border="1" width="100%"><tr><td><p><b>§13</b>: <a href="#top">§16</a></p></td></tr><tr><td><pre class="src:fragment"> 1| <xsl:template name="comment-escape-string.recursive">
| <xsl:param name="string"
| select="''"/>
| <xsl:choose>
5| <xsl:when test="contains($string, '--')">
| <xsl:value-of select="substring-before($string, '--')"/>
| <xsl:value-of select="'- -'"/>
| <xsl:call-template name="comment-escape-string.recursive">
| <xsl:with-param name="string"
10| select="substring-after($string, '--')"/>
| </xsl:call-template>
| </xsl:when>
| <xsl:otherwise>
| <xsl:value-of select="$string"/>
15| </xsl:otherwise>
| </xsl:choose>
| </xsl:template></pre></td></tr></table></pre></div></div></div><div class="reference"><a name="d0e331"></a><div class="titlepage"><div><h1 class="title"><a name="d0e331"></a>Relative URI Functions</h1></div><hr></div><div class="partintro"><div><div><h1 class="title"><a name="d0e334"></a>Introduction</h1></div></div><p>These functions manipulate relative URI references.</p><p>The following assumptions must hold true:</p><div class="orderedlist"><ol type="1"><li><p>All URIs are relative.</p></li><li><p>No URI contains the “<tt>../</tt>” sequence
which would effectively move “up” the hierarchy.</p></li></ol></div><p>If these assumptions do not hold, the results are unpredictable.</p><div class="toc"><p><b>Table of Contents</b></p><dl><dt><a href="#count.uri.path.depth">count.uri.path.depth</a> - Count the number of path components in a relative URI</dt><dt><a href="#trim.common.uri.paths">trim.common.uri.paths</a> - Trim common leading path components from a relative URI</dt></dl></div></div><div class="refentry"><a name="count.uri.path.depth"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>count.uri.path.depth — Count the number of path components in a relative URI</p></div><div class="refsect1"><h2>Description</h2><p>This function counts the number of path components in a relative URI.</p><pre class="programlisting"><a name="count.uri.path.depth.frag"></a><table border="1" width="100%"><tr><td><p><b>§14</b>: <a href="#top">§16</a></p></td></tr><tr><td><pre class="src:fragment"> 1| <xsl:template name="count.uri.path.depth">
| <xsl:param name="filename"
| select="''"/>
| <xsl:param name="count"
5| select="0"/>
|
| <xsl:choose>
| <xsl:when test="contains($filename, '/')">
| <xsl:call-template name="count.uri.path.depth">
10| <xsl:with-param name="filename"
| select="substring-after($filename, '/')"/>
| <xsl:with-param name="count"
| select="$count + 1"/>
| </xsl:call-template>
15| </xsl:when>
| <xsl:otherwise>
| <xsl:value-of select="$count"/>
| </xsl:otherwise>
| </xsl:choose>
20| </xsl:template></pre></td></tr></table></pre></div></div><div class="refentry"><div class="refentry.separator"><hr></div><a name="trim.common.uri.paths"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>trim.common.uri.paths — Trim common leading path components from a relative URI</p></div><div class="refsect1"><h2>Description</h2><p>This function trims common leading path components from a relative URI.</p><pre class="programlisting"><a name="trim.common.uri.paths.frag"></a><table border="1" width="100%"><tr><td><p><b>§15</b>: <a href="#top">§16</a></p></td></tr><tr><td><pre class="src:fragment"> 1| <xsl:template name="trim.common.uri.paths">
| <xsl:param name="uriA"
| select="''"/>
| <xsl:param name="uriB"
5| select="''"/>
| <xsl:param name="return"
| select="'A'"/>
|
| <xsl:choose>
10| <xsl:when test="contains($uriA, '/') and contains($uriB, '/') and substring-before($uriA, '/') = substring-before($uriB, '/')">
| <xsl:call-template name="trim.common.uri.paths">
| <xsl:with-param name="uriA"
| select="substring-after($uriA, '/')"/>
| <xsl:with-param name="uriB"
15| select="substring-after($uriB, '/')"/>
| <xsl:with-param name="return"
| select="$return"/>
| </xsl:call-template>
| </xsl:when>
20| <xsl:otherwise>
| <xsl:choose>
| <xsl:when test="$return = 'A'">
| <xsl:value-of select="$uriA"/>
| </xsl:when>
25| <xsl:otherwise>
| <xsl:value-of select="$uriB"/>
| </xsl:otherwise>
| </xsl:choose>
| </xsl:otherwise>
30| </xsl:choose>
| </xsl:template></pre></td></tr></table></pre></div></div></div><div class="appendix"><div class="titlepage"><div><h2 class="title"><a name="d0e385"></a>Appendix A. The Stylesheet</h2></div></div><p>The <tt>lib.xsl</tt> stylesheet is just a wrapper
around these functions.</p><a name="top"></a><table border="1" width="100%"><tr><td><p><b>§16</b></p></td></tr><tr><td><pre class="src:fragment"> 1|
| <!-- ********************************************************************
| $Id: lib.html,v 1.1 2004/01/02 00:39:30 smiley73 Exp $
| ********************************************************************
5|
| This file is part of the XSL DocBook Stylesheet distribution.
| See ../README or http://nwalsh.com/docbook/xsl/ for copyright
| and other information.
|
10| This module implements DTD-independent functions
|
| ******************************************************************** -->
|
| <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
15| exclude-result-prefixes="src"
| version="1.0">
|
| <a href="#dot.count.frag"><i>§1. dot.count</i></a>
| <a href="#copy-string.frag"><i>§2. copy-string</i></a>
20| <a href="#string.subst.frag"><i>§3. string.subst</i></a>
| <a href="#xpointer.idref.frag"><i>§4. xpointer.idref</i></a>
| <a href="#length-magnitude.frag"><i>§5. length-magnitude</i></a>
| <a href="#length-units.frag"><i>§6. length-units</i></a>
| <a href="#length-spec.frag"><i>§7. length-spec</i></a>
25| <a href="#length-in-points.frag"><i>§8. length-in-points</i></a>
| <a href="#pi-attribute.frag"><i>§9. pi-attribute</i></a>
| <a href="#lookup.key.frag"><i>§10. lookup.key</i></a>
| <a href="#xpath.location.frag"><i>§11. xpath.location</i></a>
| <a href="#comment-escape-string" title="comment-escape-string">comment-escape-string</a>
30| <a href="#comment-escape-string.recursive" title="comment-escape-string.recursive">comment-escape-string.recursive</a>
| <a href="#count.uri.path.depth.frag"><i>§14. count.uri.path.depth</i></a>
| <a href="#trim.common.uri.paths.frag"><i>§15. trim.common.uri.paths</i></a>
|
| </xsl:stylesheet></pre></td></tr></table></div></div></body></html>
|