KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xerces > parsers > DTDParser


1 /*
2  * Copyright 1999-2002,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.xerces.parsers;
18
19 import org.apache.xerces.impl.dtd.DTDGrammar;
20 import org.apache.xerces.util.SymbolTable;
21
22 import org.apache.xerces.xni.Augmentations;
23 import org.apache.xerces.xni.XMLString;
24 import org.apache.xerces.xni.XMLDTDContentModelHandler;
25 import org.apache.xerces.xni.XMLDTDHandler;
26 import org.apache.xerces.xni.XMLLocator;
27 import org.apache.xerces.xni.XNIException;
28 import org.apache.xerces.xni.parser.XMLDTDScanner;
29 import org.apache.xerces.xni.XMLResourceIdentifier;
30
31 /**
32  * @version $Id: DTDParser.java,v 1.12 2004/03/25 04:03:23 mrglavas Exp $
33  */

34 public abstract class DTDParser
35     extends XMLGrammarParser
36     implements XMLDTDHandler, XMLDTDContentModelHandler {
37
38     //
39
// Data
40
//
41

42     /** fDTDScanner */
43     protected XMLDTDScanner fDTDScanner;
44
45     //
46
// Constructors
47
//
48

49     /**
50      *
51      *
52      * @param symbolTable
53      */

54     public DTDParser(SymbolTable symbolTable) {
55         super(symbolTable);
56     }
57
58     //
59
// Methods
60
//
61

62     /**
63      * getDTDGrammar
64      *
65      * @return the grammar created by this parser
66      */

67     public DTDGrammar getDTDGrammar() {
68         return null;
69     } // getDTDGrammar
70

71     //
72
// XMLDTDHandler methods
73
//
74

75     /**
76      * This method notifies of the start of an entity. The DTD has the
77      * pseudo-name of "[dtd]" and parameter entity names start with '%'.
78      * <p>
79      * <strong>Note:</strong> Since the DTD is an entity, the handler
80      * will be notified of the start of the DTD entity by calling the
81      * startEntity method with the entity name "[dtd]" <em>before</em> calling
82      * the startDTD method.
83      *
84      * @param name The name of the entity.
85      * @param publicId The public identifier of the entity if the entity
86      * is external, null otherwise.
87      * @param systemId The system identifier of the entity if the entity
88      * is external, null otherwise.
89      * @param encoding The auto-detected IANA encoding name of the entity
90      * stream. This value will be null in those situations
91      * where the entity encoding is not auto-detected (e.g.
92      * internal parameter entities).
93      *
94      * @throws XNIException Thrown by handler to signal an error.
95      */

96     public void startEntity(String JavaDoc name, String JavaDoc publicId, String JavaDoc systemId,
97                             String JavaDoc encoding) throws XNIException {
98     }
99
100     /**
101      * Notifies of the presence of a TextDecl line in an entity. If present,
102      * this method will be called immediately following the startEntity call.
103      * <p>
104      * <strong>Note:</strong> This method is only called for external
105      * parameter entities referenced in the DTD.
106      *
107      * @param version The XML version, or null if not specified.
108      * @param encoding The IANA encoding name of the entity.
109      *
110      * @throws XNIException Thrown by handler to signal an error.
111      */

112     public void textDecl(String JavaDoc version, String JavaDoc encoding) throws XNIException {
113     }
114
115     /**
116      * The start of the DTD.
117      *
118      * @throws XNIException Thrown by handler to signal an error.
119      */

120     public void startDTD(XMLLocator locator, Augmentations augmentations)
121                          throws XNIException {
122     }
123
124     /**
125      * A comment.
126      *
127      * @param text The text in the comment.
128      *
129      * @throws XNIException Thrown by application to signal an error.
130      */

131     public void comment(XMLString text, Augmentations augmentations) throws XNIException {
132     } // comment
133

134     /**
135      * A processing instruction. Processing instructions consist of a
136      * target name and, optionally, text data. The data is only meaningful
137      * to the application.
138      * <p>
139      * Typically, a processing instruction's data will contain a series
140      * of pseudo-attributes. These pseudo-attributes follow the form of
141      * element attributes but are <strong>not</strong> parsed or presented
142      * to the application as anything other than text. The application is
143      * responsible for parsing the data.
144      *
145      * @param target The target.
146      * @param data The data or null if none specified.
147      *
148      * @throws XNIException Thrown by handler to signal an error.
149      */

150     public void processingInstruction(String JavaDoc target, XMLString data,
151                                       Augmentations augmentations)
152         throws XNIException {
153     } // processingInstruction
154

155     /**
156      * The start of the external subset.
157      *
158      * @throws XNIException Thrown by handler to signal an error.
159      */

160     public void startExternalSubset(XMLResourceIdentifier identifier,
161                                     Augmentations augmentations) throws XNIException {
162     } // startExternalSubset
163

164     /**
165      * The end of the external subset.
166      *
167      * @throws XNIException Thrown by handler to signal an error.
168      */

169     public void endExternalSubset(Augmentations augmentations) throws XNIException {
170     } // endExternalSubset
171

172     /**
173      * An element declaration.
174      *
175      * @param name The name of the element.
176      * @param contentModel The element content model.
177      *
178      * @throws XNIException Thrown by handler to signal an error.
179      */

180     public void elementDecl(String JavaDoc name, String JavaDoc contentModel,
181                             Augmentations augmentations)
182         throws XNIException {
183     } // elementDecl
184

185     /**
186      * The start of an attribute list.
187      *
188      * @param elementName The name of the element that this attribute
189      * list is associated with.
190      *
191      * @throws XNIException Thrown by handler to signal an error.
192      */

193     public void startAttlist(String JavaDoc elementName,
194                              Augmentations augmentations) throws XNIException {
195     } // startAttlist
196

197     /**
198      * An attribute declaration.
199      *
200      * @param elementName The name of the element that this attribute
201      * is associated with.
202      * @param attributeName The name of the attribute.
203      * @param type The attribute type. This value will be one of
204      * the following: "CDATA", "ENTITY", "ENTITIES",
205      * "ENUMERATION", "ID", "IDREF", "IDREFS",
206      * "NMTOKEN", "NMTOKENS", or "NOTATION".
207      * @param enumeration If the type has the value "ENUMERATION", this
208      * array holds the allowed attribute values;
209      * otherwise, this array is null.
210      * @param defaultType The attribute default type. This value will be
211      * one of the following: "#FIXED", "#IMPLIED",
212      * "#REQUIRED", or null.
213      * @param defaultValue The attribute default value, or null if no
214      * default value is specified.
215      *
216      * @throws XNIException Thrown by handler to signal an error.
217      */

218     public void attributeDecl(String JavaDoc elementName, String JavaDoc attributeName,
219                               String JavaDoc type, String JavaDoc[] enumeration,
220                               String JavaDoc defaultType, XMLString defaultValue,
221                               XMLString nonNormalizedDefaultValue, Augmentations augmentations)
222         throws XNIException {
223     } // attributeDecl
224

225     /**
226      * The end of an attribute list.
227      *
228      * @throws XNIException Thrown by handler to signal an error.
229      */

230     public void endAttlist(Augmentations augmentations) throws XNIException {
231     } // endAttlist
232

233     /**
234      * An internal entity declaration.
235      *
236      * @param name The name of the entity. Parameter entity names start with
237      * '%', whereas the name of a general entity is just the
238      * entity name.
239      * @param text The value of the entity.
240      * @param nonNormalizedText The non-normalized value of the entity. This
241      * value contains the same sequence of characters that was in
242      * the internal entity declaration, without any entity
243      * references expanded.
244      *
245      * @throws XNIException Thrown by handler to signal an error.
246      */

247     public void internalEntityDecl(String JavaDoc name, XMLString text,
248                                    XMLString nonNormalizedText,
249                                    Augmentations augmentations)
250         throws XNIException {
251     } // internalEntityDecl(String,XMLString,XMLString)
252

253     /**
254      * An external entity declaration.
255      *
256      * @param name The name of the entity. Parameter entity names start
257      * with '%', whereas the name of a general entity is just
258      * the entity name.
259      * @param identifier An object containing all location information
260      * pertinent to this entity.
261      * @param augmentations Additional information that may include infoset
262      * augmentations.
263      *
264      * @throws XNIException Thrown by handler to signal an error.
265      */

266     public void externalEntityDecl(String JavaDoc name,
267                                    XMLResourceIdentifier identifier,
268                                    Augmentations augmentations)
269         throws XNIException {
270     } // externalEntityDecl
271

272     /**
273      * An unparsed entity declaration.
274      *
275      * @param name The name of the entity.
276      * @param identifier An object containing all location information
277      * pertinent to this entity.
278      * @param notation The name of the notation.
279      *
280      * @param augmentations Additional information that may include infoset
281      * augmentations.
282      *
283      * @throws XNIException Thrown by handler to signal an error.
284      */

285     public void unparsedEntityDecl(String JavaDoc name,
286                                    XMLResourceIdentifier identifier,
287                                    String JavaDoc notation, Augmentations augmentations)
288         throws XNIException {
289     } // unparsedEntityDecl
290

291     /**
292      * A notation declaration
293      *
294      * @param name The name of the notation.
295      * @param identifier An object containing all location information
296      * pertinent to this notation.
297      * @param augmentations Additional information that may include infoset
298      * augmentations.
299      *
300      * @throws XNIException Thrown by handler to signal an error.
301      */

302     public void notationDecl(String JavaDoc name, XMLResourceIdentifier identifier,
303                              Augmentations augmentations)
304         throws XNIException {
305     } // notationDecl
306

307     /**
308      * The start of a conditional section.
309      *
310      * @param type The type of the conditional section. This value will
311      * either be CONDITIONAL_INCLUDE or CONDITIONAL_IGNORE.
312      *
313      * @throws XNIException Thrown by handler to signal an error.
314      *
315      * @see XMLDTDHandler#CONDITIONAL_INCLUDE
316      * @see XMLDTDHandler#CONDITIONAL_IGNORE
317      */

318     public void startConditional(short type, Augmentations augmentations) throws XNIException {
319     } // startConditional
320

321     /**
322      * The end of a conditional section.
323      *
324      * @throws XNIException Thrown by handler to signal an error.
325      */

326     public void endConditional(Augmentations augmentations) throws XNIException {
327     } // endConditional
328

329     /**
330      * The end of the DTD.
331      *
332      * @throws XNIException Thrown by handler to signal an error.
333      */

334     public void endDTD(Augmentations augmentations) throws XNIException {
335     } // endDTD
336

337     /**
338      * This method notifies the end of an entity. The DTD has the pseudo-name
339      * of "[dtd]" and parameter entity names start with '%'.
340      * <p>
341      * <strong>Note:</strong> Since the DTD is an entity, the handler
342      * will be notified of the end of the DTD entity by calling the
343      * endEntity method with the entity name "[dtd]" <em>after</em> calling
344      * the endDTD method.
345      *
346      * @param name The name of the entity.
347      *
348      * @throws XNIException Thrown by handler to signal an error.
349      */

350     public void endEntity(String JavaDoc name, Augmentations augmentations) throws XNIException {
351     }
352
353     //
354
// XMLDTDContentModelHandler methods
355
//
356

357     /**
358      * The start of a content model. Depending on the type of the content
359      * model, specific methods may be called between the call to the
360      * startContentModel method and the call to the endContentModel method.
361      *
362      * @param elementName The name of the element.
363      * @param type The content model type.
364      *
365      * @throws XNIException Thrown by handler to signal an error.
366      *
367      * @see org.apache.xerces.impl.dtd.XMLElementDecl#TYPE_EMPTY
368      * @see org.apache.xerces.impl.dtd.XMLElementDecl#TYPE_ANY
369      * @see org.apache.xerces.impl.dtd.XMLElementDecl#TYPE_MIXED
370      * @see org.apache.xerces.impl.dtd.XMLElementDecl#TYPE_CHILDREN
371      */

372     public void startContentModel(String JavaDoc elementName, short type)
373         throws XNIException {
374     } // startContentModel
375

376     /**
377      * A referenced element in a mixed content model. If the mixed content
378      * model only allows text content, then this method will not be called
379      * for that model. However, if this method is called for a mixed
380      * content model, then the zero or more occurrence count is implied.
381      * <p>
382      * <strong>Note:</strong> This method is only called after a call to
383      * the startContentModel method where the type is TYPE_MIXED.
384      *
385      * @param elementName The name of the referenced element.
386      *
387      * @throws XNIException Thrown by handler to signal an error.
388      *
389      * @see org.apache.xerces.impl.dtd.XMLElementDecl#TYPE_MIXED
390      */

391     public void mixedElement(String JavaDoc elementName) throws XNIException {
392     } // mixedElement
393

394     /**
395      * The start of a children group.
396      * <p>
397      * <strong>Note:</strong> This method is only called after a call to
398      * the startContentModel method where the type is TYPE_CHILDREN.
399      * <p>
400      * <strong>Note:</strong> Children groups can be nested and have
401      * associated occurrence counts.
402      *
403      * @throws XNIException Thrown by handler to signal an error.
404      *
405      * @see org.apache.xerces.impl.dtd.XMLElementDecl#TYPE_CHILDREN
406      */

407     public void childrenStartGroup() throws XNIException {
408     } // childrenStartGroup
409

410     /**
411      * A referenced element in a children content model.
412      *
413      * @param elementName The name of the referenced element.
414      *
415      * @throws XNIException Thrown by handler to signal an error.
416      *
417      * @see org.apache.xerces.impl.dtd.XMLElementDecl#TYPE_CHILDREN
418      */

419     public void childrenElement(String JavaDoc elementName) throws XNIException {
420     } // childrenElement
421

422     /**
423      * The separator between choices or sequences of a children content
424      * model.
425      * <p>
426      * <strong>Note:</strong> This method is only called after a call to
427      * the startContentModel method where the type is TYPE_CHILDREN.
428      *
429      * @param separator The type of children separator.
430      *
431      * @throws XNIException Thrown by handler to signal an error.
432      *
433      * @see XMLDTDContentModelHandler#SEPARATOR_CHOICE
434      * @see XMLDTDContentModelHandler#SEPARATOR_SEQUENCE
435      * @see org.apache.xerces.impl.dtd.XMLElementDecl#TYPE_CHILDREN
436      */

437     public void childrenSeparator(short separator) throws XNIException {
438     } // childrenSeparator
439

440     /**
441      * The occurrence count for a child in a children content model.
442      * <p>
443      * <strong>Note:</strong> This method is only called after a call to
444      * the startContentModel method where the type is TYPE_CHILDREN.
445      *
446      * @param occurrence The occurrence count for the last children element
447      * or children group.
448      *
449      * @throws XNIException Thrown by handler to signal an error.
450      *
451      * @see XMLDTDContentModelHandler#OCCURS_ZERO_OR_ONE
452      * @see XMLDTDContentModelHandler#OCCURS_ZERO_OR_MORE
453      * @see XMLDTDContentModelHandler#OCCURS_ONE_OR_MORE
454      * @see org.apache.xerces.impl.dtd.XMLElementDecl#TYPE_CHILDREN
455      */

456     public void childrenOccurrence(short occurrence) throws XNIException {
457     } // childrenOccurrence
458

459     /**
460      * The end of a children group.
461      * <p>
462      * <strong>Note:</strong> This method is only called after a call to
463      * the startContentModel method where the type is TYPE_CHILDREN.
464      *
465      * @see org.apache.xerces.impl.dtd.XMLElementDecl#TYPE_CHILDREN
466      */

467     public void childrenEndGroup() throws XNIException {
468     } // childrenEndGroup
469

470     /**
471      * The end of a content model.
472      *
473      * @throws XNIException Thrown by handler to signal an error.
474      */

475     public void endContentModel() throws XNIException {
476     } // endContentModel
477

478 } // class DTDParser
479
Popular Tags