emitted during namespace-stripping.
Also, moved pad-string template from lib to common because
it's needed in order to use logging template in the profiling
stylesheets, and the lib build relies on the profiling apparatus
(so the profiling apparatus can't rely on lib being built first...)
</variablelist>
</refparameter>
</doc:template>
-
<xsl:template name="string.upper">
<xsl:param name="string" select="''"/>
<xsl:variable name="lowercase.alpha">
</variablelist>
</refparameter>
</doc:template>
-
<xsl:template name="string.lower">
<xsl:param name="string" select="''"/>
<xsl:variable name="uppercase.alpha">
</warning>
</refdescription>
</doc:template>
-
<xsl:template name="select.choice.separator">
<xsl:variable name="choice">
<parameter>profile</parameter> parameter)</para>
</refreturn>
</doc:template>
-
<xsl:template name="evaluate.info.profile">
<xsl:param name="profile"/>
<xsl:param name="info"/>
<refreturn>
<para>Outputs a message (generally, to standard error).</para></refreturn>
</doc:template>
-
<xsl:template name="log.message">
<xsl:param name="level"/>
<xsl:param name="source"/>
</xsl:message>
</xsl:template>
+<!-- ===================================== -->
+<doc:template name="get.doc.title" xmlns="">
+ <refpurpose>Get a title for the current document</refpurpose>
+ <refdescription>
+ <para>The <function>get.doc.title</function> template is a
+ utility template for returning the first title found in the
+ current document.</para>
+ </refdescription>
+ <refreturn>
+ <para>Returns a string containing some identifying title for the
+ current document .</para></refreturn>
+</doc:template>
+<xsl:template name="get.doc.title">
+ <xsl:choose>
+ <xsl:when test="//*[local-name() = 'title'
+ or local-name() = 'refname']">
+ <xsl:value-of select="//*[local-name() = 'title'
+ or local-name() = 'refname'][1]"/>
+ </xsl:when>
+ <xsl:when test="substring(local-name(*[1]),
+ string-length(local-name(*[1])-3) = 'info')
+ and *[1]/*[local-name() = 'title']">
+ <xsl:value-of select="*[1]/*[local-name() = 'title'][1]"/>
+ </xsl:when>
+ </xsl:choose>
+</xsl:template>
+
+<!-- ===================================== -->
+<doc:template name="pad.string" xmlns="">
+ <refpurpose>Right-pad or left-pad a string out to a certain length</refpurpose>
+ <refdescription>
+ <para>This function takes string <parameter>padVar</parameter> and
+ pads it out in the direction <parameter>rightLeft</parameter> to
+ the string-length <parameter>length</parameter>, using string
+ <parameter>padChar</parameter> (a space character by default) as
+ the padding string (note that <parameter>padChar</parameter> can
+ be a string; it is not limited to just being a single
+ character).</para>
+
+ <note>
+ <para>This function began as a copy of Nate Austin's
+ <function>prepend-pad</function> function in the <ulink
+ url="http://www.dpawson.co.uk/xsl/sect2/padding.html" >Padding
+ Content</ulink> section of Dave Pawson's <ulink
+ url="http://www.dpawson.co.uk/xsl/index.html" >XSLT
+ FAQ</ulink>.</para>
+ </note>
+ </refdescription>
+ <refreturn>
+ <para>Returns a (padded) string.</para></refreturn>
+</doc:template>
+
+<xsl:template name="pad-string">
+ <!-- * recursive template to right/left pad the value with -->
+ <!-- * whatever padChar is passed in -->
+ <xsl:param name="padChar" select="' '"/>
+ <xsl:param name="leftRight">left</xsl:param>
+ <xsl:param name="padVar"/>
+ <xsl:param name="length"/>
+ <xsl:choose>
+ <xsl:when test="string-length($padVar) < $length">
+ <xsl:call-template name="pad-string">
+ <xsl:with-param name="padChar" select="$padChar"/>
+ <xsl:with-param name="leftRight" select="$leftRight"/>
+ <xsl:with-param name="padVar">
+ <xsl:choose>
+ <!-- * determine whether string should be -->
+ <!-- * right- or left-padded -->
+ <xsl:when test="$leftRight = 'left'">
+ <!-- * pad it to left -->
+ <xsl:value-of select="concat($padChar,$padVar)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <!-- * otherwise, right-pad the string -->
+ <xsl:value-of select="concat($padVar,$padChar)"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:with-param>
+ <xsl:with-param name="length" select="$length"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of
+ select="substring($padVar,string-length($padVar) - $length + 1)"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
</xsl:stylesheet>
versions of the DocBook stylesheets.
******************************************************************** -->
+<xsl:import href="../common/common.xsl"/>
+
+<!-- * Get a title for current doc so that we let the user -->
+<!-- * know what document we are processing at this point. -->
+<xsl:variable name="doc.title">
+ <xsl:call-template name="get.doc.title"/>
+</xsl:variable>
+
<!-- put an xml:base attribute on the root element -->
<xsl:template match="/*" mode="stripNS">
<xsl:choose>
<xsl:value-of select="NodeInfo:systemId()"/>
</xsl:when>
<xsl:otherwise>
- <xsl:message>
- <xsl:text>WARNING: cannot add @xml:base to node </xsl:text>
- <xsl:text>set root element. </xsl:text>
- <xsl:text>Relative paths may not work.</xsl:text>
- </xsl:message>
+ <xsl:call-template name="log.message">
+ <xsl:with-param name="level">Warn</xsl:with-param>
+ <xsl:with-param name="source" select="$doc.title"/>
+ <xsl:with-param name="context-desc">
+ <xsl:text>no @xml:base</xsl:text>
+ </xsl:with-param>
+ <xsl:with-param name="message">
+ <xsl:text>cannot add @xml:base to node-set root element</xsl:text>
+ </xsl:with-param>
+ </xsl:call-template>
+ <xsl:call-template name="log.message">
+ <xsl:with-param name="level">Warn</xsl:with-param>
+ <xsl:with-param name="source" select="$doc.title"/>
+ <xsl:with-param name="context-desc">
+ <xsl:text>no @xml:base</xsl:text>
+ </xsl:with-param>
+ <xsl:with-param name="message">
+ <xsl:text>relative paths may not work</xsl:text>
+ </xsl:with-param>
+ </xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="root.elements" select="' appendix article bibliography book chapter colophon dedication glossary index part preface qandaset refentry reference sect1 section set setindex '"/>
<xsl:template match="/">
+ <!-- * Get a title for current doc so that we let the user -->
+ <!-- * know what document we are processing at this point. -->
+ <xsl:variable name="doc.title">
+ <xsl:call-template name="get.doc.title"/>
+ </xsl:variable>
<xsl:choose>
<!-- Hack! If someone hands us a DocBook V5.x or DocBook NG document,
toss the namespace and continue. Use the docbook5 namespaced
- stylesheets for DocBook5 if you don't want to use this feature.-->
+ stylesheets for DocBook5 if you don't want to use this feature.-->
<!-- include extra test for Xalan quirk -->
<xsl:when test="(function-available('exsl:node-set') or
contains(system-property('xsl:vendor'),
'Apache Software Foundation'))
and (*/self::ng:* or */self::db:*)">
- <xsl:message>Stripping namespace from DocBook 5 document.</xsl:message>
+ <xsl:call-template name="log.message">
+ <xsl:with-param name="level">Note</xsl:with-param>
+ <xsl:with-param name="source" select="$doc.title"/>
+ <xsl:with-param name="context-desc">
+ <xsl:text>namesp. cut</xsl:text>
+ </xsl:with-param>
+ <xsl:with-param name="message">
+ <xsl:text>stripped namespace before processing</xsl:text>
+ </xsl:with-param>
+ </xsl:call-template>
<xsl:variable name="nons">
<xsl:apply-templates mode="stripNS"/>
</xsl:variable>
+ <xsl:call-template name="log.message">
+ <xsl:with-param name="level">Note</xsl:with-param>
+ <xsl:with-param name="source" select="$doc.title"/>
+ <xsl:with-param name="context-desc">
+ <xsl:text>namesp. cut</xsl:text>
+ </xsl:with-param>
+ <xsl:with-param name="message">
+ <xsl:text>processing stripped document</xsl:text>
+ </xsl:with-param>
+ </xsl:call-template>
<xsl:apply-templates select="exsl:node-set($nons)"/>
</xsl:when>
<!-- Can't process unless namespace removed -->
</xsl:template>
<xsl:template match="/">
+ <!-- * Get a title for current doc so that we let the user -->
+ <!-- * know what document we are processing at this point. -->
+ <xsl:variable name="doc.title">
+ <xsl:call-template name="get.doc.title"/>
+ </xsl:variable>
<xsl:choose>
<!-- Hack! If someone hands us a DocBook V5.x or DocBook NG document,
toss the namespace and continue. Use the docbook5 namespaced
contains(system-property('xsl:vendor'),
'Apache Software Foundation'))
and (*/self::ng:* or */self::db:*)">
- <xsl:message>Stripping namespace from DocBook 5 document.</xsl:message>
+ <xsl:call-template name="log.message">
+ <xsl:with-param name="level">Note</xsl:with-param>
+ <xsl:with-param name="source" select="$doc.title"/>
+ <xsl:with-param name="context-desc">
+ <xsl:text>namesp. cut</xsl:text>
+ </xsl:with-param>
+ <xsl:with-param name="message">
+ <xsl:text>stripped namespace before processing</xsl:text>
+ </xsl:with-param>
+ </xsl:call-template>
<xsl:variable name="nons">
<xsl:apply-templates mode="stripNS"/>
</xsl:variable>
- <xsl:message>Processing stripped document.</xsl:message>
+ <xsl:call-template name="log.message">
+ <xsl:with-param name="level">Note</xsl:with-param>
+ <xsl:with-param name="source" select="$doc.title"/>
+ <xsl:with-param name="context-desc">
+ <xsl:text>namesp. cut</xsl:text>
+ </xsl:with-param>
+ <xsl:with-param name="message">
+ <xsl:text>processing stripped document</xsl:text>
+ </xsl:with-param>
+ </xsl:call-template>
<xsl:apply-templates select="exsl:node-set($nons)"/>
</xsl:when>
<!-- Can't process unless namespace removed -->
</xsl:template>
<xsl:template match="/">
+ <!-- * Get a title for current doc so that we let the user -->
+ <!-- * know what document we are processing at this point. -->
+ <xsl:variable name="doc.title">
+ <xsl:call-template name="get.doc.title"/>
+ </xsl:variable>
<xsl:choose>
<!-- Hack! If someone hands us a DocBook V5.x or DocBook NG document,
toss the namespace and continue. Use the docbook5 namespaced
- stylesheets for DocBook5 if you don't want to use this feature.-->
+ stylesheets for DocBook5 if you don't want to use this feature.-->
<!-- include extra test for Xalan quirk -->
<xsl:when test="(function-available('exsl:node-set') or
contains(system-property('xsl:vendor'),
'Apache Software Foundation'))
and (*/self::ng:* or */self::db:*)">
- <xsl:message>Stripping namespace from DocBook 5 document.</xsl:message>
+ <xsl:call-template name="log.message">
+ <xsl:with-param name="level">Note</xsl:with-param>
+ <xsl:with-param name="source" select="$doc.title"/>
+ <xsl:with-param name="context-desc">
+ <xsl:text>namesp. cut</xsl:text>
+ </xsl:with-param>
+ <xsl:with-param name="message">
+ <xsl:text>stripped namespace before processing</xsl:text>
+ </xsl:with-param>
+ </xsl:call-template>
<xsl:variable name="nons">
<xsl:apply-templates mode="stripNS"/>
</xsl:variable>
</xsl:with-param>
</xsl:call-template>
-->
- <xsl:message>Processing stripped document.</xsl:message>
+ <xsl:call-template name="log.message">
+ <xsl:with-param name="level">Note</xsl:with-param>
+ <xsl:with-param name="source" select="$doc.title"/>
+ <xsl:with-param name="context-desc">
+ <xsl:text>namesp. cut</xsl:text>
+ </xsl:with-param>
+ <xsl:with-param name="message">
+ <xsl:text>processing stripped document</xsl:text>
+ </xsl:with-param>
+ </xsl:call-template>
<xsl:apply-templates select="exsl:node-set($nons)"/>
</xsl:when>
<!-- Can't process unless namespace removed -->
<!-- ================================================================== -->
-<refentry id="pad-string">
-<refnamediv>
-<refname>pad-string</refname>
-<refpurpose>Right-pad or left-pad a string out to a certain length</refpurpose>
-</refnamediv>
-
-<refsect1><title>Description</title>
-
-<para>This function takes string <parameter>padVar</parameter> and
- pads it out in the direction <parameter>rightLeft</parameter> to
- the string-length <parameter>length</parameter>, using string
- <parameter>padChar</parameter> (a space character by default) as
- the padding string (note that <parameter>padChar</parameter> can
- be a string; it is not limited to just being a single
- character).</para>
-
- <note>
- <para>This function began as a copy of Nate Austin's
- <function>prepend-pad</function> function in the <ulink
- url="http://www.dpawson.co.uk/xsl/sect2/padding.html" >Padding
- Content</ulink> section of Dave Pawson's <ulink
- url="http://www.dpawson.co.uk/xsl/index.html" >XSLT
- FAQ</ulink>.</para>
- </note>
-
-<programlisting><src:fragment id='pad-string.frag'>
- <xsl:template name="pad-string">
- <!-- * recursive template to right/left pad the value with -->
- <!-- * whatever padChar is passed in -->
- <xsl:param name="padChar" select="' '"/>
- <xsl:param name="leftRight">left</xsl:param>
- <xsl:param name="padVar"/>
- <xsl:param name="length"/>
- <xsl:choose>
- <xsl:when test="string-length($padVar) < $length">
- <xsl:call-template name="pad-string">
- <xsl:with-param name="padChar" select="$padChar"/>
- <xsl:with-param name="leftRight" select="$leftRight"/>
- <xsl:with-param name="padVar">
- <xsl:choose>
- <!-- * determine whether string should be -->
- <!-- * right- or left-padded -->
- <xsl:when test="$leftRight = 'left'">
- <!-- * pad it to left -->
- <xsl:value-of select="concat($padChar,$padVar)"/>
- </xsl:when>
- <xsl:otherwise>
- <!-- * otherwise, right-pad the string -->
- <xsl:value-of select="concat($padVar,$padChar)"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:with-param>
- <xsl:with-param name="length" select="$length"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of
- select="substring($padVar,string-length($padVar) - $length + 1)"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-</src:fragment></programlisting>
-
-</refsect1>
-</refentry>
-
-<!-- ================================================================== -->
-
<refentry id="trim.text">
<refnamediv>
<refname>trim.text</refname>
<src:fragref linkend="xpath.location.frag"/>
<src:fragref linkend="comment-escape-string.frag"/>
<src:fragref linkend="comment-escape-string.recursive.frag"/>
-<src:fragref linkend="pad-string.frag"/>
<src:fragref linkend="str.tokenize.keep.delimiters.frag"/>
<src:fragref linkend="apply-string-subst-map.frag"/>
<src:fragref linkend="apply-character-map.frag"/>
<xslo:variable name="profiled-content">
<xslo:choose>
<xslo:when test="*/self::ng:* or */self::db:*">
- <xslo:message>Stripping NS from DocBook 5/NG document.</xslo:message>
- <xslo:variable name="stripped-content">
- <xslo:apply-templates select="/" mode="stripNS"/>
- </xslo:variable>
- <xslo:message>Processing stripped document.</xslo:message>
- <xslo:apply-templates select="exslt:node-set($stripped-content)" mode="profile"/>
+ <xslo:message>Note: namesp. cut : stripped namespace before processing</xslo:message>
+ <xslo:variable name="stripped-content">
+ <xslo:apply-templates select="/" mode="stripNS"/>
+ </xslo:variable>
+ <xslo:message>Note: namesp. cut : processing stripped document</xslo:message>
+ <xslo:apply-templates select="exslt:node-set($stripped-content)" mode="profile"/>
</xslo:when>
<xslo:otherwise>
- <xslo:apply-templates select="/" mode="profile"/>
+ <xslo:apply-templates select="/" mode="profile"/>
</xslo:otherwise>
</xslo:choose>
</xslo:variable>