|
Subject: [xsl] using saxtransformerfactory and templates From: "Andrew Welch" <awelch@xxxxxxxxxxxxxxx> Date: Mon, 22 Jul 2002 15:20:13 +0100 |
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 |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| RE: [xsl] XSLT, frames and javascri, Jarno . Elovirta | Thread | [xsl] <xsl:fallback> use with MSXSL, Frédéric JOUAULT |
| Re: [xsl] Query re XMLSpy XPath eng, Elliotte Rusty Harol | Date | RE: [xsl] Hierarchy problem, DPawson |
| Month |