KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > org > apache > xerces > internal > parsers > DTDParser


1 /*
2  * The Apache Software License, Version 1.1
3  *
4  *
5  * Copyright (c) 1999-2002 The Apache Software Foundation. All rights
6  * reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in
17  * the documentation and/or other materials provided with the
18  * distribution.
19  *
20  * 3. The end-user documentation included with the redistribution,
21  * if any, must include the following acknowledgment:
22  * "This product includes software developed by the
23  * Apache Software Foundation (http://www.apache.org/)."
24  * Alternately, this acknowledgment may appear in the software itself,
25  * if and wherever such third-party acknowledgments normally appear.
26  *
27  * 4. The names "Xerces" and "Apache Software Foundation" must
28  * not be used to endorse or promote products derived from this
29  * software without prior written permission. For written
30  * permission, please contact apache@apache.org.
31  *
32  * 5. Products derived from this software may not be called "Apache",
33  * nor may "Apache" appear in their name, without prior written
34  * permission of the Apache Software Foundation.
35  *
36  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
40  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
43  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
46  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47  * SUCH DAMAGE.
48  * ====================================================================
49  *
50  * This software consists of voluntary contributions made by many
51  * individuals on behalf of the Apache Software Foundation and was
52  * originally based on software copyright (c) 1999, International
53  * Business Machines, Inc., http://www.apache.org. For more
54  * information on the Apache Software Foundation, please see
55  * <http://www.apache.org/>.
56  */

57
58 package com.sun.org.apache.xerces.internal.parsers;
59
60 import com.sun.org.apache.xerces.internal.impl.dtd.DTDGrammar;
61 import com.sun.org.apache.xerces.internal.util.SymbolTable;
62
63 import com.sun.org.apache.xerces.internal.xni.Augmentations;
64 import com.sun.org.apache.xerces.internal.xni.XMLString;
65 import com.sun.org.apache.xerces.internal.xni.XMLDTDContentModelHandler;
66 import com.sun.org.apache.xerces.internal.xni.XMLDTDHandler;
67 import com.sun.org.apache.xerces.internal.xni.XMLLocator;
68 import com.sun.org.apache.xerces.internal.xni.XNIException;
69 import com.sun.org.apache.xerces.internal.xni.parser.XMLDTDScanner;
70 import com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier;
71
72 /**
73  * @version $Id: DTDParser.java,v 1.10 2002/05/07 19:29:04 elena Exp $
74  */

75 public abstract class DTDParser
76     extends XMLGrammarParser
77     implements XMLDTDHandler, XMLDTDContentModelHandler {
78
79     //
80
// Data
81
//
82

83     /** fDTDScanner */
84     protected XMLDTDScanner fDTDScanner;
85
86     //
87
// Constructors
88
//
89

90     /**
91      *
92      *
93      * @param symbolTable
94      */

95     public DTDParser(SymbolTable symbolTable) {
96         super(symbolTable);
97     }
98
99     //
100
// Methods
101
//
102

103     /**
104      * getDTDGrammar
105      *
106      * @return the grammar created by this parser
107      */

108     public DTDGrammar getDTDGrammar() {
109         return null;
110     } // getDTDGrammar
111

112     //
113
// XMLDTDHandler methods
114
//
115

116     /**
117      * This method notifies of the start of an entity. The DTD has the
118      * pseudo-name of "[dtd]" and parameter entity names start with '%'.
119      * <p>
120      * <strong>Note:</strong> Since the DTD is an entity, the handler
121      * will be notified of the start of the DTD entity by calling the
122      * startEntity method with the entity name "[dtd]" <em>before</em> calling
123      * the startDTD method.
124      *
125      * @param name The name of the entity.
126      * @param publicId The public identifier of the entity if the entity
127      * is external, null otherwise.
128      * @param systemId The system identifier of the entity if the entity
129      * is external, null otherwise.
130      * @param encoding The auto-detected IANA encoding name of the entity
131      * stream. This value will be null in those situations
132      * where the entity encoding is not auto-detected (e.g.
133      * internal parameter entities).
134      *
135      * @throws XNIException Thrown by handler to signal an error.
136      */

137     public void startEntity(String JavaDoc name, String JavaDoc publicId, String JavaDoc systemId,
138                             String JavaDoc encoding) throws XNIException {
139     }
140
141     /**
142      * Notifies of the presence of a TextDecl line in an entity. If present,
143      * this method will be called immediately following the startEntity call.
144      * <p>
145      * <strong>Note:</strong> This method is only called for external
146      * parameter entities referenced in the DTD.
147      *
148      * @param version The XML version, or null if not specified.
149      * @param encoding The IANA encoding name of the entity.
150      *
151      * @throws XNIException Thrown by handler to signal an error.
152      */

153     public void textDecl(String JavaDoc version, String JavaDoc encoding) throws XNIException {
154     }
155
156     /**
157      * The start of the DTD.
158      *
159      * @throws XNIException Thrown by handler to signal an error.
160      */

161     public void startDTD(XMLLocator locator, Augmentations augmentations)
162                          throws XNIException {
163     }
164
165     /**
166      * A comment.
167      *
168      * @param text The text in the comment.
169      *
170      * @throws XNIException Thrown by application to signal an error.
171      */

172     public void comment(XMLString text, Augmentations augmentations) throws XNIException {
173     } // comment
174

175     /**
176      * A processing instruction. Processing instructions consist of a
177      * target name and, optionally, text data. The data is only meaningful
178      * to the application.
179      * <p>
180      * Typically, a processing instruction's data will contain a series
181      * of pseudo-attributes. These pseudo-attributes follow the form of
182      * element attributes but are <strong>not</strong> parsed or presented
183      * to the application as anything other than text. The application is
184      * responsible for parsing the data.
185      *
186      * @param target The target.
187      * @param data The data or null if none specified.
188      *
189      * @throws XNIException Thrown by handler to signal an error.
190      */

191     public void processingInstruction(String JavaDoc target, XMLString data,
192                                       Augmentations augmentations)
193         throws XNIException {
194     } // processingInstruction
195

196     /**
197      * The start of the external subset.
198      *
199      * @throws XNIException Thrown by handler to signal an error.
200      */

201     public void startExternalSubset(XMLResourceIdentifier identifier,
202                                     Augmentations augmentations) throws XNIException {
203     } // startExternalSubset
204

205     /**
206      * The end of the external subset.
207      *
208      * @throws XNIException Thrown by handler to signal an error.
209      */

210     public void endExternalSubset(Augmentations augmentations) throws XNIException {
211     } // endExternalSubset
212

213     /**
214      * An element declaration.
215      *
216      * @param name The name of the element.
217      * @param contentModel The element content model.
218      *
219      * @throws XNIException Thrown by handler to signal an error.
220      */

221     public void elementDecl(String JavaDoc name, String JavaDoc contentModel,
222                             Augmentations augmentations)
223         throws XNIException {
224     } // elementDecl
225

226     /**
227      * The start of an attribute list.
228      *
229      * @param elementName The name of the element that this attribute
230      * list is associated with.
231      *
232      * @throws XNIException Thrown by handler to signal an error.
233      */

234     public void startAttlist(String JavaDoc elementName,
235                              Augmentations augmentations) throws XNIException {
236     } // startAttlist
237

238     /**
239      * An attribute declaration.
240      *
241      * @param elementName The name of the element that this attribute
242      * is associated with.
243      * @param attributeName The name of the attribute.
244      * @param type The attribute type. This value will be one of
245      * the following: "CDATA", "ENTITY", "ENTITIES",
246      * "ENUMERATION", "ID", "IDREF", "IDREFS",
247      * "NMTOKEN", "NMTOKENS", or "NOTATION".
248      * @param enumeration If the type has the value "ENUMERATION", this
249      * array holds the allowed attribute values;
250      * otherwise, this array is null.
251      * @param defaultType The attribute default type. This value will be
252      * one of the following: "#FIXED", "#IMPLIED",
253      * "#REQUIRED", or null.
254      * @param defaultValue The attribute default value, or null if no
255      * default value is specified.
256      *
257      * @throws XNIException Thrown by handler to signal an error.
258      */

259     public void attributeDecl(String JavaDoc elementName, String JavaDoc attributeName,
260                               String JavaDoc type, String JavaDoc[] enumeration,
261                               String JavaDoc defaultType, XMLString defaultValue,
262                               XMLString nonNormalizedDefaultValue, Augmentations augmentations)
263         throws XNIException {
264     } // attributeDecl
265

266     /**
267      * The end of an attribute list.
268      *
269      * @throws XNIException Thrown by handler to signal an error.
270      */

271     public void endAttlist(Augmentations augmentations) throws XNIException {
272     } // endAttlist
273

274     /**
275      * An internal entity declaration.
276      *
277      * @param name The name of the entity. Parameter entity names start with
278      * '%', whereas the name of a general entity is just the
279      * entity name.
280      * @param text The value of the entity.
281      * @param nonNormalizedText The non-normalized value of the entity. This
282      * value contains the same sequence of characters that was in
283      * the internal entity declaration, without any entity
284      * references expanded.
285      *
286      * @throws XNIException Thrown by handler to signal an error.
287      */

288     public void internalEntityDecl(String JavaDoc name, XMLString text,
289                                    XMLString nonNormalizedText,
290                                    Augmentations augmentations)
291         throws XNIException {
292     } // internalEntityDecl(String,XMLString,XMLString)
293

294     /**
295      * An external entity declaration.
296      *
297      * @param name The name of the entity. Parameter entity names start
298      * with '%', whereas the name of a general entity is just
299      * the entity name.
300      * @param publicId The public identifier of the entity or null if the
301      * the entity was specified with SYSTEM.
302      * @param systemId The system identifier of the entity.
303      *
304      * @throws XNIException Thrown by handler to signal an error.
305      */

306     public void externalEntityDecl(String JavaDoc name,
307                                    XMLResourceIdentifier identifier,
308                                    Augmentations augmentations)
309         throws XNIException {
310     } // externalEntityDecl
311

312     /**
313      * An unparsed entity declaration.
314      *
315      * @param name The name of the entity.
316      * @param publicId The public identifier of the entity, or null if not
317      * specified.
318      * @param systemId The system identifier of the entity, or null if not
319      * specified.
320      * @param notation The name of the notation.
321      *
322      * @throws XNIException Thrown by handler to signal an error.
323      */

324     public void unparsedEntityDecl(String JavaDoc name,
325                                    XMLResourceIdentifier identifier,
326                                    String JavaDoc notation, Augmentations augmentations)
327         throws XNIException {
328     } // unparsedEntityDecl
329

330     /**
331      * A notation declaration
332      *
333      * @param name The name of the notation.
334      * @param publicId The public identifier of the notation, or null if not
335      * specified.
336      * @param systemId The system identifier of the notation, or null if not
337      * specified.
338      *
339      * @throws XNIException Thrown by handler to signal an error.
340      */

341     public void notationDecl(String JavaDoc name, XMLResourceIdentifier identifier,
342                              Augmentations augmentations)
343         throws XNIException {
344     } // notationDecl
345

346     /**
347      * The start of a conditional section.
348      *
349      * @param type The type of the conditional section. This value will
350      * either be CONDITIONAL_INCLUDE or CONDITIONAL_IGNORE.
351      *
352      * @throws XNIException Thrown by handler to signal an error.
353      *
354      * @see XMLDTDHandler#CONDITIONAL_INCLUDE
355      * @see XMLDTDHandler#CONDITIONAL_IGNORE
356      */

357     public void startConditional(short type, Augmentations augmentations) throws XNIException {
358     } // startConditional
359

360     /**
361      * The end of a conditional section.
362      *
363      * @throws XNIException Thrown by handler to signal an error.
364      */

365     public void endConditional(Augmentations augmentations) throws XNIException {
366     } // endConditional
367

368     /**
369      * The end of the DTD.
370      *
371      * @throws XNIException Thrown by handler to signal an error.
372      */

373     public void endDTD(Augmentations augmentations) throws XNIException {
374     } // endDTD
375

376     /**
377      * This method notifies the end of an entity. The DTD has the pseudo-name
378      * of "[dtd]" and parameter entity names start with '%'.
379      * <p>
380      * <strong>Note:</strong> Since the DTD is an entity, the handler
381      * will be notified of the end of the DTD entity by calling the
382      * endEntity method with the entity name "[dtd]" <em>after</em> calling
383      * the endDTD method.
384      *
385      * @param name The name of the entity.
386      *
387      * @throws XNIException Thrown by handler to signal an error.
388      */

389     public void endEntity(String JavaDoc name, Augmentations augmentations) throws XNIException {
390     }
391
392     //
393
// XMLDTDContentModelHandler methods
394
//
395

396     /**
397      * The start of a content model. Depending on the type of the content
398      * model, specific methods may be called between the call to the
399      * startContentModel method and the call to the endContentModel method.
400      *
401      * @param elementName The name of the element.
402      * @param type The content model type.
403      *
404      * @throws XNIException Thrown by handler to signal an error.
405      *
406      * @see com.sun.org.apache.xerces.internal.impl.dtd.XMLElementDecl#TYPE_EMPTY
407      * @see com.sun.org.apache.xerces.internal.impl.dtd.XMLElementDecl#TYPE_ANY
408      * @see com.sun.org.apache.xerces.internal.impl.dtd.XMLElementDecl#TYPE_MIXED
409      * @see com.sun.org.apache.xerces.internal.impl.dtd.XMLElementDecl#TYPE_CHILDREN
410      */

411     public void startContentModel(String JavaDoc elementName, short type)
412         throws XNIException {
413     } // startContentModel
414

415     /**
416      * A referenced element in a mixed content model. If the mixed content
417      * model only allows text content, then this method will not be called
418      * for that model. However, if this method is called for a mixed
419      * content model, then the zero or more occurrence count is implied.
420      * <p>
421      * <strong>Note:</strong> This method is only called after a call to
422      * the startContentModel method where the type is TYPE_MIXED.
423      *
424      * @param elementName The name of the referenced element.
425      *
426      * @throws XNIException Thrown by handler to signal an error.
427      *
428      * @see com.sun.org.apache.xerces.internal.impl.dtd.XMLElementDecl#TYPE_MIXED
429      */

430     public void mixedElement(String JavaDoc elementName) throws XNIException {
431     } // mixedElement
432

433     /**
434      * The start of a children group.
435      * <p>
436      * <strong>Note:</strong> This method is only called after a call to
437      * the startContentModel method where the type is TYPE_CHILDREN.
438      * <p>
439      * <strong>Note:</strong> Children groups can be nested and have
440      * associated occurrence counts.
441      *
442      * @throws XNIException Thrown by handler to signal an error.
443      *
444      * @see com.sun.org.apache.xerces.internal.impl.dtd.XMLElementDecl#TYPE_CHILDREN
445      */

446     public void childrenStartGroup() throws XNIException {
447     } // childrenStartGroup
448

449     /**
450      * A referenced element in a children content model.
451      *
452      * @param elementName The name of the referenced element.
453      *
454      * @throws XNIException Thrown by handler to signal an error.
455      *
456      * @see com.sun.org.apache.xerces.internal.impl.dtd.XMLElementDecl#TYPE_CHILDREN
457      */

458     public void childrenElement(String JavaDoc elementName) throws XNIException {
459     } // childrenElement
460

461     /**
462      * The separator between choices or sequences of a children content
463      * model.
464      * <p>
465      * <strong>Note:</strong> This method is only called after a call to
466      * the startContentModel method where the type is TYPE_CHILDREN.
467      *
468      * @param separator The type of children separator.
469      *
470      * @throws XNIException Thrown by handler to signal an error.
471      *
472      * @see XMLDTDContentModelHandler#SEPARATOR_CHOICE
473      * @see XMLDTDContentModelHandler#SEPARATOR_SEQUENCE
474      * @see com.sun.org.apache.xerces.internal.impl.dtd.XMLElementDecl#TYPE_CHILDREN
475      */

476     public void childrenSeparator(short separator) throws XNIException {
477     } // childrenSeparator
478

479     /**
480      * The occurrence count for a child in a children content model.
481      * <p>
482      * <strong>Note:</strong> This method is only called after a call to
483      * the startContentModel method where the type is TYPE_CHILDREN.
484      *
485      * @param occurrence The occurrence count for the last children element
486      * or children group.
487      *
488      * @throws XNIException Thrown by handler to signal an error.
489      *
490      * @see XMLDTDContentModelHandler#OCCURS_ZERO_OR_ONE
491      * @see XMLDTDContentModelHandler#OCCURS_ZERO_OR_MORE
492      * @see XMLDTDContentModelHandler#OCCURS_ONE_OR_MORE
493      * @see com.sun.org.apache.xerces.internal.impl.dtd.XMLElementDecl#TYPE_CHILDREN
494      */

495     public void childrenOccurrence(short occurrence) throws XNIException {
496     } // childrenOccurrence
497

498     /**
499      * The end of a children group.
500      * <p>
501      * <strong>Note:</strong> This method is only called after a call to
502      * the startContentModel method where the type is TYPE_CHILDREN.
503      *
504      * @see com.sun.org.apache.xerces.internal.impl.dtd.XMLElementDecl#TYPE_CHILDREN
505      */

506     public void childrenEndGroup() throws XNIException {
507     } // childrenEndGroup
508

509     /**
510      * The end of a content model.
511      *
512      * @throws XNIException Thrown by handler to signal an error.
513      */

514     public void endContentModel() throws XNIException {
515     } // endContentModel
516

517 } // class DTDParser
518
Popular Tags