]> granicus.if.org Git - docbook-dsssl/commitdiff
Improve the handling of $chunk.base.dir when $base.dir contains
authorBob Stayton <bobs@sagehill.net>
Tue, 18 Feb 2014 00:01:45 +0000 (00:01 +0000)
committerBob Stayton <bobs@sagehill.net>
Tue, 18 Feb 2014 00:01:45 +0000 (00:01 +0000)
the OEBPS directory in its value.

xsl/epub/docbook.xsl

index 6c96b898d94a38fb2b3df2b81f61645d7b8488fa..312921f830d20422d3d3f80c6d8d8271118aab59 100644 (file)
 
   <!-- HTML chunk output goes to $base.dir/OEPBS -->
   <xsl:variable name="chunk.base.dir">
-    <xsl:if test="$base.dir != '' and contains($base.dir, $epub.oebps.dir)">
-      <xsl:message terminate="yes">
-        <xsl:text>ERROR: the $base.dir param must not include the </xsl:text>
-        <xsl:value-of select="$epub.oebps.dir"/>
-        <xsl:text> directory in its path. Exiting.</xsl:text>
-      </xsl:message>
-    </xsl:if>
     <xsl:choose>
-     <xsl:when test="string-length($base.dir) = 0"></xsl:when>
-     <!-- make sure to add trailing slash if omitted by user -->
-     <xsl:when test="substring($base.dir, string-length($base.dir), 1) = '/'">
-       <xsl:value-of select="$base.dir"/>
-     </xsl:when>
-     <xsl:otherwise>
-       <xsl:value-of select="concat($base.dir, '/')"/>
-     </xsl:otherwise>
-   </xsl:choose>
-   <xsl:value-of select="$epub.oebps.dir"/>
+      <xsl:when test="$base.dir != '' and contains($base.dir, $epub.oebps.dir)">
+        <xsl:value-of select="substring-before($base.dir, $epub.oebps.dir)"/>
+      </xsl:when>
+      <!-- If epub.oebps.dir reset but base.dir still has OEBPS: -->
+      <xsl:when test="$base.dir != '' and contains($base.dir, 'OEBPS')">
+        <xsl:value-of select="substring-before($base.dir, 'OEBPS')"/>
+      </xsl:when>
+      <xsl:when test="string-length($base.dir) = 0"></xsl:when>
+      <!-- make sure to add trailing slash if omitted by user -->
+      <xsl:when test="substring($base.dir, string-length($base.dir), 1) = '/'">
+        <xsl:value-of select="$base.dir"/>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:value-of select="concat($base.dir, '/')"/>
+      </xsl:otherwise>
+    </xsl:choose>
+    <xsl:value-of select="$epub.oebps.dir"/>
     <xsl:if test="substring($epub.oebps.dir, string-length($epub.oebps.dir), 1) != '/'">
       <xsl:text>/</xsl:text>
     </xsl:if>
- </xsl:variable>
 </xsl:variable>
+
  <!-- This param only has a side effect of checking for base.dir usage -->
 
   <xsl:param name="epub.ncx.filename" select="'toc.ncx'"/>