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.XMLDTDSource;
24  
25  /**
26   * The DTD handler interface defines callback methods to report
27   * information items in the DTD of an XML document. Parser components
28   * interested in DTD information implement this interface and are
29   * registered as the DTD handler on the DTD source.
30   *
31   * @see XMLDTDContentModelHandler
32   *
33   * @author Andy Clark, IBM
34   *
35   */
36  public interface XMLDTDHandler {
37  
38      //
39      // Constants
40      //
41  
42      /**
43       * Conditional section: INCLUDE.
44       *
45       * @see #CONDITIONAL_IGNORE
46       */
47      public static final short CONDITIONAL_INCLUDE = 0;
48  
49      /**
50       * Conditional section: IGNORE.
51       *
52       * @see #CONDITIONAL_INCLUDE
53       */
54      public static final short CONDITIONAL_IGNORE = 1;
55  
56      //
57      // XMLDTDHandler methods
58      //
59  
60      /**
61       * The start of the DTD.
62       *
63       * @param locator  The document locator, or null if the document
64       *                 location cannot be reported during the parsing of
65       *                 the document DTD. However, it is <em>strongly</em>
66       *                 recommended that a locator be supplied that can
67       *                 at least report the base system identifier of the
68       *                 DTD.
69       * @param augmentations Additional information that may include infoset
70       *                      augmentations.
71       *
72       * @throws XNIException Thrown by handler to signal an error.
73       */
74      public void startDTD(XMLLocator locator, Augmentations augmentations)
75          throws XNIException;
76  
77      /**
78       * This method notifies of the start of a parameter entity. The parameter
79       * entity name start with a '%' character.
80       *
81       * @param name     The name of the parameter entity.
82       * @param identifier The resource identifier.
83       * @param encoding The auto-detected IANA encoding name of the entity
84       *                 stream. This value will be null in those situations
85       *                 where the entity encoding is not auto-detected (e.g.
86       *                 internal parameter entities).
87       * @param augmentations Additional information that may include infoset
88       *                      augmentations.
89       *
90       * @throws XNIException Thrown by handler to signal an error.
91       */
92      public void startParameterEntity(String name,
93                                       XMLResourceIdentifier identifier,
94                                       String encoding,
95                                       Augmentations augmentations) throws XNIException;
96  
97      /**
98       * Notifies of the presence of a TextDecl line in an entity. If present,
99       * this method will be called immediately following the startEntity call.
100      * <p>
101      * <strong>Note:</strong> This method is only called for external
102      * parameter entities referenced in the DTD.
103      *
104      * @param version  The XML version, or null if not specified.
105      * @param encoding The IANA encoding name of the entity.
106      * @param augmentations Additional information that may include infoset
107      *                      augmentations.
108      *
109      * @throws XNIException Thrown by handler to signal an error.
110      */
111     public void textDecl(String version, String encoding,
112                          Augmentations augmentations) throws XNIException;
113 
114     /**
115      * This method notifies the end of a parameter entity. Parameter entity
116      * names begin with a '%' character.
117      *
118      * @param name The name of the parameter entity.
119      * @param augmentations Additional information that may include infoset
120      *                      augmentations.
121      *
122      * @throws XNIException Thrown by handler to signal an error.
123      */
124     public void endParameterEntity(String name, Augmentations augmentations)
125         throws XNIException;
126 
127     /**
128      * The start of the DTD external subset.
129      *
130      * @param identifier The resource identifier.
131      * @param augmentations
132      *                   Additional information that may include infoset
133      *                   augmentations.
134      * @exception XNIException
135      *                   Thrown by handler to signal an error.
136      */
137     public void startExternalSubset(XMLResourceIdentifier identifier,
138                                     Augmentations augmentations)
139         throws XNIException;
140 
141     /**
142      * The end of the DTD external subset.
143      *
144      * @param augmentations Additional information that may include infoset
145      *                      augmentations.
146      *
147      * @throws XNIException Thrown by handler to signal an error.
148      */
149     public void endExternalSubset(Augmentations augmentations)
150         throws XNIException;
151 
152     /**
153      * A comment.
154      *
155      * @param text The text in the comment.
156      * @param augmentations Additional information that may include infoset
157      *                      augmentations.
158      *
159      * @throws XNIException Thrown by application to signal an error.
160      */
161     public void comment(XMLString text, Augmentations augmentations)
162         throws XNIException;
163 
164     /**
165      * A processing instruction. Processing instructions consist of a
166      * target name and, optionally, text data. The data is only meaningful
167      * to the application.
168      * <p>
169      * Typically, a processing instruction's data will contain a series
170      * of pseudo-attributes. These pseudo-attributes follow the form of
171      * element attributes but are <strong>not</strong> parsed or presented
172      * to the application as anything other than text. The application is
173      * responsible for parsing the data.
174      *
175      * @param target The target.
176      * @param data   The data or null if none specified.
177      * @param augmentations Additional information that may include infoset
178      *                      augmentations.
179      *
180      * @throws XNIException Thrown by handler to signal an error.
181      */
182     public void processingInstruction(String target, XMLString data,
183                                       Augmentations augmentations)
184         throws XNIException;
185 
186     /**
187      * An element declaration.
188      *
189      * @param name         The name of the element.
190      * @param contentModel The element content model.
191      * @param augmentations Additional information that may include infoset
192      *                      augmentations.
193      *
194      * @throws XNIException Thrown by handler to signal an error.
195      */
196     public void elementDecl(String name, String contentModel,
197                             Augmentations augmentations)
198         throws XNIException;
199 
200     /**
201      * The start of an attribute list.
202      *
203      * @param elementName The name of the element that this attribute
204      *                    list is associated with.
205      * @param augmentations Additional information that may include infoset
206      *                      augmentations.
207      *
208      * @throws XNIException Thrown by handler to signal an error.
209      */
210     public void startAttlist(String elementName,
211                              Augmentations augmentations) throws XNIException;
212 
213     /**
214      * An attribute declaration.
215      *
216      * @param elementName   The name of the element that this attribute
217      *                      is associated with.
218      * @param attributeName The name of the attribute.
219      * @param type          The attribute type. This value will be one of
220      *                      the following: "CDATA", "ENTITY", "ENTITIES",
221      *                      "ENUMERATION", "ID", "IDREF", "IDREFS",
222      *                      "NMTOKEN", "NMTOKENS", or "NOTATION".
223      * @param enumeration   If the type has the value "ENUMERATION" or
224      *                      "NOTATION", this array holds the allowed attribute
225      *                      values; otherwise, this array is null.
226      * @param defaultType   The attribute default type. This value will be
227      *                      one of the following: "#FIXED", "#IMPLIED",
228      *                      "#REQUIRED", or null.
229      * @param defaultValue  The attribute default value, or null if no
230      *                      default value is specified.
231      * @param nonNormalizedDefaultValue  The attribute default value with no normalization
232      *                      performed, or null if no default value is specified.
233      * @param augmentations Additional information that may include infoset
234      *                      augmentations.
235      *
236      * @throws XNIException Thrown by handler to signal an error.
237      */
238     public void attributeDecl(String elementName, String attributeName,
239                               String type, String[] enumeration,
240                               String defaultType, XMLString defaultValue,
241                               XMLString nonNormalizedDefaultValue, Augmentations augmentations)
242         throws XNIException;
243 
244     /**
245      * The end of an attribute list.
246      *
247      * @param augmentations Additional information that may include infoset
248      *                      augmentations.
249      *
250      * @throws XNIException Thrown by handler to signal an error.
251      */
252     public void endAttlist(Augmentations augmentations) throws XNIException;
253 
254     /**
255      * An internal entity declaration.
256      *
257      * @param name The name of the entity. Parameter entity names start with
258      *             '%', whereas the name of a general entity is just the
259      *             entity name.
260      * @param text The value of the entity.
261      * @param nonNormalizedText The non-normalized value of the entity. This
262      *             value contains the same sequence of characters that was in
263      *             the internal entity declaration, without any entity
264      *             references expanded.
265      * @param augmentations Additional information that may include infoset
266      *                      augmentations.
267      *
268      * @throws XNIException Thrown by handler to signal an error.
269      */
270     public void internalEntityDecl(String name, XMLString text,
271                                    XMLString nonNormalizedText,
272                                    Augmentations augmentations)
273         throws XNIException;
274 
275     /**
276      * An external entity declaration.
277      *
278      * @param name     The name of the entity. Parameter entity names start
279      *                 with '%', whereas the name of a general entity is just
280      *                 the entity name.
281      * @param identifier    An object containing all location information
282      *                      pertinent to this external entity.
283      * @param augmentations Additional information that may include infoset
284      *                      augmentations.
285      *
286      * @throws XNIException Thrown by handler to signal an error.
287      */
288     public void externalEntityDecl(String name,
289                                    XMLResourceIdentifier identifier,
290                                    Augmentations augmentations)
291         throws XNIException;
292 
293     /**
294      * An unparsed entity declaration.
295      *
296      * @param name     The name of the entity.
297      * @param identifier    An object containing all location information
298      *                      pertinent to this unparsed entity declaration.
299      * @param notation The name of the notation.
300      * @param augmentations Additional information that may include infoset
301      *                      augmentations.
302      *
303      * @throws XNIException Thrown by handler to signal an error.
304      */
305     public void unparsedEntityDecl(String name,
306                                    XMLResourceIdentifier identifier,
307                                    String notation, Augmentations augmentations)
308         throws XNIException;
309 
310     /**
311      * A notation declaration
312      *
313      * @param name     The name of the notation.
314      * @param identifier    An object containing all location information
315      *                      pertinent to this notation.
316      * @param augmentations Additional information that may include infoset
317      *                      augmentations.
318      *
319      * @throws XNIException Thrown by handler to signal an error.
320      */
321     public void notationDecl(String name, XMLResourceIdentifier identifier,
322                              Augmentations augmentations) throws XNIException;
323 
324     /**
325      * The start of a conditional section.
326      *
327      * @param type The type of the conditional section. This value will
328      *             either be CONDITIONAL_INCLUDE or CONDITIONAL_IGNORE.
329      * @param augmentations Additional information that may include infoset
330      *                      augmentations.
331      *
332      * @throws XNIException Thrown by handler to signal an error.
333      *
334      * @see #CONDITIONAL_INCLUDE
335      * @see #CONDITIONAL_IGNORE
336      */
337     public void startConditional(short type, Augmentations augmentations)
338         throws XNIException;
339 
340     /**
341      * Characters within an IGNORE conditional section.
342      *
343      * @param text The ignored text.
344      * @param augmentations Additional information that may include infoset
345      *                      augmentations.
346      *
347      * @throws XNIException Thrown by handler to signal an error.
348      */
349     public void ignoredCharacters(XMLString text, Augmentations augmentations)
350         throws XNIException;
351 
352     /**
353      * The end of a conditional section.
354      *
355      * @param augmentations Additional information that may include infoset
356      *                      augmentations.
357      *
358      * @throws XNIException Thrown by handler to signal an error.
359      */
360     public void endConditional(Augmentations augmentations) throws XNIException;
361 
362     /**
363      * The end of the DTD.
364      *
365      * @param augmentations Additional information that may include infoset
366      *                      augmentations.
367      *
368      * @throws XNIException Thrown by handler to signal an error.
369      */
370     public void endDTD(Augmentations augmentations) throws XNIException;
371 
372     // set the source of this handler
373     public void setDTDSource(XMLDTDSource source);
374 
375     // return the source from which this handler derives its events
376     public XMLDTDSource getDTDSource();
377 
378 } // interface XMLDTDHandler