我想在XSLT中检查HTML文件是否存在。 我该怎么做? 我已经尝试从这里https://gist.github.com/emth/4531924的文件exists.xsl但它不适合我。我一直试图让它运行2个多小时,但我被卡住了。 这里是我的蚂蚁片断:如何在XSLT中检查文件是否存在?
<target name="transform">
<xslt in="/tmp/sample.xml" out="/tmp/out.html" style="/tmp/sample.xsl" />
</target>
,这是我的XSLT文件:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:java="http://www.java.com/">
<xsl:import href="file-exists.xsl"/>
...
<xsl:if test="java:file-exists('myfile.html', base-uri())">
<!-- do something here... -->
</xsl:if>
....
与蚂蚁,我会收到以下错误运行此:
[xslt] Processing /tmp/sample.xml to /tmp/out.html
[xslt] Loading stylesheet /tmp/sample.xsl
[xslt] : Error! The first argument to the non-static Java function 'fileExists' is not a valid object reference.
[xslt] : Error! Cannot convert data-type 'void' to 'boolean'.
[xslt] : Fatal Error! Could not compile stylesheet
[xslt] Failed to process /tmp/sample.xml
灿有人提供我一个运行的例子,或者有其他的选择吗?谢谢!
我觉得库文件exists.xsl使用XSL ENGIN 2.0,但你在1.0版本上运行它http://stackoverflow.com/questions/2917655/how-do-i-check-for-the-existence-of-an-external-file-with-xsl – Sawyer
无论我使用的版本是1.0还是2.0 。我得到与2.0 – user1613270