|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Using a StreamResult as a StreamSource
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: 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








