1 28 29 package com.caucho.xsl; 30 31 import com.caucho.vfs.WriteStream; 32 33 import org.w3c.dom.Node ; 34 import org.w3c.dom.Text ; 35 import org.xml.sax.SAXException ; 36 37 import javax.xml.transform.TransformerException ; 38 import java.io.IOException ; 39 import java.io.InputStream ; 40 import java.io.OutputStream ; 41 42 public class StreamTransformerImpl extends TransformerImpl { 43 StreamTransformerImpl(StylesheetImpl stylesheet) 44 { 45 super(stylesheet); 46 } 47 48 public Object getProperty(String name) 49 { 50 if (name.equals(LINE_MAP)) 51 return _lineMap; 52 else 53 return super.getProperty(name); 54 } 55 56 public void transform(InputStream source, OutputStream os) 57 throws SAXException , IOException , TransformerException 58 { 59 transform(parseDocument(source, null), os); 60 } 61 62 public void transform(String systemId, OutputStream os) 63 throws SAXException , IOException , TransformerException 64 { 65 transform(parseDocument(systemId), os); 66 } 67 68 public void transformString(String source, OutputStream os) 69 throws SAXException , IOException , TransformerException 70 { 71 transform(parseStringDocument(source, null), os); 72 } 73 74 private void printText(WriteStream out, Node top) 75 throws IOException 76 { 77 for (; top != null; top = top.getNextSibling()) { 78 if (top instanceof Text ) 79 out.print(top.getNodeValue()); 80 else 81 printText(out, top.getFirstChild()); 82 } 83 } 84 } 85 | Popular Tags |