Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-15 10:32:52

0001 /*
0002  * Licensed to the Apache Software Foundation (ASF) under one or more
0003  * contributor license agreements.  See the NOTICE file distributed with
0004  * this work for additional information regarding copyright ownership.
0005  * The ASF licenses this file to You under the Apache License, Version 2.0
0006  * (the "License"); you may not use this file except in compliance with
0007  * the License.  You may obtain a copy of the License at
0008  * 
0009  *      http://www.apache.org/licenses/LICENSE-2.0
0010  * 
0011  * Unless required by applicable law or agreed to in writing, software
0012  * distributed under the License is distributed on an "AS IS" BASIS,
0013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014  * See the License for the specific language governing permissions and
0015  * limitations under the License.
0016  */
0017 
0018 /*
0019  * $Id$
0020  */
0021 
0022 #if !defined(XERCESC_INCLUDE_GUARD_ENTITYRESOLVER_HPP)
0023 #define XERCESC_INCLUDE_GUARD_ENTITYRESOLVER_HPP
0024 
0025 #include <xercesc/util/XercesDefs.hpp>
0026 
0027 XERCES_CPP_NAMESPACE_BEGIN
0028 
0029 class InputSource;
0030 
0031 /**
0032   * Basic interface for resolving entities.
0033   *
0034   * <p>If a SAX application needs to implement customized handling
0035   * for external entities, it must implement this interface and
0036   * register an instance with the SAX parser using the parser's
0037   * setEntityResolver method.</p>
0038   *
0039   * <p>The parser will then allow the application to intercept any
0040   * external entities (including the external DTD subset and external
0041   * parameter entities, if any) before including them.</p>
0042   *
0043   * <p>Many SAX applications will not need to implement this interface,
0044   * but it will be especially useful for applications that build
0045   * XML documents from databases or other specialised input sources,
0046   * or for applications that use URI types other than URLs.</p>
0047   *
0048   * <p>The following resolver would provide the application
0049   * with a special character stream for the entity with the system
0050   * identifier "http://www.myhost.com/today":</p>
0051   *
0052   *<code>
0053   *\#include <xercesc/sax/EntityResolver.hpp><br>
0054   *\#include <xercesc/sax/InputSource.hpp><br>
0055   *<br>
0056   *class MyResolver : public EntityResolver {<br>
0057   *  public:<br>&nbsp;
0058   *    InputSource* resolveEntity (const XMLCh* const publicId, const XMLCh* const systemId);<br>&nbsp;&nbsp;
0059   *    <br>
0060   *   ...<br>&nbsp;&nbsp;
0061   *   };<br>&nbsp;
0062   *<br>
0063   *&nbsp;MyResolver::resolveEntity {<br>
0064   *&nbsp;&nbsp;if (XMLString::compareString(systemId, "http://www.myhost.com/today")) {<br>
0065   *&nbsp;&nbsp;&nbsp;MyReader* reader = new MyReader();<br>
0066   *&nbsp;&nbsp;&nbsp;return new InputSource(reader);<br>
0067   *&nbsp;&nbsp;} else {<br>
0068   *&nbsp;&nbsp;&nbsp;return null;<br>
0069   *&nbsp;&nbsp;}<br>
0070   *&nbsp;}<br>
0071   *<br>
0072   *</code>
0073   *
0074   * <p>The application can also use this interface to redirect system
0075   * identifiers to local URIs or to look up replacements in a catalog
0076   * (possibly by using the public identifier).</p>
0077   *
0078   * <p>The HandlerBase class implements the default behaviour for
0079   * this interface, which is simply always to return null (to request
0080   * that the parser use the default system identifier).</p>
0081   *
0082   * @see Parser#setEntityResolver
0083   * @see InputSource#InputSource
0084   * @see HandlerBase#HandlerBase
0085   */
0086 class SAX_EXPORT EntityResolver
0087 {
0088 public:
0089     /** @name Constructors and Destructor */
0090     //@{
0091 
0092     /** Default Constructor */
0093     EntityResolver()
0094     {
0095     }
0096 
0097     /** Destructor */
0098     virtual ~EntityResolver()
0099     {
0100     }
0101 
0102     //@}
0103 
0104     /** @name The EntityResolver interface */
0105     //@{
0106 
0107   /**
0108     * Allow the application to resolve external entities.
0109     *
0110     * <p>The Parser will call this method before opening any external
0111     * entity except the top-level document entity (including the
0112     * external DTD subset, external entities referenced within the
0113     * DTD, and external entities referenced within the document
0114     * element): the application may request that the parser resolve
0115     * the entity itself, that it use an alternative URI, or that it
0116     * use an entirely different input source.</p>
0117     *
0118     * <p>Application writers can use this method to redirect external
0119     * system identifiers to secure and/or local URIs, to look up
0120     * public identifiers in a catalogue, or to read an entity from a
0121     * database or other input source (including, for example, a dialog
0122     * box).</p>
0123     *
0124     * <p>If the system identifier is a URL, the SAX parser must
0125     * resolve it fully before reporting it to the application.</p>
0126     *
0127     * @param publicId The public identifier of the external entity
0128     *        being referenced, or null if none was supplied.
0129     * @param systemId The system identifier of the external entity
0130     *        being referenced.
0131     * @return An InputSource object describing the new input source,
0132     *         or null to request that the parser open a regular
0133     *         URI connection to the system identifier.
0134     *         The returned InputSource is owned by the parser which is
0135     *         responsible to clean up the memory.
0136     * @exception SAXException Any SAX exception, possibly
0137     *            wrapping another exception.
0138     * @exception IOException An IO exception,
0139     *            possibly the result of creating a new InputStream
0140     *            or Reader for the InputSource.
0141     * @see InputSource#InputSource
0142     */
0143     virtual InputSource* resolveEntity
0144     (
0145         const   XMLCh* const    publicId
0146         , const XMLCh* const    systemId
0147     ) = 0;
0148 
0149     //@}
0150 
0151 private :
0152     /* Unimplemented constructors and operators */
0153 
0154 
0155     /* Copy constructor */
0156     EntityResolver(const EntityResolver&);
0157 
0158     /* Assignment operator */
0159     EntityResolver& operator=(const EntityResolver&);
0160 
0161 };
0162 
0163 XERCES_CPP_NAMESPACE_END
0164 
0165 #endif