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