我提到了xsl中的xml文件路径,但我想暂时删除文件夹中的那个xml文件,并且我总是想保留在xsl中。但是当我删除它时显示警告。
<xsl:apply-templates mode="replaceVariables"
select="document('../Folder_1/Test.xml')">
</xsl:apply-templates>
我从
Test.xml
中删除了Folder_1
。当我运行时,出现以下错误
Engine name: Saxon-PE 9.9.1.7
Severity: warning
Description: I/O error reported by XML parser processing file:/C:/Work/Folder_1/Test.xml: C:/Work/Folder_1/Test.xml (The system cannot find the file specified)
Start location: 674:48
Length: 1
即使 xml 文件在相应的提到的文件夹中删除,它在转换时也不应该显示错误。
在 XSLT 2.0 及更高版本中,有 XPath 2.0 及更高版本的函数
doc-available
例如doc-available('../Folder_1/Test.xml')
,因此您可以在 xsl:if
周围使用 xsl:apply-templates
检查,或者您甚至可以在 select
表达式的谓词中使用该检查。