xsl-list
[Top] [All Lists]

Re: check with XSL if a file is available

2003-07-07 07:38:24

There is no way to do that in standard XSLT.
A system is _allowed_ not to error on a missing file, and if it does not
error, then it must return an empty node set, and your test will work.
If however it does error (and your system seems to), you have no way to
recover.


Since you are (presumably) using xalan inside cocoon you can use
xalan's extension functions to 

eg this (which uses saxon's interface to java, but xalan has something
similar I think)


<xsl:template name="file-exists-p" xmlns:file="java.io.File">
  <xsl:param name="filename" select="'x'"/>
  <xsl:value-of select="file:exists(file:new($filename))"/>
</xsl:template>


An alternative is to customise your URI resolver classes in Java so that
they don't error on a missing file, but instead return some standard XML
file that you can test for.

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>