1 11 package org.eclipse.help.internal.dynamic; 12 13 import java.io.ByteArrayInputStream ; 14 import java.io.IOException ; 15 import java.io.InputStream ; 16 17 import javax.xml.parsers.ParserConfigurationException ; 18 import javax.xml.transform.TransformerConfigurationException ; 19 import javax.xml.transform.TransformerException ; 20 21 import org.eclipse.help.internal.UAElement; 22 import org.xml.sax.SAXException ; 23 24 28 public class XMLProcessor { 29 30 private DocumentProcessor processor; 31 private DocumentReader reader; 32 private DocumentWriter writer; 33 34 37 public XMLProcessor(ProcessorHandler[] handlers) { 38 this.processor = new DocumentProcessor(handlers); 39 } 40 41 45 public InputStream process(InputStream in, String id, String charset) throws IOException , SAXException , ParserConfigurationException , TransformerException , TransformerConfigurationException { 46 if (reader == null) { 47 reader = new DocumentReader(); 48 } 49 UAElement element = reader.read(in, charset); 50 processor.process(element, id); 51 if (writer == null) { 52 writer = new DocumentWriter(); 53 } 54 return new ByteArrayInputStream (writer.writeBytes(element, true)); 55 } 56 } 57 | Popular Tags |