KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > nwalsh > saxon > CopyEmitter


1 package com.nwalsh.saxon;
2
3 import java.util.Stack JavaDoc;
4 import java.util.StringTokenizer JavaDoc;
5 import org.xml.sax.*;
6 import org.w3c.dom.*;
7 import javax.xml.transform.TransformerException JavaDoc;
8 import com.icl.saxon.Context;
9 import com.icl.saxon.expr.*;
10 import com.icl.saxon.expr.FragmentValue;
11 import com.icl.saxon.Controller;
12 import com.icl.saxon.functions.Extensions;
13 import com.icl.saxon.om.*;
14 import com.icl.saxon.output.*;
15 import com.icl.saxon.pattern.*;
16 import com.icl.saxon.tree.*;
17
18 /**
19  * <p>A Saxon 6.0 Emitter that clones its input.</p>
20  *
21  * <p>$Id: CopyEmitter.java,v 1.1 2001/07/16 21:23:57 nwalsh Exp $</p>
22  *
23  * <p>Copyright (C) 2000 Norman Walsh.</p>
24  *
25  * <p>This class provides a
26  * <a HREF="http://users.iclway.co.uk/mhkay/saxon/">Saxon 6.*</a>
27  * implementation of an emitter that manufactures a cloned result
28  * tree fragment.</p>
29  *
30  * <p>The purpose of this emitter is to provide something for
31  * CalloutEmitter and NumberLinesEmitter to extend.
32  * This emitter simply copies all input to a new result tree fragment.</p>
33  *
34  * <p><b>Change Log:</b></p>
35  * <dl>
36  * <dt>1.0</dt>
37  * <dd><p>Initial release.</p></dd>
38  * </dl>
39  *
40  * @see CalloutEmitter
41  * @see NumberLinesEmitter
42  *
43  * @author Norman Walsh
44  * <a HREF="mailto:ndw@nwalsh.com">ndw@nwalsh.com</a>
45  *
46  * @version $Id: CopyEmitter.java,v 1.1 2001/07/16 21:23:57 nwalsh Exp $
47  *
48  */

49 public class CopyEmitter extends com.icl.saxon.output.Emitter {
50   /** The result tree fragment containing the copied fragment. */
51   protected FragmentValue rtf = null;
52   protected Emitter rtfEmitter = null;
53
54   /** <p>The namePool.</p>
55    *
56    * <p>Copied from the caller, it should be the runtime name pool.</p>
57    */

58   protected NamePool namePool = null;
59
60   /** <p>Constructor for the CopyEmitter.</p>
61    *
62    * @param namePool The name pool to use for constructing elements and attributes.
63    */

64   public CopyEmitter(Controller controller, NamePool namePool) {
65     rtf = new FragmentValue(controller);
66     rtfEmitter = rtf.getEmitter();
67     this.namePool = namePool;
68   }
69
70   /**
71    * <p>Return the result tree fragment constructed by replaying events
72    * through this emitter.</p>
73    */

74   public FragmentValue getResultTreeFragment() {
75     return rtf;
76   }
77
78   /** Copy characters. */
79   public void characters(char[] chars, int start, int len)
80     throws TransformerException JavaDoc {
81     rtfEmitter.characters(chars, start, len);
82   }
83
84   /** Copy comments. */
85   public void comment(char[] chars, int start, int length)
86     throws TransformerException JavaDoc {
87     rtfEmitter.comment(chars, start, length);
88   }
89
90   /** Copy end document events. */
91   public void endDocument()
92     throws TransformerException JavaDoc {
93     rtfEmitter.endDocument();
94   }
95
96   /** Copy end element events. */
97   public void endElement(int nameCode)
98     throws TransformerException JavaDoc {
99     rtfEmitter.endElement(nameCode);
100   }
101
102   /** Copy processing instructions. */
103   public void processingInstruction(java.lang.String JavaDoc name,
104                     java.lang.String JavaDoc data)
105     throws TransformerException JavaDoc {
106     rtfEmitter.processingInstruction(name, data);
107   }
108
109   /** Copy set document locator events. */
110   public void setDocumentLocator(org.xml.sax.Locator JavaDoc locator) {
111     rtfEmitter.setDocumentLocator(locator);
112   }
113
114   /** Copy set escaping events. */
115   public void setEscaping(boolean escaping)
116     throws TransformerException JavaDoc {
117     rtfEmitter.setEscaping(escaping);
118   }
119
120   /** Copy set name pool events. */
121   public void setNamePool(NamePool namePool) {
122     rtfEmitter.setNamePool(namePool);
123   }
124
125   /** Copy set unparsed entity events. */
126   public void setUnparsedEntity(java.lang.String JavaDoc name, java.lang.String JavaDoc uri)
127     throws TransformerException JavaDoc {
128     rtfEmitter.setUnparsedEntity(name, uri);
129   }
130
131   /** Copy set writer events. */
132   public void setWriter(java.io.Writer JavaDoc writer) {
133     rtfEmitter.setWriter(writer);
134   }
135
136   /** Copy start document events. */
137   public void startDocument()
138     throws TransformerException JavaDoc {
139     rtfEmitter.startDocument();
140   }
141
142   /** Copy start element events. */
143   public void startElement(int nameCode,
144                org.xml.sax.Attributes JavaDoc attributes,
145                int[] namespaces,
146                int nscount)
147     throws TransformerException JavaDoc {
148     rtfEmitter.startElement(nameCode, attributes, namespaces, nscount);
149   }
150 }
151
Popular Tags