oswcab
2/4/2014 - 3:10 PM

Check if a file exists using fn:unparsed-text-available(). Note: "The XSLT 2.0 function unparsed-text-available() is only suitable for loca

Check if a file exists using fn:unparsed-text-available(). Note: "The XSLT 2.0 function unparsed-text-available() is only suitable for locating text files and even if a text file with the specifies URI exists this function may return false(), because it also must read the contents of the file and check that it only contains allowed characters".

<xsl:variable name="textfile" select="concat($inputPath, '/', no, '-article.txt')" />
<xsl:if test="unparsed-text-available($textfile)">
  <corps>
    <texte typetexte="libre">
      <xsl:value-of select="tokenize(unparsed-text($textfile, 'UTF-8'), '\n')" />
    </texte>
  </corps>
</xsl:if>