[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Chaining Transformers/Templates
> > > 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|