]> granicus.if.org Git - docbook-dsssl/commitdiff
Add support for standard XSL 1.1 bookmarks and parameter
authorBob Stayton <bobs@sagehill.net>
Tue, 7 Jan 2014 21:36:28 +0000 (21:36 +0000)
committerBob Stayton <bobs@sagehill.net>
Tue, 7 Jan 2014 21:36:28 +0000 (21:36 +0000)
$xsl1.1.bookmarks to turn them on or off.

xsl/fo/autotoc.xsl
xsl/fo/component.xsl
xsl/fo/division.xsl
xsl/fo/docbook.xsl
xsl/fo/fop1.xsl
xsl/fo/param.ent
xsl/fo/param.xweb
xsl/fo/refentry.xsl
xsl/fo/sections.xsl
xsl/fo/xep.xsl

index 543cc139e69fb2cd1907ebcca7e4650979b8025b..97fc0acfd225cc0c753e55417472d08c3214aa9a 100644 (file)
@@ -35,7 +35,7 @@
   <xsl:if test="$nodes">
     <fo:block id="toc...{$id}"
               xsl:use-attribute-sets="toc.margin.properties">
-      <xsl:if test="$axf.extensions != 0">
+      <xsl:if test="$axf.extensions != 0 and $xsl1.1.bookmarks = 0">
         <xsl:attribute name="axf:outline-level">1</xsl:attribute>
         <xsl:attribute name="axf:outline-expand">false</xsl:attribute>
         <xsl:attribute name="axf:outline-title">
@@ -77,7 +77,7 @@
   <xsl:if test="$nodes">
     <fo:block id="toc...{$cid}"
               xsl:use-attribute-sets="toc.margin.properties">
-      <xsl:if test="$axf.extensions != 0">
+      <xsl:if test="$axf.extensions != 0 and $xsl1.1.bookmarks = 0">
         <xsl:attribute name="axf:outline-level">1</xsl:attribute>
         <xsl:attribute name="axf:outline-expand">false</xsl:attribute>
         <xsl:attribute name="axf:outline-title">
index d68106073f54ea85d978e425c5f7da96a1c5ebd7..10d13223849967107d5d1a8e409cf8441760ad70 100644 (file)
@@ -71,7 +71,7 @@
         <xsl:with-param name="key" select="'hyphenation-remain-character-count'"/>
       </xsl:call-template>
     </xsl:attribute>
-    <xsl:if test="$axf.extensions != 0">
+    <xsl:if test="$axf.extensions != 0 and $xsl1.1.bookmarks = 0">
       <xsl:attribute name="axf:outline-level">
         <xsl:value-of select="count($node/ancestor::*)"/>
       </xsl:attribute>
   </xsl:variable>
 
   <fo:block id='{$id}'>
-    <xsl:if test="$axf.extensions != 0">
+    <xsl:if test="$axf.extensions != 0 and $xsl1.1.bookmarks = 0">
       <xsl:attribute name="axf:outline-level">
         <xsl:value-of select="count(ancestor::*)+2"/>
       </xsl:attribute>
index e7402633898c39fa8292a3a286372af2bcb0c8a0..9c479c3b761f67d6749e7064b4f35aa315590845 100644 (file)
@@ -31,7 +31,7 @@
 
   <fo:block keep-with-next.within-column="always"
             hyphenate="false">
-    <xsl:if test="$axf.extensions != 0">
+    <xsl:if test="$axf.extensions != 0 and $xsl1.1.bookmarks = 0">
       <xsl:attribute name="axf:outline-level">
         <xsl:choose>
           <xsl:when test="count($node/ancestor::*) > 0">
index f2c396501ed546dc79ed022052f3312428d1c1e2..8ef5e8e9e1b1becc0a55122eae19a2a38c2d0b1a 100644 (file)
 
     <xsl:call-template name="setup.pagemasters"/>
 
-    <xsl:if test="$fop.extensions != 0">
-      <xsl:apply-templates select="$document.element" mode="fop.outline"/>
-    </xsl:if>
-
     <xsl:if test="$fop1.extensions != 0">
       <xsl:call-template name="fop1-document-information"/>
+      <xsl:apply-templates select="$document.element" mode="fop1.foxdest"/>
+    </xsl:if>
+
+    <!-- generate bookmark tree -->
+    <xsl:call-template name="generate.bookmarks"/>
+
+    <xsl:apply-templates select="$document.element"/>
+  </fo:root>
+</xsl:template>
+
+<xsl:template name="generate.bookmarks">
+  <xsl:choose>
+    <!-- use standard bookmark elements? -->
+    <xsl:when test="$xsl1.1.bookmarks != 0">
       <xsl:variable name="bookmarks">
         <xsl:apply-templates select="$document.element" 
-                             mode="fop1.outline"/>
+                             mode="bookmark"/>
       </xsl:variable>
       <xsl:if test="string($bookmarks) != ''">
         <fo:bookmark-tree>
           <xsl:copy-of select="$bookmarks"/>
         </fo:bookmark-tree>
       </xsl:if>
-      <xsl:apply-templates select="$document.element" 
-                           mode="fop1.foxdest"/>
-    </xsl:if>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:choose>
+        <!-- pre FOP 1.0 -->
+        <xsl:when test="$fop.extensions != 0">
+          <xsl:apply-templates select="$document.element" mode="fop.outline"/>
+        </xsl:when>
+    
+        <!-- FOP 1.0 -->
+        <xsl:when test="$fop1.extensions != 0">
+          <xsl:variable name="bookmarks">
+            <xsl:apply-templates select="$document.element" 
+                                 mode="fop1.outline"/>
+          </xsl:variable>
+          <xsl:if test="string($bookmarks) != ''">
+            <fo:bookmark-tree>
+              <xsl:copy-of select="$bookmarks"/>
+            </fo:bookmark-tree>
+          </xsl:if>
+        </xsl:when>
+  
+        <!-- RenderX XEP 4.6 and earlier -->
+        <xsl:when test="$xep.extensions != 0">
+          <xsl:variable name="bookmarks">
+            <xsl:apply-templates select="$document.element" mode="xep.outline"/>
+          </xsl:variable>
+          <xsl:if test="string($bookmarks) != ''">
+            <rx:outline xmlns:rx="http://www.renderx.com/XSL/Extensions">
+              <xsl:copy-of select="$bookmarks"/>
+            </rx:outline>
+          </xsl:if>
+        </xsl:when>
+  
+        <!-- PTC Arbortext -->
+        <xsl:when test="$arbortext.extensions != 0">
+          <xsl:variable name="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>
+          </xsl:if>
+        </xsl:when>
+      </xsl:choose>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
 
-    <xsl:if test="$xep.extensions != 0">
-      <xsl:variable name="bookmarks">
-        <xsl:apply-templates select="$document.element" mode="xep.outline"/>
-      </xsl:variable>
-      <xsl:if test="string($bookmarks) != ''">
-        <rx:outline xmlns:rx="http://www.renderx.com/XSL/Extensions">
-          <xsl:copy-of select="$bookmarks"/>
-        </rx:outline>
-      </xsl:if>
-    </xsl:if>
+<xsl:template match="*" mode="bookmark">
+  <xsl:apply-templates select="*" mode="bookmark"/>
+</xsl:template>
 
-    <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:template match="set|book|part|reference|
+                     preface|chapter|appendix|article|topic
+                     |glossary|bibliography|index|setindex
+                     |refentry
+                     |sect1|sect2|sect3|sect4|sect5|section"
+              mode="bookmark">
+
+  <xsl:variable name="id">
+    <xsl:call-template name="object.id"/>
+  </xsl:variable>
+  <xsl:variable name="bookmark-label">
+    <xsl:apply-templates select="." mode="object.title.markup"/>
+  </xsl:variable>
+
+  <!-- Put the root element bookmark at the same level as its children -->
+  <!-- If the object is a set or book, generate a bookmark for the toc -->
+
+  <xsl:choose>
+    <xsl:when test="self::index and $generate.index = 0"/>
+    <xsl:when test="parent::*">
+      <fo:bookmark internal-destination="{$id}">
+        <xsl:attribute name="starting-state">
+          <xsl:value-of select="$bookmarks.state"/>
+        </xsl:attribute>
+        <fo:bookmark-title>
+          <xsl:value-of select="normalize-space($bookmark-label)"/>
+        </fo:bookmark-title>
+        <xsl:apply-templates select="*" mode="bookmark"/>
+      </fo:bookmark>
+    </xsl:when>
+    <xsl:otherwise>
+      <fo:bookmark internal-destination="{$id}">
+        <xsl:attribute name="starting-state">
+          <xsl:value-of select="$bookmarks.state"/>
+        </xsl:attribute>
+        <fo:bookmark-title>
+          <xsl:value-of select="normalize-space($bookmark-label)"/>
+        </fo:bookmark-title>
+      </fo:bookmark>
+
+      <xsl:variable name="toc.params">
+        <xsl:call-template name="find.path.params">
+          <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
+        </xsl:call-template>
       </xsl:variable>
-      <xsl:if test="string($bookmarks) != ''">
-        <fo:bookmark-tree>
-          <xsl:copy-of select="$bookmarks"/>
-        </fo:bookmark-tree>
-      </xsl:if>
-    </xsl:if>
 
-    <xsl:apply-templates select="$document.element"/>
-  </fo:root>
+      <xsl:if test="contains($toc.params, 'toc')
+                    and (book|part|reference|preface|chapter|appendix|article|topic
+                         |glossary|bibliography|index|setindex
+                         |refentry
+                         |sect1|sect2|sect3|sect4|sect5|section)">
+        <fo:bookmark internal-destination="toc...{$id}">
+          <fo:bookmark-title>
+            <xsl:call-template name="gentext">
+              <xsl:with-param name="key" select="'TableofContents'"/>
+            </xsl:call-template>
+          </fo:bookmark-title>
+        </fo:bookmark>
+      </xsl:if>
+      <xsl:apply-templates select="*" mode="bookmark"/>
+    </xsl:otherwise>
+  </xsl:choose>
 </xsl:template>
 
 <xsl:template name="root.messages">
index 7daf16b8c64de37131eb87fe2524521c98a9be68..ee167e0871a360da01fee963ccdb6d20fd50fb3e 100644 (file)
 
 <!-- ==================================================================== -->
 
-<xsl:variable name="bookmarks.state">
-  <xsl:choose>
-    <xsl:when test="$bookmarks.collapse != 0">hide</xsl:when>
-    <xsl:otherwise>show</xsl:otherwise>
-  </xsl:choose>
-</xsl:variable>
-
 <xsl:template match="*" mode="fop1.outline">
   <xsl:apply-templates select="*" mode="fop1.outline"/>
 </xsl:template>
index c8eb6b699a7b2c10635166795f3a328808f8e54b..fa231115696523b0c623fd1877f9b11cb0e5d8e2 100644 (file)
 <!ENTITY activate.external.olinks SYSTEM "../params/activate.external.olinks.xml">
 <!ENTITY force.blank.pages SYSTEM "../params/force.blank.pages.xml">
 <!ENTITY mark.optional.procedure.steps SYSTEM "../params/mark.optional.procedure.steps.xml">
+<!ENTITY xsl1.1.bookmarks SYSTEM "../params/xsl1.1.bookmarks.xml">
index 8bdd9ce9b2ac5b1ea01beffac73fecf963d55f52..d114f34f5e70fe1ae4534aa2eb4ed37b2531edbc 100644 (file)
@@ -282,6 +282,7 @@ generate.section.toc.level;
 &monospace.verbatim.font.width;
 &exsl.node.set.available;
 &bookmarks.collapse;
+&xsl1.1.bookmarks;
 &generate.consistent.ids;
 &base.dir;
 &chunk.quietly;
@@ -932,6 +933,7 @@ around all these parameters.</para>
 <src:fragref linkend="region.outer.properties.frag"/>
 <src:fragref linkend="para.properties.frag"/>
 <src:fragref linkend="mark.optional.procedure.steps.frag"/>
+<src:fragref linkend="xsl1.1.bookmarks.frag"/>
 
 </xsl:stylesheet>
 </src:fragment>
index 004080925bce7089426eefdd110c8758725b4fb1..f969d681c3281463dabb23b939ec0e342aa8f228 100644 (file)
       </xsl:choose>
     </xsl:variable>
 
-    <xsl:if test="$axf.extensions != 0">
+    <xsl:if test="$axf.extensions != 0 and $xsl1.1.bookmarks = 0">
       <xsl:attribute name="axf:outline-level">
         <xsl:value-of select="count(ancestor::*)-1 + $offset"/>
       </xsl:attribute>
index 691c7308eacd23a5fb8e2b33d922f46b09ede01d..6b242067d770c7c433f6898f1cccb4baa8b8feaf 100644 (file)
       </xsl:apply-templates>
     </xsl:variable>
 
-    <xsl:if test="$axf.extensions != 0">
+    <xsl:if test="$axf.extensions != 0 and $xsl1.1.bookmarks = 0">
       <xsl:attribute name="axf:outline-level">
         <xsl:value-of select="count(ancestor::*)-1"/>
       </xsl:attribute>
index 782ab378e7f3cf466ed695b6ad1e34204c73fc1d..8af1a30ae9165828b1128f192e608bc431c6a0d4 100644 (file)
     <xsl:when test="self::index and $generate.index = 0"/>     
     <xsl:when test="parent::*">
       <rx:bookmark internal-destination="{$id}">
+        <xsl:attribute name="starting-state">
+          <xsl:value-of select="$bookmarks.state"/>
+        </xsl:attribute>
         <rx:bookmark-label>
           <xsl:value-of select="normalize-space($bookmark-label)"/>
         </rx:bookmark-label>
     <xsl:otherwise>
       <xsl:if test="$bookmark-label != ''">
         <rx:bookmark internal-destination="{$id}">
+          <xsl:attribute name="starting-state">
+            <xsl:value-of select="$bookmarks.state"/>
+          </xsl:attribute>
           <rx:bookmark-label>
             <xsl:value-of select="normalize-space($bookmark-label)"/>
           </rx:bookmark-label>