|
Subject: Re: [xsl] Using a StreamResult as a StreamSource From: "Ritu Kama" <rkama@xxxxxxxxxxx> Date: Mon, 11 Aug 2003 15:08:38 -0500 |
You can use SAXTransformerFactory to chain a series of Transformations by
piping the SAX events from one transformer to next one
example
TransformerFactory tFactory = TransformerFactory.newInstance();
TransformerFactory tFactory = TransformerFactory.newInstance();
if (tFactory.getFeature(SAXSource.FEATURE) &&
tFactory.getFeature(SAXResult.FEATURE))
{
// Cast the TransformerFactory to SAXTransformerFactory.
SAXTransformerFactory saxTFactory = ((SAXTransformerFactory) tFactory);
// Create a TransformerHandler for each stylesheet.
TransformerHandler tHandler1 = saxTFactory.newTransformerHandler(new
StreamSource("foo1.xsl"));
TransformerHandler tHandler2 = saxTFactory.newTransformerHandler(new
StreamSource("foo2.xsl"));
TransformerHandler tHandler3 = saxTFactory.newTransformerHandler(new
StreamSource("foo3.xsl"));
// Create an XMLReader.
XMLReader reader = XMLReaderFactory.createXMLReader();
reader.setContentHandler(tHandler1);
reader.setProperty("http://xml.org/sax/properties/lexical-handler",
tHandler1);
tHandler1.setResult(new SAXResult(tHandler2));
tHandler2.setResult(new SAXResult(tHandler3));
// transformer3 outputs SAX events to the serializer.
Serializer serializer =
SerializerFactory.getSerializer(OutputProperties.getDefaultMethodProperties(
"xml"));
serializer.setOutputStream(System.out);
tHandler3.setResult(new SAXResult(serializer.asContentHandler()));
// Parse the XML input document. The input ContentHandler and output
ContentHandler
// work in separate threads to optimize performance.
reader.parse("foo.xml");
}
----- Original Message -----
From: <John.Coffie@xxxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Monday, August 11, 2003 1:57 PM
Subject: [xsl] Using a StreamResult as a StreamSource
> How can I use a StreamResult for a StreamSource. I am transforming an xml
> document twice. The result of the first transform is used to generate the
> transformer object for the second transform. What is the best way to
> accomplish this task. Please include examples with your suggestions.
>
>
>
>
> CONFIDENTIALITY NOTICE: This e-mail message, including any attachments, is
> for the sole use of the intended recipient(s) and may contain confidential
> and privileged information or otherwise protected by law. Any
unauthorized
> review, use, disclosure or distribution is prohibited. If you are not the
> intended recipient, please contact the sender by reply e-mail and destroy
> all copies of the original message.
>
>
>
>
> 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 |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] Using a StreamResult as a Str, John . Coffie | Thread | RE: [xsl] Using a StreamResult as a, Michael Kay |
| [xsl] Using a StreamResult as a Str, John . Coffie | Date | Re: [xsl] value of NDATA Entities i, David Carlisle |
| Month |