]> granicus.if.org Git - docbook-dsssl/commitdiff
Fix it the right way: always test for top-level elements
authorNorman Walsh <ndw@nwalsh.com>
Thu, 29 Nov 2001 17:56:51 +0000 (17:56 +0000)
committerNorman Walsh <ndw@nwalsh.com>
Thu, 29 Nov 2001 17:56:51 +0000 (17:56 +0000)
xsl/fo/xep.xsl

index 4b528886f1c67ea5949d45576956993ec0abc6d1..73cd7c0aa56ca63d2386b6723b8129b713edc419 100644 (file)
     <xsl:apply-templates select="." mode="title.content"/>
   </xsl:variable>
 
-<!--
-  <rx:bookmark internal-destination="{$id}">
-    <rx:bookmark-label>
-      <xsl:value-of select="translate($bookmark-label, $a-dia, $a-asc)"/>
-    </rx:bookmark-label>
--->
-
-  <xsl:if test="book">
-      <xsl:apply-templates select="book"
-                           mode="xep.outline"/>
-  </xsl:if>
-
-<!--
-  </rx:bookmark>
--->
+  <xsl:choose>
+    <xsl:when test="parent::*">
+      <xsl:if test="book">
+        <xsl:apply-templates select="book"
+                             mode="xep.outline"/>
+      </xsl:if>
+    </xsl:when>
+    <xsl:otherwise>
+      <rx:bookmark internal-destination="{$id}">
+        <rx:bookmark-label>
+          <xsl:value-of select="translate($bookmark-label, $a-dia, $a-asc)"/>
+        </rx:bookmark-label>
+        <xsl:if test="book">
+          <xsl:apply-templates select="book"
+                               mode="xep.outline"/>
+        </xsl:if>
+      </rx:bookmark>
+    </xsl:otherwise>
+  </xsl:choose>
 </xsl:template>
 
 <xsl:template match="book" mode="xep.outline">
   </xsl:variable>
 
   <xsl:choose>
-    <xsl:when test="parent::set">
+    <xsl:when test="parent::*">
       <rx:bookmark internal-destination="{$id}">
         <rx:bookmark-label>
           <xsl:value-of select="translate($bookmark-label, $a-dia, $a-asc)"/>
         </rx:bookmark-label>
-
         <xsl:if test="part|preface|chapter|appendix">
           <xsl:apply-templates select="part|preface|chapter|appendix"
                                mode="xep.outline"/>
     <xsl:apply-templates select="." mode="title.markup"/>
   </xsl:variable>
 
-  <rx:bookmark internal-destination="{$id}">
-    <rx:bookmark-label>
-      <xsl:value-of select="translate($bookmark-label, $a-dia, $a-asc)"/>
-    </rx:bookmark-label>
+  <xsl:choose>
+    <xsl:when test="parent::*">
+      <rx:bookmark internal-destination="{$id}">
+        <rx:bookmark-label>
+          <xsl:value-of select="translate($bookmark-label, $a-dia, $a-asc)"/>
+        </rx:bookmark-label>
+        <xsl:if test="chapter|appendix|preface|reference">
+          <xsl:apply-templates select="chapter|appendix|preface|reference"
+                               mode="xep.outline"/>
+        </xsl:if>
+      </rx:bookmark>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:if test="chapter|appendix|preface|reference">
+        <xsl:apply-templates select="chapter|appendix|preface|reference"
+                             mode="xep.outline"/>
+      </xsl:if>
+    </xsl:otherwise>
+  </xsl:choose>
 
-  <xsl:if test="chapter|appendix|preface|reference">
-      <xsl:apply-templates select="chapter|appendix|preface|reference"
-                           mode="xep.outline"/>
-  </xsl:if>
-  </rx:bookmark>
 </xsl:template>
 
 <xsl:template match="preface|chapter|appendix"
     <xsl:apply-templates select="." mode="title.markup"/>
   </xsl:variable>
 
-  <rx:bookmark internal-destination="{$id}">
-    <rx:bookmark-label>
-      <xsl:value-of select="translate($bookmark-label, $a-dia, $a-asc)"/>
-    </rx:bookmark-label>
-
-  <xsl:if test="section|sect1">
-      <xsl:apply-templates select="section|sect1"
-                           mode="xep.outline"/>
-  </xsl:if>
-  </rx:bookmark>
+  <xsl:choose>
+    <xsl:when test="parent::*">
+      <rx:bookmark internal-destination="{$id}">
+        <rx:bookmark-label>
+          <xsl:value-of select="translate($bookmark-label, $a-dia, $a-asc)"/>
+        </rx:bookmark-label>
+        <xsl:if test="section|sect1">
+          <xsl:apply-templates select="section|sect1"
+                               mode="xep.outline"/>
+        </xsl:if>
+      </rx:bookmark>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:if test="section|sect1">
+        <xsl:apply-templates select="section|sect1"
+                             mode="xep.outline"/>
+      </xsl:if>
+    </xsl:otherwise>
+  </xsl:choose>
 </xsl:template>
 
 <xsl:template match="section|sect1|sect2|sect3|sect4|sect5"
     <xsl:apply-templates select="." mode="title.markup"/>
   </xsl:variable>
 
-  <rx:bookmark internal-destination="{$id}">
-    <rx:bookmark-label>
-      <xsl:value-of select="translate($bookmark-label, $a-dia, $a-asc)"/>
-    </rx:bookmark-label>
-
-  <xsl:if test="section|sect2|sect3|sect4|sect5">
-      <xsl:apply-templates select="section|sect2|sect3|sect4|sect5"
-                           mode="xep.outline"/>
-  </xsl:if>
-  </rx:bookmark>
+  <xsl:choose>
+    <xsl:when test="parent::*">
+      <rx:bookmark internal-destination="{$id}">
+        <rx:bookmark-label>
+          <xsl:value-of select="translate($bookmark-label, $a-dia, $a-asc)"/>
+        </rx:bookmark-label>
+        <xsl:if test="section|sect2|sect3|sect4|sect5">
+          <xsl:apply-templates select="section|sect2|sect3|sect4|sect5"
+                               mode="xep.outline"/>
+        </xsl:if>
+      </rx:bookmark>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:if test="section|sect2|sect3|sect4|sect5">
+        <xsl:apply-templates select="section|sect2|sect3|sect4|sect5"
+                             mode="xep.outline"/>
+      </xsl:if>
+    </xsl:otherwise>
+  </xsl:choose>
 </xsl:template>
 
 <xsl:template match="bibliography|glossary|index"
     <xsl:apply-templates select="." mode="title.markup"/>
   </xsl:variable>
 
-  <rx:bookmark internal-destination="{$id}">
-    <rx:bookmark-label>
+  <xsl:choose>
+    <xsl:when test="parent::*">
+      <rx:bookmark internal-destination="{$id}">
+        <rx:bookmark-label>
+          <xsl:value-of select="translate($bookmark-label, $a-dia, $a-asc)"/>
+        </rx:bookmark-label>
+      </rx:bookmark>
+    </xsl:when>
+    <xsl:otherwise>
       <xsl:value-of select="translate($bookmark-label, $a-dia, $a-asc)"/>
-    </rx:bookmark-label>
-  </rx:bookmark>
+    </xsl:otherwise>
+  </xsl:choose>
 </xsl:template>
-<!-- Added missing template for "article" -->
+
 <xsl:template match="article"
               mode="xep.outline">
   <xsl:variable name="id">
     <xsl:apply-templates select="." mode="title.markup"/>
   </xsl:variable>
 
-  <rx:bookmark internal-destination="{$id}">
-    <rx:bookmark-label>
-      <xsl:value-of select="translate($bookmark-label, $a-dia, $a-asc)"/>
-    </rx:bookmark-label>
-
-  <xsl:if test="section|sect1|appendix|bibliography|glossary|index">
-      <xsl:apply-templates select="section|sect1|appendix|bibliography|glossary|index"
-                           mode="xep.outline"/>
-  </xsl:if>
-  </rx:bookmark>
+  <xsl:choose>
+    <xsl:when test="parent::*">
+      <rx:bookmark internal-destination="{$id}">
+        <rx:bookmark-label>
+          <xsl:value-of select="translate($bookmark-label, $a-dia, $a-asc)"/>
+        </rx:bookmark-label>
+        <xsl:if test="section|sect1|appendix|bibliography|glossary|index">
+          <xsl:apply-templates select="section|sect1|appendix|bibliography|glossary|index"
+                               mode="xep.outline"/>
+        </xsl:if>
+      </rx:bookmark>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:if test="section|sect1|appendix|bibliography|glossary|index">
+        <xsl:apply-templates select="section|sect1|appendix|bibliography|glossary|index"
+                             mode="xep.outline"/>
+      </xsl:if>
+    </xsl:otherwise>
+  </xsl:choose>
 </xsl:template>
 
-
-
 <xsl:template match="title" mode="xep.outline">
   <xsl:apply-templates/>
 </xsl:template>