xsl-list
[Top] [All Lists]

RE: [xsl] File:New generates error

2009-03-18 06:54:01

Hi, we are exactly doing the same thing as suggested by you. 
The static block in the class sets the system property for TransforerFactory

static {
                System.setProperty("javax.xml.parsers.DocumentBuilderFactory",
                "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
                System.setProperty("javax.xml.parsers.SAXParserFactory",
                        "org.apache.xerces.jaxp.SAXParserFactoryImpl");
                System.setProperty("javax.xml.transform.TransformerFactory",
                                "com.icl.saxon.TransformerFactoryImpl   }

But still, why processor still picks up factory from rt.jar. Any idea?

regards,
Ranjan

--- On Wed, 3/18/09, Michael Kay <mike(_at_)saxonica(_dot_)com> wrote:

From: Michael Kay <mike(_at_)saxonica(_dot_)com>
Subject: RE: [xsl] File:New generates error
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Date: Wednesday, March 18, 2009, 6:13 AM

The JAXP factory mechanism, which relies on searching the
classpath for the
first XSLT processor it finds, is really best avoided. It's
expensive and
unpredictable. If your code is written to only work with
one particular
processor, then instantiate it directly (replace
TransformerFactory.newInstance() by new
net.sf.saxon.TransformerFactoryImpl()). Or set the Java
system property
javax.xml.transform.TransformerFactory to the value
"net.sf.saxon.TransformerFactoryImpl".

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

-----Original Message-----
From: Cool The Breezer [mailto:techcool(_dot_)kumar(_at_)yahoo(_dot_)com]

Sent: 18 March 2009 09:29
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: RE: [xsl] File:New generates error


Hi, We have this problem appeared again. We found that

Saxon.jar file was present in the classpath. I
understand 
that this might not be directly related to XSLT
problem but 
it is something which is caused when java is not able
to 
access saxon.jar or xalan.jar in classpath and
accesses 
default processor from rt.jar. As this problem occurs

randomly, it makes me very difficult to find the root
cause 
of the problem. Any help/suggestion/input would be
highly appreciated.

- RB

--- On Mon, 3/16/09, Cool The Breezer 
<techcool(_dot_)kumar(_at_)yahoo(_dot_)com>
wrote:

From: Cool The Breezer <techcool(_dot_)kumar(_at_)yahoo(_dot_)com>
Subject: RE: [xsl] File:New generates error
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Date: Monday, March 16, 2009, 12:08 PM

Thanks lot for pointing me in right direction. In
the code 
base system 
property for transformation factory is set to
"null" that's why 
processor uses sun's transformation
packages(XSLTC) instead of saxon which gives
error. I realized that 

com.sun.org.apache.xalan.internal.xsltc.compiler.Variable
present in rt.jar which is part of JDK. This does
not occur always, 
becos the part of code setting system property
for transformation 
factory to null is executed in *Some*
conditions.

-RB

--- On Mon, 3/16/09, Michael Kay <mike(_at_)saxonica(_dot_)com>
wrote:

From: Michael Kay <mike(_at_)saxonica(_dot_)com>
Subject: RE: [xsl] File:New generates error
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Date: Monday, March 16, 2009, 8:52 AM

You're not using Saxon here, you're using
the XSLTC 
processor (part 
of the Xalan product). I suspect that's
related to the 
the problem, 
since calling conventions for extension
functions depend on the
processor
you are using.

Since file:exists in Java returns a boolean,
I would 
suggest taking 
out the " = 'true'" part of the test, since
comparing a
boolean to
a string is
somewhat error-prone.

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

-----Original Message-----
From: Cool The Breezer 
[mailto:techcool(_dot_)kumar(_at_)yahoo(_dot_)com]

Sent: 16 March 2009 12:18
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] File:New generates
error


Hi,
We have strange error started coming
recently
for
using java
A= PI to check file existence. Recently
we moved
to
saxon and
earlier we were using Xalan but I dont
think
this
caused the
error. We were using this code since
years or so
without any
problem and this error =A0comes
randomly. I am
not
able to
replicate this in dev environment. I
would
appreciate
your
help on finding root cause of this
problem.

XSL Code:

<xsl:template name="file-exists"
xmlns:file="java.io.File">

        <xsl:param
name="filename"/>
       
<xsl:choose>
       
    <xsl:when
test="file:exists(file:new($filename))
=
'true'">true</xsl:when>
       
   

<xsl:otherwise>false</xsl:otherwise>
       
</xsl:choose>
    </xsl:template>

Error:
ERROR:  'Cannot convert
argument/return type in
call to
method 'java.io.File.new(reference)''

FATAL ERROR:  'Could not compile
stylesheet'

  

java.lang.ClassCastException: 



com.sun.org.apache.xalan.internal.xsltc.compiler.Variable
cannot be cast to



com.sun.org.apache.xalan.internal.xsltc.compiler.Param

       at



com.sun.org.apache.xalan.internal.xsltc.compiler.SymbolTable.a
ddParam(Unknown Source)





       





--~------------------------------------------------------------------
XSL-List info and archive:  
http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--






--~------------------------------------------------------------------
XSL-List info and archive:  
http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--








--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




       


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--






--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

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