Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 28th, 2014, 11:43 AM
Authorized User
 
Join Date: Aug 2013
Posts: 30
Thanks: 9
Thanked 0 Times in 0 Posts
Default Check if image file exists

Hi,

I would like to test if an image online exists.
I have read this XSLT Check if directory exist and also a suggestion here
but still there is something i must be getting wrong (please also note that I have never worked with java).

my xslt (Saxon 9.5.1.3) works on a local file and needs to check the existence of this file building the url on the basis of a varible, like this:

source:
Code:
<list>
<ROW RECORDID="373"/>
 </list>
Code:
<xsl:function name="java:file-exists" xmlns:file="java.io.File" as="xs:boolean">
        <xsl:param name="file" as="xs:string"/>
        <xsl:param name="base-uri" as="xs:string"/>
        
        <xsl:variable name="absolute-uri" select="resolve-uri($file, $base-uri)" as="xs:anyURI"/>
        <xsl:sequence select="file:exists(file:new($absolute-uri))"/>
    </xsl:function>
...
<xsl:template match="ROW">
<xsl:variable name="URI">
<xsl:value-of select="concat('http://foo.xx/detail-base.php?image=Image_5_Large&amp;recid=', @RECORDID)"/>
</xsl:variable>
<xsl:if  test="java:file-exists($URI, base-uri())">
           <graphic url="{$URI}"/></xsl:if>
...
</xsl:template>
the error I get is:

Quote:
jt:java.lang.IllegalArgumentException: Exception thrown by extension function {public java.io.File(java.net.URI)}: java.lang.IllegalArgumentException: URI scheme is not "file"
and I do not understand it.

Any help would be greatly appreciated.
Thank you very much
Pietro





Similar Threads
Thread Thread Starter Forum Replies Last Post
document() - check if a file exists N.Todd XSLT 2 September 19th, 2007 05:50 AM
Check if a file exists on network darrenb Access VBA 2 March 27th, 2007 07:15 PM
hei,anyone know how to check a remote file exists lsj113 C# 2005 3 November 28th, 2006 02:55 AM
Check if file starting with a pattern exists or no desperado1306 Excel VBA 1 May 30th, 2006 08:28 AM
check first to see if the file exists crmpicco Classic ASP Professional 2 December 1st, 2005 12:34 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.