我想要在XSLT中检查HTML文件是否存在。
我该怎么做?
我已经尝试了这里的file-exists.xsl https://gist.github.com/emth/4531924,但对我来说没有用。我一直在尝试让它运行超过2个小时,但我卡住了。
这是我的ant片段:
使用Ant运行时,我会收到以下错误信息:
我该怎么做?
我已经尝试了这里的file-exists.xsl https://gist.github.com/emth/4531924,但对我来说没有用。我一直在尝试让它运行超过2个小时,但我卡住了。
这是我的ant片段:
<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>
....
使用Ant运行时,我会收到以下错误信息:
[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
有没有人可以给我提供一个运行的例子,或者是否有其他的选择?谢谢!