]> granicus.if.org Git - docbook-dsssl/commitdiff
Check in fix for bug #1336 to support absolute file URLs
authorBob Stayton <bobs@sagehill.net>
Sat, 6 Sep 2014 08:14:22 +0000 (08:14 +0000)
committerBob Stayton <bobs@sagehill.net>
Sat, 6 Sep 2014 08:14:22 +0000 (08:14 +0000)
that start with file:/.  Also consolidate code that determines
whether an image file path is relative into a new template
variable $is.relative.

xsl/html/graphics.xsl

index a1fcb06232a3cf5ec1a7198b19bad42ceb65ce22..e1de9b1c6006e7062726a8cabe673a77d0c92b44 100644 (file)
     </xsl:choose>
   </xsl:variable>
 
-  <xsl:variable name="output_filename">
-    <xsl:choose>
-      <xsl:when test="@entityref">
-        <xsl:value-of select="$filename"/>
-      </xsl:when>
-      <!--
-        Moved test for $keep.relative.image.uris to template below:
-            <xsl:template match="@fileref">
-      -->
-      <xsl:otherwise>
-        <xsl:value-of select="$filename"/>
-      </xsl:otherwise>
-    </xsl:choose>
-  </xsl:variable>
-
   <xsl:variable name="img.src.path.pi">
     <xsl:call-template name="pi.dbhtml_img.src.path">
       <xsl:with-param name="node" select=".."/>
     </xsl:call-template>
   </xsl:variable>
 
+  <!-- is the file path relative and can be modified by img.src.path? -->
+  <xsl:variable name="is.relative">
+    <xsl:choose>
+      <xsl:when test="$img.src.path != '' and
+                      $tag = 'img' and
+                      not(starts-with($filename, '/')) and
+                      not(starts-with($filename, 'file:/')) and
+                      not(contains($filename, '://'))">1</xsl:when>
+      <xsl:otherwise>0</xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+
   <xsl:variable name="filename.for.graphicsize">
     <xsl:choose>
       <xsl:when test="$img.src.path.pi != ''">
         <xsl:value-of select="concat($img.src.path.pi, $filename)"/>
       </xsl:when>
-      <xsl:when test="$img.src.path != '' and
-                      $graphicsize.use.img.src.path != 0 and
-                      $tag = 'img' and
-                      not(starts-with($filename, '/')) and
-                      not(contains($filename, '://'))">
+      <xsl:when test="$is.relative = 1 and
+                      $graphicsize.use.img.src.path != 0">
         <xsl:value-of select="concat($img.src.path, $filename)"/>
       </xsl:when>
       <xsl:otherwise>
@@ -550,14 +544,11 @@ valign: <xsl:value-of select="@valign"/></xsl:message>
         <object type="image/svg+xml">
          <xsl:attribute name="data">
            <xsl:choose>
-             <xsl:when test="$img.src.path != '' and
-                           $tag = 'img' and
-                          not(starts-with($output_filename, '/')) and
-                          not(contains($output_filename, '://'))">
+             <xsl:when test="$is.relative = 1">
                <xsl:value-of select="$img.src.path"/>
              </xsl:when>
            </xsl:choose>
-          <xsl:value-of select="$output_filename"/>
+          <xsl:value-of select="$filename"/>
          </xsl:attribute>
          <xsl:call-template name="process.image.attributes">
             <!--xsl:with-param name="alt" select="$alt"/ there's no alt here-->
@@ -584,14 +575,11 @@ valign: <xsl:value-of select="@valign"/></xsl:message>
            <embed type="image/svg+xml">
              <xsl:attribute name="src">
                <xsl:choose>
-                  <xsl:when test="$img.src.path != '' and
-                                 $tag = 'img' and
-                                 not(starts-with($output_filename, '/')) and
-                                 not(contains($output_filename, '://'))">
+                  <xsl:when test="$is.relative = 1">
                    <xsl:value-of select="$img.src.path"/>
                   </xsl:when>
                </xsl:choose>
-               <xsl:value-of select="$output_filename"/>
+               <xsl:value-of select="$filename"/>
               </xsl:attribute>
               <xsl:call-template name="process.image.attributes">
                 <!--xsl:with-param name="alt" select="$alt"/ there's no alt here -->
@@ -611,14 +599,11 @@ valign: <xsl:value-of select="@valign"/></xsl:message>
       <xsl:otherwise>
         <xsl:variable name="src">
           <xsl:choose>
-             <xsl:when test="$img.src.path != '' and
-                             $tag = 'img' and
-                             not(starts-with($output_filename, '/')) and
-                             not(contains($output_filename, '://'))">
+             <xsl:when test="$is.relative = 1">
                <xsl:value-of select="$img.src.path"/>
              </xsl:when>
            </xsl:choose>
-           <xsl:value-of select="$output_filename"/>
+           <xsl:value-of select="$filename"/>
         </xsl:variable>
         <xsl:variable name="imgcontents">
         <xsl:element name="{$tag}">