1/* 2 * reserved comment block 3 * DO NOT REMOVE OR ALTER! 4 */ 5/* 6 * Licensed to the Apache Software Foundation (ASF) under one or more 7 * contributor license agreements. See the NOTICE file distributed with 8 * this work for additional information regarding copyright ownership. 9 * The ASF licenses this file to You under the Apache License, Version 2.0 10 * (the "License"); you may not use this file except in compliance with 11 * the License. You may obtain a copy of the License at 12 * 13 * http://www.apache.org/licenses/LICENSE-2.0 14 * 15 * Unless required by applicable law or agreed to in writing, software 16 * distributed under the License is distributed on an "AS IS" BASIS, 17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 * See the License for the specific language governing permissions and 19 * limitations under the License. 20 */ 21 22package com.sun.org.apache.xerces.internal.parsers; 23 24import com.sun.org.apache.xerces.internal.impl.dtd.DTDGrammar; 25import com.sun.org.apache.xerces.internal.util.SymbolTable; 26 27import com.sun.org.apache.xerces.internal.xni.Augmentations; 28import com.sun.org.apache.xerces.internal.xni.XMLString; 29import com.sun.org.apache.xerces.internal.xni.XMLDTDContentModelHandler; 30import com.sun.org.apache.xerces.internal.xni.XMLDTDHandler; 31import com.sun.org.apache.xerces.internal.xni.XMLLocator; 32import com.sun.org.apache.xerces.internal.xni.XNIException; 33import com.sun.org.apache.xerces.internal.xni.parser.XMLDTDScanner; 34import com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier; 35 36/** 37 */ 38public abstract class DTDParser 39 extends XMLGrammarParser 40 implements XMLDTDHandler, XMLDTDContentModelHandler { 41 42 // 43 // Data 44 // 45 46 /** fDTDScanner */ 47 protected XMLDTDScanner fDTDScanner; 48 49 // 50 // Constructors 51 // 52 53 /** 54 * 55 * 56 * @param symbolTable 57 */ 58 public DTDParser(SymbolTable symbolTable) { 59 super(symbolTable); 60 } 61 62 // 63 // Methods 64 // 65 66 /** 67 * getDTDGrammar 68 * 69 * @return the grammar created by this parser 70 */ 71 public DTDGrammar getDTDGrammar() { 72 return null; 73 } // getDTDGrammar 74 75 // 76 // XMLDTDHandler methods 77 // 78 79 /** 80 * This method notifies of the start of an entity. The DTD has the 81 * pseudo-name of "[dtd]" and parameter entity names start with '%'. 82 * <p> 83 * <strong>Note:</strong> Since the DTD is an entity, the handler 84 * will be notified of the start of the DTD entity by calling the 85 * startEntity method with the entity name "[dtd]" <em>before</em> calling 86 * the startDTD method. 87 * 88 * @param name The name of the entity. 89 * @param publicId The public identifier of the entity if the entity 90 * is external, null otherwise. 91 * @param systemId The system identifier of the entity if the entity 92 * is external, null otherwise. 93 * @param encoding The auto-detected IANA encoding name of the entity 94 * stream. This value will be null in those situations 95 * where the entity encoding is not auto-detected (e.g. 96 * internal parameter entities). 97 * 98 * @throws XNIException Thrown by handler to signal an error. 99 */ 100 public void startEntity(String name, String publicId, String systemId, 101 String encoding) throws XNIException { 102 } 103 104 /** 105 * Notifies of the presence of a TextDecl line in an entity. If present, 106 * this method will be called immediately following the startEntity call. 107 * <p> 108 * <strong>Note:</strong> This method is only called for external 109 * parameter entities referenced in the DTD. 110 * 111 * @param version The XML version, or null if not specified. 112 * @param encoding The IANA encoding name of the entity. 113 * 114 * @throws XNIException Thrown by handler to signal an error. 115 */ 116 public void textDecl(String version, String encoding) throws XNIException { 117 } 118 119 /** 120 * The start of the DTD. 121 * 122 * @throws XNIException Thrown by handler to signal an error. 123 */ 124 public void startDTD(XMLLocator locator, Augmentations augmentations) 125 throws XNIException { 126 } 127 128 /** 129 * A comment. 130 * 131 * @param text The text in the comment. 132 * 133 * @throws XNIException Thrown by application to signal an error. 134 */ 135 public void comment(XMLString text, Augmentations augmentations) throws XNIException { 136 } // comment 137 138 /** 139 * A processing instruction. Processing instructions consist of a 140 * target name and, optionally, text data. The data is only meaningful 141 * to the application. 142 * <p> 143 * Typically, a processing instruction's data will contain a series 144 * of pseudo-attributes. These pseudo-attributes follow the form of 145 * element attributes but are <strong>not</strong> parsed or presented 146 * to the application as anything other than text. The application is 147 * responsible for parsing the data. 148 * 149 * @param target The target. 150 * @param data The data or null if none specified. 151 * 152 * @throws XNIException Thrown by handler to signal an error. 153 */ 154 public void processingInstruction(String target, XMLString data, 155 Augmentations augmentations) 156 throws XNIException { 157 } // processingInstruction 158 159 /** 160 * The start of the external subset. 161 * 162 * @throws XNIException Thrown by handler to signal an error. 163 */ 164 public void startExternalSubset(XMLResourceIdentifier identifier, 165 Augmentations augmentations) throws XNIException { 166 } // startExternalSubset 167 168 /** 169 * The end of the external subset. 170 * 171 * @throws XNIException Thrown by handler to signal an error. 172 */ 173 public void endExternalSubset(Augmentations augmentations) throws XNIException { 174 } // endExternalSubset 175 176 /** 177 * An element declaration. 178 * 179 * @param name The name of the element. 180 * @param contentModel The element content model. 181 * 182 * @throws XNIException Thrown by handler to signal an error. 183 */ 184 public void elementDecl(String name, String contentModel, 185 Augmentations augmentations) 186 throws XNIException { 187 } // elementDecl 188 189 /** 190 * The start of an attribute list. 191 * 192 * @param elementName The name of the element that this attribute 193 * list is associated with. 194 * 195 * @throws XNIException Thrown by handler to signal an error. 196 */ 197 public void startAttlist(String elementName, 198 Augmentations augmentations) throws XNIException { 199 } // startAttlist 200 201 /** 202 * An attribute declaration. 203 * 204 * @param elementName The name of the element that this attribute 205 * is associated with. 206 * @param attributeName The name of the attribute. 207 * @param type The attribute type. This value will be one of 208 * the following: "CDATA", "ENTITY", "ENTITIES", 209 * "ENUMERATION", "ID", "IDREF", "IDREFS", 210 * "NMTOKEN", "NMTOKENS", or "NOTATION". 211 * @param enumeration If the type has the value "ENUMERATION", this 212 * array holds the allowed attribute values; 213 * otherwise, this array is null. 214 * @param defaultType The attribute default type. This value will be 215 * one of the following: "#FIXED", "#IMPLIED", 216 * "#REQUIRED", or null. 217 * @param defaultValue The attribute default value, or null if no 218 * default value is specified. 219 * 220 * @throws XNIException Thrown by handler to signal an error. 221 */ 222 public void attributeDecl(String elementName, String attributeName, 223 String type, String[] enumeration, 224 String defaultType, XMLString defaultValue, 225 XMLString nonNormalizedDefaultValue, Augmentations augmentations) 226 throws XNIException { 227 } // attributeDecl 228 229 /** 230 * The end of an attribute list. 231 * 232 * @throws XNIException Thrown by handler to signal an error. 233 */ 234 public void endAttlist(Augmentations augmentations) throws XNIException { 235 } // endAttlist 236 237 /** 238 * An internal entity declaration. 239 * 240 * @param name The name of the entity. Parameter entity names start with 241 * '%', whereas the name of a general entity is just the 242 * entity name. 243 * @param text The value of the entity. 244 * @param nonNormalizedText The non-normalized value of the entity. This 245 * value contains the same sequence of characters that was in 246 * the internal entity declaration, without any entity 247 * references expanded. 248 * 249 * @throws XNIException Thrown by handler to signal an error. 250 */ 251 public void internalEntityDecl(String name, XMLString text, 252 XMLString nonNormalizedText, 253 Augmentations augmentations) 254 throws XNIException { 255 } // internalEntityDecl(String,XMLString,XMLString) 256 257 /** 258 * An external entity declaration. 259 * 260 * @param name The name of the entity. Parameter entity names start 261 * with '%', whereas the name of a general entity is just 262 * the entity name. 263 * @param identifier An object containing all location information 264 * pertinent to this entity. 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 externalEntityDecl(String name, 271 XMLResourceIdentifier identifier, 272 Augmentations augmentations) 273 throws XNIException { 274 } // externalEntityDecl 275 276 /** 277 * An unparsed entity declaration. 278 * 279 * @param name The name of the entity. 280 * @param identifier An object containing all location information 281 * pertinent to this entity. 282 * @param notation The name of the notation. 283 * 284 * @param augmentations Additional information that may include infoset 285 * augmentations. 286 * 287 * @throws XNIException Thrown by handler to signal an error. 288 */ 289 public void unparsedEntityDecl(String name, 290 XMLResourceIdentifier identifier, 291 String notation, Augmentations augmentations) 292 throws XNIException { 293 } // unparsedEntityDecl 294 295 /** 296 * A notation declaration 297 * 298 * @param name The name of the notation. 299 * @param identifier An object containing all location information 300 * pertinent to this notation. 301 * @param augmentations Additional information that may include infoset 302 * augmentations. 303 * 304 * @throws XNIException Thrown by handler to signal an error. 305 */ 306 public void notationDecl(String name, XMLResourceIdentifier identifier, 307 Augmentations augmentations) 308 throws XNIException { 309 } // notationDecl 310 311 /** 312 * The start of a conditional section. 313 * 314 * @param type The type of the conditional section. This value will 315 * either be CONDITIONAL_INCLUDE or CONDITIONAL_IGNORE. 316 * 317 * @throws XNIException Thrown by handler to signal an error. 318 * 319 * @see XMLDTDHandler#CONDITIONAL_INCLUDE 320 * @see XMLDTDHandler#CONDITIONAL_IGNORE 321 */ 322 public void startConditional(short type, Augmentations augmentations) throws XNIException { 323 } // startConditional 324 325 /** 326 * The end of a conditional section. 327 * 328 * @throws XNIException Thrown by handler to signal an error. 329 */ 330 public void endConditional(Augmentations augmentations) throws XNIException { 331 } // endConditional 332 333 /** 334 * The end of the DTD. 335 * 336 * @throws XNIException Thrown by handler to signal an error. 337 */ 338 public void endDTD(Augmentations augmentations) throws XNIException { 339 } // endDTD 340 341 /** 342 * This method notifies the end of an entity. The DTD has the pseudo-name 343 * of "[dtd]" and parameter entity names start with '%'. 344 * <p> 345 * <strong>Note:</strong> Since the DTD is an entity, the handler 346 * will be notified of the end of the DTD entity by calling the 347 * endEntity method with the entity name "[dtd]" <em>after</em> calling 348 * the endDTD method. 349 * 350 * @param name The name of the entity. 351 * 352 * @throws XNIException Thrown by handler to signal an error. 353 */ 354 public void endEntity(String name, Augmentations augmentations) throws XNIException { 355 } 356 357 // 358 // XMLDTDContentModelHandler methods 359 // 360 361 /** 362 * The start of a content model. Depending on the type of the content 363 * model, specific methods may be called between the call to the 364 * startContentModel method and the call to the endContentModel method. 365 * 366 * @param elementName The name of the element. 367 * @param type The content model type. 368 * 369 * @throws XNIException Thrown by handler to signal an error. 370 * 371 * @see com.sun.org.apache.xerces.internal.impl.dtd.XMLElementDecl#TYPE_EMPTY 372 * @see com.sun.org.apache.xerces.internal.impl.dtd.XMLElementDecl#TYPE_ANY 373 * @see com.sun.org.apache.xerces.internal.impl.dtd.XMLElementDecl#TYPE_MIXED 374 * @see com.sun.org.apache.xerces.internal.impl.dtd.XMLElementDecl#TYPE_CHILDREN 375 */ 376 public void startContentModel(String elementName, short type) 377 throws XNIException { 378 } // startContentModel 379 380 /** 381 * A referenced element in a mixed content model. If the mixed content 382 * model only allows text content, then this method will not be called 383 * for that model. However, if this method is called for a mixed 384 * content model, then the zero or more occurrence count is implied. 385 * <p> 386 * <strong>Note:</strong> This method is only called after a call to 387 * the startContentModel method where the type is TYPE_MIXED. 388 * 389 * @param elementName The name of the referenced element. 390 * 391 * @throws XNIException Thrown by handler to signal an error. 392 * 393 * @see com.sun.org.apache.xerces.internal.impl.dtd.XMLElementDecl#TYPE_MIXED 394 */ 395 public void mixedElement(String elementName) throws XNIException { 396 } // mixedElement 397 398 /** 399 * The start of a children group. 400 * <p> 401 * <strong>Note:</strong> This method is only called after a call to 402 * the startContentModel method where the type is TYPE_CHILDREN. 403 * <p> 404 * <strong>Note:</strong> Children groups can be nested and have 405 * associated occurrence counts. 406 * 407 * @throws XNIException Thrown by handler to signal an error. 408 * 409 * @see com.sun.org.apache.xerces.internal.impl.dtd.XMLElementDecl#TYPE_CHILDREN 410 */ 411 public void childrenStartGroup() throws XNIException { 412 } // childrenStartGroup 413 414 /** 415 * A referenced element in a children content model. 416 * 417 * @param elementName The name of the referenced element. 418 * 419 * @throws XNIException Thrown by handler to signal an error. 420 * 421 * @see com.sun.org.apache.xerces.internal.impl.dtd.XMLElementDecl#TYPE_CHILDREN 422 */ 423 public void childrenElement(String elementName) throws XNIException { 424 } // childrenElement 425 426 /** 427 * The separator between choices or sequences of a children content 428 * model. 429 * <p> 430 * <strong>Note:</strong> This method is only called after a call to 431 * the startContentModel method where the type is TYPE_CHILDREN. 432 * 433 * @param separator The type of children separator. 434 * 435 * @throws XNIException Thrown by handler to signal an error. 436 * 437 * @see XMLDTDContentModelHandler#SEPARATOR_CHOICE 438 * @see XMLDTDContentModelHandler#SEPARATOR_SEQUENCE 439 * @see com.sun.org.apache.xerces.internal.impl.dtd.XMLElementDecl#TYPE_CHILDREN 440 */ 441 public void childrenSeparator(short separator) throws XNIException { 442 } // childrenSeparator 443 444 /** 445 * The occurrence count for a child in a children content model. 446 * <p> 447 * <strong>Note:</strong> This method is only called after a call to 448 * the startContentModel method where the type is TYPE_CHILDREN. 449 * 450 * @param occurrence The occurrence count for the last children element 451 * or children group. 452 * 453 * @throws XNIException Thrown by handler to signal an error. 454 * 455 * @see XMLDTDContentModelHandler#OCCURS_ZERO_OR_ONE 456 * @see XMLDTDContentModelHandler#OCCURS_ZERO_OR_MORE 457 * @see XMLDTDContentModelHandler#OCCURS_ONE_OR_MORE 458 * @see com.sun.org.apache.xerces.internal.impl.dtd.XMLElementDecl#TYPE_CHILDREN 459 */ 460 public void childrenOccurrence(short occurrence) throws XNIException { 461 } // childrenOccurrence 462 463 /** 464 * The end of a children group. 465 * <p> 466 * <strong>Note:</strong> This method is only called after a call to 467 * the startContentModel method where the type is TYPE_CHILDREN. 468 * 469 * @see com.sun.org.apache.xerces.internal.impl.dtd.XMLElementDecl#TYPE_CHILDREN 470 */ 471 public void childrenEndGroup() throws XNIException { 472 } // childrenEndGroup 473 474 /** 475 * The end of a content model. 476 * 477 * @throws XNIException Thrown by handler to signal an error. 478 */ 479 public void endContentModel() throws XNIException { 480 } // endContentModel 481 482} // class DTDParser 483