1 | /*
|
---|
2 | * The Apache Software License, Version 1.1
|
---|
3 | *
|
---|
4 | * Copyright (c) 1999-2000 The Apache Software Foundation. All rights
|
---|
5 | * reserved.
|
---|
6 | *
|
---|
7 | * Redistribution and use in source and binary forms, with or without
|
---|
8 | * modification, are permitted provided that the following conditions
|
---|
9 | * are met:
|
---|
10 | *
|
---|
11 | * 1. Redistributions of source code must retain the above copyright
|
---|
12 | * notice, this list of conditions and the following disclaimer.
|
---|
13 | *
|
---|
14 | * 2. Redistributions in binary form must reproduce the above copyright
|
---|
15 | * notice, this list of conditions and the following disclaimer in
|
---|
16 | * the documentation and/or other materials provided with the
|
---|
17 | * distribution.
|
---|
18 | *
|
---|
19 | * 3. The end-user documentation included with the redistribution,
|
---|
20 | * if any, must include the following acknowledgment:
|
---|
21 | * "This product includes software developed by the
|
---|
22 | * Apache Software Foundation (http://www.apache.org/)."
|
---|
23 | * Alternately, this acknowledgment may appear in the software itself,
|
---|
24 | * if and wherever such third-party acknowledgments normally appear.
|
---|
25 | *
|
---|
26 | * 4. The names "Xerces" and "Apache Software Foundation" must
|
---|
27 | * not be used to endorse or promote products derived from this
|
---|
28 | * software without prior written permission. For written
|
---|
29 | * permission, please contact apache\@apache.org.
|
---|
30 | *
|
---|
31 | * 5. Products derived from this software may not be called "Apache",
|
---|
32 | * nor may "Apache" appear in their name, without prior written
|
---|
33 | * permission of the Apache Software Foundation.
|
---|
34 | *
|
---|
35 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
---|
36 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
37 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
---|
38 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
---|
39 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
---|
40 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
---|
41 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
---|
42 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
---|
43 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
---|
44 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
---|
45 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
---|
46 | * SUCH DAMAGE.
|
---|
47 | * ====================================================================
|
---|
48 | *
|
---|
49 | * This software consists of voluntary contributions made by many
|
---|
50 | * individuals on behalf of the Apache Software Foundation, and was
|
---|
51 | * originally based on software copyright (c) 1999, International
|
---|
52 | * Business Machines, Inc., http://www.ibm.com . For more information
|
---|
53 | * on the Apache Software Foundation, please see
|
---|
54 | * <http://www.apache.org/>.
|
---|
55 | */
|
---|
56 |
|
---|
57 | /*
|
---|
58 | * $Log: XMLEntityHandler.hpp,v $
|
---|
59 | * Revision 1.7 2003/10/30 21:37:31 knoaman
|
---|
60 | * Enhanced Entity Resolver Support. Thanks to David Cargill.
|
---|
61 | *
|
---|
62 | * Revision 1.6 2003/03/07 18:08:10 tng
|
---|
63 | * Return a reference instead of void for operator=
|
---|
64 | *
|
---|
65 | * Revision 1.5 2002/11/04 15:00:21 tng
|
---|
66 | * C++ Namespace Support.
|
---|
67 | *
|
---|
68 | * Revision 1.4 2002/06/06 20:41:51 tng
|
---|
69 | * Regression fix: should assign the returned InputSource from resolveEntity to srcToFill.
|
---|
70 | *
|
---|
71 | * Revision 1.3 2002/05/31 15:14:07 tng
|
---|
72 | * Fix doxygen documentation.
|
---|
73 | *
|
---|
74 | * Revision 1.2 2002/05/29 21:47:08 knoaman
|
---|
75 | * DOM L3 LS: DOMInputSource, DOMEntityResolver, DOMImplementationLS and DOMBuilder
|
---|
76 | *
|
---|
77 | * Revision 1.1.1.1 2002/02/01 22:21:51 peiyongz
|
---|
78 | * sane_include
|
---|
79 | *
|
---|
80 | * Revision 1.7 2000/03/02 19:54:25 roddey
|
---|
81 | * This checkin includes many changes done while waiting for the
|
---|
82 | * 1.1.0 code to be finished. I can't list them all here, but a list is
|
---|
83 | * available elsewhere.
|
---|
84 | *
|
---|
85 | * Revision 1.6 2000/02/24 20:00:23 abagchi
|
---|
86 | * Swat for removing Log from API docs
|
---|
87 | *
|
---|
88 | * Revision 1.5 2000/02/16 21:42:58 aruna1
|
---|
89 | * API Doc++ summary changes in
|
---|
90 | *
|
---|
91 | * Revision 1.4 2000/02/15 01:21:31 roddey
|
---|
92 | * Some initial documentation improvements. More to come...
|
---|
93 | *
|
---|
94 | * Revision 1.3 2000/02/06 07:47:48 rahulj
|
---|
95 | * Year 2K copyright swat.
|
---|
96 | *
|
---|
97 | * Revision 1.2 1999/12/15 19:46:28 roddey
|
---|
98 | * Got rid of redundant 'const' on bool return value. Some compilers choke on this
|
---|
99 | * and its not useful anyway.
|
---|
100 | *
|
---|
101 | * Revision 1.1.1.1 1999/11/09 01:08:33 twl
|
---|
102 | * Initial checkin
|
---|
103 | *
|
---|
104 | * Revision 1.2 1999/11/08 20:44:38 rahul
|
---|
105 | * Swat for adding in Product name and CVS comment log variable.
|
---|
106 | *
|
---|
107 | */
|
---|
108 |
|
---|
109 |
|
---|
110 | #if !defined(XMLENTITYHANDLER_HPP)
|
---|
111 | #define XMLENTITYHANDLER_HPP
|
---|
112 |
|
---|
113 | #include <xercesc/util/XercesDefs.hpp>
|
---|
114 |
|
---|
115 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
116 |
|
---|
117 | class InputSource;
|
---|
118 | class XMLBuffer;
|
---|
119 | class XMLResourceIdentifier;
|
---|
120 |
|
---|
121 | /**
|
---|
122 | * This abstract class is a callback mechanism for the scanner. By creating
|
---|
123 | * a derivative of this class and plugging into the scanner, the scanner
|
---|
124 | * will call back on the object's methods to entity events.
|
---|
125 | *
|
---|
126 | * This class is primarily for use by those writing their own parser classes.
|
---|
127 | * If you use the standard parser classes, DOMParser and SAXParser, you won't
|
---|
128 | * use this API. You will instead use a similar mechanism defined by the SAX
|
---|
129 | * API, called EntityResolver.
|
---|
130 | */
|
---|
131 | class XMLPARSER_EXPORT XMLEntityHandler
|
---|
132 | {
|
---|
133 | public:
|
---|
134 | // -----------------------------------------------------------------------
|
---|
135 | // Constructors are hidden, only the virtual destructor is exposed
|
---|
136 | // -----------------------------------------------------------------------
|
---|
137 |
|
---|
138 | /** @name Destructor */
|
---|
139 | //@{
|
---|
140 |
|
---|
141 | /**
|
---|
142 | * Default destructor
|
---|
143 | */
|
---|
144 | virtual ~XMLEntityHandler()
|
---|
145 | {
|
---|
146 | }
|
---|
147 | //@}
|
---|
148 |
|
---|
149 |
|
---|
150 | // -----------------------------------------------------------------------
|
---|
151 | // The virtual entity handler interface
|
---|
152 | // -----------------------------------------------------------------------
|
---|
153 | /** @name The pure virtual methods in this interface. */
|
---|
154 | //@{
|
---|
155 |
|
---|
156 | /**
|
---|
157 | * This method get called after the scanner has finished reading from
|
---|
158 | * the given input source while processing external entity references.
|
---|
159 | *
|
---|
160 | * @param inputSource The input source for the entity
|
---|
161 | */
|
---|
162 | virtual void endInputSource(const InputSource& inputSource) = 0;
|
---|
163 |
|
---|
164 | /**
|
---|
165 | * This method allows the passes the scanned systemId to the entity
|
---|
166 | * handler, thereby giving it a chance to provide any customized
|
---|
167 | * handling like resolving relative path names. The scanner first
|
---|
168 | * calls this method before calling <code>resolveEntity</code>.
|
---|
169 | *
|
---|
170 | * @param systemId The system id extracted by the scanner from the
|
---|
171 | * input source.
|
---|
172 | * @param toFill The buffer in which the fully expanded system id needs
|
---|
173 | * to be stored.
|
---|
174 | */
|
---|
175 | virtual bool expandSystemId
|
---|
176 | (
|
---|
177 | const XMLCh* const systemId
|
---|
178 | , XMLBuffer& toFill
|
---|
179 | ) = 0;
|
---|
180 |
|
---|
181 | /**
|
---|
182 | * This method allows the entity handler to reset itself, so that
|
---|
183 | * it can be used again. It is called prior to a new document parse
|
---|
184 | * operation.
|
---|
185 | */
|
---|
186 | virtual void resetEntities() = 0;
|
---|
187 |
|
---|
188 | /**
|
---|
189 | * This method allows the entity handler to provide customized
|
---|
190 | * application specific entity resolution. This method is defined
|
---|
191 | * by SAX 1.0 API.
|
---|
192 | *
|
---|
193 | * <i>Only one resolveEntity method will be used. If both setEntityResolver and
|
---|
194 | * setXMLEntityResolver are called, then the last one is used.</i>
|
---|
195 | *
|
---|
196 | * @param publicId A const pointer to a Unicode string representing the
|
---|
197 | * public id of the entity just parsed.
|
---|
198 | * @param systemId A const pointer to a Unicode string representing the
|
---|
199 | * system id of the entity just parsed.
|
---|
200 | * @param baseURI A const pointer to a Unicode string representing the
|
---|
201 | * base URI of the entity just parsed,
|
---|
202 | * or <code>null</code> if there is no base URI.
|
---|
203 | * @return The value returned by the SAX resolveEntity method or
|
---|
204 | * NULL otherwise to indicate no processing was done.
|
---|
205 | * The returned InputSource is owned by the parser which is
|
---|
206 | * responsible to clean up the memory.
|
---|
207 | */
|
---|
208 | virtual InputSource* resolveEntity
|
---|
209 | (
|
---|
210 | const XMLCh* const publicId
|
---|
211 | , const XMLCh* const systemId
|
---|
212 | , const XMLCh* const baseURI = 0
|
---|
213 | ) = 0;
|
---|
214 |
|
---|
215 | /**
|
---|
216 | * This method allows the entity handler to provide customized
|
---|
217 | * application specific entity resolution.
|
---|
218 | *
|
---|
219 | * <i>Only one resolveEntity method will be used. If both setEntityResolver and
|
---|
220 | * setXMLEntityResolver are called, then the last one is used.</i>
|
---|
221 | *
|
---|
222 | * @param resourceIdentifier An object containing the type of
|
---|
223 | * resource to be resolved and the associated data members
|
---|
224 | * corresponding to this type.
|
---|
225 | * @return The value returned by the resolveEntity method or
|
---|
226 | * NULL otherwise to indicate no processing was done.
|
---|
227 | * The returned InputSource is owned by the parser which is
|
---|
228 | * responsible to clean up the memory.
|
---|
229 | */
|
---|
230 | virtual InputSource* resolveEntity
|
---|
231 | (
|
---|
232 | XMLResourceIdentifier* resourceIdentifier
|
---|
233 | ) = 0;
|
---|
234 |
|
---|
235 | /**
|
---|
236 | * This method will be called before the scanner starts reading
|
---|
237 | * from an input source while processing external entity references.
|
---|
238 | *
|
---|
239 | * @param inputSource The external input source.
|
---|
240 | */
|
---|
241 | virtual void startInputSource(const InputSource& inputSource) = 0;
|
---|
242 | //@}
|
---|
243 |
|
---|
244 |
|
---|
245 | protected :
|
---|
246 | // -----------------------------------------------------------------------
|
---|
247 | // Hidden Constructors
|
---|
248 | // -----------------------------------------------------------------------
|
---|
249 | /** @name Constructor */
|
---|
250 | //@{
|
---|
251 |
|
---|
252 | /**
|
---|
253 | * Protected default constructor
|
---|
254 | */
|
---|
255 | XMLEntityHandler()
|
---|
256 | {
|
---|
257 | }
|
---|
258 | //@}
|
---|
259 |
|
---|
260 |
|
---|
261 |
|
---|
262 | private:
|
---|
263 | // -----------------------------------------------------------------------
|
---|
264 | // Unimplemented constructors and destructor
|
---|
265 | // -----------------------------------------------------------------------
|
---|
266 | XMLEntityHandler(const XMLEntityHandler&);
|
---|
267 | XMLEntityHandler& operator=(const XMLEntityHandler&);
|
---|
268 | };
|
---|
269 |
|
---|
270 | XERCES_CPP_NAMESPACE_END
|
---|
271 |
|
---|
272 | #endif
|
---|