1 | // |
---|
2 | // LexicalHandler.h |
---|
3 | // |
---|
4 | // $Id: //poco/1.3/XML/include/Poco/SAX/LexicalHandler.h#1 $ |
---|
5 | // |
---|
6 | // Library: XML |
---|
7 | // Package: SAX |
---|
8 | // Module: SAX |
---|
9 | // |
---|
10 | // SAX2-ext LexicalHandler Interface. |
---|
11 | // |
---|
12 | // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. |
---|
13 | // and Contributors. |
---|
14 | // |
---|
15 | // Permission is hereby granted, free of charge, to any person or organization |
---|
16 | // obtaining a copy of the software and accompanying documentation covered by |
---|
17 | // this license (the "Software") to use, reproduce, display, distribute, |
---|
18 | // execute, and transmit the Software, and to prepare derivative works of the |
---|
19 | // Software, and to permit third-parties to whom the Software is furnished to |
---|
20 | // do so, all subject to the following: |
---|
21 | // |
---|
22 | // The copyright notices in the Software and this entire statement, including |
---|
23 | // the above license grant, this restriction and the following disclaimer, |
---|
24 | // must be included in all copies of the Software, in whole or in part, and |
---|
25 | // all derivative works of the Software, unless such copies or derivative |
---|
26 | // works are solely in the form of machine-executable object code generated by |
---|
27 | // a source language processor. |
---|
28 | // |
---|
29 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
---|
30 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
---|
31 | // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT |
---|
32 | // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE |
---|
33 | // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, |
---|
34 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
---|
35 | // DEALINGS IN THE SOFTWARE. |
---|
36 | // |
---|
37 | |
---|
38 | |
---|
39 | #ifndef SAX_LexicalHandler_INCLUDED |
---|
40 | #define SAX_LexicalHandler_INCLUDED |
---|
41 | |
---|
42 | |
---|
43 | #include "Poco/XML/XML.h" |
---|
44 | #include "Poco/XML/XMLString.h" |
---|
45 | |
---|
46 | |
---|
47 | namespace Poco { |
---|
48 | namespace XML { |
---|
49 | |
---|
50 | |
---|
51 | class XML_API LexicalHandler |
---|
52 | /// This is an optional extension handler for SAX2 to provide lexical information |
---|
53 | /// about an XML document, such as comments and CDATA section boundaries. |
---|
54 | /// XML readers are not required to recognize this handler, and it is not part of |
---|
55 | /// core-only SAX2 distributions. |
---|
56 | /// |
---|
57 | /// The events in the lexical handler apply to the entire document, not just to the |
---|
58 | /// document element, and all lexical handler events must appear between the content |
---|
59 | /// handler's startDocument and endDocument events. |
---|
60 | /// |
---|
61 | /// To set the LexicalHandler for an XML reader, use the setProperty method with the |
---|
62 | /// property name http://xml.org/sax/properties/lexical-handler and an object implementing |
---|
63 | /// this interface (or null) as the value. If the reader does not report lexical events, |
---|
64 | /// it will throw a SAXNotRecognizedException when you attempt to register the handler. |
---|
65 | { |
---|
66 | public: |
---|
67 | virtual void startDTD(const XMLString& name, const XMLString& publicId, const XMLString& systemId) = 0; |
---|
68 | /// Report the start of DTD declarations, if any. |
---|
69 | /// |
---|
70 | /// This method is intended to report the beginning of the DOCTYPE declaration; |
---|
71 | /// if the document has no DOCTYPE declaration, this method will not be invoked. |
---|
72 | /// |
---|
73 | /// All declarations reported through DTDHandler or DeclHandler events must appear |
---|
74 | /// between the startDTD and endDTD events. Declarations are assumed to belong to |
---|
75 | /// the internal DTD subset unless they appear between startEntity and endEntity |
---|
76 | /// events. Comments and processing instructions from the DTD should also be reported |
---|
77 | /// between the startDTD and endDTD events, in their original order of (logical) occurrence; |
---|
78 | /// they are not required to appear in their correct locations relative to DTDHandler or |
---|
79 | /// DeclHandler events, however. |
---|
80 | /// |
---|
81 | /// Note that the start/endDTD events will appear within the start/endDocument events from |
---|
82 | /// ContentHandler and before the first startElement event. |
---|
83 | |
---|
84 | virtual void endDTD() = 0; |
---|
85 | /// Report the end of DTD declarations. |
---|
86 | /// |
---|
87 | /// This method is intended to report the end of the DOCTYPE declaration; if the document |
---|
88 | /// has no DOCTYPE declaration, this method will not be invoked. |
---|
89 | |
---|
90 | virtual void startEntity(const XMLString& name) = 0; |
---|
91 | /// Report the beginning of some internal and external XML entities. |
---|
92 | /// |
---|
93 | /// The reporting of parameter entities (including the external DTD subset) is optional, |
---|
94 | /// and SAX2 drivers that report LexicalHandler events may not implement it; you can use the |
---|
95 | /// http://xml.org/sax/features/lexical-handler/parameter-entities feature to query or control |
---|
96 | /// the reporting of parameter entities. |
---|
97 | /// |
---|
98 | /// General entities are reported with their regular names, parameter entities have '%' |
---|
99 | /// prepended to their names, and the external DTD subset has the pseudo-entity name "[dtd]". |
---|
100 | /// |
---|
101 | /// When a SAX2 driver is providing these events, all other events must be properly nested |
---|
102 | /// within start/end entity events. There is no additional requirement that events from |
---|
103 | /// DeclHandler or DTDHandler be properly ordered. |
---|
104 | /// |
---|
105 | /// Note that skipped entities will be reported through the skippedEntity event, which is part of |
---|
106 | /// the ContentHandler interface. |
---|
107 | /// |
---|
108 | /// Because of the streaming event model that SAX uses, some entity boundaries cannot be reported under |
---|
109 | /// any circumstances: |
---|
110 | /// |
---|
111 | /// * general entities within attribute values |
---|
112 | /// * parameter entities within declarations |
---|
113 | /// |
---|
114 | /// These will be silently expanded, with no indication of where the original entity boundaries were. |
---|
115 | /// |
---|
116 | /// Note also that the boundaries of character references (which are not really entities anyway) are not reported. |
---|
117 | /// |
---|
118 | /// All start/endEntity events must be properly nested. |
---|
119 | |
---|
120 | virtual void endEntity(const XMLString& name) = 0; |
---|
121 | /// Report the end of an entity. |
---|
122 | |
---|
123 | virtual void startCDATA() = 0; |
---|
124 | /// Report the start of a CDATA section. |
---|
125 | /// |
---|
126 | /// The contents of the CDATA section will be reported through the regular characters event; |
---|
127 | /// this event is intended only to report the boundary. |
---|
128 | |
---|
129 | virtual void endCDATA() = 0; |
---|
130 | /// Report the end of a CDATA section. |
---|
131 | |
---|
132 | virtual void comment(const XMLChar ch[], int start, int length) = 0; |
---|
133 | /// Report an XML comment anywhere in the document. |
---|
134 | /// |
---|
135 | /// This callback will be used for comments inside or outside the document element, |
---|
136 | /// including comments in the external DTD subset (if read). Comments in the DTD must |
---|
137 | /// be properly nested inside start/endDTD and start/endEntity events (if used). |
---|
138 | |
---|
139 | protected: |
---|
140 | virtual ~LexicalHandler(); |
---|
141 | }; |
---|
142 | |
---|
143 | |
---|
144 | } } // namespace Poco::XML |
---|
145 | |
---|
146 | |
---|
147 | #endif // SAX_LexicalHandler_INCLUDED |
---|