It's possible to do this entirely with JAXP interfaces, you don't need to
resort to Xalan-specific or Saxon-specific methods. This relies on the fact
that a serializer is simply an identity transformer from a SAX source to a
Stream result:
TransformerHandler serializer = TransformerFactory.getTransformerHandler();
serializer.getTransformer().setOutputProperties(properties);
serializer.setResult(new StreamResult(System.out)):
xmlFilter2.setContentHandler(serializer);
You can do it using lower-level Saxon methods if you prefer, this gives you
a bit more control but it's trickier because there are more objects to
manage and more things to get wrong (and it's likely to change a bit from
one release to the next). You're almost there, but it's probably best to use
the same Configuration and NamePool throughout the pipeline, so rather than
creating a new Configuration, get the one that's already used for the
transformation, e.g. as
((Controller)((Filter)xmlFilter2).getTransformer()).getConfiguration();
Michael Kay
http://www.saxonica.com/
-----Original Message-----
From: Neville Thomas [mailto:nthomas(_at_)virtc(_dot_)com]
Sent: 17 December 2004 19:11
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Saxon Serializing and COntentHandler
In Xalan I am able to do the following:
Serializer serializer = SerializerFactory.getSerializer
(OutputPropertiesFactory.getDefaultMethodProperties("xml"));
serializer.setOutputStream(System.out);
xmlFilter2.setContentHandler(serializer.asContentHandler());
How will I acheive similar with Saxon8b.
I tried using that ContentEmitter along with the
ReceivingContentHandler
(see below) but I dont think I am setting up the Configuration Object
properly.
Properties xep = new Properties();
NamePool np = NamePool.getDefaultNamePool();
Configuration config = new Configuration();
config.setNamePool(np);
XMLEmitter xe = new XMLEmitter();
xe.setStreamResult(new StreamResult(new PrintWriter(System.out,
true)));
xe.setOutputProperties(xep);
xe.setConfiguration(config);
ReceivingContentHandler rch = new ReceivingContentHandler();
rch.setReceiver(xe);
rch.setNamePool(np);
xmlFilter2.setContentHandler(rch);
xmlFilter2.parse(new InputSource("SouthPole.xml"));
Neville
--
==================================================================
Virtual Technology Corporation | 5510 Cherokee Rd, Suite 350
| Alexandria, VA 22312-2300
_/ _/_/_/_/_/_/_/_/_/ |
_/ _/ |
_/ _/ _/ _/_/_/_/ | Neville Thomas
_/ _/ _/ _/ | E-Mail addr: nthomas(_at_)virtc(_dot_)com
_/ _/ _/ _/ | Office : 703.333.6233
_/_/ _/ _/ | Fax : 703.658.7057
_/ _/ _/_/_/_/ |
|
===================================================================
"Software and Systems Engineering Professionals."
===================================================================
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--