]> granicus.if.org Git - docbook-dsssl/commitdiff
Added check to have the manpages stylesheet log/emit an error
authorMichael Smith <xmldoc@users.sourceforge.net>
Sat, 23 Jun 2007 09:08:06 +0000 (09:08 +0000)
committerMichael Smith <xmldoc@users.sourceforge.net>
Sat, 23 Jun 2007 09:08:06 +0000 (09:08 +0000)
message if it is given a namespaced DocBook document, with
instructions to instead either use the docbook5-xsl stylesheets to
directly process the document, or to use the stripns.xsl
stylesheet to pre-process it.

xsl/manpages/docbook.xsl
xsl/manpages/other.xsl

index 3ec2c34d60e504d8c6e1c1064b5137a2ea191bd7..95c8e3a923852ba8ad56f979bace4b57bf634845 100644 (file)
   <!-- ==================================================================== -->
 
   <xsl:template match="/">
-        <xsl:choose>
-          <xsl:when test="//refentry">
-            <!-- * Check to see if we have any refentry children in this -->
-            <!-- * document; if so, process them. -->
-            <xsl:apply-templates select="//refentry"/>
-            <!-- * if $man.output.manifest.enabled is non-zero, -->
-            <!-- * generate a manifest file -->
-            <xsl:if test="not($man.output.manifest.enabled = 0)">
-              <xsl:call-template name="generate.manifest">
-                <xsl:with-param name="filename">
-                  <xsl:choose>
-                    <xsl:when test="not($man.output.manifest.filename = '')">
-                      <!-- * If a name for the manifest file is specified, -->
-                      <!-- * use that name. -->
-                      <xsl:value-of select="$man.output.manifest.filename"/>
-                    </xsl:when>
-                    <xsl:otherwise>
-                      <!-- * Otherwise, if user has unset -->
-                      <!-- * $man.output.manifest.filename, default to -->
-                      <!-- * using "MAN.MANIFEST" as the filename. Because -->
-                      <!-- * $man.output.manifest.enabled is non-zero and -->
-                      <!-- * so we must have a filename in order to -->
-                      <!-- * generate the manifest. -->
-                      <xsl:text>MAN.MANIFEST</xsl:text>
-                    </xsl:otherwise>
-                  </xsl:choose>
-                </xsl:with-param>
-              </xsl:call-template>
-            </xsl:if>
-          </xsl:when>
-          <xsl:otherwise>
-            <!-- * Otherwise, the document does not contain any -->
-            <!-- * refentry elements, so emit message and stop. -->
-            <xsl:variable name="title">
-              <!-- * Get a title so that we let the user know what -->
-              <!-- * document we are processing at this point. -->
+    <xsl:variable name="title">
+      <!-- * Get a title so that we let the user know what -->
+      <!-- * document we are processing at this point. -->
+      <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:variable>
+    <xsl:choose>
+      <xsl:when test="(//self::ng:* or //self::db:*) and $DistroName = 'docbook-xsl'">
+        <xsl:call-template name="log.message">
+          <xsl:with-param name="level">Erro</xsl:with-param>
+          <xsl:with-param name="source" select="$title"/>
+          <xsl:with-param name="context-desc">
+            <xsl:text>   namespace</xsl:text>
+          </xsl:with-param>
+          <xsl:with-param name="message">
+            <xsl:text>Can't process namespaced DocBook document.</xsl:text>
+          </xsl:with-param>
+        </xsl:call-template>
+        <xsl:message>
+          <xsl:text>  To create man-page output from a namespaced DocBook document</xsl:text>
+          <xsl:text>&#10;</xsl:text>
+          <xsl:text>  (DocBook 5 or later), you must either use the docbook5-xsl</xsl:text>
+          <xsl:text>&#10;</xsl:text>
+          <xsl:text>  stylesheets:</xsl:text>
+          <xsl:text>&#10;</xsl:text>
+          <xsl:text>&#10;</xsl:text>
+          <xsl:text>    http://docbook.sf.net/files/docbook5-xsl/latest</xsl:text>
+          <xsl:text>&#10;</xsl:text>
+          <xsl:text>&#10;</xsl:text>
+          <xsl:text>  Or you must first pre-process your document with the</xsl:text>
+          <xsl:text>&#10;</xsl:text>
+          <xsl:text>  stripns.xsl stylesheet to strip the namespace. You can strip</xsl:text>
+          <xsl:text>&#10;</xsl:text>
+          <xsl:text>  the namespace and convert the document to man-page output in</xsl:text>
+          <xsl:text>&#10;</xsl:text>
+          <xsl:text>  one pass using a pipe; for example:</xsl:text>
+          <xsl:text>&#10;</xsl:text>
+          <xsl:text>&#10;</xsl:text>
+          <xsl:text>  xsltproc \</xsl:text>
+          <xsl:text>&#10;</xsl:text>
+          <xsl:text>   http://docbook.sf.net/release/xsl/current/common/stripns.xsl \</xsl:text>
+          <xsl:text>&#10;</xsl:text>
+          <xsl:text>   </xsl:text>
+          <xsl:value-of select="$title"/>
+          <xsl:text>.xml \</xsl:text>
+          <xsl:text>&#10;</xsl:text>
+          <xsl:text>   | xsltproc \</xsl:text>
+          <xsl:text>&#10;</xsl:text>
+          <xsl:text>   http://docbook.sf.net/release/xsl/current/manpages/docbook.xsl -</xsl:text>
+        </xsl:message>
+      </xsl:when>
+      <xsl:when test="//refentry">
+        <!-- * Check to see if we have any refentry children in this -->
+        <!-- * document; if so, process them. -->
+        <xsl:apply-templates select="//refentry"/>
+        <!-- * if $man.output.manifest.enabled is non-zero, -->
+        <!-- * generate a manifest file -->
+        <xsl:if test="not($man.output.manifest.enabled = 0)">
+          <xsl:call-template name="generate.manifest">
+            <xsl:with-param name="filename">
               <xsl:choose>
-                <xsl:when test="title">
-                  <xsl:value-of select="title[1]"/>
+                <xsl:when test="not($man.output.manifest.filename = '')">
+                  <!-- * If a name for the manifest file is specified, -->
+                  <!-- * use that name. -->
+                  <xsl:value-of select="$man.output.manifest.filename"/>
                 </xsl:when>
-                <xsl:when test="substring(local-name(*[1]),
-                                string-length(local-name(*[1])-3) = 'info')
-                                and *[1]/title">
-                  <xsl:value-of select="*[1]/title[1]"/>
+                <xsl:otherwise>
+                  <!-- * Otherwise, if user has unset -->
+                  <!-- * $man.output.manifest.filename, default to -->
+                  <!-- * using "MAN.MANIFEST" as the filename. Because -->
+                  <!-- * $man.output.manifest.enabled is non-zero and -->
+                  <!-- * so we must have a filename in order to -->
+                  <!-- * generate the manifest. -->
+                  <xsl:text>MAN.MANIFEST</xsl:text>
+                </xsl:otherwise>
+              </xsl:choose>
+            </xsl:with-param>
+          </xsl:call-template>
+        </xsl:if>
+      </xsl:when>
+      <xsl:otherwise>
+        <!-- * Otherwise, the document does not contain any -->
+        <!-- * refentry elements, so log/emit message and stop. -->
+        <xsl:call-template name="log.message">
+          <xsl:with-param name="level">Erro</xsl:with-param>
+          <xsl:with-param name="source" select="$title"/>
+          <xsl:with-param name="context-desc">
+            <xsl:text> no refentry</xsl:text>
+          </xsl:with-param>
+          <xsl:with-param name="message">
+            <xsl:text>No refentry elements found</xsl:text>
+            <xsl:if test="$title != ''">
+            <xsl:text> in "</xsl:text>
+              <xsl:choose>
+                <xsl:when test="string-length($title) &gt; 30">
+                  <xsl:value-of select="substring($title,1,30)"/>
+                  <xsl:text>...</xsl:text>
                 </xsl:when>
+                <xsl:otherwise>
+                  <xsl:value-of select="$title"/>
+                </xsl:otherwise>
               </xsl:choose>
-            </xsl:variable>
-            <xsl:message>
-              <xsl:text>Note: No refentry elements found in "</xsl:text>
-              <xsl:value-of select="local-name(.)"/>
-              <xsl:if test="$title != ''">
-                <xsl:choose>
-                  <xsl:when test="string-length($title) &gt; 30">
-                    <xsl:value-of select="substring($title,1,30)"/>
-                    <xsl:text>...</xsl:text>
-                  </xsl:when>
-                  <xsl:otherwise>
-                    <xsl:value-of select="$title"/>
-                  </xsl:otherwise>
-                </xsl:choose>
-              </xsl:if>
               <xsl:text>"</xsl:text>
-            </xsl:message>
-          </xsl:otherwise>
-        </xsl:choose>
+            </xsl:if>
+            <xsl:text>.</xsl:text>
+          </xsl:with-param>
+        </xsl:call-template>
+      </xsl:otherwise>
+    </xsl:choose>
   </xsl:template>
 
   <!-- ============================================================== -->
index f59a2c6467a4dc3dbc1a41b0ffb283e124158f98..c2c349b1d72ee89a7185beb084866ded5def5fad 100644 (file)
@@ -1,6 +1,7 @@
 <?xml version='1.0'?>
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                 xmlns:exsl="http://exslt.org/common"
+                xmlns:ng="http://docbook.org/docbook-ng"
                 xmlns:db="http://docbook.org/ns/docbook"
                 exclude-result-prefixes="exsl"
                 version='1.0'>
@@ -155,6 +156,7 @@ db:manvolnum
       <xsl:with-param name="source" select="$refname"/>
       <xsl:with-param name="context-desc">
         <xsl:text>limitation</xsl:text>
+      </xsl:with-param>
       <xsl:with-param name="message">
         <xsl:text>Output for foo element is not yet supported.</xsl:text>
       </xsl:with-param>