You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by "Voytenko, Dimitry" <DV...@SECTORBASE.COM> on 2000/11/27 03:26:40 UTC

Precompiled stylesheets

Hi,
from the release notes of Xalan-J 1.2.1, open bugs:
A "not serializable exception" occurs when you attempt to run a precompiled
stylesheet that expects parameter values to be passed in. If you encounter
this problem, you should forego the use of precompiled stylesheets until a
fix is available.

I think I found the problem. 
private variable m_xpathFactory is declared as transient that is pretty
clear. After precompiled stylesheet is loaded the value of this variable is
null. So the first usage in the pushTopLevelVariables() will through
NullPointerException.
On other hand it is not clear why variables m_xpath and m_xpathProcessor are
not transient (I think it's another bug). If you run precompiled stylesheet
before you call XSLTProcessor.processStyleSheet() then
Stylesheet.initXPath(XSLTEngineImpl, XPathFactory) won't be called and then
xslt functions: "document" and "format-number" won't be registered. So first
invoke of any of this function will fail with NullPointerException (or other
functions will be called from org.apache.xalan.xpath package).
I declared all these three variables m_xpathFactory, m_xpath,
m_xpathProcessor as transient and in the StylesheetRoot class I corrected
process next way:
public void process( XSLTProcessor iprocessor, Node sourceTree,
XSLTResultTarget outputTarget)
  throws SAXException, MalformedURLException, FileNotFoundException,
IOException
{
    XSLTEngineImpl processor = (XSLTEngineImpl)iprocessor; // TODO: Check
for class cast exception
// only this line added <------------------------
checkInit (processor);
// .................
And I put method checkInit into the Stylesheet class as
protected synchronized void checkInit (XSLTEngineImpl processor) {
  if (m_xpathFactory == null)
     initXPath (processor, m_xpathFactory);
}
After this changes precompiled stylesheets started working fine with
external parameters.
It would be great if you will make such changes shortly, I really need this
feature to work correctly. I can download latest versions of these files and
make necessary changes myself. And you can commit them after testing. 
But there's one more unclear thing I found out. Stylesheet.initXPath
(XSLTEngineImpl, XPathFactory) method registers "document" and
"format-number" functions and it's called every time
XSLTProcessor.processStylesheet method is invoked. So those functions are
registered each time processStylesheet is called. I don't think it's really
necessary, functions pool is static.
Thank you
Dmitry E. Voytenko