[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 14:55:36 -0000
xslt chaining
> 
> Two of the classes mentioned, XMLReaderFactory and SerializerFactory,
> aren't in JAXP: any reason why you're not writing pure JAXP code?
> 

Again, probably newbie-itis as far as XSLT is concerned. The first example I
found in Wrox's "Professional Java XML" uses these classes. Probably by the
time I get to the end, I'll find other/better ways of doing it :)

> The XMLReader and the TransformerHandlers are serially 
> reusable but not
> multithreaded. It's generally best to create a new instance of these
> classes for each transformation, if only to be sure of clearing out
> unwanted data in memory. The important object to reuse is the 
> Templates
> object.
> 

What if I cloned newly created XMLReader and returned that?

Thanks again

Roger

 
> 
> > -----Original Message-----
> > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> > Varley, Roger
> > Sent: 10 December 2002 13:01
> > To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'
> > Subject: 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.getDefaultMet
> > hodProperties(
> > "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
> 


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

 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.