1 package net.sf.tomp.xtcl.command;
2
3 import net.sf.tomp.xtcl.Context;
4
5 import org.w3c.dom.Document;
6
7 import javax.xml.parsers.DocumentBuilder;
8
9 import java.io.PrintStream;
10
11 /***
12 * DOCUMENT ME!
13 *
14 * @author tomp
15 */
16 public class Doc extends VarCommand {
17 /***
18 * DOCUMENT ME!
19 *
20 * @param context DOCUMENT ME!
21 * @return DOCUMENT ME!
22 * @throws Exception DOCUMENT ME!
23 */
24 public int execute(Context context) throws Exception {
25 DocumentBuilder db = context.getDocumentBuilder();
26 PrintStream out = context.getOut();
27 Document doc = db.newDocument();
28
29 context.put(var, doc);
30
31 if (out != null) {
32 out.print("OK " + this);
33 }
34
35 return 0;
36 }
37
38 /***
39 * DOCUMENT ME!
40 *
41 * @return DOCUMENT ME!
42 */
43 public String toString() {
44 return "DOCUMENT " + var;
45 }
46 }
47
48
49
50
51
52
53
54
55
56
57