logo       


RE: Examples on how to serialize a Templates object?: msg#00114

Subject: RE: Examples on how to serialize a Templates object?
As I think I said in my other message, this facility was only introduced in 7.x.
 
Michael Kay
-----Original Message-----
From: saxon-help-admin-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@xxxxxxxxxxxxxxxx [mailto:saxon-help-admin-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@xxxxxxxxxxxxxxxx] On Behalf Of Nestor Boscan
Sent: 31 January 2004 14:03
To: saxon-help-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@xxxxxxxxxxxxxxxx
Subject: RE: [saxon] Examples on how to serialize a Templates object?

Thanks again Michael
 
I tried to serialize the templates object and I get:
 
java.io.NotSerializableException: com.icl.saxon.PreparedStyleSheet
 
 void java.io.ObjectOutputStream.outputObject(java.lang.Object)
 
  ObjectOutputStream.java:1148
 
 void java.io.ObjectOutputStream.writeObject(java.lang.Object)
 
  ObjectOutputStream.java:366
 
 void com.tcs.wireless.Prueba.main(java.lang.String[])
 
  Prueba.java:29
I'm working right now with 6.5.3.
 
Regards,
 
Néstor Boscán
 
 


De: saxon-help-admin-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@xxxxxxxxxxxxxxxx [mailto:saxon-help-admin-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@xxxxxxxxxxxxxxxx] En nombre de Michael Kay
Enviado el: Saturday, January 31, 2004 6:43 AM
Para: saxon-help-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@xxxxxxxxxxxxxxxx
Asunto: RE: [saxon] Examples on how to serialize a Templates object?

You can create and serialize the Templates object using the net.sf.saxon.Compile command from the command line; if you want to do it from the API, take a look at the source code for this command to see how it works. It's essentially:
 
Templates sheet = factory.newTemplates(styleSource);
ObjectOutputStream oos = new ObjectOutputStream(
                                             new FileOutputStream(outputFileName));
oos.writeObject(sheet);
oos.close();
 
To load it back into memory, you can use the -c option on the net.sf.saxon.Transform command, or again you can do it from your application. The only tricky thing is that you have to make sure the NamePool that was used when compiling the stylesheet is also used when running it:
 
                        ObjectInputStream ois = new ObjectInputStream(new FileInputStream(styleFileName));
                        Templates sheet = (Templates)ois.readObject();
                        ois.close();
                        ((PreparedStyleSheet)sheet).setConfiguration(config);
                        NamePool.setDefaultNamePool(((PreparedStyleSheet)sheet).getTargetNamePool());
 
Don't expect vast savings from this. A compiled stylesheet, when serialized, occupies more space on disk than the original source XML stylesheet, and this means it's not all that much faster to read the compiled stylesheet in from disk than it is to recompile the original. If you make any performance measurements, I would be interested to see them.
 
Michael Kay
 
 
-----Original Message-----
From: saxon-help-admin-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@xxxxxxxxxxxxxxxx [mailto:saxon-help-admin-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@xxxxxxxxxxxxxxxx] On Behalf Of Nestor Boscan
Sent: 30 January 2004 23:21
To: saxon-help-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@xxxxxxxxxxxxxxxx
Subject: [saxon] Examples on how to serialize a Templates object?

Hi
 
I would like to serialize the XSL Templates object so I can load it directly to memory in an application and not provide the XSL document. Is there a way to do this?. Any examples?
 
Regards
 
Néstor Boscán
 
 
Ruby Jobs
Java Jobs
Jobs in California
more...
what
job title, keywords
where
city, state, zip
jobs by job search
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
encryption.gpg....    ietf.rfc822/199...    freebsd.devel.i...    lang.haskell.li...    mail.squirrelma...    web.zope.plone....    yellowdog.gener...    text.xml.xalan....    recreation.phot...    kde.devel.educa...    hardware.bus.ca...    printing.ghosts...    voip.peering/20...    assembly/2006-0...    org.user-groups...    culture.interne...    network.i2p/200...    boot-loaders.ya...    xfree86.render/...    qnx.openqnx.dev...    jakarta.velocit...    user-groups.pal...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe