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: EntityResolver.hpp,v $
|
---|
59 | * Revision 1.4 2003/03/07 18:10:06 tng
|
---|
60 | * Return a reference instead of void for operator=
|
---|
61 | *
|
---|
62 | * Revision 1.3 2002/11/04 14:56:25 tng
|
---|
63 | * C++ Namespace Support.
|
---|
64 | *
|
---|
65 | * Revision 1.2 2002/06/06 20:39:16 tng
|
---|
66 | * Document Fix: document that the returned object from resolveEntity is owned by the parser
|
---|
67 | *
|
---|
68 | * Revision 1.1.1.1 2002/02/01 22:22:08 peiyongz
|
---|
69 | * sane_include
|
---|
70 | *
|
---|
71 | * Revision 1.6 2000/03/02 19:54:34 roddey
|
---|
72 | * This checkin includes many changes done while waiting for the
|
---|
73 | * 1.1.0 code to be finished. I can't list them all here, but a list is
|
---|
74 | * available elsewhere.
|
---|
75 | *
|
---|
76 | * Revision 1.5 2000/02/24 20:12:55 abagchi
|
---|
77 | * Swat for removing Log from API docs
|
---|
78 | *
|
---|
79 | * Revision 1.4 2000/02/12 03:31:55 rahulj
|
---|
80 | * Removed duplicate CVS Log entries.
|
---|
81 | *
|
---|
82 | * Revision 1.3 2000/02/12 01:27:19 aruna1
|
---|
83 | * Documentation updated
|
---|
84 | *
|
---|
85 | * Revision 1.2 2000/02/06 07:47:57 rahulj
|
---|
86 | * Year 2K copyright swat.
|
---|
87 | *
|
---|
88 | * Revision 1.1.1.1 1999/11/09 01:07:44 twl
|
---|
89 | * Initial checkin
|
---|
90 | *
|
---|
91 | * Revision 1.3 1999/11/08 20:44:56 rahul
|
---|
92 | * Swat for adding in Product name and CVS comment log variable.
|
---|
93 | *
|
---|
94 | */
|
---|
95 |
|
---|
96 |
|
---|
97 | #ifndef ENTITYRESOLVER_HPP
|
---|
98 | #define ENTITYRESOLVER_HPP
|
---|
99 |
|
---|
100 | #include <xercesc/util/XercesDefs.hpp>
|
---|
101 |
|
---|
102 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
103 |
|
---|
104 | class InputSource;
|
---|
105 |
|
---|
106 | /**
|
---|
107 | * Basic interface for resolving entities.
|
---|
108 | *
|
---|
109 | * <p>If a SAX application needs to implement customized handling
|
---|
110 | * for external entities, it must implement this interface and
|
---|
111 | * register an instance with the SAX parser using the parser's
|
---|
112 | * setEntityResolver method.</p>
|
---|
113 | *
|
---|
114 | * <p>The parser will then allow the application to intercept any
|
---|
115 | * external entities (including the external DTD subset and external
|
---|
116 | * parameter entities, if any) before including them.</p>
|
---|
117 | *
|
---|
118 | * <p>Many SAX applications will not need to implement this interface,
|
---|
119 | * but it will be especially useful for applications that build
|
---|
120 | * XML documents from databases or other specialised input sources,
|
---|
121 | * or for applications that use URI types other than URLs.</p>
|
---|
122 | *
|
---|
123 | * <p>The following resolver would provide the application
|
---|
124 | * with a special character stream for the entity with the system
|
---|
125 | * identifier "http://www.myhost.com/today":</p>
|
---|
126 | *
|
---|
127 | *<pre>
|
---|
128 | *#include <xercesc/sax/EntityResolver.hpp>
|
---|
129 | *#include <xercesc/sax/InputSource.hpp>
|
---|
130 | *
|
---|
131 | *class MyResolver : public EntityResolver {
|
---|
132 | * public:
|
---|
133 | * InputSource resolveEntity (const XMLCh* const publicId,
|
---|
134 | * const XMLCh* const systemId);
|
---|
135 | * ...
|
---|
136 | * };
|
---|
137 | *
|
---|
138 | * MyResolver::resolveEntity {
|
---|
139 | * if (XMLString::compareString(systemId, "http://www.myhost.com/today")) {
|
---|
140 | * MyReader* reader = new MyReader();
|
---|
141 | * return new InputSource(reader);
|
---|
142 | * } else {
|
---|
143 | * return null;
|
---|
144 | * }
|
---|
145 | * }
|
---|
146 | *
|
---|
147 | *</pre>
|
---|
148 | *
|
---|
149 | * <p>The application can also use this interface to redirect system
|
---|
150 | * identifiers to local URIs or to look up replacements in a catalog
|
---|
151 | * (possibly by using the public identifier).</p>
|
---|
152 | *
|
---|
153 | * <p>The HandlerBase class implements the default behaviour for
|
---|
154 | * this interface, which is simply always to return null (to request
|
---|
155 | * that the parser use the default system identifier).</p>
|
---|
156 | *
|
---|
157 | * @see Parser#setEntityResolver
|
---|
158 | * @see InputSource#InputSource
|
---|
159 | * @see HandlerBase#HandlerBase
|
---|
160 | */
|
---|
161 | class SAX_EXPORT EntityResolver
|
---|
162 | {
|
---|
163 | public:
|
---|
164 | /** @name Constructors and Destructor */
|
---|
165 | //@{
|
---|
166 |
|
---|
167 | /** Default Constructor */
|
---|
168 | EntityResolver()
|
---|
169 | {
|
---|
170 | }
|
---|
171 |
|
---|
172 | /** Destructor */
|
---|
173 | virtual ~EntityResolver()
|
---|
174 | {
|
---|
175 | }
|
---|
176 |
|
---|
177 | //@}
|
---|
178 |
|
---|
179 | /** @name The EntityResolver interface */
|
---|
180 | //@{
|
---|
181 |
|
---|
182 | /**
|
---|
183 | * Allow the application to resolve external entities.
|
---|
184 | *
|
---|
185 | * <p>The Parser will call this method before opening any external
|
---|
186 | * entity except the top-level document entity (including the
|
---|
187 | * external DTD subset, external entities referenced within the
|
---|
188 | * DTD, and external entities referenced within the document
|
---|
189 | * element): the application may request that the parser resolve
|
---|
190 | * the entity itself, that it use an alternative URI, or that it
|
---|
191 | * use an entirely different input source.</p>
|
---|
192 | *
|
---|
193 | * <p>Application writers can use this method to redirect external
|
---|
194 | * system identifiers to secure and/or local URIs, to look up
|
---|
195 | * public identifiers in a catalogue, or to read an entity from a
|
---|
196 | * database or other input source (including, for example, a dialog
|
---|
197 | * box).</p>
|
---|
198 | *
|
---|
199 | * <p>If the system identifier is a URL, the SAX parser must
|
---|
200 | * resolve it fully before reporting it to the application.</p>
|
---|
201 | *
|
---|
202 | * @param publicId The public identifier of the external entity
|
---|
203 | * being referenced, or null if none was supplied.
|
---|
204 | * @param systemId The system identifier of the external entity
|
---|
205 | * being referenced.
|
---|
206 | * @return An InputSource object describing the new input source,
|
---|
207 | * or null to request that the parser open a regular
|
---|
208 | * URI connection to the system identifier.
|
---|
209 | * The returned InputSource is owned by the parser which is
|
---|
210 | * responsible to clean up the memory.
|
---|
211 | * @exception SAXException Any SAX exception, possibly
|
---|
212 | * wrapping another exception.
|
---|
213 | * @exception IOException An IO exception,
|
---|
214 | * possibly the result of creating a new InputStream
|
---|
215 | * or Reader for the InputSource.
|
---|
216 | * @see InputSource#InputSource
|
---|
217 | */
|
---|
218 | virtual InputSource* resolveEntity
|
---|
219 | (
|
---|
220 | const XMLCh* const publicId
|
---|
221 | , const XMLCh* const systemId
|
---|
222 | ) = 0;
|
---|
223 |
|
---|
224 | //@}
|
---|
225 |
|
---|
226 | private :
|
---|
227 | /* Unimplemented constructors and operators */
|
---|
228 |
|
---|
229 |
|
---|
230 | /* Copy constructor */
|
---|
231 | EntityResolver(const EntityResolver&);
|
---|
232 |
|
---|
233 | /* Assignment operator */
|
---|
234 | EntityResolver& operator=(const EntityResolver&);
|
---|
235 |
|
---|
236 | };
|
---|
237 |
|
---|
238 | XERCES_CPP_NAMESPACE_END
|
---|
239 |
|
---|
240 | #endif
|
---|