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