Я хотел бы проверить в XSLT, существует ли файл HTML или нет. Как я могу это сделать? Я уже пробовал файл-exist.xsl отсюда https://gist.github.com/emth/4531924, но он не работает для меня. Я пытался запустить его более 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