Hi All,

Does anyone have any examples of the best approach to checking for the existence of a local and remote file (like images for example) from within a stylesheet?

I'd like to be able to make a decision in the stylesheet that is dependent upon whether a file exists or not.
I've tried a number of different ways.


The closest I've come, so far, is by creating an extension using rhino 1.5R4_1 (js.jar), and doing an importClass(java.io.File).

The problem with this is that I want to be able to check remote files via HTTP, too. When I try to importClass(java.net.URL) using rhino 1.5, I get:

XSLT Error (javax.xml.transform.TransformerException): Could not create extension: fileExists because of: java.lang.reflect.InvocationTargetException


I've also tried to write an extension in Java and use it within the stylesheet but, when I tried calling the class (trying to follow the idea behind the example "Formatting a Date" on http://xml.apache.org/xalan-j/extensions.html ), the error I got was:


java.lang.NoSuchMethodException: For extension function, could not find method java.lang.String.URLExists([ExpressionContext,] ).

(it really weird to me that something would be trying to tie the custom class URLExists as an extension of java.lang.String)

Please let me know if you would like me post code.

If you have any suggested resources or code samples, too that would be great.

TIA,
Bennett



Reply via email to