相关疑难解决方法(0)

如何在XSLT中检查文件是否存在?

我想检查XSLT是否存在HTML文件.我怎样才能做到这一点?我已经从这里https://gist.github.com/emth/4531924尝试了file-exist.xsl,但它对我不起作用.我一直试图让它运行超过2个小时,但我被卡住了.这是我的蚂蚁片段:

<target name="transform">
    <xslt in="/tmp/sample.xml" out="/tmp/out.html" style="/tmp/sample.xsl" />
</target>
Run Code Online (Sandbox Code Playgroud)

这是我的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>
....
Run Code Online (Sandbox Code Playgroud)

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

ant xslt

5
推荐指数
1
解决办法
5256
查看次数

标签 统计

ant ×1

xslt ×1