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.XMLDTDSource;
  59. /**
  60. * The DTD handler interface defines callback methods to report
  61. * information items in the DTD of an XML document. Parser components
  62. * interested in DTD information implement this interface and are
  63. * registered as the DTD handler on the DTD source.
  64. *
  65. * @see XMLDTDContentModelHandler
  66. *
  67. * @author Andy Clark, IBM
  68. *
  69. * @version $Id: XMLDTDHandler.java,v 1.11 2002/12/07 00:07:51 neilg Exp $
  70. */
  71. public interface XMLDTDHandler {
  72. //
  73. // Constants
  74. //
  75. /**
  76. * Conditional section: INCLUDE.
  77. *
  78. * @see #CONDITIONAL_IGNORE
  79. */
  80. public static final short CONDITIONAL_INCLUDE = 0;
  81. /**
  82. * Conditional section: IGNORE.
  83. *
  84. * @see #CONDITIONAL_INCLUDE
  85. */
  86. public static final short CONDITIONAL_IGNORE = 1;
  87. //
  88. // XMLDTDHandler methods
  89. //
  90. /**
  91. * The start of the DTD.
  92. *
  93. * @param locator The document locator, or null if the document
  94. * location cannot be reported during the parsing of
  95. * the document DTD. However, it is <em>strongly</em>
  96. * recommended that a locator be supplied that can
  97. * at least report the base system identifier of the
  98. * DTD.
  99. * @param augmentations Additional information that may include infoset
  100. * augmentations.
  101. *
  102. * @throws XNIException Thrown by handler to signal an error.
  103. */
  104. public void startDTD(XMLLocator locator, Augmentations augmentations)
  105. throws XNIException;
  106. /**
  107. * This method notifies of the start of a parameter entity. The parameter
  108. * entity name start with a '%' character.
  109. *
  110. * @param name The name of the parameter entity.
  111. * @param identifier The resource identifier.
  112. * @param encoding The auto-detected IANA encoding name of the entity
  113. * stream. This value will be null in those situations
  114. * where the entity encoding is not auto-detected (e.g.
  115. * internal parameter entities).
  116. * @param augmentations Additional information that may include infoset
  117. * augmentations.
  118. *
  119. * @throws XNIException Thrown by handler to signal an error.
  120. */
  121. public void startParameterEntity(String name,
  122. XMLResourceIdentifier identifier,
  123. String encoding,
  124. Augmentations augmentations) throws XNIException;
  125. /**
  126. * Notifies of the presence of a TextDecl line in an entity. If present,
  127. * this method will be called immediately following the startEntity call.
  128. * <p>
  129. * <strong>Note:</strong> This method is only called for external
  130. * parameter entities referenced in the DTD.
  131. *
  132. * @param version The XML version, or null if not specified.
  133. * @param encoding The IANA encoding name of the entity.
  134. * @param augmentations Additional information that may include infoset
  135. * augmentations.
  136. *
  137. * @throws XNIException Thrown by handler to signal an error.
  138. */
  139. public void textDecl(String version, String encoding,
  140. Augmentations augmentations) throws XNIException;
  141. /**
  142. * This method notifies the end of a parameter entity. Parameter entity
  143. * names begin with a '%' character.
  144. *
  145. * @param name The name of the parameter entity.
  146. * @param augmentations Additional information that may include infoset
  147. * augmentations.
  148. *
  149. * @throws XNIException Thrown by handler to signal an error.
  150. */
  151. public void endParameterEntity(String name, Augmentations augmentations)
  152. throws XNIException;
  153. /**
  154. * The start of the DTD external subset.
  155. *
  156. * @param identifier The resource identifier.
  157. * @param augmentations
  158. * Additional information that may include infoset
  159. * augmentations.
  160. * @exception XNIException
  161. * Thrown by handler to signal an error.
  162. */
  163. public void startExternalSubset(XMLResourceIdentifier identifier,
  164. Augmentations augmentations)
  165. throws XNIException;
  166. /**
  167. * The end of the DTD external subset.
  168. *
  169. * @param augmentations Additional information that may include infoset
  170. * augmentations.
  171. *
  172. * @throws XNIException Thrown by handler to signal an error.
  173. */
  174. public void endExternalSubset(Augmentations augmentations)
  175. throws XNIException;
  176. /**
  177. * A comment.
  178. *
  179. * @param text The text in the comment.
  180. * @param augmentations Additional information that may include infoset
  181. * augmentations.
  182. *
  183. * @throws XNIException Thrown by application to signal an error.
  184. */
  185. public void comment(XMLString text, Augmentations augmentations)
  186. throws XNIException;
  187. /**
  188. * A processing instruction. Processing instructions consist of a
  189. * target name and, optionally, text data. The data is only meaningful
  190. * to the application.
  191. * <p>
  192. * Typically, a processing instruction's data will contain a series
  193. * of pseudo-attributes. These pseudo-attributes follow the form of
  194. * element attributes but are <strong>not</strong> parsed or presented
  195. * to the application as anything other than text. The application is
  196. * responsible for parsing the data.
  197. *
  198. * @param target The target.
  199. * @param data The data or null if none specified.
  200. * @param augmentations Additional information that may include infoset
  201. * augmentations.
  202. *
  203. * @throws XNIException Thrown by handler to signal an error.
  204. */
  205. public void processingInstruction(String target, XMLString data,
  206. Augmentations augmentations)
  207. throws XNIException;
  208. /**
  209. * An element declaration.
  210. *
  211. * @param name The name of the element.
  212. * @param contentModel The element content model.
  213. * @param augmentations Additional information that may include infoset
  214. * augmentations.
  215. *
  216. * @throws XNIException Thrown by handler to signal an error.
  217. */
  218. public void elementDecl(String name, String contentModel,
  219. Augmentations augmentations)
  220. throws XNIException;
  221. /**
  222. * The start of an attribute list.
  223. *
  224. * @param elementName The name of the element that this attribute
  225. * list is associated with.
  226. * @param augmentations Additional information that may include infoset
  227. * augmentations.
  228. *
  229. * @throws XNIException Thrown by handler to signal an error.
  230. */
  231. public void startAttlist(String elementName,
  232. Augmentations augmentations) throws XNIException;
  233. /**
  234. * An attribute declaration.
  235. *
  236. * @param elementName The name of the element that this attribute
  237. * is associated with.
  238. * @param attributeName The name of the attribute.
  239. * @param type The attribute type. This value will be one of
  240. * the following: "CDATA", "ENTITY", "ENTITIES",
  241. * "ENUMERATION", "ID", "IDREF", "IDREFS",
  242. * "NMTOKEN", "NMTOKENS", or "NOTATION".
  243. * @param enumeration If the type has the value "ENUMERATION" or
  244. * "NOTATION", this array holds the allowed attribute
  245. * values; otherwise, this array is null.
  246. * @param defaultType The attribute default type. This value will be
  247. * one of the following: "#FIXED", "#IMPLIED",
  248. * "#REQUIRED", or null.
  249. * @param defaultValue The attribute default value, or null if no
  250. * default value is specified.
  251. * @param nonNormalizedDefaultValue The attribute default value with no normalization
  252. * performed, or null if no default value is specified.
  253. * @param augmentations Additional information that may include infoset
  254. * augmentations.
  255. *
  256. * @throws XNIException Thrown by handler to signal an error.
  257. */
  258. public void attributeDecl(String elementName, String attributeName,
  259. String type, String[] enumeration,
  260. String defaultType, XMLString defaultValue,
  261. XMLString nonNormalizedDefaultValue, Augmentations augmentations)
  262. throws XNIException;
  263. /**
  264. * The end of an attribute list.
  265. *
  266. * @param augmentations Additional information that may include infoset
  267. * augmentations.
  268. *
  269. * @throws XNIException Thrown by handler to signal an error.
  270. */
  271. public void endAttlist(Augmentations augmentations) throws XNIException;
  272. /**
  273. * An internal entity declaration.
  274. *
  275. * @param name The name of the entity. Parameter entity names start with
  276. * '%', whereas the name of a general entity is just the
  277. * entity name.
  278. * @param text The value of the entity.
  279. * @param nonNormalizedText The non-normalized value of the entity. This
  280. * value contains the same sequence of characters that was in
  281. * the internal entity declaration, without any entity
  282. * references expanded.
  283. * @param augmentations Additional information that may include infoset
  284. * augmentations.
  285. *
  286. * @throws XNIException Thrown by handler to signal an error.
  287. */
  288. public void internalEntityDecl(String name, XMLString text,
  289. XMLString nonNormalizedText,
  290. Augmentations augmentations)
  291. throws XNIException;
  292. /**
  293. * An external entity declaration.
  294. *
  295. * @param name The name of the entity. Parameter entity names start
  296. * with '%', whereas the name of a general entity is just
  297. * the entity name.
  298. * @param identifier An object containing all location information
  299. * pertinent to this external entity.
  300. * @param augmentations Additional information that may include infoset
  301. * augmentations.
  302. *
  303. * @throws XNIException Thrown by handler to signal an error.
  304. */
  305. public void externalEntityDecl(String name,
  306. XMLResourceIdentifier identifier,
  307. Augmentations augmentations)
  308. throws XNIException;
  309. /**
  310. * An unparsed entity declaration.
  311. *
  312. * @param name The name of the entity.
  313. * @param identifier An object containing all location information
  314. * pertinent to this unparsed entity declaration.
  315. * @param notation The name of the notation.
  316. * @param augmentations Additional information that may include infoset
  317. * augmentations.
  318. *
  319. * @throws XNIException Thrown by handler to signal an error.
  320. */
  321. public void unparsedEntityDecl(String name,
  322. XMLResourceIdentifier identifier,
  323. String notation, Augmentations augmentations)
  324. throws XNIException;
  325. /**
  326. * A notation declaration
  327. *
  328. * @param name The name of the notation.
  329. * @param identifier An object containing all location information
  330. * pertinent to this notation.
  331. * @param augmentations Additional information that may include infoset
  332. * augmentations.
  333. *
  334. * @throws XNIException Thrown by handler to signal an error.
  335. */
  336. public void notationDecl(String name, XMLResourceIdentifier identifier,
  337. Augmentations augmentations) throws XNIException;
  338. /**
  339. * The start of a conditional section.
  340. *
  341. * @param type The type of the conditional section. This value will
  342. * either be CONDITIONAL_INCLUDE or CONDITIONAL_IGNORE.
  343. * @param augmentations Additional information that may include infoset
  344. * augmentations.
  345. *
  346. * @throws XNIException Thrown by handler to signal an error.
  347. *
  348. * @see #CONDITIONAL_INCLUDE
  349. * @see #CONDITIONAL_IGNORE
  350. */
  351. public void startConditional(short type, Augmentations augmentations)
  352. throws XNIException;
  353. /**
  354. * Characters within an IGNORE conditional section.
  355. *
  356. * @param text The ignored text.
  357. * @param augmentations Additional information that may include infoset
  358. * augmentations.
  359. *
  360. * @throws XNIException Thrown by handler to signal an error.
  361. */
  362. public void ignoredCharacters(XMLString text, Augmentations augmentations)
  363. throws XNIException;
  364. /**
  365. * The end of a conditional section.
  366. *
  367. * @param augmentations Additional information that may include infoset
  368. * augmentations.
  369. *
  370. * @throws XNIException Thrown by handler to signal an error.
  371. */
  372. public void endConditional(Augmentations augmentations) throws XNIException;
  373. /**
  374. * The end of the DTD.
  375. *
  376. * @param augmentations Additional information that may include infoset
  377. * augmentations.
  378. *
  379. * @throws XNIException Thrown by handler to signal an error.
  380. */
  381. public void endDTD(Augmentations augmentations) throws XNIException;
  382. // set the source of this handler
  383. public void setDTDSource(XMLDTDSource source);
  384. // return the source from which this handler derives its events
  385. public XMLDTDSource getDTDSource();
  386. } // interface XMLDTDHandler