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

using saxtransformerfactory and templates

Subject: using saxtransformerfactory and templates
From: "Andrew Welch" <awelch@xxxxxxxxxxxxxxx>
Date: Mon, 22 Jul 2002 15:20:13 +0100
saxtransformerfactory
I am trying to use templates with XMLFilter()

I have a normal (non-templates) transform working with XMLFilter(), but
the only example Ive seen of using templates with SAXTransformerFactory
uses XMLReader().

As far as I can tell, I can only setParent() on XMLFilter()'s not on
XMLReaders so is it possible to use templates with
SAXTransformerFactory?

Here is my current non-templates code:

SAXTransformerFactory saxFactory = (SAXTransformerFactory)factory;
ajwFilter xmlFilter = new ajwFilter();
xmlFilter.setParent(new com.icl.saxon.aelfred.SAXDriver());
XMLFilter styleSheet = saxFactory.newXMLFilter(new StreamSource(style));
styleSheet.setParent(xmlFilter);
TransformerHandler serializer = saxFactory.newTransformerHandler();
serializer.setResult(new StreamResult(System.out));
styleSheet.setContentHandler(serializer);
styleSheet.parse(source.getSystemId());

This is basically what I've gleaned from the example, but it doesn't
work because you can only chain xmlFilters and not xmlReaders - is it
possible to modify this code so it will work?:

SAXTransformerFactory saxFactory = (SAXTransformerFactory)factory;
TemplatesHandler templatesHandler =  saxFactory.newTemplatesHandler();
ajwFilter xmlFilter = new ajwFilter();
org.xml.sax.XMLReader styleSheet2 = 
  org.xml.sax.helpers.XMLReaderFactory.createXMLReader();
styleSheet2.setContentHandler(templatesHandler);
styleSheet2.parse("C:\\ajw\\test.xsl");
xmlFilter.setParent(new com.icl.saxon.aelfred.SAXDriver());
templates = templatesHandler.getTemplates();            
styleSheet2.setParent(xmlFilter);
//**fails here**
TransformerHandler serializer =
saxFactory.newTransformerHandler(templates);
serializer.setResult(new StreamResult(System.out));
styleSheet2.setContentHandler(serializer);
styleSheet2.parse(source.getSystemId());

Any advice on what is needed would be great

Cheers
andrew

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.373 / Virus Database: 208 - Release Date: 01/07/2002
 

 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.