001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package org.apache.xerces.parsers;
019:
020: import org.apache.xerces.impl.dtd.DTDGrammar;
021: import org.apache.xerces.util.SymbolTable;
022:
023: import org.apache.xerces.xni.Augmentations;
024: import org.apache.xerces.xni.XMLString;
025: import org.apache.xerces.xni.XMLDTDContentModelHandler;
026: import org.apache.xerces.xni.XMLDTDHandler;
027: import org.apache.xerces.xni.XMLLocator;
028: import org.apache.xerces.xni.XNIException;
029: import org.apache.xerces.xni.parser.XMLDTDScanner;
030: import org.apache.xerces.xni.XMLResourceIdentifier;
031:
032: /**
033: * @version $Id: DTDParser.java 447239 2006-09-18 05:08:26Z mrglavas $
034: */
035: public abstract class DTDParser extends XMLGrammarParser implements
036: XMLDTDHandler, XMLDTDContentModelHandler {
037:
038: //
039: // Data
040: //
041:
042: /** fDTDScanner */
043: protected XMLDTDScanner fDTDScanner;
044:
045: //
046: // Constructors
047: //
048:
049: /**
050: *
051: *
052: * @param symbolTable
053: */
054: public DTDParser(SymbolTable symbolTable) {
055: super (symbolTable);
056: }
057:
058: //
059: // Methods
060: //
061:
062: /**
063: * getDTDGrammar
064: *
065: * @return the grammar created by this parser
066: */
067: public DTDGrammar getDTDGrammar() {
068: return null;
069: } // getDTDGrammar
070:
071: //
072: // XMLDTDHandler methods
073: //
074:
075: /**
076: * This method notifies of the start of an entity. The DTD has the
077: * pseudo-name of "[dtd]" and parameter entity names start with '%'.
078: * <p>
079: * <strong>Note:</strong> Since the DTD is an entity, the handler
080: * will be notified of the start of the DTD entity by calling the
081: * startEntity method with the entity name "[dtd]" <em>before</em> calling
082: * the startDTD method.
083: *
084: * @param name The name of the entity.
085: * @param publicId The public identifier of the entity if the entity
086: * is external, null otherwise.
087: * @param systemId The system identifier of the entity if the entity
088: * is external, null otherwise.
089: * @param encoding The auto-detected IANA encoding name of the entity
090: * stream. This value will be null in those situations
091: * where the entity encoding is not auto-detected (e.g.
092: * internal parameter entities).
093: *
094: * @throws XNIException Thrown by handler to signal an error.
095: */
096: public void startEntity(String name, String publicId,
097: String systemId, String encoding) throws XNIException {
098: }
099:
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 version, String encoding)
113: throws XNIException {
114: }
115:
116: /**
117: * The start of the DTD.
118: *
119: * @throws XNIException Thrown by handler to signal an error.
120: */
121: public void startDTD(XMLLocator locator, Augmentations augmentations)
122: throws XNIException {
123: }
124:
125: /**
126: * A comment.
127: *
128: * @param text The text in the comment.
129: *
130: * @throws XNIException Thrown by application to signal an error.
131: */
132: public void comment(XMLString text, Augmentations augmentations)
133: throws XNIException {
134: } // comment
135:
136: /**
137: * A processing instruction. Processing instructions consist of a
138: * target name and, optionally, text data. The data is only meaningful
139: * to the application.
140: * <p>
141: * Typically, a processing instruction's data will contain a series
142: * of pseudo-attributes. These pseudo-attributes follow the form of
143: * element attributes but are <strong>not</strong> parsed or presented
144: * to the application as anything other than text. The application is
145: * responsible for parsing the data.
146: *
147: * @param target The target.
148: * @param data The data or null if none specified.
149: *
150: * @throws XNIException Thrown by handler to signal an error.
151: */
152: public void processingInstruction(String target, XMLString data,
153: Augmentations augmentations) throws XNIException {
154: } // processingInstruction
155:
156: /**
157: * The start of the external subset.
158: *
159: * @throws XNIException Thrown by handler to signal an error.
160: */
161: public void startExternalSubset(XMLResourceIdentifier identifier,
162: Augmentations augmentations) throws XNIException {
163: } // startExternalSubset
164:
165: /**
166: * The end of the external subset.
167: *
168: * @throws XNIException Thrown by handler to signal an error.
169: */
170: public void endExternalSubset(Augmentations augmentations)
171: throws XNIException {
172: } // endExternalSubset
173:
174: /**
175: * An element declaration.
176: *
177: * @param name The name of the element.
178: * @param contentModel The element content model.
179: *
180: * @throws XNIException Thrown by handler to signal an error.
181: */
182: public void elementDecl(String name, String contentModel,
183: Augmentations augmentations) throws XNIException {
184: } // elementDecl
185:
186: /**
187: * The start of an attribute list.
188: *
189: * @param elementName The name of the element that this attribute
190: * list is associated with.
191: *
192: * @throws XNIException Thrown by handler to signal an error.
193: */
194: public void startAttlist(String elementName,
195: Augmentations augmentations) throws XNIException {
196: } // startAttlist
197:
198: /**
199: * An attribute declaration.
200: *
201: * @param elementName The name of the element that this attribute
202: * is associated with.
203: * @param attributeName The name of the attribute.
204: * @param type The attribute type. This value will be one of
205: * the following: "CDATA", "ENTITY", "ENTITIES",
206: * "ENUMERATION", "ID", "IDREF", "IDREFS",
207: * "NMTOKEN", "NMTOKENS", or "NOTATION".
208: * @param enumeration If the type has the value "ENUMERATION", this
209: * array holds the allowed attribute values;
210: * otherwise, this array is null.
211: * @param defaultType The attribute default type. This value will be
212: * one of the following: "#FIXED", "#IMPLIED",
213: * "#REQUIRED", or null.
214: * @param defaultValue The attribute default value, or null if no
215: * default value is specified.
216: *
217: * @throws XNIException Thrown by handler to signal an error.
218: */
219: public void attributeDecl(String elementName, String attributeName,
220: String type, String[] enumeration, String defaultType,
221: XMLString defaultValue,
222: XMLString nonNormalizedDefaultValue,
223: Augmentations augmentations) throws XNIException {
224: } // attributeDecl
225:
226: /**
227: * The end of an attribute list.
228: *
229: * @throws XNIException Thrown by handler to signal an error.
230: */
231: public void endAttlist(Augmentations augmentations)
232: throws XNIException {
233: } // endAttlist
234:
235: /**
236: * An internal entity declaration.
237: *
238: * @param name The name of the entity. Parameter entity names start with
239: * '%', whereas the name of a general entity is just the
240: * entity name.
241: * @param text The value of the entity.
242: * @param nonNormalizedText The non-normalized value of the entity. This
243: * value contains the same sequence of characters that was in
244: * the internal entity declaration, without any entity
245: * references expanded.
246: *
247: * @throws XNIException Thrown by handler to signal an error.
248: */
249: public void internalEntityDecl(String name, XMLString text,
250: XMLString nonNormalizedText, Augmentations augmentations)
251: throws XNIException {
252: } // internalEntityDecl(String,XMLString,XMLString)
253:
254: /**
255: * An external entity declaration.
256: *
257: * @param name The name of the entity. Parameter entity names start
258: * with '%', whereas the name of a general entity is just
259: * the entity name.
260: * @param identifier An object containing all location information
261: * pertinent to this entity.
262: * @param augmentations Additional information that may include infoset
263: * augmentations.
264: *
265: * @throws XNIException Thrown by handler to signal an error.
266: */
267: public void externalEntityDecl(String name,
268: XMLResourceIdentifier identifier,
269: Augmentations augmentations) 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 name,
286: XMLResourceIdentifier identifier, String notation,
287: Augmentations augmentations) throws XNIException {
288: } // unparsedEntityDecl
289:
290: /**
291: * A notation declaration
292: *
293: * @param name The name of the notation.
294: * @param identifier An object containing all location information
295: * pertinent to this notation.
296: * @param augmentations Additional information that may include infoset
297: * augmentations.
298: *
299: * @throws XNIException Thrown by handler to signal an error.
300: */
301: public void notationDecl(String name,
302: XMLResourceIdentifier identifier,
303: Augmentations augmentations) throws XNIException {
304: } // notationDecl
305:
306: /**
307: * The start of a conditional section.
308: *
309: * @param type The type of the conditional section. This value will
310: * either be CONDITIONAL_INCLUDE or CONDITIONAL_IGNORE.
311: *
312: * @throws XNIException Thrown by handler to signal an error.
313: *
314: * @see XMLDTDHandler#CONDITIONAL_INCLUDE
315: * @see XMLDTDHandler#CONDITIONAL_IGNORE
316: */
317: public void startConditional(short type, Augmentations augmentations)
318: 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)
327: throws XNIException {
328: } // endConditional
329:
330: /**
331: * The end of the DTD.
332: *
333: * @throws XNIException Thrown by handler to signal an error.
334: */
335: public void endDTD(Augmentations augmentations) throws XNIException {
336: } // endDTD
337:
338: /**
339: * This method notifies the end of an entity. The DTD has the pseudo-name
340: * of "[dtd]" and parameter entity names start with '%'.
341: * <p>
342: * <strong>Note:</strong> Since the DTD is an entity, the handler
343: * will be notified of the end of the DTD entity by calling the
344: * endEntity method with the entity name "[dtd]" <em>after</em> calling
345: * the endDTD method.
346: *
347: * @param name The name of the entity.
348: *
349: * @throws XNIException Thrown by handler to signal an error.
350: */
351: public void endEntity(String name, Augmentations augmentations)
352: throws XNIException {
353: }
354:
355: //
356: // XMLDTDContentModelHandler methods
357: //
358:
359: /**
360: * The start of a content model. Depending on the type of the content
361: * model, specific methods may be called between the call to the
362: * startContentModel method and the call to the endContentModel method.
363: *
364: * @param elementName The name of the element.
365: * @param type The content model type.
366: *
367: * @throws XNIException Thrown by handler to signal an error.
368: *
369: * @see org.apache.xerces.impl.dtd.XMLElementDecl#TYPE_EMPTY
370: * @see org.apache.xerces.impl.dtd.XMLElementDecl#TYPE_ANY
371: * @see org.apache.xerces.impl.dtd.XMLElementDecl#TYPE_MIXED
372: * @see org.apache.xerces.impl.dtd.XMLElementDecl#TYPE_CHILDREN
373: */
374: public void startContentModel(String elementName, short type)
375: throws XNIException {
376: } // startContentModel
377:
378: /**
379: * A referenced element in a mixed content model. If the mixed content
380: * model only allows text content, then this method will not be called
381: * for that model. However, if this method is called for a mixed
382: * content model, then the zero or more occurrence count is implied.
383: * <p>
384: * <strong>Note:</strong> This method is only called after a call to
385: * the startContentModel method where the type is TYPE_MIXED.
386: *
387: * @param elementName The name of the referenced element.
388: *
389: * @throws XNIException Thrown by handler to signal an error.
390: *
391: * @see org.apache.xerces.impl.dtd.XMLElementDecl#TYPE_MIXED
392: */
393: public void mixedElement(String elementName) throws XNIException {
394: } // mixedElement
395:
396: /**
397: * The start of a children group.
398: * <p>
399: * <strong>Note:</strong> This method is only called after a call to
400: * the startContentModel method where the type is TYPE_CHILDREN.
401: * <p>
402: * <strong>Note:</strong> Children groups can be nested and have
403: * associated occurrence counts.
404: *
405: * @throws XNIException Thrown by handler to signal an error.
406: *
407: * @see org.apache.xerces.impl.dtd.XMLElementDecl#TYPE_CHILDREN
408: */
409: public void childrenStartGroup() throws XNIException {
410: } // childrenStartGroup
411:
412: /**
413: * A referenced element in a children content model.
414: *
415: * @param elementName The name of the referenced element.
416: *
417: * @throws XNIException Thrown by handler to signal an error.
418: *
419: * @see org.apache.xerces.impl.dtd.XMLElementDecl#TYPE_CHILDREN
420: */
421: public void childrenElement(String elementName) throws XNIException {
422: } // childrenElement
423:
424: /**
425: * The separator between choices or sequences of a children content
426: * model.
427: * <p>
428: * <strong>Note:</strong> This method is only called after a call to
429: * the startContentModel method where the type is TYPE_CHILDREN.
430: *
431: * @param separator The type of children separator.
432: *
433: * @throws XNIException Thrown by handler to signal an error.
434: *
435: * @see XMLDTDContentModelHandler#SEPARATOR_CHOICE
436: * @see XMLDTDContentModelHandler#SEPARATOR_SEQUENCE
437: * @see org.apache.xerces.impl.dtd.XMLElementDecl#TYPE_CHILDREN
438: */
439: public void childrenSeparator(short separator) throws XNIException {
440: } // childrenSeparator
441:
442: /**
443: * The occurrence count for a child in a children content model.
444: * <p>
445: * <strong>Note:</strong> This method is only called after a call to
446: * the startContentModel method where the type is TYPE_CHILDREN.
447: *
448: * @param occurrence The occurrence count for the last children element
449: * or children group.
450: *
451: * @throws XNIException Thrown by handler to signal an error.
452: *
453: * @see XMLDTDContentModelHandler#OCCURS_ZERO_OR_ONE
454: * @see XMLDTDContentModelHandler#OCCURS_ZERO_OR_MORE
455: * @see XMLDTDContentModelHandler#OCCURS_ONE_OR_MORE
456: * @see org.apache.xerces.impl.dtd.XMLElementDecl#TYPE_CHILDREN
457: */
458: public void childrenOccurrence(short occurrence)
459: throws XNIException {
460: } // childrenOccurrence
461:
462: /**
463: * The end of a children group.
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: * @see org.apache.xerces.impl.dtd.XMLElementDecl#TYPE_CHILDREN
469: */
470: public void childrenEndGroup() throws XNIException {
471: } // childrenEndGroup
472:
473: /**
474: * The end of a content model.
475: *
476: * @throws XNIException Thrown by handler to signal an error.
477: */
478: public void endContentModel() throws XNIException {
479: } // endContentModel
480:
481: } // class DTDParser
|