1 28 29 package com.caucho.xsl; 30 31 import com.caucho.java.LineMap; 32 import com.caucho.vfs.IOExceptionWrapper; 33 import com.caucho.xml.DOMBuilder; 34 import com.caucho.xml.Xml; 35 36 import org.w3c.dom.Node ; 37 import org.xml.sax.SAXException ; 38 39 import java.io.IOException ; 40 import java.io.InputStream ; 41 42 public class NodeTransformerImpl extends TransformerImpl { 43 protected LineMap _lineMap; 44 45 NodeTransformerImpl(StylesheetImpl stylesheet) 46 { 47 super(stylesheet); 48 } 49 50 public Object getProperty(String name) 51 { 52 if (name.equals(LINE_MAP)) 53 return _lineMap; 54 else 55 return super.getProperty(name); 56 } 57 58 65 public Node transform(InputStream source, Node node) 66 throws SAXException , IOException 67 { 68 return transform(parseDocument(source, null), node); 69 } 70 71 public Node transform(String systemId, Node node) 72 throws SAXException , IOException 73 { 74 return transform(parseDocument(systemId), node); 75 } 76 77 public Node transformString(String source, Node node) 78 throws SAXException , IOException 79 { 80 return transform(parseStringDocument(source, null), node); 81 } 82 83 public Node transform(Node sourceNode, Node destNode) 84 throws SAXException , IOException 85 { 86 _lineMap = null; 87 OutputFormat output = _stylesheet.getOutputFormat(); 88 89 if (destNode == null) 90 destNode = Xml.createDocument(); 91 92 DOMBuilder out = new DOMBuilder(); 93 out.init(destNode); 94 95 try { 96 out.startDocument(); 97 _stylesheet.transform(sourceNode, out, this); 98 out.endDocument(); 99 } catch (Exception e) { 100 throw new IOExceptionWrapper(e); 101 } 102 103 return destNode; 104 } 105 } 106 | Popular Tags |