RE: [xsl] Error Namespace 'java.io.File' does not contain any functions" (was Re: [xsl] XSL cant check if "File exists"?)

Subject: RE: [xsl] Error Namespace 'java.io.File' does not contain any functions" (was Re: [xsl] XSL cant check if "File exists"?)
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 1 Sep 2006 10:01:20 +0100
Generally, you can't rely on extension functions being portable across
different processors. Certainly, you can't expect Java extension functions
to work in the Internet Explorer processor (MSXML).

As a matter of interest, is the file you are checking for client side or
server side? There may well be security reasons why you aren't allowed to do
this, regardless of any other issues.

Generally, if you stray outside the XSLT 1.0 specification, you will need to
write processor-specific code. You should be able to write conditional code
that executes differently depending which processor you are using.
Alternatively, you might find you can do the work outside your XSLT, in the
calling Javascript, and pass the result in as a parameter. 

Michael Kay
http://www.saxonica.com/



> -----Original Message-----
> From: Laky Tang [mailto:tulaky@xxxxxxxxx] 
> Sent: 31 August 2006 22:51
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Error Namespace 'java.io.File' does not 
> contain any functions" (was Re: [xsl] XSL cant check if "File 
> exists"?)
> 
> Thanks Mike, David and Mukul, 
> > If you have to work client side, then you're stuck with 
> XSLT 1.0 for a 
> > couple of years yet.
> 
> I am hearing the bottomline is that XSL (client side) cannot 
> gracefully check if a file exists for now.
> 
> But going back to my earlier question (which I am not sure 
> was answered), I read there is a way to check using 
> extensions, but the following example gives me an error 
> "Namespace 'java.io.File'
> does not contain any functions" in IE and XML spy. It works 
> incorrectly in Firefox / Flock by always saying the file does 
> not exist (even if it does). Changing XSLT 1.0 to 2.0 did not 
> make any difference. Am I missing something in the namespace 
> declarations?
> 
>  If there is no way this can be gracfully done in XSL (client 
> side) then we might have to dump our work in XSL and start 
> looking for alternatives to XSL and I hope the guru's have 
> some solution.
> Thanks,
> -Tulaky
> Example adapted from another posting:
> ------------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
> xmlns:fo="http://www.w3.org/1999/XSL/Format";
> xmlns:xs="http://www.w3.org/2001/XMLSchema";
> xmlns:fn="http://www.w3.org/2005/02/xpath-functions";
> xmlns:xdt="http://www.w3.org/2005/02/xpath-datatypes";
> xmlns:xlink="http://www.w3.org/1999/xlink";
> xmlns:h="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd";>
> <!-- my other templates go here which call this with the 
> Fully qualified or relative filename--> <xsl:template 
> name="file_exists"
> xmlns:file="java.io.File">
>   <xsl:param name="filename" />
> 
>   <xsl:if test="not(file:exists($filename))">
>   file <xsl:value-of select="$filename"/> does not exist!
>   </xsl:if>
> </xsl:template>
> </xsl:stylesheet>
> 
> 
> 
> > ------------------------------
> > 
> > Date: Wed, 30 Aug 2006 13:41:44 +0100
> > To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
> > From: "Michael Kay" <mike@xxxxxxxxxxxx>
> > Subject: RE: [xsl] Namespace
> > 'http://www.w3.org/2005/xpath-functions' does not
> > contain any functions (was Re: [xsl] XSL cant check
> > if "File exists"?)
> > Message-ID: <00d801c6cc31$a69b3090$1a09010a@turtle>
> > 
> > > 
> > >  but IE says Namespace
> > > 'http://www.w3.org/2006/xpath-functions' does not
> > contain any 
> > > functions.(tried both 2006 and 2005 in the fn
> > namespace 
> > > declaration) Firefox says "Error during XSLT
> > transformation: 
> > > An unknown XPath extension function was called."
> > 
> > In both cases, they are saying "I'm an XSLT 1.0
> > processor, I don't
> > understand anything about XSLT 2.0 functions".
> > 
> > If you have to work client side, then you're stuck
> > with XSLT 1.0 for a
> > couple of years yet.
> > 
> > Michael Kay
> > http://www.saxonica.com/
> > 
> > ------------------------------
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 

Current Thread