]> granicus.if.org Git - docbook-dsssl/commitdiff
Improved modularization in opf.spine and created new spine.cover template
authorThomas Schraitle <tom_schr@web.de>
Thu, 2 May 2013 06:36:28 +0000 (06:36 +0000)
committerThomas Schraitle <tom_schr@web.de>
Thu, 2 May 2013 06:36:28 +0000 (06:36 +0000)
xsl/epub/docbook.xsl

index cd34e966427a5c3b3948fa0016b1f30873dcc739..97237d74b9ec94a8f07ed49c212eb4d0b6fae30e 100644 (file)
         <xsl:value-of select="$epub.ncx.toc.id"/>
       </xsl:attribute>
 
-      <xsl:if test="$info/cover or $info//mediaobject[@role='cover' or ancestor::cover]"> 
-        <xsl:element namespace="http://www.idpf.org/2007/opf" name="itemref">
-          <xsl:attribute name="idref">
-            <xsl:value-of select="$epub.cover.id"/>
-          </xsl:attribute>
-          <xsl:attribute name="linear">
-          <xsl:choose>
-            <xsl:when test="$epub.cover.linear">
-              <xsl:text>yes</xsl:text>
-            </xsl:when>
-            <xsl:otherwise>no</xsl:otherwise>
-          </xsl:choose>
-          </xsl:attribute>
-        </xsl:element>
-      </xsl:if>
-
+      <xsl:call-template name="spine.cover"/>
 
       <xsl:if test="contains($toc.params, 'toc')">
         <xsl:element namespace="http://www.idpf.org/2007/opf" name="itemref">
           <xsl:apply-templates select="/*/*" mode="opf.spine"/>
         </xsl:otherwise>
       </xsl:choose>
-                                   
     </xsl:element>
   </xsl:template>
+  
+  <xsl:template name="spine.cover">
+    <xsl:variable name="info" select="*/*[contains(local-name(.), 'info')][1]"/>
+    <xsl:variable name="cover.image" 
+                  select="$info//mediaobject[@role='cover' or ancestor::cover]"/>
+    
+    <xsl:if test="$cover.image">
+      <xsl:element namespace="http://www.idpf.org/2007/opf" name="itemref">
+        <xsl:attribute name="idref">
+          <xsl:value-of select="$epub.cover.id"/>
+        </xsl:attribute>
+        <xsl:attribute name="linear">
+          <xsl:choose>
+            <xsl:when test="$epub.cover.linear">
+              <xsl:text>yes</xsl:text>
+            </xsl:when>
+            <xsl:otherwise>no</xsl:otherwise>
+          </xsl:choose>
+        </xsl:attribute>
+      </xsl:element>
+    </xsl:if>
+  </xsl:template>
+  
 
   <xsl:template match="*" mode="opf.spine">
     <xsl:variable name="is.chunk">