使用XSLT 2.0,saxon9HE检查xml文件是否存在

use*_*892 7 xml xslt

我想用xslt 2.0检查文件是否存在.但是,它不起作用.我试过这个:

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

(路径正确)

但是,当文件不存在时,这会导致错误.

还有这个:

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

它不起作用,它告诉我文件在那里显然不存在.

这是正确的方法吗?如果存在xml文件,则检查的可靠方法.

dav*_*rey 3

根据这个类似的问题,作者提到,就检查 xml 文件是否存在而言,这样的东西对他们有用。

现在,它单独检查每个文件夹,如果该文件不存在于该文件夹中,则将其写入输出,无论它是否已存在于另一个先前的文件夹中。

<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>
Run Code Online (Sandbox Code Playgroud)