2
* Licensed to the Apache Software Foundation (ASF) under one or more
3
* contributor license agreements. See the NOTICE file distributed with
4
* this work for additional information regarding copyright ownership.
5
* The ASF licenses this file to You under the Apache License, Version 2.0
6
* (the "License"); you may not use this file except in compliance with
7
* the License. You may obtain a copy of the License at
9
* http://www.apache.org/licenses/LICENSE-2.0
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
18
package org.apache.xerces.xni;
20
import org.apache.xerces.xni.parser.XMLDocumentSource;
23
* The document handler interface defines callback methods to report
24
* information items in XML documents. Parser components interested in
25
* document information implement this interface and are registered
26
* as the document handler on the document source.
28
* @author Andy Clark, IBM
30
* @version $Id: XMLDocumentHandler.java,v 1.2 2009/12/10 03:18:46 matthewoliver Exp $
32
public interface XMLDocumentHandler {
35
// XMLDocumentHandler methods
39
* The start of the document.
41
* @param locator The document locator, or null if the document
42
* location cannot be reported during the parsing
43
* of this document. However, it is <em>strongly</em>
44
* recommended that a locator be supplied that can
45
* at least report the system identifier of the
47
* @param encoding The auto-detected IANA encoding name of the entity
48
* stream. This value will be null in those situations
49
* where the entity encoding is not auto-detected (e.g.
50
* internal entities or a document entity that is
51
* parsed from a java.io.Reader).
52
* @param namespaceContext
53
* The namespace context in effect at the
54
* start of this document.
55
* This object represents the current context.
56
* Implementors of this class are responsible
57
* for copying the namespace bindings from the
58
* the current context (and its parent contexts)
59
* if that information is important.
61
* @param augs Additional information that may include infoset augmentations
62
* @exception XNIException
63
* Thrown by handler to signal an error.
65
public void startDocument(XMLLocator locator, String encoding,
66
NamespaceContext namespaceContext,
71
* Notifies of the presence of an XMLDecl line in the document. If
72
* present, this method will be called immediately following the
75
* @param version The XML version.
76
* @param encoding The IANA encoding name of the document, or null if
78
* @param standalone The standalone value, or null if not specified.
79
* @param augs Additional information that may include infoset augmentations
81
* @exception XNIException
82
* Thrown by handler to signal an error.
84
public void xmlDecl(String version, String encoding, String standalone, Augmentations augs)
88
* Notifies of the presence of the DOCTYPE line in the document.
91
* The name of the root element.
92
* @param publicId The public identifier if an external DTD or null
93
* if the external DTD is specified using SYSTEM.
94
* @param systemId The system identifier if an external DTD, null
96
* @param augs Additional information that may include infoset augmentations
98
* @exception XNIException
99
* Thrown by handler to signal an error.
101
public void doctypeDecl(String rootElement, String publicId, String systemId, Augmentations augs)
107
* @param text The text in the comment.
108
* @param augs Additional information that may include infoset augmentations
110
* @exception XNIException
111
* Thrown by application to signal an error.
113
public void comment(XMLString text, Augmentations augs) throws XNIException;
116
* A processing instruction. Processing instructions consist of a
117
* target name and, optionally, text data. The data is only meaningful
118
* to the application.
120
* Typically, a processing instruction's data will contain a series
121
* of pseudo-attributes. These pseudo-attributes follow the form of
122
* element attributes but are <strong>not</strong> parsed or presented
123
* to the application as anything other than text. The application is
124
* responsible for parsing the data.
126
* @param target The target.
127
* @param data The data or null if none specified.
128
* @param augs Additional information that may include infoset augmentations
130
* @exception XNIException
131
* Thrown by handler to signal an error.
133
public void processingInstruction(String target, XMLString data, Augmentations augs)
137
* The start of an element.
139
* @param element The name of the element.
140
* @param attributes The element attributes.
141
* @param augs Additional information that may include infoset augmentations
143
* @exception XNIException
144
* Thrown by handler to signal an error.
146
public void startElement(QName element, XMLAttributes attributes, Augmentations augs)
152
* @param element The name of the element.
153
* @param attributes The element attributes.
154
* @param augs Additional information that may include infoset augmentations
156
* @exception XNIException
157
* Thrown by handler to signal an error.
159
public void emptyElement(QName element, XMLAttributes attributes, Augmentations augs)
163
* This method notifies the start of a general entity.
165
* <strong>Note:</strong> This method is not called for entity references
166
* appearing as part of attribute values.
168
* @param name The name of the general entity.
169
* @param identifier The resource identifier.
170
* @param encoding The auto-detected IANA encoding name of the entity
171
* stream. This value will be null in those situations
172
* where the entity encoding is not auto-detected (e.g.
173
* internal entities or a document entity that is
174
* parsed from a java.io.Reader).
175
* @param augs Additional information that may include infoset augmentations
177
* @exception XNIException Thrown by handler to signal an error.
179
public void startGeneralEntity(String name,
180
XMLResourceIdentifier identifier,
182
Augmentations augs) throws XNIException;
185
* Notifies of the presence of a TextDecl line in an entity. If present,
186
* this method will be called immediately following the startEntity call.
188
* <strong>Note:</strong> This method will never be called for the
189
* document entity; it is only called for external general entities
190
* referenced in document content.
192
* <strong>Note:</strong> This method is not called for entity references
193
* appearing as part of attribute values.
195
* @param version The XML version, or null if not specified.
196
* @param encoding The IANA encoding name of the entity.
197
* @param augs Additional information that may include infoset augmentations
199
* @exception XNIException
200
* Thrown by handler to signal an error.
202
public void textDecl(String version, String encoding, Augmentations augs) throws XNIException;
205
* This method notifies the end of a general entity.
207
* <strong>Note:</strong> This method is not called for entity references
208
* appearing as part of attribute values.
210
* @param name The name of the entity.
211
* @param augs Additional information that may include infoset augmentations
213
* @exception XNIException
214
* Thrown by handler to signal an error.
216
public void endGeneralEntity(String name, Augmentations augs) throws XNIException;
221
* @param text The content.
222
* @param augs Additional information that may include infoset augmentations
224
* @exception XNIException
225
* Thrown by handler to signal an error.
227
public void characters(XMLString text, Augmentations augs) throws XNIException;
230
* Ignorable whitespace. For this method to be called, the document
231
* source must have some way of determining that the text containing
232
* only whitespace characters should be considered ignorable. For
233
* example, the validator can determine if a length of whitespace
234
* characters in the document are ignorable based on the element
237
* @param text The ignorable whitespace.
238
* @param augs Additional information that may include infoset augmentations
240
* @exception XNIException
241
* Thrown by handler to signal an error.
243
public void ignorableWhitespace(XMLString text, Augmentations augs) throws XNIException;
246
* The end of an element.
248
* @param element The name of the element.
249
* @param augs Additional information that may include infoset augmentations
251
* @exception XNIException
252
* Thrown by handler to signal an error.
254
public void endElement(QName element, Augmentations augs) throws XNIException;
257
* The start of a CDATA section.
259
* @param augs Additional information that may include infoset augmentations
261
* @exception XNIException
262
* Thrown by handler to signal an error.
264
public void startCDATA(Augmentations augs) throws XNIException;
267
* The end of a CDATA section.
269
* @param augs Additional information that may include infoset augmentations
271
* @exception XNIException
272
* Thrown by handler to signal an error.
274
public void endCDATA(Augmentations augs) throws XNIException;
277
* The end of the document.
279
* @param augs Additional information that may include infoset augmentations
281
* @exception XNIException
282
* Thrown by handler to signal an error.
284
public void endDocument(Augmentations augs) throws XNIException;
287
/** Sets the document source. */
288
public void setDocumentSource(XMLDocumentSource source);
291
/** Returns the document source. */
292
public XMLDocumentSource getDocumentSource();
294
} // interface XMLDocumentHandler