[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Chaining Transformers/Templates

Subject: RE: Chaining Transformers/Templates
From: "Varley, Roger" <Roger.Varley@xxxxxxxxxxx>
Date: Tue, 10 Dec 2002 13:00:54 -0000
xmlreaderfactory singleton
> 
> > The reason that I want to to use Templates is that I 
> > will have a large number of threads performing a 
> > transormations using two standard XSL stylesheets so I want 
> > to avoid the overhead of re-processing the transform 
> > instructions every time. 

Thanks to Micheal Kays response I now have the following code running and
working in the processing threads.

           TransformerFactory tFactory = TransformerFactory.newInstance();
           SAXTransformerFactory saxFactory = (SAXTransformerFactory)
tFactory;
           
           TransformerHandler standardTH =
saxFactory.newTransformerHandler(standardTemplate);
           TransformerHandler recipientTH =
saxFactory.newTransformerHandler(recipientTemplate);
           
           XMLReader reader = XMLReaderFactory.createXMLReader();
           reader.setContentHandler(standardTH);
           standardTH.setResult(new SAXResult(recipientTH));
           
           Serializer serializer =
SerializerFactory.getSerializer(OutputProperties.getDefaultMethodProperties(
"xml"));
           serializer.setOutputStream(new FileOutputStream(incomingPath +
"result.xml"));
           
           recipientTH.setResult(new
SAXResult(serializer.asContentHandler())); 

The template objects are created by an external singleton class called by
the processing thread. The singleton class has to call
TransformerFactory.newInstance() to create the template, so I'm now
wondering how much of the above code I can move to my external singleton
class and still remain threadsafe. For example, could I go as far as moving
all this code to my external class so that the XMLReader is only built once
and return the XMLReader object to every thread that asks for it. The thread
then builds the input for the XMLReader and then calls XMLReader.parse().

Regards
Roger 

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.