View Javadoc
1   /*
2    * reserved comment block
3    * DO NOT REMOVE OR ALTER!
4    */
5   /*
6    * Copyright 2000-2002,2004 The Apache Software Foundation.
7    *
8    * Licensed under the Apache License, Version 2.0 (the "License");
9    * you may not use this file except in compliance with the License.
10   * You may obtain a copy of the License at
11   *
12   *      http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing, software
15   * distributed under the License is distributed on an "AS IS" BASIS,
16   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17   * See the License for the specific language governing permissions and
18   * limitations under the License.
19   */
20  
21  package com.sun.org.apache.xerces.internal.xni;
22  
23  import com.sun.org.apache.xerces.internal.xni.parser.XMLDocumentSource;
24  
25  /**
26   * The document handler interface defines callback methods to report
27   * information items in XML documents. Parser components interested in
28   * document information implement this interface and are registered
29   * as the document handler on the document source.
30   *
31   * @author Andy Clark, IBM
32   *
33   */
34  public interface XMLDocumentHandler {
35  
36      //
37      // XMLDocumentHandler methods
38      //
39  
40      /**
41       * The start of the document.
42       *
43       * @param locator  The document locator, or null if the document
44       *                 location cannot be reported during the parsing
45       *                 of this document. However, it is <em>strongly</em>
46       *                 recommended that a locator be supplied that can
47       *                 at least report the system identifier of the
48       *                 document.
49       * @param encoding The auto-detected IANA encoding name of the entity
50       *                 stream. This value will be null in those situations
51       *                 where the entity encoding is not auto-detected (e.g.
52       *                 internal entities or a document entity that is
53       *                 parsed from a java.io.Reader).
54       * @param namespaceContext
55       *                 The namespace context in effect at the
56       *                 start of this document.
57       *                 This object represents the current context.
58       *                 Implementors of this class are responsible
59       *                 for copying the namespace bindings from the
60       *                 the current context (and its parent contexts)
61       *                 if that information is important.
62       *
63       * @param augs     Additional information that may include infoset augmentations
64       * @exception XNIException
65       *                   Thrown by handler to signal an error.
66       */
67      public void startDocument(XMLLocator locator, String encoding,
68                                NamespaceContext namespaceContext,
69                                Augmentations augs)
70          throws XNIException;
71  
72      /**
73       * Notifies of the presence of an XMLDecl line in the document. If
74       * present, this method will be called immediately following the
75       * startDocument call.
76       *
77       * @param version    The XML version.
78       * @param encoding   The IANA encoding name of the document, or null if
79       *                   not specified.
80       * @param standalone The standalone value, or null if not specified.
81       * @param augs       Additional information that may include infoset augmentations
82       *
83       * @exception XNIException
84       *                   Thrown by handler to signal an error.
85       */
86      public void xmlDecl(String version, String encoding, String standalone, Augmentations augs)
87          throws XNIException;
88  
89      /**
90       * Notifies of the presence of the DOCTYPE line in the document.
91       *
92       * @param rootElement
93       *                 The name of the root element.
94       * @param publicId The public identifier if an external DTD or null
95       *                 if the external DTD is specified using SYSTEM.
96       * @param systemId The system identifier if an external DTD, null
97       *                 otherwise.
98       * @param augs     Additional information that may include infoset augmentations
99       *
100      * @exception XNIException
101      *                   Thrown by handler to signal an error.
102      */
103     public void doctypeDecl(String rootElement, String publicId, String systemId, Augmentations augs)
104         throws XNIException;
105 
106     /**
107      * A comment.
108      *
109      * @param text   The text in the comment.
110      * @param augs   Additional information that may include infoset augmentations
111      *
112      * @exception XNIException
113      *                   Thrown by application to signal an error.
114      */
115     public void comment(XMLString text, Augmentations augs) throws XNIException;
116 
117     /**
118      * A processing instruction. Processing instructions consist of a
119      * target name and, optionally, text data. The data is only meaningful
120      * to the application.
121      * <p>
122      * Typically, a processing instruction's data will contain a series
123      * of pseudo-attributes. These pseudo-attributes follow the form of
124      * element attributes but are <strong>not</strong> parsed or presented
125      * to the application as anything other than text. The application is
126      * responsible for parsing the data.
127      *
128      * @param target The target.
129      * @param data   The data or null if none specified.
130      * @param augs   Additional information that may include infoset augmentations
131      *
132      * @exception XNIException
133      *                   Thrown by handler to signal an error.
134      */
135     public void processingInstruction(String target, XMLString data, Augmentations augs)
136         throws XNIException;
137 
138     /**
139      * The start of an element.
140      *
141      * @param element    The name of the element.
142      * @param attributes The element attributes.
143      * @param augs       Additional information that may include infoset augmentations
144      *
145      * @exception XNIException
146      *                   Thrown by handler to signal an error.
147      */
148     public void startElement(QName element, XMLAttributes attributes, Augmentations augs)
149         throws XNIException;
150 
151     /**
152      * An empty element.
153      *
154      * @param element    The name of the element.
155      * @param attributes The element attributes.
156      * @param augs       Additional information that may include infoset augmentations
157      *
158      * @exception XNIException
159      *                   Thrown by handler to signal an error.
160      */
161     public void emptyElement(QName element, XMLAttributes attributes, Augmentations augs)
162         throws XNIException;
163 
164     /**
165      * This method notifies the start of a general entity.
166      * <p>
167      * <strong>Note:</strong> This method is not called for entity references
168      * appearing as part of attribute values.
169      *
170      * @param name     The name of the general entity.
171      * @param identifier The resource identifier.
172      * @param encoding The auto-detected IANA encoding name of the entity
173      *                 stream. This value will be null in those situations
174      *                 where the entity encoding is not auto-detected (e.g.
175      *                 internal entities or a document entity that is
176      *                 parsed from a java.io.Reader).
177      * @param augs     Additional information that may include infoset augmentations
178      *
179      * @exception XNIException Thrown by handler to signal an error.
180      */
181     public void startGeneralEntity(String name,
182                                    XMLResourceIdentifier identifier,
183                                    String encoding,
184                                    Augmentations augs) throws XNIException;
185 
186     /**
187      * Notifies of the presence of a TextDecl line in an entity. If present,
188      * this method will be called immediately following the startEntity call.
189      * <p>
190      * <strong>Note:</strong> This method will never be called for the
191      * document entity; it is only called for external general entities
192      * referenced in document content.
193      * <p>
194      * <strong>Note:</strong> This method is not called for entity references
195      * appearing as part of attribute values.
196      *
197      * @param version  The XML version, or null if not specified.
198      * @param encoding The IANA encoding name of the entity.
199      * @param augs     Additional information that may include infoset augmentations
200      *
201      * @exception XNIException
202      *                   Thrown by handler to signal an error.
203      */
204     public void textDecl(String version, String encoding, Augmentations augs) throws XNIException;
205 
206     /**
207      * This method notifies the end of a general entity.
208      * <p>
209      * <strong>Note:</strong> This method is not called for entity references
210      * appearing as part of attribute values.
211      *
212      * @param name   The name of the entity.
213      * @param augs   Additional information that may include infoset augmentations
214      *
215      * @exception XNIException
216      *                   Thrown by handler to signal an error.
217      */
218     public void endGeneralEntity(String name, Augmentations augs) throws XNIException;
219 
220     /**
221      * Character content.
222      *
223      * @param text   The content.
224      * @param augs   Additional information that may include infoset augmentations
225      *
226      * @exception XNIException
227      *                   Thrown by handler to signal an error.
228      */
229     public void characters(XMLString text, Augmentations augs) throws XNIException;
230 
231     /**
232      * Ignorable whitespace. For this method to be called, the document
233      * source must have some way of determining that the text containing
234      * only whitespace characters should be considered ignorable. For
235      * example, the validator can determine if a length of whitespace
236      * characters in the document are ignorable based on the element
237      * content model.
238      *
239      * @param text   The ignorable whitespace.
240      * @param augs   Additional information that may include infoset augmentations
241      *
242      * @exception XNIException
243      *                   Thrown by handler to signal an error.
244      */
245     public void ignorableWhitespace(XMLString text, Augmentations augs) throws XNIException;
246 
247     /**
248      * The end of an element.
249      *
250      * @param element The name of the element.
251      * @param augs    Additional information that may include infoset augmentations
252      *
253      * @exception XNIException
254      *                   Thrown by handler to signal an error.
255      */
256     public void endElement(QName element, Augmentations augs) throws XNIException;
257 
258     /**
259      * The start of a CDATA section.
260      *
261      * @param augs   Additional information that may include infoset augmentations
262      *
263      * @exception XNIException
264      *                   Thrown by handler to signal an error.
265      */
266     public void startCDATA(Augmentations augs) throws XNIException;
267 
268     /**
269      * The end of a CDATA section.
270      *
271      * @param augs   Additional information that may include infoset augmentations
272      *
273      * @exception XNIException
274      *                   Thrown by handler to signal an error.
275      */
276     public void endCDATA(Augmentations augs) throws XNIException;
277 
278     /**
279      * The end of the document.
280      *
281      * @param augs   Additional information that may include infoset augmentations
282      *
283      * @exception XNIException
284      *                   Thrown by handler to signal an error.
285      */
286     public void endDocument(Augmentations augs) throws XNIException;
287 
288 
289     /** Sets the document source. */
290     public void setDocumentSource(XMLDocumentSource source);
291 
292 
293     /** Returns the document source. */
294     public XMLDocumentSource getDocumentSource();
295 
296 } // interface XMLDocumentHandler