1. /*
  2. * The Apache Software License, Version 1.1
  3. *
  4. *
  5. * Copyright (c) 2001, 2002 The Apache Software Foundation.
  6. * All rights 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. package com.sun.org.apache.xerces.internal.parsers;
  58. import com.sun.org.apache.xerces.internal.xni.Augmentations;
  59. import com.sun.org.apache.xerces.internal.xni.NamespaceContext;
  60. import com.sun.org.apache.xerces.internal.xni.QName;
  61. import com.sun.org.apache.xerces.internal.xni.XMLAttributes;
  62. import com.sun.org.apache.xerces.internal.xni.XMLDTDContentModelHandler;
  63. import com.sun.org.apache.xerces.internal.xni.XMLDTDHandler;
  64. import com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler;
  65. import com.sun.org.apache.xerces.internal.xni.XMLLocator;
  66. import com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier;
  67. import com.sun.org.apache.xerces.internal.xni.XMLString;
  68. import com.sun.org.apache.xerces.internal.xni.XNIException;
  69. import com.sun.org.apache.xerces.internal.xni.parser.XMLDTDContentModelSource;
  70. import com.sun.org.apache.xerces.internal.xni.parser.XMLDTDSource;
  71. import com.sun.org.apache.xerces.internal.xni.parser.XMLDocumentSource;
  72. import com.sun.org.apache.xerces.internal.xni.parser.XMLParserConfiguration;
  73. /**
  74. * This is the base class for all XML document parsers. XMLDocumentParser
  75. * provides a common implementation shared by the various document parsers
  76. * in the Xerces package. While this class is provided for convenience, it
  77. * does not prevent other kinds of parsers to be constructed using the XNI
  78. * interfaces.
  79. *
  80. * @author Arnaud Le Hors, IBM
  81. * @author Andy Clark, IBM
  82. *
  83. * @version $Id: AbstractXMLDocumentParser.java,v 1.17 2003/05/08 20:11:58 elena Exp $
  84. */
  85. public abstract class AbstractXMLDocumentParser
  86. extends XMLParser
  87. implements XMLDocumentHandler, XMLDTDHandler, XMLDTDContentModelHandler {
  88. //
  89. // Data
  90. //
  91. // state
  92. /** True if inside DTD. */
  93. protected boolean fInDTD;
  94. /** Document source*/
  95. protected XMLDocumentSource fDocumentSource;
  96. /** DTD source*/
  97. protected XMLDTDSource fDTDSource;
  98. /** DTD content model source*/
  99. protected XMLDTDContentModelSource fDTDContentModelSource;
  100. //
  101. // Constructors
  102. //
  103. /**
  104. * Constructs a document parser using the default symbol table
  105. * and grammar pool.
  106. */
  107. protected AbstractXMLDocumentParser(XMLParserConfiguration config) {
  108. super(config);
  109. // set handlers
  110. config.setDocumentHandler(this);
  111. config.setDTDHandler(this);
  112. config.setDTDContentModelHandler(this);
  113. } // <init>(XMLParserConfiguration)
  114. //
  115. // XMLDocumentHandler methods
  116. //
  117. /**
  118. * The start of the document.
  119. *
  120. * @param locator The system identifier of the entity if the entity
  121. * is external, null otherwise.
  122. * @param encoding The auto-detected IANA encoding name of the entity
  123. * stream. This value will be null in those situations
  124. * where the entity encoding is not auto-detected (e.g.
  125. * internal entities or a document entity that is
  126. * parsed from a java.io.Reader).
  127. * @param namespaceContext
  128. * The namespace context in effect at the
  129. * start of this document.
  130. * This object represents the current context.
  131. * Implementors of this class are responsible
  132. * for copying the namespace bindings from the
  133. * the current context (and its parent contexts)
  134. * if that information is important.
  135. * @param augs Additional information that may include infoset augmentations
  136. *
  137. * @throws XNIException Thrown by handler to signal an error.
  138. */
  139. public void startDocument(XMLLocator locator, String encoding,
  140. NamespaceContext namespaceContext, Augmentations augs)
  141. throws XNIException {
  142. } // startDocument(XMLLocator,String)
  143. /**
  144. * Notifies of the presence of an XMLDecl line in the document. If
  145. * present, this method will be called immediately following the
  146. * startDocument call.
  147. *
  148. * @param version The XML version.
  149. * @param encoding The IANA encoding name of the document, or null if
  150. * not specified.
  151. * @param standalone The standalone value, or null if not specified.
  152. * @param augs Additional information that may include infoset augmentations
  153. *
  154. * @throws XNIException Thrown by handler to signal an error.
  155. */
  156. public void xmlDecl(String version, String encoding, String standalone, Augmentations augs)
  157. throws XNIException {
  158. } // xmlDecl(String,String,String)
  159. /**
  160. * Notifies of the presence of the DOCTYPE line in the document.
  161. *
  162. * @param rootElement The name of the root element.
  163. * @param publicId The public identifier if an external DTD or null
  164. * if the external DTD is specified using SYSTEM.
  165. * @param systemId The system identifier if an external DTD, null
  166. * @param augs Additional information that may include infoset augmentations
  167. * otherwise.
  168. *
  169. * @throws XNIException Thrown by handler to signal an error.
  170. */
  171. public void doctypeDecl(String rootElement, String publicId, String systemId, Augmentations augs)
  172. throws XNIException {
  173. } // doctypeDecl(String,String,String)
  174. /**
  175. * The start of an element. If the document specifies the start element
  176. * by using an empty tag, then the startElement method will immediately
  177. * be followed by the endElement method, with no intervening methods.
  178. *
  179. * @param element The name of the element.
  180. * @param attributes The element attributes.
  181. * @param augs Additional information that may include infoset augmentations
  182. *
  183. * @throws XNIException Thrown by handler to signal an error.
  184. */
  185. public void startElement(QName element, XMLAttributes attributes, Augmentations augs)
  186. throws XNIException {
  187. } // startElement(QName,XMLAttributes)
  188. /**
  189. * An empty element.
  190. *
  191. * @param element The name of the element.
  192. * @param attributes The element attributes.
  193. * @param augs Additional information that may include infoset augmentations
  194. *
  195. * @throws XNIException Thrown by handler to signal an error.
  196. */
  197. public void emptyElement(QName element, XMLAttributes attributes, Augmentations augs)
  198. throws XNIException {
  199. startElement(element, attributes, augs);
  200. endElement(element, augs);
  201. } // emptyElement(QName,XMLAttributes)
  202. /**
  203. * Character content.
  204. *
  205. * @param text The content.
  206. * @param augs Additional information that may include infoset augmentations
  207. *
  208. * @throws XNIException Thrown by handler to signal an error.
  209. */
  210. public void characters(XMLString text, Augmentations augs) throws XNIException {
  211. } // characters(XMLString)
  212. /**
  213. * Ignorable whitespace. For this method to be called, the document
  214. * source must have some way of determining that the text containing
  215. * only whitespace characters should be considered ignorable. For
  216. * example, the validator can determine if a length of whitespace
  217. * characters in the document are ignorable based on the element
  218. * content model.
  219. *
  220. * @param text The ignorable whitespace.
  221. * @param augs Additional information that may include infoset augmentations
  222. *
  223. * @throws XNIException Thrown by handler to signal an error.
  224. */
  225. public void ignorableWhitespace(XMLString text, Augmentations augs) throws XNIException {
  226. } // ignorableWhitespace(XMLString)
  227. /**
  228. * The end of an element.
  229. *
  230. * @param element The name of the element.
  231. * @param augs Additional information that may include infoset augmentations
  232. *
  233. * @throws XNIException Thrown by handler to signal an error.
  234. */
  235. public void endElement(QName element, Augmentations augs) throws XNIException {
  236. } // endElement(QName)
  237. /**
  238. * The start of a CDATA section.
  239. * @param augs Additional information that may include infoset augmentations
  240. *
  241. * @throws XNIException Thrown by handler to signal an error.
  242. */
  243. public void startCDATA(Augmentations augs) throws XNIException {
  244. } // startCDATA()
  245. /**
  246. * The end of a CDATA section.
  247. * @param augs Additional information that may include infoset augmentations
  248. *
  249. * @throws XNIException Thrown by handler to signal an error.
  250. */
  251. public void endCDATA(Augmentations augs) throws XNIException {
  252. } // endCDATA()
  253. /**
  254. * The end of the document.
  255. * @param augs Additional information that may include infoset augmentations
  256. *
  257. * @throws XNIException Thrown by handler to signal an error.
  258. */
  259. public void endDocument(Augmentations augs) throws XNIException {
  260. } // endDocument()
  261. /**
  262. * This method notifies the start of an entity.
  263. * <p>
  264. * <strong>Note:</strong> This method is not called for entity references
  265. * appearing as part of attribute values.
  266. *
  267. * @param name The name of the entity.
  268. * @param identifier The resource identifier.
  269. * @param encoding The auto-detected IANA encoding name of the entity
  270. * stream. This value will be null in those situations
  271. * where the entity encoding is not auto-detected (e.g.
  272. * internal entities or a document entity that is
  273. * parsed from a java.io.Reader).
  274. * @param augs Additional information that may include infoset augmentations
  275. *
  276. * @exception XNIException Thrown by handler to signal an error.
  277. */
  278. public void startGeneralEntity(String name,
  279. XMLResourceIdentifier identifier,
  280. String encoding,
  281. Augmentations augs) throws XNIException {
  282. } // startGeneralEntity(String,XMLResourceIdentifier,String,Augmentations)
  283. /**
  284. * Notifies of the presence of a TextDecl line in an entity. If present,
  285. * this method will be called immediately following the startEntity call.
  286. * <p>
  287. * <strong>Note:</strong> This method will never be called for the
  288. * document entity; it is only called for external general entities
  289. * referenced in document content.
  290. * <p>
  291. * <strong>Note:</strong> This method is not called for entity references
  292. * appearing as part of attribute values.
  293. *
  294. * @param version The XML version, or null if not specified.
  295. * @param encoding The IANA encoding name of the entity.
  296. * @param augs Additional information that may include infoset augmentations
  297. *
  298. * @exception XNIException
  299. * Thrown by handler to signal an error.
  300. */
  301. public void textDecl(String version, String encoding, Augmentations augs) throws XNIException {
  302. } // textDecl(String, String, Augmentations)
  303. /**
  304. * This method notifies the end of an entity.
  305. * <p>
  306. * <strong>Note:</strong> This method is not called for entity references
  307. * appearing as part of attribute values.
  308. *
  309. * @param name The name of the entity.
  310. * @param augs Additional information that may include infoset augmentations
  311. *
  312. * @exception XNIException
  313. * Thrown by handler to signal an error.
  314. */
  315. public void endGeneralEntity(String name, Augmentations augs)
  316. throws XNIException {
  317. } // endGeneralEntity(String,Augmentations)
  318. /**
  319. * A comment.
  320. *
  321. * @param text The text in the comment.
  322. * @param augs Additional information that may include infoset augmentations
  323. *
  324. * @exception XNIException
  325. * Thrown by application to signal an error.
  326. */
  327. public void comment(XMLString text, Augmentations augs) throws XNIException {
  328. } // comment (XMLString, Augmentations)
  329. /**
  330. * A processing instruction. Processing instructions consist of a
  331. * target name and, optionally, text data. The data is only meaningful
  332. * to the application.
  333. * <p>
  334. * Typically, a processing instruction's data will contain a series
  335. * of pseudo-attributes. These pseudo-attributes follow the form of
  336. * element attributes but are <strong>not</strong> parsed or presented
  337. * to the application as anything other than text. The application is
  338. * responsible for parsing the data.
  339. *
  340. * @param target The target.
  341. * @param data The data or null if none specified.
  342. * @param augs Additional information that may include infoset augmentations
  343. *
  344. * @exception XNIException
  345. * Thrown by handler to signal an error.
  346. */
  347. public void processingInstruction(String target, XMLString data, Augmentations augs)
  348. throws XNIException {
  349. } // processingInstruction(String, XMLString, Augmentations)
  350. /** Sets the document source */
  351. public void setDocumentSource(XMLDocumentSource source){
  352. fDocumentSource = source;
  353. } // setDocumentSource
  354. /** Returns the document source */
  355. public XMLDocumentSource getDocumentSource (){
  356. return fDocumentSource;
  357. } // getDocumentSource
  358. //
  359. // XMLDTDHandler methods
  360. //
  361. /**
  362. * The start of the DTD.
  363. *
  364. * @param locator The document locator, or null if the document
  365. * location cannot be reported during the parsing of
  366. * the document DTD. However, it is <em>strongly</em>
  367. * recommended that a locator be supplied that can
  368. * at least report the base system identifier of the
  369. * DTD.
  370. * @param augs Additional information that may include infoset
  371. * augmentations.
  372. *
  373. * @throws XNIException Thrown by handler to signal an error.
  374. */
  375. public void startDTD(XMLLocator locator, Augmentations augs) throws XNIException {
  376. fInDTD = true;
  377. } // startDTD(XMLLocator)
  378. /**
  379. * The start of the DTD external subset.
  380. *
  381. * @param augmentations Additional information that may include infoset
  382. * augmentations.
  383. *
  384. * @throws XNIException Thrown by handler to signal an error.
  385. */
  386. public void startExternalSubset(XMLResourceIdentifier identifier, Augmentations augmentations)
  387. throws XNIException {
  388. } // startExternalSubset(Augmentations)
  389. /**
  390. * The end of the DTD external subset.
  391. *
  392. * @param augmentations Additional information that may include infoset
  393. * augmentations.
  394. *
  395. * @throws XNIException Thrown by handler to signal an error.
  396. */
  397. public void endExternalSubset(Augmentations augmentations)
  398. throws XNIException {
  399. } // endExternalSubset(Augmentations)
  400. /**
  401. * This method notifies the start of an entity.
  402. * <p>
  403. * <strong>Note:</strong> This method is not called for entity references
  404. * appearing as part of attribute values.
  405. *
  406. * @param name The name of the entity.
  407. * @param identifier The resource identifier.
  408. * @param encoding The auto-detected IANA encoding name of the entity
  409. * stream. This value will be null in those situations
  410. * where the entity encoding is not auto-detected (e.g.
  411. * internal entities or a document entity that is
  412. * parsed from a java.io.Reader).
  413. * @param augs Additional information that may include infoset augmentations
  414. *
  415. * @exception XNIException Thrown by handler to signal an error.
  416. */
  417. public void startParameterEntity(String name,
  418. XMLResourceIdentifier identifier,
  419. String encoding,
  420. Augmentations augs) throws XNIException {
  421. } // startParameterEntity(String,XMLResourceIdentifier,String,Augmentations)
  422. /**
  423. * This method notifies the end of an entity.
  424. * <p>
  425. * <strong>Note:</strong> This method is not called for entity references
  426. * appearing as part of attribute values.
  427. *
  428. * @param name The name of the entity.
  429. * @param augs Additional information that may include infoset augmentations
  430. *
  431. * @exception XNIException
  432. * Thrown by handler to signal an error.
  433. */
  434. public void endParameterEntity(String name, Augmentations augs)
  435. throws XNIException {
  436. } // endParameterEntity(String,Augmentations)
  437. /**
  438. * Characters within an IGNORE conditional section.
  439. *
  440. * @param text The ignored text.
  441. * @param augs Additional information that may include infoset
  442. * augmentations.
  443. *
  444. * @throws XNIException Thrown by handler to signal an error.
  445. */
  446. public void ignoredCharacters(XMLString text, Augmentations augs) throws XNIException {
  447. } // ignoredCharacters(XMLString, Augmentations)
  448. /**
  449. * An element declaration.
  450. *
  451. * @param name The name of the element.
  452. * @param contentModel The element content model.
  453. * @param augs Additional information that may include infoset
  454. * augmentations.
  455. *
  456. * @throws XNIException Thrown by handler to signal an error.
  457. */
  458. public void elementDecl(String name, String contentModel, Augmentations augs)
  459. throws XNIException {
  460. } // elementDecl(String,String)
  461. /**
  462. * The start of an attribute list.
  463. *
  464. * @param elementName The name of the element that this attribute
  465. * list is associated with.
  466. * @param augs Additional information that may include infoset
  467. * augmentations.
  468. *
  469. * @throws XNIException Thrown by handler to signal an error.
  470. */
  471. public void startAttlist(String elementName, Augmentations augs) throws XNIException {
  472. } // startAttlist(String)
  473. /**
  474. * An attribute declaration.
  475. *
  476. * @param elementName The name of the element that this attribute
  477. * is associated with.
  478. * @param attributeName The name of the attribute.
  479. * @param type The attribute type. This value will be one of
  480. * the following: "CDATA", "ENTITY", "ENTITIES",
  481. * "ENUMERATION", "ID", "IDREF", "IDREFS",
  482. * "NMTOKEN", "NMTOKENS", or "NOTATION".
  483. * @param enumeration If the type has the value "ENUMERATION" or
  484. * "NOTATION", this array holds the allowed attribute
  485. * values; otherwise, this array is null.
  486. * @param defaultType The attribute default type. This value will be
  487. * one of the following: "#FIXED", "#IMPLIED",
  488. * "#REQUIRED", or null.
  489. * @param defaultValue The attribute default value, or null if no
  490. * default value is specified.
  491. * @param nonNormalizedDefaultValue The attribute default value with no normalization
  492. * performed, or null if no default value is specified.
  493. * @param augs Additional information that may include infoset
  494. * augmentations.
  495. *
  496. * @throws XNIException Thrown by handler to signal an error.
  497. */
  498. public void attributeDecl(String elementName, String attributeName,
  499. String type, String[] enumeration,
  500. String defaultType, XMLString defaultValue,
  501. XMLString nonNormalizedDefaultValue, Augmentations augs)
  502. throws XNIException {
  503. } // attributeDecl(String,String,String,String[],String,XMLString, XMLString, Augmentations)
  504. /**
  505. * The end of an attribute list.
  506. *
  507. * @param augs Additional information that may include infoset
  508. * augmentations.
  509. *
  510. * @throws XNIException Thrown by handler to signal an error.
  511. */
  512. public void endAttlist(Augmentations augs) throws XNIException {
  513. } // endAttlist()
  514. /**
  515. * An internal entity declaration.
  516. *
  517. * @param name The name of the entity. Parameter entity names start with
  518. * '%', whereas the name of a general entity is just the
  519. * entity name.
  520. * @param text The value of the entity.
  521. * @param nonNormalizedText The non-normalized value of the entity. This
  522. * value contains the same sequence of characters that was in
  523. * the internal entity declaration, without any entity
  524. * references expanded.
  525. * @param augs Additional information that may include infoset
  526. * augmentations.
  527. *
  528. * @throws XNIException Thrown by handler to signal an error.
  529. */
  530. public void internalEntityDecl(String name, XMLString text,
  531. XMLString nonNormalizedText, Augmentations augs)
  532. throws XNIException {
  533. } // internalEntityDecl(String,XMLString,XMLString)
  534. /**
  535. * An external entity declaration.
  536. *
  537. * @param name The name of the entity. Parameter entity names start
  538. * with '%', whereas the name of a general entity is just
  539. * the entity name.
  540. * @param identifier An object containing all location information
  541. * pertinent to this entity.
  542. * @param augs Additional information that may include infoset
  543. * augmentations.
  544. *
  545. * @throws XNIException Thrown by handler to signal an error.
  546. */
  547. public void externalEntityDecl(String name, XMLResourceIdentifier identifier,
  548. Augmentations augs) throws XNIException {
  549. } // externalEntityDecl(String,XMLResourceIdentifier, Augmentations)
  550. /**
  551. * An unparsed entity declaration.
  552. *
  553. * @param name The name of the entity.
  554. * @param identifier An object containing all location information
  555. * pertinent to this entity.
  556. * @param notation The name of the notation.
  557. * @param augs Additional information that may include infoset
  558. * augmentations.
  559. *
  560. * @throws XNIException Thrown by handler to signal an error.
  561. */
  562. public void unparsedEntityDecl(String name, XMLResourceIdentifier identifier,
  563. String notation, Augmentations augs) throws XNIException {
  564. } // unparsedEntityDecl(String,XMLResourceIdentifier, String, Augmentations)
  565. /**
  566. * A notation declaration
  567. *
  568. * @param name The name of the notation.
  569. * @param identifier An object containing all location information
  570. * pertinent to this notation.
  571. * @param augs Additional information that may include infoset
  572. * augmentations.
  573. *
  574. * @throws XNIException Thrown by handler to signal an error.
  575. */
  576. public void notationDecl(String name, XMLResourceIdentifier identifier,
  577. Augmentations augs)
  578. throws XNIException {
  579. } // notationDecl(String,XMLResourceIdentifier, Augmentations)
  580. /**
  581. * The start of a conditional section.
  582. *
  583. * @param type The type of the conditional section. This value will
  584. * either be CONDITIONAL_INCLUDE or CONDITIONAL_IGNORE.
  585. * @param augs Additional information that may include infoset
  586. * augmentations.
  587. *
  588. * @throws XNIException Thrown by handler to signal an error.
  589. *
  590. * @see #CONDITIONAL_INCLUDE
  591. * @see #CONDITIONAL_IGNORE
  592. */
  593. public void startConditional(short type, Augmentations augs) throws XNIException {
  594. } // startConditional(short)
  595. /**
  596. * The end of a conditional section.
  597. *
  598. * @param augs Additional information that may include infoset
  599. * augmentations.
  600. *
  601. * @throws XNIException Thrown by handler to signal an error.
  602. */
  603. public void endConditional(Augmentations augs) throws XNIException {
  604. } // endConditional()
  605. /**
  606. * The end of the DTD.
  607. *
  608. * @param augs Additional information that may include infoset
  609. * augmentations.
  610. *
  611. * @throws XNIException Thrown by handler to signal an error.
  612. */
  613. public void endDTD(Augmentations augs) throws XNIException {
  614. fInDTD = false;
  615. } // endDTD()
  616. // set the source of this handler
  617. public void setDTDSource(XMLDTDSource source) {
  618. fDTDSource = source;
  619. }
  620. // return the source from which this handler derives its events
  621. public XMLDTDSource getDTDSource() {
  622. return fDTDSource;
  623. }
  624. //
  625. // XMLDTDContentModelHandler methods
  626. //
  627. /**
  628. * The start of a content model. Depending on the type of the content
  629. * model, specific methods may be called between the call to the
  630. * startContentModel method and the call to the endContentModel method.
  631. *
  632. * @param elementName The name of the element.
  633. * @param augs Additional information that may include infoset
  634. * augmentations.
  635. *
  636. * @throws XNIException Thrown by handler to signal an error.
  637. */
  638. public void startContentModel(String elementName, Augmentations augs) throws XNIException {
  639. } // startContentModel(String, Augmentations)
  640. /**
  641. * A content model of ANY.
  642. *
  643. * @param augs Additional information that may include infoset
  644. * augmentations.
  645. *
  646. * @throws XNIException Thrown by handler to signal an error.
  647. *
  648. * @see #empty
  649. * @see #startGroup
  650. */
  651. public void any(Augmentations augs) throws XNIException {
  652. } // any(Augmentations)
  653. /**
  654. * A content model of EMPTY.
  655. *
  656. * @param augs Additional information that may include infoset
  657. * augmentations.
  658. *
  659. * @throws XNIException Thrown by handler to signal an error.
  660. *
  661. * @see #any
  662. * @see #startGroup
  663. */
  664. public void empty(Augmentations augs) throws XNIException {
  665. } // empty(Augmentations)
  666. /**
  667. * A start of either a mixed or children content model. A mixed
  668. * content model will immediately be followed by a call to the
  669. * <code>pcdata()</code> method. A children content model will
  670. * contain additional groups and/or elements.
  671. *
  672. * @param augs Additional information that may include infoset
  673. * augmentations.
  674. *
  675. * @throws XNIException Thrown by handler to signal an error.
  676. *
  677. * @see #any
  678. * @see #empty
  679. */
  680. public void startGroup(Augmentations augs) throws XNIException {
  681. } // stargGroup(Augmentations)
  682. /**
  683. * The appearance of "#PCDATA" within a group signifying a
  684. * mixed content model. This method will be the first called
  685. * following the content model's <code>startGroup()</code>.
  686. *
  687. * @param augs Additional information that may include infoset
  688. * augmentations.
  689. *
  690. * @throws XNIException Thrown by handler to signal an error.
  691. *
  692. * @see #startGroup
  693. */
  694. public void pcdata(Augmentations augs) throws XNIException {
  695. } // pcdata(Augmentations)
  696. /**
  697. * A referenced element in a mixed or children content model.
  698. *
  699. * @param elementName The name of the referenced element.
  700. * @param augs Additional information that may include infoset
  701. * augmentations.
  702. *
  703. * @throws XNIException Thrown by handler to signal an error.
  704. */
  705. public void element(String elementName, Augmentations augs) throws XNIException {
  706. } // element(String, Augmentations)
  707. /**
  708. * The separator between choices or sequences of a mixed or children
  709. * content model.
  710. *
  711. * @param separator The type of children separator.
  712. * @param augs Additional information that may include infoset
  713. * augmentations.
  714. *
  715. * @throws XNIException Thrown by handler to signal an error.
  716. *
  717. * @see #SEPARATOR_CHOICE
  718. * @see #SEPARATOR_SEQUENCE
  719. */
  720. public void separator(short separator, Augmentations augs) throws XNIException {
  721. } // separator(short, Augmentations)
  722. /**
  723. * The occurrence count for a child in a children content model or
  724. * for the mixed content model group.
  725. *
  726. * @param occurrence The occurrence count for the last element
  727. * or group.
  728. * @param augs Additional information that may include infoset
  729. * augmentations.
  730. *
  731. * @throws XNIException Thrown by handler to signal an error.
  732. *
  733. * @see #OCCURS_ZERO_OR_ONE
  734. * @see #OCCURS_ZERO_OR_MORE
  735. * @see #OCCURS_ONE_OR_MORE
  736. */
  737. public void occurrence(short occurrence, Augmentations augs) throws XNIException {
  738. } // occurence(short, Augmentations)
  739. /**
  740. * The end of a group for mixed or children content models.
  741. *
  742. * @param augs Additional information that may include infoset
  743. * augmentations.
  744. *
  745. * @throws XNIException Thrown by handler to signal an error.
  746. */
  747. public void endGroup(Augmentations augs) throws XNIException {
  748. } // endGroup(Augmentations)
  749. /**
  750. * The end of a content model.
  751. *
  752. * @param augs Additional information that may include infoset
  753. * augmentations.
  754. *
  755. * @throws XNIException Thrown by handler to signal an error.
  756. */
  757. public void endContentModel(Augmentations augs) throws XNIException {
  758. } // endContentModel(Augmentations)
  759. // set content model source
  760. public void setDTDContentModelSource(XMLDTDContentModelSource source) {
  761. fDTDContentModelSource = source;
  762. }
  763. // get content model source
  764. public XMLDTDContentModelSource getDTDContentModelSource() {
  765. return fDTDContentModelSource;
  766. }
  767. //
  768. // Protected methods
  769. //
  770. /**
  771. * reset all components before parsing
  772. */
  773. protected void reset() throws XNIException {
  774. super.reset();
  775. fInDTD = false;
  776. } // reset()
  777. } // class AbstractXMLDocumentParser