]> granicus.if.org Git - docbook-dsssl/commitdiff
Terminate with message if processing DB5 and cannot strip the namespace.
authorBob Stayton <bobs@sagehill.net>
Mon, 9 Oct 2006 07:35:16 +0000 (07:35 +0000)
committerBob Stayton <bobs@sagehill.net>
Mon, 9 Oct 2006 07:35:16 +0000 (07:35 +0000)
xsl/fo/docbook.xsl
xsl/html/chunk-code.xsl
xsl/html/docbook.xsl

index c6d094d98fa4659c963e220437293a3c471a41a3..217f1e71cb213be0c6453e13bfa83f610c31d25c 100644 (file)
@@ -2,8 +2,8 @@
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                 xmlns:exsl="http://exslt.org/common"
                 xmlns:fo="http://www.w3.org/1999/XSL/Format"
-               xmlns:ng="http://docbook.org/docbook-ng"
-               xmlns:db="http://docbook.org/ns/docbook"
+                xmlns:ng="http://docbook.org/docbook-ng"
+                xmlns:db="http://docbook.org/ns/docbook"
                 exclude-result-prefixes="db ng exsl"
                 version='1.0'>
 
                        'Apache Software Foundation'))
                     and (*/self::ng:* or */self::db:*)">
       <!-- Hack! If someone hands us a DocBook V5.x or DocBook NG document,
-          toss the namespace and continue. Someday we'll reverse this logic
-          and add the namespace to documents that don't have one.
-          But not before the whole stylesheet has been converted to use
-          namespaces. i.e., don't hold your breath -->
+           toss the namespace and continue. Someday we'll reverse this logic
+           and add the namespace to documents that don't have one.
+           But not before the whole stylesheet has been converted to use
+           namespaces. i.e., don't hold your breath -->
       <xsl:message>Stripping namespace from DocBook 5 document.</xsl:message>
       <xsl:variable name="nons">
         <xsl:apply-templates mode="stripNS"/>
       </xsl:variable>
       <xsl:apply-templates select="exsl:node-set($nons)"/>
     </xsl:when>
+    <!-- Can't process unless namespace removed -->
+    <xsl:when test="*/self::ng:* or */self::db:*">
+      <xsl:message terminate="yes">
+        <xsl:text>Unable to strip the namespace from DB5 document,</xsl:text>
+        <xsl:text> cannot proceed.</xsl:text>
+      </xsl:message>
+    </xsl:when>
     <xsl:otherwise>
       <xsl:choose>
         <xsl:when test="$rootid != ''">
     <xsl:if test="$fop1.extensions != 0">
       <xsl:variable name="bookmarks">
         <xsl:apply-templates select="$document.element" 
-                            mode="fop1.outline"/>
+                             mode="fop1.outline"/>
       </xsl:variable>
       <xsl:if test="string($bookmarks) != ''">
         <fo:bookmark-tree>
           <xsl:copy-of select="$bookmarks"/>
-       </fo:bookmark-tree>
+        </fo:bookmark-tree>
       </xsl:if>
     </xsl:if>
 
 
     <xsl:if test="$arbortext.extensions != 0 and $ati.xsl11.bookmarks != 0">
       <xsl:variable name="bookmarks">
-       <xsl:apply-templates select="$document.element"
-                            mode="ati.xsl11.bookmarks"/>
+        <xsl:apply-templates select="$document.element"
+                             mode="ati.xsl11.bookmarks"/>
       </xsl:variable>
       <xsl:if test="string($bookmarks) != ''">
-       <fo:bookmark-tree>
-         <xsl:copy-of select="$bookmarks"/>
-       </fo:bookmark-tree>
+        <fo:bookmark-tree>
+          <xsl:copy-of select="$bookmarks"/>
+        </fo:bookmark-tree>
       </xsl:if>
     </xsl:if>
 
index 6134d4e4d88e86132643d2dba60f450f15732b5f..28f416cad2701b6b8ed1fe23af917f2e2c4b89ad 100644 (file)
@@ -1,8 +1,8 @@
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                 xmlns:exsl="http://exslt.org/common"
                 xmlns:cf="http://docbook.sourceforge.net/xmlns/chunkfast/1.0"
-               xmlns:ng="http://docbook.org/docbook-ng"
-               xmlns:db="http://docbook.org/ns/docbook"
+                xmlns:ng="http://docbook.org/docbook-ng"
+                xmlns:db="http://docbook.org/ns/docbook"
                 version="1.0"
                 exclude-result-prefixes="exsl cf ng db">
 
              |preceding::bibliography[parent::article or parent::book or parent::part][1]
              |preceding::glossary[parent::article or parent::book or parent::part][1]
              |preceding::index[$generate.index != 0]
-                              [parent::article or parent::book or parent::part][1]
+                               [parent::article or parent::book or parent::part][1]
              |preceding::setindex[$generate.index != 0][1]
              |ancestor::set
              |ancestor::book[1]
              |following::bibliography[parent::article or parent::book or parent::part][1]
              |following::glossary[parent::article or parent::book or parent::part][1]
              |following::index[$generate.index != 0]
-                              [parent::article or parent::book or parent::part][1]
+                               [parent::article or parent::book or parent::part][1]
              |following::article[1]
              |following::setindex[$generate.index != 0][1]
              |descendant::book[1]
              |descendant::bibliography[parent::article or parent::book or parent::part][1]
              |descendant::glossary[parent::article or parent::book or parent::part][1]
              |descendant::index[$generate.index != 0]
-                              [parent::article or parent::book or parent::part][1]
+                               [parent::article or parent::book or parent::part][1]
              |descendant::colophon[1]
              |descendant::setindex[$generate.index != 0][1]
              |descendant::part[1]
              |preceding::bibliography[parent::article or parent::book or parent::part][1]
              |preceding::glossary[parent::article or parent::book or parent::part][1]
              |preceding::index[$generate.index != 0]
-                              [parent::article or parent::book or parent::part][1]
+                               [parent::article or parent::book or parent::part][1]
              |preceding::setindex[$generate.index != 0][1]
              |ancestor::set
              |ancestor::book[1]
              |following::bibliography[parent::article or parent::book or parent::part][1]
              |following::glossary[parent::article or parent::book or parent::part][1]
              |following::index[$generate.index != 0]
-                              [parent::article or parent::book][1]
+                               [parent::article or parent::book][1]
              |following::article[1]
              |following::setindex[$generate.index != 0][1]
              |descendant::book[1]
              |descendant::bibliography[parent::article or parent::book][1]
              |descendant::glossary[parent::article or parent::book or parent::part][1]
              |descendant::index[$generate.index != 0]
-                              [parent::article or parent::book][1]
+                               [parent::article or parent::book][1]
              |descendant::colophon[1]
              |descendant::setindex[$generate.index != 0][1]
              |descendant::part[1]
                        'Apache Software Foundation'))
                     and (*/self::ng:* or */self::db:*)">
       <!-- Hack! If someone hands us a DocBook V5.x or DocBook NG document,
-          toss the namespace and continue. Someday we'll reverse this logic
-          and add the namespace to documents that don't have one.
-          But not before the whole stylesheet has been converted to use
-          namespaces. i.e., don't hold your breath -->
+           toss the namespace and continue. Someday we'll reverse this logic
+           and add the namespace to documents that don't have one.
+           But not before the whole stylesheet has been converted to use
+           namespaces. i.e., don't hold your breath -->
       <xsl:message>Stripping namespace from DocBook 5 document.</xsl:message>
       <xsl:variable name="nons">
-       <xsl:apply-templates mode="stripNS"/>
+        <xsl:apply-templates mode="stripNS"/>
       </xsl:variable>
       <xsl:message>Processing stripped document.</xsl:message>
       <xsl:apply-templates select="exsl:node-set($nons)"/>
     </xsl:when>
+    <!-- Can't process unless namespace removed -->
+    <xsl:when test="*/self::ng:* or */self::db:*">
+      <xsl:message terminate="yes">
+        <xsl:text>Unable to strip the namespace from DB5 document,</xsl:text>
+        <xsl:text> cannot proceed.</xsl:text>
+      </xsl:message>
+    </xsl:when>
     <xsl:otherwise>
       <xsl:choose>
-       <xsl:when test="$rootid != ''">
-         <xsl:choose>
-           <xsl:when test="count(key('id',$rootid)) = 0">
-             <xsl:message terminate="yes">
-               <xsl:text>ID '</xsl:text>
-               <xsl:value-of select="$rootid"/>
-               <xsl:text>' not found in document.</xsl:text>
-             </xsl:message>
-           </xsl:when>
-           <xsl:otherwise>
-             <xsl:if test="$collect.xref.targets = 'yes' or
-                           $collect.xref.targets = 'only'">
-               <xsl:apply-templates select="key('id', $rootid)"
-                                    mode="collect.targets"/>
-             </xsl:if>
-             <xsl:if test="$collect.xref.targets != 'only'">
-               <xsl:apply-templates select="key('id',$rootid)"
-                                    mode="process.root"/>
-               <xsl:if test="$tex.math.in.alt != ''">
-                 <xsl:apply-templates select="key('id',$rootid)"
-                                      mode="collect.tex.math"/>
-               </xsl:if>
-               <xsl:if test="$generate.manifest != 0">
-                 <xsl:call-template name="generate.manifest">
-                   <xsl:with-param name="node" select="key('id',$rootid)"/>
-                 </xsl:call-template>
-               </xsl:if>
-             </xsl:if>
-           </xsl:otherwise>
-         </xsl:choose>
-       </xsl:when>
-       <xsl:otherwise>
-         <xsl:if test="$collect.xref.targets = 'yes' or
-                       $collect.xref.targets = 'only'">
-           <xsl:apply-templates select="/" mode="collect.targets"/>
-         </xsl:if>
-         <xsl:if test="$collect.xref.targets != 'only'">
-           <xsl:apply-templates select="/" mode="process.root"/>
-           <xsl:if test="$tex.math.in.alt != ''">
-             <xsl:apply-templates select="/" mode="collect.tex.math"/>
-           </xsl:if>
-           <xsl:if test="$generate.manifest != 0">
-             <xsl:call-template name="generate.manifest">
-               <xsl:with-param name="node" select="/"/>
-             </xsl:call-template>
-           </xsl:if>
-         </xsl:if>
-       </xsl:otherwise>
+        <xsl:when test="$rootid != ''">
+          <xsl:choose>
+            <xsl:when test="count(key('id',$rootid)) = 0">
+              <xsl:message terminate="yes">
+                <xsl:text>ID '</xsl:text>
+                <xsl:value-of select="$rootid"/>
+                <xsl:text>' not found in document.</xsl:text>
+              </xsl:message>
+            </xsl:when>
+            <xsl:otherwise>
+              <xsl:if test="$collect.xref.targets = 'yes' or
+                            $collect.xref.targets = 'only'">
+                <xsl:apply-templates select="key('id', $rootid)"
+                                     mode="collect.targets"/>
+              </xsl:if>
+              <xsl:if test="$collect.xref.targets != 'only'">
+                <xsl:apply-templates select="key('id',$rootid)"
+                                     mode="process.root"/>
+                <xsl:if test="$tex.math.in.alt != ''">
+                  <xsl:apply-templates select="key('id',$rootid)"
+                                       mode="collect.tex.math"/>
+                </xsl:if>
+                <xsl:if test="$generate.manifest != 0">
+                  <xsl:call-template name="generate.manifest">
+                    <xsl:with-param name="node" select="key('id',$rootid)"/>
+                  </xsl:call-template>
+                </xsl:if>
+              </xsl:if>
+            </xsl:otherwise>
+          </xsl:choose>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:if test="$collect.xref.targets = 'yes' or
+                        $collect.xref.targets = 'only'">
+            <xsl:apply-templates select="/" mode="collect.targets"/>
+          </xsl:if>
+          <xsl:if test="$collect.xref.targets != 'only'">
+            <xsl:apply-templates select="/" mode="process.root"/>
+            <xsl:if test="$tex.math.in.alt != ''">
+              <xsl:apply-templates select="/" mode="collect.tex.math"/>
+            </xsl:if>
+            <xsl:if test="$generate.manifest != 0">
+              <xsl:call-template name="generate.manifest">
+                <xsl:with-param name="node" select="/"/>
+              </xsl:call-template>
+            </xsl:if>
+          </xsl:if>
+        </xsl:otherwise>
       </xsl:choose>
     </xsl:otherwise>
   </xsl:choose>
               <xsl:with-param name="next" select="/foo"/>
               <xsl:with-param name="nav.context" select="'toc'"/>
               <xsl:with-param name="content">
-               <xsl:if test="$chunk.tocs.and.lots.has.title != 0">
-                 <h1>
-                   <xsl:apply-templates select="." mode="object.title.markup"/>
-                 </h1>
-               </xsl:if>
+                <xsl:if test="$chunk.tocs.and.lots.has.title != 0">
+                  <h1>
+                    <xsl:apply-templates select="." mode="object.title.markup"/>
+                  </h1>
+                </xsl:if>
                 <xsl:copy-of select="$lots"/>
               </xsl:with-param>
             </xsl:call-template>
 
   <!-- FIXME: When chunking, only the annotations actually used
               in this chunk should be referenced. I don't think it
-             does any harm to reference them all, but it adds
-             unnecessary bloat to each chunk. -->
+              does any harm to reference them all, but it adds
+              unnecessary bloat to each chunk. -->
   <xsl:if test="$annotation.support != 0 and //annotation">
     <div class="annotation-list">
       <div class="annotation-nocss">
-       <p>The following annotations are from this essay. You are seeing
-       them here because your browser doesn’t support the user-interface
-       techniques used to make them appear as ‘popups’ on modern browsers.</p>
+        <p>The following annotations are from this essay. You are seeing
+        them here because your browser doesn’t support the user-interface
+        techniques used to make them appear as ‘popups’ on modern browsers.</p>
       </div>
 
       <xsl:apply-templates select="//annotation"
-                          mode="annotation-popup"/>
+                           mode="annotation-popup"/>
     </div>
   </xsl:if>
 </xsl:template>
index de85f17dcb173d405a6ba497fe8f2138208fa84d..e0f9bd4a9070600fc5a70bbeddb7279083dcdad6 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version='1.0'?>
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-               xmlns:ng="http://docbook.org/docbook-ng"
-               xmlns:db="http://docbook.org/ns/docbook"
+                xmlns:ng="http://docbook.org/docbook-ng"
+                xmlns:db="http://docbook.org/ns/docbook"
                 xmlns:exsl="http://exslt.org/common"
                 exclude-result-prefixes="db ng exsl"
                 version='1.0'>
@@ -266,24 +266,24 @@ body { background-image: url('</xsl:text>
 
   <!-- FIXME: When chunking, only the annotations actually used
               in this chunk should be referenced. I don't think it
-             does any harm to reference them all, but it adds
-             unnecessary bloat to each chunk. -->
+              does any harm to reference them all, but it adds
+              unnecessary bloat to each chunk. -->
   <xsl:if test="$annotation.support != 0 and //annotation">
     <xsl:call-template name="add.annotation.links"/>
     <script type="text/javascript">
       <xsl:text>&#10;// Create PopupWindow objects</xsl:text>
       <xsl:for-each select="//annotation">
-       <xsl:text>&#10;var popup_</xsl:text>
-       <xsl:value-of select="generate-id(.)"/>
-       <xsl:text> = new PopupWindow("popup-</xsl:text>
-       <xsl:value-of select="generate-id(.)"/>
-       <xsl:text>");&#10;</xsl:text>
-       <xsl:text>popup_</xsl:text>
-       <xsl:value-of select="generate-id(.)"/>
-       <xsl:text>.offsetY = 15;&#10;</xsl:text>
-       <xsl:text>popup_</xsl:text>
-       <xsl:value-of select="generate-id(.)"/>
-       <xsl:text>.autoHide();&#10;</xsl:text>
+        <xsl:text>&#10;var popup_</xsl:text>
+        <xsl:value-of select="generate-id(.)"/>
+        <xsl:text> = new PopupWindow("popup-</xsl:text>
+        <xsl:value-of select="generate-id(.)"/>
+        <xsl:text>");&#10;</xsl:text>
+        <xsl:text>popup_</xsl:text>
+        <xsl:value-of select="generate-id(.)"/>
+        <xsl:text>.offsetY = 15;&#10;</xsl:text>
+        <xsl:text>popup_</xsl:text>
+        <xsl:value-of select="generate-id(.)"/>
+        <xsl:text>.autoHide();&#10;</xsl:text>
       </xsl:for-each>
     </script>
 
@@ -333,67 +333,74 @@ body { background-image: url('</xsl:text>
                        'Apache Software Foundation'))
                     and (*/self::ng:* or */self::db:*)">
       <!-- Hack! If someone hands us a DocBook V5.x or DocBook NG document,
-          toss the namespace and continue. Someday we'll reverse this logic
-          and add the namespace to documents that don't have one.
-          But not before the whole stylesheet has been converted to use
-          namespaces. i.e., don't hold your breath -->
+           toss the namespace and continue. Someday we'll reverse this logic
+           and add the namespace to documents that don't have one.
+           But not before the whole stylesheet has been converted to use
+           namespaces. i.e., don't hold your breath -->
       <xsl:message>Stripping namespace from DocBook 5 document.</xsl:message>
       <xsl:variable name="nons">
-       <xsl:apply-templates mode="stripNS"/>
+        <xsl:apply-templates mode="stripNS"/>
       </xsl:variable>
       <!--
       <xsl:message>Saving stripped document.</xsl:message>
       <xsl:call-template name="write.chunk">
-       <xsl:with-param name="filename" select="'/tmp/stripped.xml'"/>
-       <xsl:with-param name="method" select="'xml'"/>
-       <xsl:with-param name="content">
-         <xsl:copy-of select="exsl:node-set($nons)"/>
-       </xsl:with-param>
+        <xsl:with-param name="filename" select="'/tmp/stripped.xml'"/>
+        <xsl:with-param name="method" select="'xml'"/>
+        <xsl:with-param name="content">
+          <xsl:copy-of select="exsl:node-set($nons)"/>
+        </xsl:with-param>
       </xsl:call-template>
       -->
       <xsl:message>Processing stripped document.</xsl:message>
       <xsl:apply-templates select="exsl:node-set($nons)"/>
     </xsl:when>
+    <!-- Can't process unless namespace removed -->
+    <xsl:when test="*/self::ng:* or */self::db:*">
+      <xsl:message terminate="yes">
+        <xsl:text>Unable to strip the namespace from DB5 document,</xsl:text>
+        <xsl:text> cannot proceed.</xsl:text>
+      </xsl:message>
+    </xsl:when>
     <xsl:otherwise>
       <xsl:choose>
-       <xsl:when test="$rootid != ''">
-         <xsl:choose>
-           <xsl:when test="count(key('id',$rootid)) = 0">
-             <xsl:message terminate="yes">
-               <xsl:text>ID '</xsl:text>
-               <xsl:value-of select="$rootid"/>
-               <xsl:text>' not found in document.</xsl:text>
-             </xsl:message>
-           </xsl:when>
-           <xsl:otherwise>
-             <xsl:if test="$collect.xref.targets = 'yes' or
-                           $collect.xref.targets = 'only'">
-               <xsl:apply-templates select="key('id', $rootid)"
-                                    mode="collect.targets"/>
-             </xsl:if>
-             <xsl:if test="$collect.xref.targets != 'only'">
-               <xsl:apply-templates select="key('id',$rootid)"
-                                    mode="process.root"/>
-               <xsl:if test="$tex.math.in.alt != ''">
-                 <xsl:apply-templates select="key('id',$rootid)"
-                                      mode="collect.tex.math"/>
-               </xsl:if>
-             </xsl:if>
-           </xsl:otherwise>
-         </xsl:choose>
-       </xsl:when>
-       <xsl:otherwise>
-         <xsl:if test="$collect.xref.targets = 'yes' or
-                       $collect.xref.targets = 'only'">
-           <xsl:apply-templates select="/" mode="collect.targets"/>
-         </xsl:if>
-         <xsl:if test="$collect.xref.targets != 'only'">
-           <xsl:apply-templates select="/" mode="process.root"/>
-           <xsl:if test="$tex.math.in.alt != ''">
-             <xsl:apply-templates select="/" mode="collect.tex.math"/>
-           </xsl:if>
-         </xsl:if>
-       </xsl:otherwise>
+        <xsl:when test="$rootid != ''">
+          <xsl:choose>
+            <xsl:when test="count(key('id',$rootid)) = 0">
+              <xsl:message terminate="yes">
+                <xsl:text>ID '</xsl:text>
+                <xsl:value-of select="$rootid"/>
+                <xsl:text>' not found in document.</xsl:text>
+              </xsl:message>
+            </xsl:when>
+            <xsl:otherwise>
+              <xsl:if test="$collect.xref.targets = 'yes' or
+                            $collect.xref.targets = 'only'">
+                <xsl:apply-templates select="key('id', $rootid)"
+                                     mode="collect.targets"/>
+              </xsl:if>
+              <xsl:if test="$collect.xref.targets != 'only'">
+                <xsl:apply-templates select="key('id',$rootid)"
+                                     mode="process.root"/>
+                <xsl:if test="$tex.math.in.alt != ''">
+                  <xsl:apply-templates select="key('id',$rootid)"
+                                       mode="collect.tex.math"/>
+                </xsl:if>
+              </xsl:if>
+            </xsl:otherwise>
+          </xsl:choose>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:if test="$collect.xref.targets = 'yes' or
+                        $collect.xref.targets = 'only'">
+            <xsl:apply-templates select="/" mode="collect.targets"/>
+          </xsl:if>
+          <xsl:if test="$collect.xref.targets != 'only'">
+            <xsl:apply-templates select="/" mode="process.root"/>
+            <xsl:if test="$tex.math.in.alt != ''">
+              <xsl:apply-templates select="/" mode="collect.tex.math"/>
+            </xsl:if>
+          </xsl:if>
+        </xsl:otherwise>
       </xsl:choose>
     </xsl:otherwise>
   </xsl:choose>