public void usePipe(Vector vTHandler, String source, String target)
throws TransformerException, TransformerConfigurationException,
FileNotFoundException, IOException, SAXException, SAXNotRecognizedException
{
XMLReader reader = XMLReaderFactory.createXMLReader();
TransformerHandler tHFirst = (TransformerHandler)vTHandler.firstElement();
reader.setContentHandler(tHFirst);
reader.setProperty("http://xml.org/sax/properties/lexical-handler", tHFirst);
for (int i = 1; i < vTHandler.size(); i++)
{
TransformerHandler tHFrom = (TransformerHandler)vTHandler.elementAt(i-1);
TransformerHandler tHTo = (TransformerHandler)vTHandler.elementAt(i);
tHFrom.setResult(new SAXResult(tHTo));
}
TransformerHandler tHLast = (TransformerHandler)vTHandler.lastElement();
Transformer trans = tHLast.getTransformer();
Properties outputProps = trans.getOutputProperties();
Serializer serializer = SerializerFactory.getSerializer(outputProps);
FileOutputStream out = new FileOutputStream(target);
try
{
serializer.setOutputStream(out);
tHLast.setResult(new SAXResult(serializer.asContentHandler()));
reader.parse(source);
}
finally
{
// Always clean up the FileOutputStream,