Project

Profile

Help

Bug #4289

closed

file:exists() is always faise

Added by Kevon Hayes over 4 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Documentation
Sprint/Milestone:
Start date:
2019-08-20
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
9.9, trunk
Fix Committed on Branch:
9.9, trunk
Fixed in Maintenance Release:
Platforms:

Description

I have the following code and test="file:exists()" always returns false no matter if I pass in $file-path1 or $file-path2.

$file-path2 actually renders images when converting this the output of the below transformation into a PDF. So it cannot always be false. Please advise if I am calling this function correctly.

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:axf="http://www.antennahouse.com/names/XSL/Extensions" xmlns:rev="http://www.boeing.com/FTID-ML/Revision" xmlns:exsl="http://exslt.org/common" xmlns:ftid="http://www.boeing.com/FTID-ML" exclude-result-prefixes="xd" version="3.0" xmlns:file="http://expath.org/ns/file" xmlns:saxon="http://saxon.sf.net/" xmlns:pn="http://internal-project-namespace">

<xsl:template match="ftid:Illustration"> fo:block fo:marker <xsl:attribute name="marker-class-name"> <xsl:value-of select="name()"></xsl:value-of> </xsl:attribute> </fo:marker> <xsl:variable name="filename"> xsl:choose <xsl:when test="starts-with(@fileRef, 'G')"> <xsl:value-of select="substring(@fileRef, 2)"/> </xsl:when> xsl:otherwise <xsl:value-of select="@fileRef"/> </xsl:otherwise> </xsl:choose> </xsl:variable>

  <xsl:variable name="file-path1" select="concat('../images/',$filename,'.jpg')"/>
  <xsl:variable name="file-path2" select="concat('../../images/',$filename,'.jpg')"/>

  <!-- Check if file exists-->
  <xsl:choose>
    <xsl:when test="file:exists($file-path1)" xmlns:file="http://expath.org/ns/file">
      <xsl:variable name="file-src" select="$file-path1"/>
      <fo:external-graphic content-width="scale-to-fit"
                       content-height="scale-to-fit"
                       max-height="100%"
                       src="{$file-src}">
        <xsl:choose>
          <xsl:when test="parent::ftid:ModelGraphic">
            <xsl:attribute name="height">1.5in</xsl:attribute>
          </xsl:when>
          <xsl:otherwise>
            <xsl:attribute name="width">4.5in</xsl:attribute>
          </xsl:otherwise>
        </xsl:choose>
      </fo:external-graphic>
    </xsl:when>
    <xsl:otherwise>
      <xsl:variable name="file-src" select="$file-path2"/>
      <fo:external-graphic content-width="scale-to-fit"
                       content-height="scale-to-fit"
                       max-height="100%"
                       src="{$file-src}">
        <xsl:choose>
          <xsl:when test="parent::ftid:ModelGraphic">
            <xsl:attribute name="height">1.5in</xsl:attribute>
          </xsl:when>
          <xsl:otherwise>
            <xsl:attribute name="width">4.5in</xsl:attribute>
          </xsl:otherwise>
        </xsl:choose>
      </fo:external-graphic>
    </xsl:otherwise>
  </xsl:choose>
</fo:block>

</xsl:template> </xsl:stylesheet>

Please register to edit this issue

Also available in: Atom PDF