]> granicus.if.org Git - docbook-dsssl/commitdiff
Updated stylesheets to use common logging template to log messages
authorMichael Smith <xmldoc@users.sourceforge.net>
Mon, 25 Jun 2007 04:36:37 +0000 (04:36 +0000)
committerMichael Smith <xmldoc@users.sourceforge.net>
Mon, 25 Jun 2007 04:36:37 +0000 (04:36 +0000)
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...)

xsl/common/common.xsl
xsl/common/stripns.xsl
xsl/fo/docbook.xsl
xsl/html/chunk-code.xsl
xsl/html/docbook.xsl
xsl/lib/lib.xweb
xsl/profiling/xsl2profile.xsl

index 55ed906d51fef18bb702e6bf38381221530934ab..fd95fcca015cdf344e400d5bc77624603544d45b 100644 (file)
@@ -1836,7 +1836,6 @@ unchanged.</para>
 </variablelist>
 </refparameter>
 </doc:template>
-
 <xsl:template name="string.upper">
   <xsl:param name="string" select="''"/>
   <xsl:variable name="lowercase.alpha">
@@ -1878,7 +1877,6 @@ unchanged.</para>
 </variablelist>
 </refparameter>
 </doc:template>
-
 <xsl:template name="string.lower">
   <xsl:param name="string" select="''"/>
   <xsl:variable name="uppercase.alpha">
@@ -1936,7 +1934,6 @@ unchanged.</para>
     </warning>
   </refdescription>
 </doc:template>
-
 <xsl:template name="select.choice.separator">
   
   <xsl:variable name="choice">
@@ -2002,7 +1999,6 @@ unchanged.</para>
     <parameter>profile</parameter> parameter)</para>
   </refreturn>
 </doc:template>
-
   <xsl:template name="evaluate.info.profile">
     <xsl:param name="profile"/>
     <xsl:param name="info"/>
@@ -2118,7 +2114,6 @@ engine does not support it.
   <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"/>
@@ -2190,4 +2185,92 @@ engine does not support it.
   </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) &lt; $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>
index 18d18441a96b9b99ee216a73e4e96307e44f31e7..ad3d4f5db5c9e333af633758d59e86152a6f6fe3 100644 (file)
      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>
index b1f9bbfaf1ee190d1d905b3c80964ae4f9b14abb..553329136dfc661ea6208d5d873fec85f9c0e6a7 100644 (file)
 <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 -->
index cd853e20a055b4997dda9f84bab943100e862fc9..a6f7a70f40e1d6096ab9754a52a15fe0e1ecefdf 100644 (file)
 </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 -->
index d438c40e6c76da4d05a10cb59eb9f415ff1271f6..87c7c958724f3ea5f1a64dbf1182e821951c8034 100644 (file)
@@ -326,16 +326,30 @@ body { background-image: url('</xsl:text>
 </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>
@@ -349,7 +363,16 @@ body { background-image: url('</xsl:text>
         </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 -->
index b821265dd1245b4b939fbe8e2f0288ecd83be6eb..f53a373aa83c52cec130cf0b77542c2d6a048acc 100644 (file)
@@ -633,74 +633,6 @@ by <function>comment-escape-string</function>.</para>
 
 <!-- ================================================================== -->
 
-<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) &lt; $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>
@@ -1248,7 +1180,6 @@ around these functions.</para>
 <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"/>
index a8e2eafcbd33fd64a28451b130c97a91bce7f653..2c69596ce86a121769648c0c2586760e5ab678d8 100644 (file)
   <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>