1. // DeclHandler.java - Optional handler for DTD declaration events.
  2. // http://www.saxproject.org
  3. // Public Domain: no warranty.
  4. // $Id: DeclHandler.java,v 1.1.24.1 2004/05/01 08:34:43 jsuttor Exp $
  5. package org.xml.sax.ext;
  6. import org.xml.sax.SAXException;
  7. /**
  8. * SAX2 extension handler for DTD declaration events.
  9. *
  10. * <blockquote>
  11. * <em>This module, both source code and documentation, is in the
  12. * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
  13. * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
  14. * for further information.
  15. * </blockquote>
  16. *
  17. * <p>This is an optional extension handler for SAX2 to provide more
  18. * complete information about DTD declarations in an XML document.
  19. * XML readers are not required to recognize this handler, and it
  20. * is not part of core-only SAX2 distributions.</p>
  21. *
  22. * <p>Note that data-related DTD declarations (unparsed entities and
  23. * notations) are already reported through the {@link
  24. * org.xml.sax.DTDHandler DTDHandler} interface.</p>
  25. *
  26. * <p>If you are using the declaration handler together with a lexical
  27. * handler, all of the events will occur between the
  28. * {@link org.xml.sax.ext.LexicalHandler#startDTD startDTD} and the
  29. * {@link org.xml.sax.ext.LexicalHandler#endDTD endDTD} events.</p>
  30. *
  31. * <p>To set the DeclHandler for an XML reader, use the
  32. * {@link org.xml.sax.XMLReader#setProperty setProperty} method
  33. * with the property name
  34. * <code>http://xml.org/sax/properties/declaration-handler</code>
  35. * and an object implementing this interface (or null) as the value.
  36. * If the reader does not report declaration events, it will throw a
  37. * {@link org.xml.sax.SAXNotRecognizedException SAXNotRecognizedException}
  38. * when you attempt to register the handler.</p>
  39. *
  40. * @since SAX 2.0 (extensions 1.0)
  41. * @author David Megginson
  42. * @version 2.0.1 (sax2r2)
  43. */
  44. public interface DeclHandler
  45. {
  46. /**
  47. * Report an element type declaration.
  48. *
  49. * <p>The content model will consist of the string "EMPTY", the
  50. * string "ANY", or a parenthesised group, optionally followed
  51. * by an occurrence indicator. The model will be normalized so
  52. * that all parameter entities are fully resolved and all whitespace
  53. * is removed,and will include the enclosing parentheses. Other
  54. * normalization (such as removing redundant parentheses or
  55. * simplifying occurrence indicators) is at the discretion of the
  56. * parser.</p>
  57. *
  58. * @param name The element type name.
  59. * @param model The content model as a normalized string.
  60. * @exception SAXException The application may raise an exception.
  61. */
  62. public abstract void elementDecl (String name, String model)
  63. throws SAXException;
  64. /**
  65. * Report an attribute type declaration.
  66. *
  67. * <p>Only the effective (first) declaration for an attribute will
  68. * be reported. The type will be one of the strings "CDATA",
  69. * "ID", "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", "ENTITY",
  70. * "ENTITIES", a parenthesized token group with
  71. * the separator "|" and all whitespace removed, or the word
  72. * "NOTATION" followed by a space followed by a parenthesized
  73. * token group with all whitespace removed.</p>
  74. *
  75. * <p>The value will be the value as reported to applications,
  76. * appropriately normalized and with entity and character
  77. * references expanded. </p>
  78. *
  79. * @param eName The name of the associated element.
  80. * @param aName The name of the attribute.
  81. * @param type A string representing the attribute type.
  82. * @param mode A string representing the attribute defaulting mode
  83. * ("#IMPLIED", "#REQUIRED", or "#FIXED") or null if
  84. * none of these applies.
  85. * @param value A string representing the attribute's default value,
  86. * or null if there is none.
  87. * @exception SAXException The application may raise an exception.
  88. */
  89. public abstract void attributeDecl (String eName,
  90. String aName,
  91. String type,
  92. String mode,
  93. String value)
  94. throws SAXException;
  95. /**
  96. * Report an internal entity declaration.
  97. *
  98. * <p>Only the effective (first) declaration for each entity
  99. * will be reported. All parameter entities in the value
  100. * will be expanded, but general entities will not.</p>
  101. *
  102. * @param name The name of the entity. If it is a parameter
  103. * entity, the name will begin with '%'.
  104. * @param value The replacement text of the entity.
  105. * @exception SAXException The application may raise an exception.
  106. * @see #externalEntityDecl
  107. * @see org.xml.sax.DTDHandler#unparsedEntityDecl
  108. */
  109. public abstract void internalEntityDecl (String name, String value)
  110. throws SAXException;
  111. /**
  112. * Report a parsed external entity declaration.
  113. *
  114. * <p>Only the effective (first) declaration for each entity
  115. * will be reported.</p>
  116. *
  117. * <p>If the system identifier is a URL, the parser must resolve it
  118. * fully before passing it to the application.</p>
  119. *
  120. * @param name The name of the entity. If it is a parameter
  121. * entity, the name will begin with '%'.
  122. * @param publicId The entity's public identifier, or null if none
  123. * was given.
  124. * @param systemId The entity's system identifier.
  125. * @exception SAXException The application may raise an exception.
  126. * @see #internalEntityDecl
  127. * @see org.xml.sax.DTDHandler#unparsedEntityDecl
  128. */
  129. public abstract void externalEntityDecl (String name, String publicId,
  130. String systemId)
  131. throws SAXException;
  132. }
  133. // end of DeclHandler.java