I'd like to check, whether a file exists, with xslt 2.0. However, it's not working. I've tried this:
<xsl:choose>
<xsl:when test="doc(iri-to-uri(concat($currFolder, '/', $currSubFolder, '/', @href)))">
(The path is correct)
however, this results in an error, when the file isnt there.
and this:
<xsl:choose>
<xsl:when test="doc-available(iri-to-uri(concat($currFolder, '/', $currSubFolder, '/', @href)))">
doesn't work, it tells me files are there that clearly don't exist.
Whats the correct way to do this? A reliable way to check, if an xml file exists.
According to this similar question, the author mentions that something such as this worked for them as far as checking for the existence of an xml file.
Right now, it checks each folder individually an if the file doesnt exist in that folder, it writes it to the output, regardless of whether it already exists in another previous folder.
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions">
<xsl:variable name="currInput" select="tokenize(document-uri(.), '/')[last()]"/>
<xsl:choose>
<xsl:when test="doc-available(iri-to-uri(concat(.,'/',$currInput))) = fn:false()"></xsl:when>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With