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.XMLDTDContentModelSource;
  59. /**
  60. * The DTD content model handler interface defines callback methods
  61. * to report information items in DTD content models of an element
  62. * declaration. Parser components interested in DTD content model
  63. * information implement this interface and are registered as the DTD
  64. * content model handler on the DTD content model source.
  65. *
  66. * @see XMLDTDHandler
  67. *
  68. * @author Andy Clark, IBM
  69. *
  70. * @version $Id: XMLDTDContentModelHandler.java,v 1.5 2002/12/07 00:07:51 neilg Exp $
  71. */
  72. public interface XMLDTDContentModelHandler {
  73. //
  74. // Constants
  75. //
  76. // separators
  77. /**
  78. * A choice separator for children and mixed content models. This
  79. * separator is used to specify that the allowed child is one of a
  80. * collection.
  81. * <p>
  82. * For example:
  83. * <pre>
  84. * <!ELEMENT elem (foo|bar)>
  85. * <!ELEMENT elem (foo|bar+)>
  86. * <!ELEMENT elem (foo|bar|baz)>
  87. * <!ELEMENT elem (#PCDATA|foo|bar)*>
  88. * </pre>
  89. *
  90. * @see #SEPARATOR_SEQUENCE
  91. */
  92. public static final short SEPARATOR_CHOICE = 0;
  93. /**
  94. * A sequence separator for children content models. This separator
  95. * is used to specify that the allowed children must follow in the
  96. * specified sequence.
  97. * <p>
  98. * <pre>
  99. * <!ELEMENT elem (foo,bar)>
  100. * <!ELEMENT elem (foo,bar*)>
  101. * <!ELEMENT elem (foo,bar,baz)>
  102. * </pre>
  103. *
  104. * @see #SEPARATOR_CHOICE
  105. */
  106. public static final short SEPARATOR_SEQUENCE = 1;
  107. // occurrence counts
  108. /**
  109. * This occurrence count limits the element, choice, or sequence in a
  110. * children content model to zero or one. In other words, the child
  111. * is optional.
  112. * <p>
  113. * For example:
  114. * <pre>
  115. * <!ELEMENT elem (foo?)>
  116. * </pre>
  117. *
  118. * @see #OCCURS_ZERO_OR_MORE
  119. * @see #OCCURS_ONE_OR_MORE
  120. */
  121. public static final short OCCURS_ZERO_OR_ONE = 2;
  122. /**
  123. * This occurrence count limits the element, choice, or sequence in a
  124. * children content model to zero or more. In other words, the child
  125. * may appear an arbitrary number of times, or not at all. This
  126. * occurrence count is also used for mixed content models.
  127. * <p>
  128. * For example:
  129. * <pre>
  130. * <!ELEMENT elem (foo*)>
  131. * <!ELEMENT elem (#PCDATA|foo|bar)*>
  132. * </pre>
  133. *
  134. * @see #OCCURS_ZERO_OR_ONE
  135. * @see #OCCURS_ONE_OR_MORE
  136. */
  137. public static final short OCCURS_ZERO_OR_MORE = 3;
  138. /**
  139. * This occurrence count limits the element, choice, or sequence in a
  140. * children content model to one or more. In other words, the child
  141. * may appear an arbitrary number of times, but must appear at least
  142. * once.
  143. * <p>
  144. * For example:
  145. * <pre>
  146. * <!ELEMENT elem (foo+)>
  147. * </pre>
  148. *
  149. * @see #OCCURS_ZERO_OR_ONE
  150. * @see #OCCURS_ZERO_OR_MORE
  151. */
  152. public static final short OCCURS_ONE_OR_MORE = 4;
  153. //
  154. // XMLDTDContentModelHandler methods
  155. //
  156. /**
  157. * The start of a content model. Depending on the type of the content
  158. * model, specific methods may be called between the call to the
  159. * startContentModel method and the call to the endContentModel method.
  160. *
  161. * @param elementName The name of the element.
  162. * @param augmentations Additional information that may include infoset
  163. * augmentations.
  164. *
  165. * @throws XNIException Thrown by handler to signal an error.
  166. */
  167. public void startContentModel(String elementName, Augmentations augmentations)
  168. throws XNIException;
  169. /**
  170. * A content model of ANY.
  171. *
  172. * @param augmentations Additional information that may include infoset
  173. * augmentations.
  174. *
  175. * @throws XNIException Thrown by handler to signal an error.
  176. *
  177. * @see #empty
  178. * @see #startGroup
  179. */
  180. public void any(Augmentations augmentations) throws XNIException;
  181. /**
  182. * A content model of EMPTY.
  183. *
  184. * @throws XNIException Thrown by handler to signal an error.
  185. *
  186. * @param augmentations Additional information that may include infoset
  187. * augmentations.
  188. *
  189. * @see #any
  190. * @see #startGroup
  191. */
  192. public void empty(Augmentations augmentations) throws XNIException;
  193. /**
  194. * A start of either a mixed or children content model. A mixed
  195. * content model will immediately be followed by a call to the
  196. * <code>pcdata()</code> method. A children content model will
  197. * contain additional groups and/or elements.
  198. *
  199. * @param augmentations Additional information that may include infoset
  200. * augmentations.
  201. *
  202. * @throws XNIException Thrown by handler to signal an error.
  203. *
  204. * @see #any
  205. * @see #empty
  206. */
  207. public void startGroup(Augmentations augmentations) throws XNIException;
  208. /**
  209. * The appearance of "#PCDATA" within a group signifying a
  210. * mixed content model. This method will be the first called
  211. * following the content model's <code>startGroup()</code>.
  212. *
  213. * @param augmentations Additional information that may include infoset
  214. * augmentations.
  215. *
  216. * @throws XNIException Thrown by handler to signal an error.
  217. *
  218. * @see #startGroup
  219. */
  220. public void pcdata(Augmentations augmentations) throws XNIException;
  221. /**
  222. * A referenced element in a mixed or children content model.
  223. *
  224. * @param elementName The name of the referenced element.
  225. * @param augmentations Additional information that may include infoset
  226. * augmentations.
  227. *
  228. * @throws XNIException Thrown by handler to signal an error.
  229. */
  230. public void element(String elementName, Augmentations augmentations)
  231. throws XNIException;
  232. /**
  233. * The separator between choices or sequences of a mixed or children
  234. * content model.
  235. *
  236. * @param separator The type of children separator.
  237. * @param augmentations Additional information that may include infoset
  238. * augmentations.
  239. *
  240. * @throws XNIException Thrown by handler to signal an error.
  241. *
  242. * @see #SEPARATOR_CHOICE
  243. * @see #SEPARATOR_SEQUENCE
  244. */
  245. public void separator(short separator, Augmentations augmentations)
  246. throws XNIException;
  247. /**
  248. * The occurrence count for a child in a children content model or
  249. * for the mixed content model group.
  250. *
  251. * @param occurrence The occurrence count for the last element
  252. * or group.
  253. * @param augmentations Additional information that may include infoset
  254. * augmentations.
  255. *
  256. * @throws XNIException Thrown by handler to signal an error.
  257. *
  258. * @see #OCCURS_ZERO_OR_ONE
  259. * @see #OCCURS_ZERO_OR_MORE
  260. * @see #OCCURS_ONE_OR_MORE
  261. */
  262. public void occurrence(short occurrence, Augmentations augmentations)
  263. throws XNIException;
  264. /**
  265. * The end of a group for mixed or children content models.
  266. *
  267. * @param augmentations Additional information that may include infoset
  268. * augmentations.
  269. *
  270. * @throws XNIException Thrown by handler to signal an error.
  271. */
  272. public void endGroup(Augmentations augmentations) throws XNIException;
  273. /**
  274. * The end of a content model.
  275. *
  276. * @param augmentations Additional information that may include infoset
  277. * augmentations.
  278. *
  279. * @throws XNIException Thrown by handler to signal an error.
  280. */
  281. public void endContentModel(Augmentations augmentations) throws XNIException;
  282. // set content model source
  283. public void setDTDContentModelSource(XMLDTDContentModelSource source);
  284. // get content model source
  285. public XMLDTDContentModelSource getDTDContentModelSource();
  286. } // interface XMLDTDContentModelHandler