1 package org.ejen; 22 23 import java.util.Properties ; 24 import org.ejen.ext.Version; 25 import org.ejen.util.DOMUtil; 26 import javax.xml.transform.dom.DOMSource ; 27 import org.w3c.dom.Document ; 28 29 63 public class EjenSourceNode extends EjenChildNode { 64 protected String _file = null; 65 66 70 public String nodeName() { 71 return "source"; 72 } 73 74 78 public Properties getAttributes() { 79 Properties attrs = super.getAttributes(); 80 81 if (_file != null) { 82 attrs.setProperty("file", _file); 83 } 84 return attrs; 85 } 86 87 93 public void setFile(String file) { 94 _file = file; 95 putInGlobalContext("DOM_SOURCE_FILE", file); 96 } 97 98 101 public void check() { 102 super.check(); 103 } 104 105 111 public void process() { 112 super.process(); 113 try { 114 Document doc = null; 115 116 if (_file != null) { 117 doc = DOMUtil.parseXMLFile(evaluateAVT(_file)); 118 } else { 119 doc = DOMUtil.parseXMLString(null); 120 } 121 doc.getDocumentElement().setAttribute("ejen-version", 122 Version.toString(null)); 123 putInGlobalContext(CTX_DOM_SOURCE, new DOMSource (doc)); 124 } catch (EjenException e) { 125 throw e; 126 } catch (Exception e) { 127 throw new EjenException(this, "bad source file: " + _file, e); 128 } 129 } 130 } 131 | Popular Tags |