source: NonGTP/Xerces/xerces/include/xercesc/sax/EntityResolver.hpp @ 358

Revision 358, 6.8 KB checked in by bittner, 19 years ago (diff)

xerces added

Line 
1/*
2 * Copyright 1999-2000,2004 The Apache Software Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/*
18 * $Log: EntityResolver.hpp,v $
19 * Revision 1.6  2004/09/26 01:06:30  cargilld
20 * Fix documentation generation problem.  Replace <pre> with <code>.  Patch from James Littlejohn.
21 *
22 * Revision 1.5  2004/09/08 13:56:19  peiyongz
23 * Apache License Version 2.0
24 *
25 * Revision 1.4  2003/03/07 18:10:06  tng
26 * Return a reference instead of void for operator=
27 *
28 * Revision 1.3  2002/11/04 14:56:25  tng
29 * C++ Namespace Support.
30 *
31 * Revision 1.2  2002/06/06 20:39:16  tng
32 * Document Fix: document that the returned object from resolveEntity is owned by the parser
33 *
34 * Revision 1.1.1.1  2002/02/01 22:22:08  peiyongz
35 * sane_include
36 *
37 * Revision 1.6  2000/03/02 19:54:34  roddey
38 * This checkin includes many changes done while waiting for the
39 * 1.1.0 code to be finished. I can't list them all here, but a list is
40 * available elsewhere.
41 *
42 * Revision 1.5  2000/02/24 20:12:55  abagchi
43 * Swat for removing Log from API docs
44 *
45 * Revision 1.4  2000/02/12 03:31:55  rahulj
46 * Removed duplicate CVS Log entries.
47 *
48 * Revision 1.3  2000/02/12 01:27:19  aruna1
49 * Documentation updated
50 *
51 * Revision 1.2  2000/02/06 07:47:57  rahulj
52 * Year 2K copyright swat.
53 *
54 * Revision 1.1.1.1  1999/11/09 01:07:44  twl
55 * Initial checkin
56 *
57 * Revision 1.3  1999/11/08 20:44:56  rahul
58 * Swat for adding in Product name and CVS comment log variable.
59 *
60 */
61
62
63#ifndef ENTITYRESOLVER_HPP
64#define ENTITYRESOLVER_HPP
65
66#include <xercesc/util/XercesDefs.hpp>
67
68XERCES_CPP_NAMESPACE_BEGIN
69
70class InputSource;
71
72/**
73  * Basic interface for resolving entities.
74  *
75  * <p>If a SAX application needs to implement customized handling
76  * for external entities, it must implement this interface and
77  * register an instance with the SAX parser using the parser's
78  * setEntityResolver method.</p>
79  *
80  * <p>The parser will then allow the application to intercept any
81  * external entities (including the external DTD subset and external
82  * parameter entities, if any) before including them.</p>
83  *
84  * <p>Many SAX applications will not need to implement this interface,
85  * but it will be especially useful for applications that build
86  * XML documents from databases or other specialised input sources,
87  * or for applications that use URI types other than URLs.</p>
88  *
89  * <p>The following resolver would provide the application
90  * with a special character stream for the entity with the system
91  * identifier "http://www.myhost.com/today":</p>
92  *
93  *<code>
94  *#include <xercesc/sax/EntityResolver.hpp><br>
95  *#include <xercesc/sax/InputSource.hpp><br>
96  *<br>
97  *class MyResolver : public EntityResolver {<br>
98  *  public:<br>&nbsp;
99  *    InputSource resolveEntity (const XMLCh* const publicId, const XMLCh* const systemId);<br>&nbsp;&nbsp;
100  *    <br>
101  *   ...<br>&nbsp;&nbsp;
102  *   };<br>&nbsp;
103  *<br>
104  *&nbsp;MyResolver::resolveEntity {<br>
105  *&nbsp;&nbsp;if (XMLString::compareString(systemId, "http://www.myhost.com/today")) {<br>
106  *&nbsp;&nbsp;&nbsp;MyReader* reader = new MyReader();<br>
107  *&nbsp;&nbsp;&nbsp;return new InputSource(reader);<br>
108  *&nbsp;&nbsp;} else {<br>
109  *&nbsp;&nbsp;&nbsp;return null;<br>
110  *&nbsp;&nbsp;}<br>
111  *&nbsp;}<br>
112  *<br>
113  *</code>
114  *
115  * <p>The application can also use this interface to redirect system
116  * identifiers to local URIs or to look up replacements in a catalog
117  * (possibly by using the public identifier).</p>
118  *
119  * <p>The HandlerBase class implements the default behaviour for
120  * this interface, which is simply always to return null (to request
121  * that the parser use the default system identifier).</p>
122  *
123  * @see Parser#setEntityResolver
124  * @see InputSource#InputSource
125  * @see HandlerBase#HandlerBase
126  */
127class SAX_EXPORT EntityResolver
128{
129public:
130    /** @name Constructors and Destructor */
131    //@{
132
133    /** Default Constructor */
134    EntityResolver()
135    {
136    }
137
138    /** Destructor */
139    virtual ~EntityResolver()
140    {
141    }
142
143    //@}
144
145    /** @name The EntityResolver interface */
146    //@{
147
148  /**
149    * Allow the application to resolve external entities.
150    *
151    * <p>The Parser will call this method before opening any external
152    * entity except the top-level document entity (including the
153    * external DTD subset, external entities referenced within the
154    * DTD, and external entities referenced within the document
155    * element): the application may request that the parser resolve
156    * the entity itself, that it use an alternative URI, or that it
157    * use an entirely different input source.</p>
158    *
159    * <p>Application writers can use this method to redirect external
160    * system identifiers to secure and/or local URIs, to look up
161    * public identifiers in a catalogue, or to read an entity from a
162    * database or other input source (including, for example, a dialog
163    * box).</p>
164    *
165    * <p>If the system identifier is a URL, the SAX parser must
166    * resolve it fully before reporting it to the application.</p>
167    *
168    * @param publicId The public identifier of the external entity
169    *        being referenced, or null if none was supplied.
170    * @param systemId The system identifier of the external entity
171    *        being referenced.
172    * @return An InputSource object describing the new input source,
173    *         or null to request that the parser open a regular
174    *         URI connection to the system identifier.
175    *         The returned InputSource is owned by the parser which is
176    *         responsible to clean up the memory.
177    * @exception SAXException Any SAX exception, possibly
178    *            wrapping another exception.
179    * @exception IOException An IO exception,
180    *            possibly the result of creating a new InputStream
181    *            or Reader for the InputSource.
182    * @see InputSource#InputSource
183    */
184    virtual InputSource* resolveEntity
185    (
186        const   XMLCh* const    publicId
187        , const XMLCh* const    systemId
188    ) = 0;
189
190    //@}
191
192private :
193    /* Unimplemented constructors and operators */
194
195
196    /* Copy constructor */
197    EntityResolver(const EntityResolver&);
198
199    /* Assignment operator */
200    EntityResolver& operator=(const EntityResolver&);
201
202};
203
204XERCES_CPP_NAMESPACE_END
205
206#endif
Note: See TracBrowser for help on using the repository browser.