source: NonGTP/Xerces/xerces/include/xercesc/util/XMLResourceIdentifier.hpp @ 358

Revision 358, 7.0 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: XMLResourceIdentifier.hpp,v $
19 * Revision 1.7  2004/09/26 01:06:31  cargilld
20 * Fix documentation generation problem.  Replace <pre> with <code>.  Patch from James Littlejohn.
21 *
22 * Revision 1.6  2004/09/08 13:56:24  peiyongz
23 * Apache License Version 2.0
24 *
25 * Revision 1.5  2004/02/15 19:37:16  amassari
26 * Removed cause for warnings in VC 7.1
27 *
28 * Revision 1.4  2004/02/13 14:28:30  cargilld
29 * Fix for bug 26900 (remove virtual on destructor)
30 *
31 * Revision 1.3  2004/01/29 11:48:47  cargilld
32 * Code cleanup changes to get rid of various compiler diagnostic messages.
33 *
34 * Revision 1.2  2003/11/25 18:16:38  knoaman
35 * Documentation update. Thanks to David Cargill.
36 *
37 * Revision 1.1  2003/10/30 21:37:32  knoaman
38 * Enhanced Entity Resolver Support. Thanks to David Cargill.
39 *
40 *
41 * Revision 1.1    1999/11/09 01:07:44  twl
42 * Initial checkin
43 *
44 */
45
46#ifndef XMLRESOURCEIDENTIFIER_HPP
47#define XMLRESOURCEIDENTIFIER_HPP
48
49XERCES_CPP_NAMESPACE_BEGIN
50
51/**
52  * <p>This class is used along with XMLEntityResolver to resolve entities.
53  * Instead of passing publicId and systemId on the resolveEntity call,
54  * as is done with the SAX entity resolver, an object of type XMLResourceIdentifier
55  * is passed.  By calling the getResourceIdentifierType() method the user can
56  * determine which data members are available for inspection:</p>
57  *
58  * <table border='1'>
59  * <tr>
60  *  <td>ResourceIdentifierType</td>
61  *  <td>Available Data Members</td>
62  * </tr>
63  * <tr>
64  *  <td>SchemaGrammar</td>
65  *  <td>schemaLocation, nameSpace & baseURI (current document)</td>
66  * </tr>
67  * <tr>
68  *  <td>SchemaImport</td>
69  *  <td>schemaLocation, nameSpace & baseURI (current document)</td>
70  * </tr>
71  * <tr>
72  *  <td>SchemaInclude</td>
73  *  <td>schemaLocation & baseURI (current document)</td>
74  * </tr>
75  * <tr>
76  *  <td>SchemaRedefine</td>
77  *  <td>schemaLocation & baseURI (current document)</td>
78  * </tr>
79  * <tr>
80  *  <td>ExternalEntity</td>
81  *  <td>systemId, publicId & baseURI (some items may be NULL)</td>
82  * </tr>
83  * </table>
84  *
85  * <p>The following resolver would provide the application
86  * with a special character stream for the entity with the system
87  * identifier "http://www.myhost.com/today":</p>
88  *
89  *<code>
90  * #include <xercesc/util/XMLEntityResolver.hpp><br>
91  * #include <xercesc/sax/InputSource.hpp><br>
92  *<br>
93  *&nbsp;class MyResolver : public XMLEntityResolver {<br>
94  *&nbsp;&nbsp;public:<br>
95  *&nbsp;&nbsp;&nbsp;InputSource resolveEntity (XMLResourceIdentifier* xmlri);<br>
96  *&nbsp;&nbsp;&nbsp;...<br>
97  *&nbsp;&nbsp;};<br>
98  *<br>
99  *&nbsp;&nbsp;MyResolver::resolveEntity(XMLResourceIdentifier* xmlri) {<br>
100  *&nbsp;&nbsp;&nbsp;switch(xmlri->getResourceIdentifierType()) {<br>
101  *&nbsp;&nbsp;&nbsp;&nbsp;case XMLResourceIdentifier::SystemId:<br>
102  *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (XMLString::compareString(xmlri->getSystemId(), "http://www.myhost.com/today")) {<br>
103  *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MyReader* reader = new MyReader();<br>
104  *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return new InputSource(reader);<br>
105  *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} else {<br>
106  *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return null;<br>
107  *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>
108  *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br>
109  *&nbsp;&nbsp;&nbsp;&nbsp;default:<br>
110  *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return null;<br>
111  *&nbsp;&nbsp;&nbsp;}<br>
112  *&nbsp;&nbsp;}</code>
113  *
114  * @see SAXParser#setXMLEntityResolver
115  * @see InputSource#InputSource
116  */
117class XMLUTIL_EXPORT XMLResourceIdentifier
118{
119public:
120
121    enum ResourceIdentifierType {
122        SchemaGrammar = 0,
123        SchemaImport,
124        SchemaInclude,
125        SchemaRedefine ,
126        ExternalEntity,
127        UnKnown = 255
128    //@{
129    };
130
131    /** @name Constructors and Destructor */
132
133    /** Constructor */
134
135    XMLResourceIdentifier(const ResourceIdentifierType resourceIdentitiferType
136                            , const XMLCh* const  systemId
137                            , const XMLCh* const  nameSpace = 0
138                            , const XMLCh* const  publicId = 0
139                            , const XMLCh* const  baseURI = 0);
140
141    /** Destructor */
142    ~XMLResourceIdentifier()
143    {
144    }
145
146    //@}
147
148    // -----------------------------------------------------------------------
149    //  Getter methods
150    // -----------------------------------------------------------------------
151    ResourceIdentifierType getResourceIdentifierType() const;
152    const XMLCh* getPublicId()          const;
153    const XMLCh* getSystemId()          const;
154    const XMLCh* getSchemaLocation()    const;
155    const XMLCh* getBaseURI()           const;
156    const XMLCh* getNameSpace()         const;
157
158private :
159
160    const ResourceIdentifierType    fResourceIdentifierType;
161    const XMLCh*                    fPublicId;
162    const XMLCh*                    fSystemId;
163    const XMLCh*                    fBaseURI;
164    const XMLCh*                    fNameSpace;
165
166
167    /* Unimplemented constructors and operators */
168
169    /* Copy constructor */
170    XMLResourceIdentifier(const XMLResourceIdentifier&);
171
172    /* Assignment operator */
173    XMLResourceIdentifier& operator=(const XMLResourceIdentifier&);
174
175};
176
177inline XMLResourceIdentifier::ResourceIdentifierType XMLResourceIdentifier::getResourceIdentifierType() const
178{
179    return fResourceIdentifierType;
180}
181
182inline const XMLCh* XMLResourceIdentifier::getPublicId() const
183{
184    return fPublicId;
185}
186
187inline const XMLCh* XMLResourceIdentifier::getSystemId() const
188{
189    return fSystemId;
190}
191
192inline const XMLCh* XMLResourceIdentifier::getSchemaLocation() const
193{
194    return fSystemId;
195}
196
197inline const XMLCh* XMLResourceIdentifier::getBaseURI() const
198{
199    return fBaseURI;
200}
201
202inline const XMLCh* XMLResourceIdentifier::getNameSpace() const
203{
204    return fNameSpace;
205}
206
207inline XMLResourceIdentifier::XMLResourceIdentifier(const ResourceIdentifierType resourceIdentifierType
208                            , const XMLCh* const  systemId
209                            , const XMLCh* const  nameSpace
210                            , const XMLCh* const  publicId
211                            , const XMLCh* const  baseURI )
212    : fResourceIdentifierType(resourceIdentifierType)
213    , fPublicId(publicId)
214    , fSystemId(systemId)
215    , fBaseURI(baseURI)
216    , fNameSpace(nameSpace)   
217{
218}
219
220XERCES_CPP_NAMESPACE_END
221
222#endif
Note: See TracBrowser for help on using the repository browser.