You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by tiberiu <ti...@hotmail.de> on 2007/08/01 21:42:16 UTC

is StylesheetRoot really java.io.Serializable ?

Hi,
in xalan documentation there is a hint to use Templates and to cache them,
in order to increase performance.
I need to cache them on disk, so that I tried to use (java.io) Serializable
interface.
The Problem is that even if StyleSheetRoot (the Templates Object) implements
Serializable,
ExtensionNamespaceSupport doesn't.

So, trying to save a StylesheetRoot with xalan2.4.0 crashes, in 2.7.0 I
didn't obtain an error but the read Class from such a File return on method
StylesheetRoot.getExtensions() a null. This null is at the end converted in
an "Unknown Error in XPath" Error because of the following Code from
ExtensionsTable class:
Vector extensions = m_sroot.getExtensions();
    for (int i = 0; i < extensions.size(); i++)

Without these Extensions the Templates doesn't know defined Namespaces.

My Question is if it is a possibility to serialize StylesheetRoot in a File,
and to can use that serialized form in order to generate a good Transformer.


Thanks for an answer.

-- 
View this message in context: http://www.nabble.com/is-StylesheetRoot-really-java.io.Serializable---tf4202280.html#a11952525
Sent from the Xalan - J - Users mailing list archive at Nabble.com.

Re: is StylesheetRoot really java.io.Serializable ?

Posted by tiberiu <ti...@hotmail.de>.
Hi Christine,
thanks for the fast answer :).
Meanwhile I quite managed to solve my problem, after some xalan Code
Inspection.
I'm not so sure it's a Bug as in StylesheetRoot there is expressed set the
Extensions Manager as transient ("private transient
ExtensionNamespacesManager m_extNsMgr = null;").

My Problem came from the fact that I had some extra Namespace declarations
as from those default.
The work around I'm using is to recreate for serialized Templates the
transient Data, something as:
StylesheetRoot root = ...;
String[] myNamespaces = new String[] {.....};
for(int i = 0; i < myNamespaces.length;i++) {
  root.getExtensionNamespacesManager().registerExtension(myNamespaces[i]);
}
root.getExtensionNamespacesManager().registerUnregisteredNamespaces();

I don't know if to open a Bug only for that (it's true that Transformer
crash with "Unknown..." if Stylesheet. getExtensionNamespacesManager() isn't
called), if you want I can do it :)

I did also some performances tests, yes, you are right the default Java
Serialization (in Files) is slower as Templates recreation, but with few
alterations can be done faster (in fact Caching Software on Disk (as jcs)
uses also Serialization and is fast enough).

Unfortunatelly I can't use xsltc as the xslt Code I use can't be compiled
with that one (Xalan accept many same xsl:variable definitions in same xpath
branch, xsltc seems not).
About compiling, I believed that a StylesheetRoot exactly that is - a
compiled Class of xslt statements :).


Many Thanks again :),
Tiberiu


Christine Li wrote:
> 
> Hi,
> 
> It looks like a bug in the code. Please open a bug report for it 
> http://issues.apache.org/jira/browse/XALANJ
> 
> By the way, I did some performance comparison long time ago, it showed 
> that serialize and deserialize a Template object is slower than regenerate 
> a Template object from a stylesheet. 
> 
> If you want to get better performance, you can use XSLTC, you can compile 
> a stylesheet into a translet (a java class), then you can do 
> transformation later. More details please refer to 
> http://xml.apache.org/xalan-j/xsltc_usage.html
> 
> Hope it helps,
> 
> Christine Li
> XSLT Development
> IBM Toronto Lab
> Tel: (905)413-2601
> Email: jycli@ca.ibm.com
> 
> 
> 
> tiberiu <ti...@hotmail.de> 
> 01/08/2007 03:42 PM
> 
> To
> xalan-j-users@xml.apache.org
> cc
> 
> Subject
> is StylesheetRoot really java.io.Serializable ?
> 
> 
> 
> 
> 
> 
> Hi, in xalan documentation there is a hint to use Templates and to cache 
> them, in order to increase performance. I need to cache them on disk, so 
> that I tried to use (java.io) Serializable interface. The Problem is that 
> even if StyleSheetRoot (the Templates Object) implements Serializable, 
> ExtensionNamespaceSupport doesn't. So, trying to save a StylesheetRoot 
> with xalan2.4.0 crashes, in 2.7.0 I didn't obtain an error but the read 
> Class from such a File return on method StylesheetRoot.getExtensions() a 
> null. This null is at the end converted in an "Unknown Error in XPath" 
> Error because of the following Code from ExtensionsTable class: Vector 
> extensions = m_sroot.getExtensions(); for (int i = 0; i < 
> extensions.size(); i++) Without these Extensions the Templates doesn't 
> know defined Namespaces. My Question is if it is a possibility to 
> serialize StylesheetRoot in a File, and to can use that serialized form in 
> order to generate a good Transformer. Thanks for an answer. 
> View this message in context: is StylesheetRoot really 
> java.io.Serializable ?
> Sent from the Xalan - J - Users mailing list archive at Nabble.com.
> 
> 

-- 
View this message in context: http://www.nabble.com/is-StylesheetRoot-really-java.io.Serializable---tf4202280.html#a11955038
Sent from the Xalan - J - Users mailing list archive at Nabble.com.


Re: is StylesheetRoot really java.io.Serializable ?

Posted by Christine Li <jy...@ca.ibm.com>.
Hi,

It looks like a bug in the code. Please open a bug report for it 
http://issues.apache.org/jira/browse/XALANJ

By the way, I did some performance comparison long time ago, it showed 
that serialize and deserialize a Template object is slower than regenerate 
a Template object from a stylesheet. 

If you want to get better performance, you can use XSLTC, you can compile 
a stylesheet into a translet (a java class), then you can do 
transformation later. More details please refer to 
http://xml.apache.org/xalan-j/xsltc_usage.html

Hope it helps,

Christine Li
XSLT Development
IBM Toronto Lab
Tel: (905)413-2601
Email: jycli@ca.ibm.com



tiberiu <ti...@hotmail.de> 
01/08/2007 03:42 PM

To
xalan-j-users@xml.apache.org
cc

Subject
is StylesheetRoot really java.io.Serializable ?






Hi, in xalan documentation there is a hint to use Templates and to cache 
them, in order to increase performance. I need to cache them on disk, so 
that I tried to use (java.io) Serializable interface. The Problem is that 
even if StyleSheetRoot (the Templates Object) implements Serializable, 
ExtensionNamespaceSupport doesn't. So, trying to save a StylesheetRoot 
with xalan2.4.0 crashes, in 2.7.0 I didn't obtain an error but the read 
Class from such a File return on method StylesheetRoot.getExtensions() a 
null. This null is at the end converted in an "Unknown Error in XPath" 
Error because of the following Code from ExtensionsTable class: Vector 
extensions = m_sroot.getExtensions(); for (int i = 0; i < 
extensions.size(); i++) Without these Extensions the Templates doesn't 
know defined Namespaces. My Question is if it is a possibility to 
serialize StylesheetRoot in a File, and to can use that serialized form in 
order to generate a good Transformer. Thanks for an answer. 
View this message in context: is StylesheetRoot really 
java.io.Serializable ?
Sent from the Xalan - J - Users mailing list archive at Nabble.com.