This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

using saxtransformerfactory and templates


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]