1. /*
  2. * The Apache Software License, Version 1.1
  3. *
  4. *
  5. * Copyright (c) 2000-2002 The Apache Software Foundation. All rights
  6. * reserved.
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. *
  12. * 1. Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. *
  15. * 2. Redistributions in binary form must reproduce the above copyright
  16. * notice, this list of conditions and the following disclaimer in
  17. * the documentation and/or other materials provided with the
  18. * distribution.
  19. *
  20. * 3. The end-user documentation included with the redistribution,
  21. * if any, must include the following acknowledgment:
  22. * "This product includes software developed by the
  23. * Apache Software Foundation (http://www.apache.org/)."
  24. * Alternately, this acknowledgment may appear in the software itself,
  25. * if and wherever such third-party acknowledgments normally appear.
  26. *
  27. * 4. The names "Xerces" and "Apache Software Foundation" must
  28. * not be used to endorse or promote products derived from this
  29. * software without prior written permission. For written
  30. * permission, please contact apache@apache.org.
  31. *
  32. * 5. Products derived from this software may not be called "Apache",
  33. * nor may "Apache" appear in their name, without prior written
  34. * permission of the Apache Software Foundation.
  35. *
  36. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  37. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  38. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  39. * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  40. * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  41. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  42. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  43. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  44. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  45. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  46. * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  47. * SUCH DAMAGE.
  48. * ====================================================================
  49. *
  50. * This software consists of voluntary contributions made by many
  51. * individuals on behalf of the Apache Software Foundation and was
  52. * originally based on software copyright (c) 1999, International
  53. * Business Machines, Inc., http://www.apache.org. For more
  54. * information on the Apache Software Foundation, please see
  55. * <http://www.apache.org/>.
  56. */
  57. package com.sun.org.apache.xerces.internal.xni;
  58. import com.sun.org.apache.xerces.internal.xni.parser.XMLDocumentSource;
  59. /**
  60. * The document handler interface defines callback methods to report
  61. * information items in XML documents. Parser components interested in
  62. * document information implement this interface and are registered
  63. * as the document handler on the document source.
  64. *
  65. * @author Andy Clark, IBM
  66. *
  67. * @version $Id: XMLDocumentHandler.java,v 1.10 2002/12/16 01:26:21 elena Exp $
  68. */
  69. public interface XMLDocumentHandler {
  70. //
  71. // XMLDocumentHandler methods
  72. //
  73. /**
  74. * The start of the document.
  75. *
  76. * @param locator The document locator, or null if the document
  77. * location cannot be reported during the parsing
  78. * of this document. However, it is <em>strongly</em>
  79. * recommended that a locator be supplied that can
  80. * at least report the system identifier of the
  81. * document.
  82. * @param encoding The auto-detected IANA encoding name of the entity
  83. * stream. This value will be null in those situations
  84. * where the entity encoding is not auto-detected (e.g.
  85. * internal entities or a document entity that is
  86. * parsed from a java.io.Reader).
  87. * @param namespaceContext
  88. * The namespace context in effect at the
  89. * start of this document.
  90. * This object represents the current context.
  91. * Implementors of this class are responsible
  92. * for copying the namespace bindings from the
  93. * the current context (and its parent contexts)
  94. * if that information is important.
  95. *
  96. * @param augs Additional information that may include infoset augmentations
  97. * @exception XNIException
  98. * Thrown by handler to signal an error.
  99. */
  100. public void startDocument(XMLLocator locator, String encoding,
  101. NamespaceContext namespaceContext,
  102. Augmentations augs)
  103. throws XNIException;
  104. /**
  105. * Notifies of the presence of an XMLDecl line in the document. If
  106. * present, this method will be called immediately following the
  107. * startDocument call.
  108. *
  109. * @param version The XML version.
  110. * @param encoding The IANA encoding name of the document, or null if
  111. * not specified.
  112. * @param standalone The standalone value, or null if not specified.
  113. * @param augs Additional information that may include infoset augmentations
  114. *
  115. * @exception XNIException
  116. * Thrown by handler to signal an error.
  117. */
  118. public void xmlDecl(String version, String encoding, String standalone, Augmentations augs)
  119. throws XNIException;
  120. /**
  121. * Notifies of the presence of the DOCTYPE line in the document.
  122. *
  123. * @param rootElement
  124. * The name of the root element.
  125. * @param publicId The public identifier if an external DTD or null
  126. * if the external DTD is specified using SYSTEM.
  127. * @param systemId The system identifier if an external DTD, null
  128. * otherwise.
  129. * @param augs Additional information that may include infoset augmentations
  130. *
  131. * @exception XNIException
  132. * Thrown by handler to signal an error.
  133. */
  134. public void doctypeDecl(String rootElement, String publicId, String systemId, Augmentations augs)
  135. throws XNIException;
  136. /**
  137. * A comment.
  138. *
  139. * @param text The text in the comment.
  140. * @param augs Additional information that may include infoset augmentations
  141. *
  142. * @exception XNIException
  143. * Thrown by application to signal an error.
  144. */
  145. public void comment(XMLString text, Augmentations augs) throws XNIException;
  146. /**
  147. * A processing instruction. Processing instructions consist of a
  148. * target name and, optionally, text data. The data is only meaningful
  149. * to the application.
  150. * <p>
  151. * Typically, a processing instruction's data will contain a series
  152. * of pseudo-attributes. These pseudo-attributes follow the form of
  153. * element attributes but are <strong>not</strong> parsed or presented
  154. * to the application as anything other than text. The application is
  155. * responsible for parsing the data.
  156. *
  157. * @param target The target.
  158. * @param data The data or null if none specified.
  159. * @param augs Additional information that may include infoset augmentations
  160. *
  161. * @exception XNIException
  162. * Thrown by handler to signal an error.
  163. */
  164. public void processingInstruction(String target, XMLString data, Augmentations augs)
  165. throws XNIException;
  166. /**
  167. * The start of an element.
  168. *
  169. * @param element The name of the element.
  170. * @param attributes The element attributes.
  171. * @param augs Additional information that may include infoset augmentations
  172. *
  173. * @exception XNIException
  174. * Thrown by handler to signal an error.
  175. */
  176. public void startElement(QName element, XMLAttributes attributes, Augmentations augs)
  177. throws XNIException;
  178. /**
  179. * An empty element.
  180. *
  181. * @param element The name of the element.
  182. * @param attributes The element attributes.
  183. * @param augs Additional information that may include infoset augmentations
  184. *
  185. * @exception XNIException
  186. * Thrown by handler to signal an error.
  187. */
  188. public void emptyElement(QName element, XMLAttributes attributes, Augmentations augs)
  189. throws XNIException;
  190. /**
  191. * This method notifies the start of a general entity.
  192. * <p>
  193. * <strong>Note:</strong> This method is not called for entity references
  194. * appearing as part of attribute values.
  195. *
  196. * @param name The name of the general entity.
  197. * @param identifier The resource identifier.
  198. * @param encoding The auto-detected IANA encoding name of the entity
  199. * stream. This value will be null in those situations
  200. * where the entity encoding is not auto-detected (e.g.
  201. * internal entities or a document entity that is
  202. * parsed from a java.io.Reader).
  203. * @param augs Additional information that may include infoset augmentations
  204. *
  205. * @exception XNIException Thrown by handler to signal an error.
  206. */
  207. public void startGeneralEntity(String name,
  208. XMLResourceIdentifier identifier,
  209. String encoding,
  210. Augmentations augs) throws XNIException;
  211. /**
  212. * Notifies of the presence of a TextDecl line in an entity. If present,
  213. * this method will be called immediately following the startEntity call.
  214. * <p>
  215. * <strong>Note:</strong> This method will never be called for the
  216. * document entity; it is only called for external general entities
  217. * referenced in document content.
  218. * <p>
  219. * <strong>Note:</strong> This method is not called for entity references
  220. * appearing as part of attribute values.
  221. *
  222. * @param version The XML version, or null if not specified.
  223. * @param encoding The IANA encoding name of the entity.
  224. * @param augs Additional information that may include infoset augmentations
  225. *
  226. * @exception XNIException
  227. * Thrown by handler to signal an error.
  228. */
  229. public void textDecl(String version, String encoding, Augmentations augs) throws XNIException;
  230. /**
  231. * This method notifies the end of a general entity.
  232. * <p>
  233. * <strong>Note:</strong> This method is not called for entity references
  234. * appearing as part of attribute values.
  235. *
  236. * @param name The name of the entity.
  237. * @param augs Additional information that may include infoset augmentations
  238. *
  239. * @exception XNIException
  240. * Thrown by handler to signal an error.
  241. */
  242. public void endGeneralEntity(String name, Augmentations augs) throws XNIException;
  243. /**
  244. * Character content.
  245. *
  246. * @param text The content.
  247. * @param augs Additional information that may include infoset augmentations
  248. *
  249. * @exception XNIException
  250. * Thrown by handler to signal an error.
  251. */
  252. public void characters(XMLString text, Augmentations augs) throws XNIException;
  253. /**
  254. * Ignorable whitespace. For this method to be called, the document
  255. * source must have some way of determining that the text containing
  256. * only whitespace characters should be considered ignorable. For
  257. * example, the validator can determine if a length of whitespace
  258. * characters in the document are ignorable based on the element
  259. * content model.
  260. *
  261. * @param text The ignorable whitespace.
  262. * @param augs Additional information that may include infoset augmentations
  263. *
  264. * @exception XNIException
  265. * Thrown by handler to signal an error.
  266. */
  267. public void ignorableWhitespace(XMLString text, Augmentations augs) throws XNIException;
  268. /**
  269. * The end of an element.
  270. *
  271. * @param element The name of the element.
  272. * @param augs Additional information that may include infoset augmentations
  273. *
  274. * @exception XNIException
  275. * Thrown by handler to signal an error.
  276. */
  277. public void endElement(QName element, Augmentations augs) throws XNIException;
  278. /**
  279. * The start of a CDATA section.
  280. *
  281. * @param augs Additional information that may include infoset augmentations
  282. *
  283. * @exception XNIException
  284. * Thrown by handler to signal an error.
  285. */
  286. public void startCDATA(Augmentations augs) throws XNIException;
  287. /**
  288. * The end of a CDATA section.
  289. *
  290. * @param augs Additional information that may include infoset augmentations
  291. *
  292. * @exception XNIException
  293. * Thrown by handler to signal an error.
  294. */
  295. public void endCDATA(Augmentations augs) throws XNIException;
  296. /**
  297. * The end of the document.
  298. *
  299. * @param augs Additional information that may include infoset augmentations
  300. *
  301. * @exception XNIException
  302. * Thrown by handler to signal an error.
  303. */
  304. public void endDocument(Augmentations augs) throws XNIException;
  305. /** Sets the document source. */
  306. public void setDocumentSource(XMLDocumentSource source);
  307. /** Returns the document source. */
  308. public XMLDocumentSource getDocumentSource();
  309. } // interface XMLDocumentHandler