Check if xml file exists with XSLT 2.0, saxon9HE

I want to check if a file exists with xslt 2.0. However, it does not work. I tried this:

<xsl:choose> <xsl:when test="doc(iri-to-uri(concat($currFolder, '/', $currSubFolder, '/', @href)))"> 

(The path is true)

however, this leads to an error when the file does not exist.

and this:

 <xsl:choose> <xsl:when test="doc-available(iri-to-uri(concat($currFolder, '/', $currSubFolder, '/', @href)))"> 

it doesn’t work, it tells me that the files there clearly do not exist.

What is the right way to do this? A reliable way to check if an xml file exists.

+7
xml xslt
source share
1 answer

In accordance with this similar question, the author mentions that something like this worked for them, checking for the presence of an XML file.

At the moment, it checks each folder separately, if the file does not exist in this folder, it writes it to the output, regardless of whether it 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> 
+3
source share

All Articles