KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > icl > saxon > output > ErrorEmitter


1 package com.icl.saxon.output;
2 import com.icl.saxon.*;
3 //import com.icl.saxon.om.Name;
4
import com.icl.saxon.om.Namespace;
5 import com.icl.saxon.om.NamePool;
6
7 import org.xml.sax.Attributes JavaDoc;
8 //import org.w3c.dom.*;
9
import javax.xml.transform.TransformerException JavaDoc;
10
11 import java.io.Writer JavaDoc;
12
13
14 /**
15   * ErrorEmitter is an Emitter that generates an error message if any attempt
16   * is made to produce output. It is used while a saxon:function is active to
17   * prevent functions writing to the result tree.
18   */

19   
20 public class ErrorEmitter extends Emitter
21 {
22     /**
23     * Start of the document.
24     */

25     
26     public void startDocument () throws TransformerException JavaDoc {}
27
28     /**
29     * End of the document.
30     */

31     
32     public void endDocument () throws TransformerException JavaDoc {}
33
34     /**
35     * Start of an element. Output the start tag, escaping special characters.
36     */

37     
38     public void startElement (int name, Attributes JavaDoc attributes,
39                               int[] namespaces, int nscount) throws TransformerException JavaDoc
40     {
41         error();
42     }
43     
44     /**
45     * End of an element.
46     */

47
48     public void endElement (int name) throws TransformerException JavaDoc
49     {
50         error();
51     }
52
53
54     /**
55     * Character data.
56     */

57
58     public void characters (char[] ch, int start, int length) throws TransformerException JavaDoc
59     {
60         error();
61     }
62
63
64     /**
65     * Handle a processing instruction.
66     */

67     
68     public void processingInstruction (String JavaDoc target, String JavaDoc data)
69         throws TransformerException JavaDoc
70     {
71         error();
72     }
73
74     /**
75     * Handle a comment.
76     */

77     
78     public void comment (char ch[], int start, int length) throws TransformerException JavaDoc
79     {
80         error();
81     }
82
83     /**
84     * Report an error: can't write to result tree
85     */

86
87     private void error() throws TransformerException JavaDoc {
88         throw new TransformerException JavaDoc("Cannot write to result tree while executing a function");
89     }
90
91
92     
93 }
94
95 //
96
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
97
// you may not use this file except in compliance with the License. You may obtain a copy of the
98
// License at http://www.mozilla.org/MPL/
99
//
100
// Software distributed under the License is distributed on an "AS IS" basis,
101
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
102
// See the License for the specific language governing rights and limitations under the License.
103
//
104
// The Original Code is: all this file.
105
//
106
// The Initial Developer of the Original Code is
107
// Michael Kay of International Computers Limited (mhkay@iclway.co.uk).
108
//
109
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
110
//
111
// Contributor(s): none.
112
//
113
Popular Tags