1 | /*
|
---|
2 | * The Apache Software License, Version 1.1
|
---|
3 | *
|
---|
4 | * Copyright (c) 2002 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 | * $Id: Wrapper4InputSource.hpp,v 1.8 2003/12/17 00:18:33 cargilld Exp $
|
---|
59 | */
|
---|
60 |
|
---|
61 |
|
---|
62 | #ifndef WRAPPER4INPUTSOURCE_HPP
|
---|
63 | #define WRAPPER4INPUTSOURCE_HPP
|
---|
64 |
|
---|
65 | #include <xercesc/dom/DOMInputSource.hpp>
|
---|
66 | #include <xercesc/util/PlatformUtils.hpp>
|
---|
67 |
|
---|
68 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
69 |
|
---|
70 | class InputSource;
|
---|
71 |
|
---|
72 |
|
---|
73 | /**
|
---|
74 | * Wrap a SAX InputSource object to a DOM InputSource.
|
---|
75 | */
|
---|
76 | class XMLPARSER_EXPORT Wrapper4InputSource: public DOMInputSource
|
---|
77 | {
|
---|
78 | public:
|
---|
79 | /** @name Constructors and Destructor */
|
---|
80 | //@{
|
---|
81 |
|
---|
82 | /**
|
---|
83 | * Constructor
|
---|
84 | *
|
---|
85 | * Wrap a SAX InputSource and pretend it to be a DOMInputSource.
|
---|
86 | * By default, the wrapper will adopt the SAX InputSource that is wrapped.
|
---|
87 | *
|
---|
88 | * @param inputSource The SAX InputSource to be wrapped
|
---|
89 | * @param adoptFlag Indicates if the wrapper should adopt the wrapped
|
---|
90 | * SAX InputSource. Default is true.
|
---|
91 | */
|
---|
92 | Wrapper4InputSource(InputSource* const inputSource
|
---|
93 | , const bool adoptFlag = true
|
---|
94 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
|
---|
95 |
|
---|
96 | /**
|
---|
97 | * Destructor
|
---|
98 | *
|
---|
99 | */
|
---|
100 | virtual ~Wrapper4InputSource();
|
---|
101 | //@}
|
---|
102 |
|
---|
103 |
|
---|
104 | // -----------------------------------------------------------------------
|
---|
105 | /** @name Virtual input source interface */
|
---|
106 | //@{
|
---|
107 | /**
|
---|
108 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
109 | *
|
---|
110 | * Makes the byte stream for this input source.
|
---|
111 | *
|
---|
112 | * <p>The function will call the makeStream of the wrapped input source.
|
---|
113 | * The returned stream becomes the parser's property.</p>
|
---|
114 | *
|
---|
115 | * @see BinInputStream
|
---|
116 | */
|
---|
117 | BinInputStream* makeStream() const;
|
---|
118 |
|
---|
119 | //@}
|
---|
120 |
|
---|
121 | // -----------------------------------------------------------------------
|
---|
122 | /** @name Getter methods */
|
---|
123 | //@{
|
---|
124 | /**
|
---|
125 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
126 | *
|
---|
127 | * An input source can be set to force the parser to assume a particular
|
---|
128 | * encoding for the data that input source reprsents, via the setEncoding()
|
---|
129 | * method. This method will delegate to the wrapped input source to return
|
---|
130 | * name of the encoding that is to be forced. If the encoding has never
|
---|
131 | * been forced, it returns a null pointer.
|
---|
132 | *
|
---|
133 | * @return The forced encoding, or null if none was supplied.
|
---|
134 | * @see #setEncoding
|
---|
135 | */
|
---|
136 | const XMLCh* getEncoding() const;
|
---|
137 |
|
---|
138 |
|
---|
139 | /**
|
---|
140 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
141 | *
|
---|
142 | * Get the public identifier for this input source. Delegated to the
|
---|
143 | * wrapped input source object.
|
---|
144 | *
|
---|
145 | * @return The public identifier, or null if none was supplied.
|
---|
146 | * @see #setPublicId
|
---|
147 | */
|
---|
148 | const XMLCh* getPublicId() const;
|
---|
149 |
|
---|
150 |
|
---|
151 | /**
|
---|
152 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
153 | *
|
---|
154 | * Get the system identifier for this input source. Delegated to the
|
---|
155 | * wrapped input source object.
|
---|
156 | *
|
---|
157 | * <p>If the system ID is a URL, it will be fully resolved.</p>
|
---|
158 | *
|
---|
159 | * @return The system identifier.
|
---|
160 | * @see #setSystemId
|
---|
161 | */
|
---|
162 | const XMLCh* getSystemId() const;
|
---|
163 |
|
---|
164 | /**
|
---|
165 | * Get the base URI to be used for resolving relative URIs to absolute
|
---|
166 | * URIs. If the baseURI is itself a relative URI, the behavior is
|
---|
167 | * implementation dependent. Delegated to the wrapped intput source
|
---|
168 | * object.
|
---|
169 | *
|
---|
170 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
171 | *
|
---|
172 | * @return The base URI.
|
---|
173 | * @see #setBaseURI
|
---|
174 | * @since DOM Level 3
|
---|
175 | */
|
---|
176 | const XMLCh* getBaseURI() const;
|
---|
177 |
|
---|
178 | /**
|
---|
179 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
180 | *
|
---|
181 | * Get the flag that indicates if the parser should issue fatal error if this input source
|
---|
182 | * is not found. Delegated to the wrapped input source object.
|
---|
183 | *
|
---|
184 | * @return True if the parser should issue fatal error if this input source is not found.
|
---|
185 | * False if the parser issue warning message instead.
|
---|
186 | * @see #setIssueFatalErrorIfNotFound
|
---|
187 | */
|
---|
188 | bool getIssueFatalErrorIfNotFound() const;
|
---|
189 |
|
---|
190 | //@}
|
---|
191 |
|
---|
192 |
|
---|
193 | // -----------------------------------------------------------------------
|
---|
194 | /** @name Setter methods */
|
---|
195 | //@{
|
---|
196 |
|
---|
197 | /**
|
---|
198 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
199 | *
|
---|
200 | * Set the encoding which will be required for use with the XML text read
|
---|
201 | * via a stream opened by this input source. This will update the wrapped
|
---|
202 | * input source object.
|
---|
203 | *
|
---|
204 | * <p>This is usually not set, allowing the encoding to be sensed in the
|
---|
205 | * usual XML way. However, in some cases, the encoding in the file is known
|
---|
206 | * to be incorrect because of intermediate transcoding, for instance
|
---|
207 | * encapsulation within a MIME document.
|
---|
208 | *
|
---|
209 | * @param encodingStr The name of the encoding to force.
|
---|
210 | */
|
---|
211 | void setEncoding(const XMLCh* const encodingStr);
|
---|
212 |
|
---|
213 |
|
---|
214 | /**
|
---|
215 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
216 | *
|
---|
217 | * Set the public identifier for this input source. This will update the
|
---|
218 | * wrapped input source object.
|
---|
219 | *
|
---|
220 | * <p>The public identifier is always optional: if the application writer
|
---|
221 | * includes one, it will be provided as part of the location information.</p>
|
---|
222 | *
|
---|
223 | * @param publicId The public identifier as a string.
|
---|
224 | * @see Locator#getPublicId
|
---|
225 | * @see SAXParseException#getPublicId
|
---|
226 | * @see #getPublicId
|
---|
227 | */
|
---|
228 | void setPublicId(const XMLCh* const publicId);
|
---|
229 |
|
---|
230 | /**
|
---|
231 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
232 | *
|
---|
233 | * Set the system identifier for this input source. This will update the
|
---|
234 | * wrapped input source object.
|
---|
235 | *
|
---|
236 | * <p>The system id is always required. The public id may be used to map
|
---|
237 | * to another system id, but the system id must always be present as a fall
|
---|
238 | * back.</p>
|
---|
239 | *
|
---|
240 | * <p>If the system ID is a URL, it must be fully resolved.</p>
|
---|
241 | *
|
---|
242 | * @param systemId The system identifier as a string.
|
---|
243 | * @see #getSystemId
|
---|
244 | * @see Locator#getSystemId
|
---|
245 | * @see SAXParseException#getSystemId
|
---|
246 | */
|
---|
247 | void setSystemId(const XMLCh* const systemId);
|
---|
248 |
|
---|
249 | /**
|
---|
250 | * Set the base URI to be used for resolving relative URIs to absolute
|
---|
251 | * URIs. If the baseURI is itself a relative URI, the behavior is
|
---|
252 | * implementation dependent. This will update the wrapped input source
|
---|
253 | * object.
|
---|
254 | *
|
---|
255 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
256 | *
|
---|
257 | * @param baseURI The base URI.
|
---|
258 | * @see #getBaseURI
|
---|
259 | * @since DOM Level 3
|
---|
260 | */
|
---|
261 | void setBaseURI(const XMLCh* const baseURI);
|
---|
262 |
|
---|
263 | /**
|
---|
264 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
265 | *
|
---|
266 | * Indicates if the parser should issue fatal error if this input source
|
---|
267 | * is not found. If set to false, the parser issue warning message
|
---|
268 | * instead. This will update the wrapped input source object.
|
---|
269 | *
|
---|
270 | * @param flag True if the parser should issue fatal error if this input
|
---|
271 | * source is not found.
|
---|
272 | * If set to false, the parser issue warning message instead.
|
---|
273 | * (Default: true)
|
---|
274 | *
|
---|
275 | * @see #getIssueFatalErrorIfNotFound
|
---|
276 | */
|
---|
277 | void setIssueFatalErrorIfNotFound(const bool flag);
|
---|
278 |
|
---|
279 | /**
|
---|
280 | * Called to indicate that this DOMInputSource is no longer in use
|
---|
281 | * and that the implementation may relinquish any resources associated with it.
|
---|
282 | *
|
---|
283 | * Access to a released object will lead to unexpected result.
|
---|
284 | */
|
---|
285 | void release();
|
---|
286 |
|
---|
287 | //@}
|
---|
288 |
|
---|
289 |
|
---|
290 | private:
|
---|
291 | // -----------------------------------------------------------------------
|
---|
292 | // Unimplemented constructors and operators
|
---|
293 | // -----------------------------------------------------------------------
|
---|
294 | Wrapper4InputSource(const Wrapper4InputSource&);
|
---|
295 | Wrapper4InputSource& operator=(const Wrapper4InputSource&);
|
---|
296 |
|
---|
297 | // -----------------------------------------------------------------------
|
---|
298 | // Private data members
|
---|
299 | // -----------------------------------------------------------------------
|
---|
300 | bool fAdoptInputSource;
|
---|
301 | InputSource* fInputSource;
|
---|
302 | };
|
---|
303 |
|
---|
304 |
|
---|
305 | // ---------------------------------------------------------------------------
|
---|
306 | // Wrapper4InputSource: Getter methods
|
---|
307 | // ---------------------------------------------------------------------------
|
---|
308 | inline const XMLCh* Wrapper4InputSource::getBaseURI() const
|
---|
309 | {
|
---|
310 | return 0; // REVISIT - should we return an empty string?
|
---|
311 | }
|
---|
312 |
|
---|
313 | // ---------------------------------------------------------------------------
|
---|
314 | // Wrapper4InputSource: Setter methods
|
---|
315 | // ---------------------------------------------------------------------------
|
---|
316 | inline void Wrapper4InputSource::setBaseURI(const XMLCh* const)
|
---|
317 | {
|
---|
318 | }
|
---|
319 |
|
---|
320 | XERCES_CPP_NAMESPACE_END
|
---|
321 |
|
---|
322 | #endif
|
---|