DeclHandler.h 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. //
  2. // DeclHandler.h
  3. //
  4. // Library: XML
  5. // Package: SAX
  6. // Module: SAX
  7. //
  8. // SAX2-ext DeclHandler Interface.
  9. //
  10. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
  11. // and Contributors.
  12. //
  13. // SPDX-License-Identifier: BSL-1.0
  14. //
  15. #ifndef SAX_DeclHandler_INCLUDED
  16. #define SAX_DeclHandler_INCLUDED
  17. #include "Poco/XML/XML.h"
  18. #include "Poco/XML/XMLString.h"
  19. namespace Poco {
  20. namespace XML {
  21. class XML_API DeclHandler
  22. /// This is an optional extension handler for SAX2 to provide information
  23. /// about DTD declarations in an XML document. XML
  24. /// readers are not required to support this handler, and this handler is
  25. /// not included in the core SAX2 distribution.
  26. ///
  27. /// Note that data-related DTD declarations (unparsed entities and notations)
  28. /// are already reported through the DTDHandler interface.
  29. /// If you are using the declaration handler together with a lexical handler,
  30. /// all of the events will occur between the startDTD and the endDTD events.
  31. /// To set the DeclHandler for an XML reader, use the setProperty method
  32. /// with the propertyId "http://xml.org/sax/properties/declaration-handler".
  33. /// If the reader does not support declaration events, it will throw a
  34. /// SAXNotRecognizedException or a SAXNotSupportedException when you attempt to
  35. /// register the handler.
  36. {
  37. public:
  38. virtual void attributeDecl(const XMLString& eName, const XMLString& aName, const XMLString* valueDefault, const XMLString* value) = 0;
  39. /// Report an attribute type declaration.
  40. ///
  41. /// Only the effective (first) declaration for an attribute will be reported.
  42. /// The type will be one of the strings "CDATA", "ID", "IDREF", "IDREFS",
  43. /// "NMTOKEN", "NMTOKENS", "ENTITY", "ENTITIES", a parenthesized token group
  44. /// with the separator "|" and all whitespace removed, or the word "NOTATION"
  45. /// followed by a space followed by a parenthesized token group with all whitespace
  46. /// removed.
  47. ///
  48. /// The value will be the value as reported to applications, appropriately normalized
  49. /// and with entity and character references expanded.
  50. virtual void elementDecl(const XMLString& name, const XMLString& model) = 0;
  51. /// Report an element type declaration.
  52. ///
  53. /// The content model will consist of the string "EMPTY", the string "ANY", or a
  54. /// parenthesised group, optionally followed by an occurrence indicator. The model
  55. /// will be normalized so that all parameter entities are fully resolved and all
  56. /// whitespace is removed,and will include the enclosing parentheses. Other
  57. /// normalization (such as removing redundant parentheses or simplifying occurrence
  58. /// indicators) is at the discretion of the parser.
  59. virtual void externalEntityDecl(const XMLString& name, const XMLString* publicId, const XMLString& systemId) = 0;
  60. /// Report an external entity declaration.
  61. ///
  62. /// Only the effective (first) declaration for each entity will be reported.
  63. ///
  64. /// If the system identifier is a URL, the parser must resolve it fully before
  65. /// passing it to the application.
  66. virtual void internalEntityDecl(const XMLString& name, const XMLString& value) = 0;
  67. /// Report an internal entity declaration.
  68. ///
  69. /// Only the effective (first) declaration for each entity will be reported. All
  70. /// parameter entities in the value will be expanded, but general entities will not.
  71. protected:
  72. virtual ~DeclHandler();
  73. };
  74. } } // namespace Poco::XML
  75. #endif // SAX_DeclHandler_INCLUDED