Unable to cast the net.sf.saxon.jaxp.TemplatesImpl to serializable

677 views Asked by At

i have one question : Can we able to serialize net.sf.saxon.jaxp.TemplatesImpl object. my issue: I am unable to serialize my net.sf.saxon.jaxp.TemplatesImpl instance, can any one help how to serialize my object. I got the exception like below:

java.lang.ClassCastException: net.sf.saxon.jaxp.TemplatesImpl cannot cast to java.io.Serializable

I am Using following depedencies:

<!-- https://mvnrepository.com/artifact/net.sf.saxon/Saxon-HE -->
<dependency>
<groupId>net.sf.saxon</groupId>
<artifactId>Saxon-HE</artifactId>
<version>9.8.0-4</version>
</dependency>

and javax.xml api i am using to transform.

1

There are 1 answers

0
Michael Kay On BEST ANSWER

At one time we did attempt to allow you to use Java serialization to make a persistent copy of a compiled stylesheet. It didn't work at all well. There were lots of problems. For example. the compiled stylesheet has references to some Java classes that aren't serializable (like RuleBasedCollator). Also, the size of the serialized form was so large that it was often quicker to recompile from source XSLT than to deserialize the compiled form. Imported schemas were also a problem. I forget now what all the issues were, but we eventually decided to scrap this facility.

In place of this, Saxon-EE now has the capability to export a compiled stylesheet into a Saxon-defined XML representation (the Stylesheet Export File or SEF) which can be reloaded on the same or a different machine. This is also the basis of Saxon-JS, which allows the exported stylesheet to be executed in the browser.