[188] | 1 | /*
|
---|
| 2 | * The Apache Software License, Version 1.1
|
---|
| 3 | *
|
---|
| 4 | * Copyright (c) 2001-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) 2001, 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: XercesDOMParser.hpp,v 1.18 2004/01/29 11:46:32 cargilld Exp $
|
---|
| 59 | *
|
---|
| 60 | */
|
---|
| 61 |
|
---|
| 62 | #if !defined(XercesDOMParser_HPP)
|
---|
| 63 | #define XercesDOMParser_HPP
|
---|
| 64 |
|
---|
| 65 |
|
---|
| 66 | #include <xercesc/parsers/AbstractDOMParser.hpp>
|
---|
| 67 |
|
---|
| 68 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
| 69 |
|
---|
| 70 |
|
---|
| 71 | class EntityResolver;
|
---|
| 72 | class ErrorHandler;
|
---|
| 73 | class Grammar;
|
---|
| 74 | class XMLEntityResolver;
|
---|
| 75 | class XMLResourceIdentifier;
|
---|
| 76 |
|
---|
| 77 | /**
|
---|
| 78 | * This class implements the Document Object Model (DOM) interface.
|
---|
| 79 | * It should be used by applications which choose to parse and
|
---|
| 80 | * process the XML document using the DOM api's. This implementation
|
---|
| 81 | * also allows the applications to install an error and an entitty
|
---|
| 82 | * handler (useful extensions to the DOM specification).
|
---|
| 83 | *
|
---|
| 84 | * <p>It can be used to instantiate a validating or non-validating
|
---|
| 85 | * parser, by setting a member flag.</p>
|
---|
| 86 | */
|
---|
| 87 | class PARSERS_EXPORT XercesDOMParser : public AbstractDOMParser
|
---|
| 88 | {
|
---|
| 89 | public :
|
---|
| 90 | // -----------------------------------------------------------------------
|
---|
| 91 | // Constructors and Detructor
|
---|
| 92 | // -----------------------------------------------------------------------
|
---|
| 93 |
|
---|
| 94 | /** @name Constructors and Destructor */
|
---|
| 95 | //@{
|
---|
| 96 | /** Construct a XercesDOMParser, with an optional validator
|
---|
| 97 | *
|
---|
| 98 | * Constructor with an instance of validator class to use for
|
---|
| 99 | * validation. If you don't provide a validator, a default one will
|
---|
| 100 | * be created for you in the scanner.
|
---|
| 101 | *
|
---|
| 102 | * @param gramPool Pointer to the grammar pool instance from
|
---|
| 103 | * external application.
|
---|
| 104 | * The parser does NOT own it.
|
---|
| 105 | *
|
---|
| 106 | * @param valToAdopt Pointer to the validator instance to use. The
|
---|
| 107 | * parser is responsible for freeing the memory.
|
---|
| 108 | * @param manager Pointer to the memory manager to be used to
|
---|
| 109 | * allocate objects.
|
---|
| 110 | */
|
---|
| 111 | XercesDOMParser
|
---|
| 112 | (
|
---|
| 113 | XMLValidator* const valToAdopt = 0
|
---|
| 114 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
|
---|
| 115 | , XMLGrammarPool* const gramPool = 0
|
---|
| 116 | );
|
---|
| 117 |
|
---|
| 118 | /**
|
---|
| 119 | * Destructor
|
---|
| 120 | */
|
---|
| 121 | virtual ~XercesDOMParser();
|
---|
| 122 |
|
---|
| 123 | //@}
|
---|
| 124 |
|
---|
| 125 |
|
---|
| 126 | // -----------------------------------------------------------------------
|
---|
| 127 | // Getter methods
|
---|
| 128 | // -----------------------------------------------------------------------
|
---|
| 129 |
|
---|
| 130 | /** @name Getter methods */
|
---|
| 131 | //@{
|
---|
| 132 |
|
---|
| 133 | /** Get a pointer to the error handler
|
---|
| 134 | *
|
---|
| 135 | * This method returns the installed error handler. If no handler
|
---|
| 136 | * has been installed, then it will be a zero pointer.
|
---|
| 137 | *
|
---|
| 138 | * @return The pointer to the installed error handler object.
|
---|
| 139 | */
|
---|
| 140 | ErrorHandler* getErrorHandler();
|
---|
| 141 |
|
---|
| 142 | /** Get a const pointer to the error handler
|
---|
| 143 | *
|
---|
| 144 | * This method returns the installed error handler. If no handler
|
---|
| 145 | * has been installed, then it will be a zero pointer.
|
---|
| 146 | *
|
---|
| 147 | * @return A const pointer to the installed error handler object.
|
---|
| 148 | */
|
---|
| 149 | const ErrorHandler* getErrorHandler() const;
|
---|
| 150 |
|
---|
| 151 | /** Get a pointer to the entity resolver
|
---|
| 152 | *
|
---|
| 153 | * This method returns the installed entity resolver. If no resolver
|
---|
| 154 | * has been installed, then it will be a zero pointer.
|
---|
| 155 | *
|
---|
| 156 | * @return The pointer to the installed entity resolver object.
|
---|
| 157 | */
|
---|
| 158 | EntityResolver* getEntityResolver();
|
---|
| 159 |
|
---|
| 160 | /** Get a const pointer to the entity resolver
|
---|
| 161 | *
|
---|
| 162 | * This method returns the installed entity resolver. If no resolver
|
---|
| 163 | * has been installed, then it will be a zero pointer.
|
---|
| 164 | *
|
---|
| 165 | * @return A const pointer to the installed entity resolver object.
|
---|
| 166 | */
|
---|
| 167 | const EntityResolver* getEntityResolver() const;
|
---|
| 168 |
|
---|
| 169 | /**
|
---|
| 170 | * Get a pointer to the entity resolver
|
---|
| 171 | *
|
---|
| 172 | * This method returns the installed entity resolver. If no resolver
|
---|
| 173 | * has been installed, then it will be a zero pointer.
|
---|
| 174 | *
|
---|
| 175 | * @return The pointer to the installed entity resolver object.
|
---|
| 176 | */
|
---|
| 177 | XMLEntityResolver* getXMLEntityResolver();
|
---|
| 178 |
|
---|
| 179 | /**
|
---|
| 180 | * Get a const pointer to the entity resolver
|
---|
| 181 | *
|
---|
| 182 | * This method returns the installed entity resolver. If no resolver
|
---|
| 183 | * has been installed, then it will be a zero pointer.
|
---|
| 184 | *
|
---|
| 185 | * @return A const pointer to the installed entity resolver object.
|
---|
| 186 | */
|
---|
| 187 | const XMLEntityResolver* getXMLEntityResolver() const;
|
---|
| 188 |
|
---|
| 189 | /** Get the 'Grammar caching' flag
|
---|
| 190 | *
|
---|
| 191 | * This method returns the state of the parser's grammar caching when
|
---|
| 192 | * parsing an XML document.
|
---|
| 193 | *
|
---|
| 194 | * @return true, if the parser is currently configured to
|
---|
| 195 | * cache grammars, false otherwise.
|
---|
| 196 | *
|
---|
| 197 | * @see #cacheGrammarFromParse
|
---|
| 198 | */
|
---|
| 199 | bool isCachingGrammarFromParse() const;
|
---|
| 200 |
|
---|
| 201 | /** Get the 'Use cached grammar' flag
|
---|
| 202 | *
|
---|
| 203 | * This method returns the state of the parser's use of cached grammar
|
---|
| 204 | * when parsing an XML document.
|
---|
| 205 | *
|
---|
| 206 | * @return true, if the parser is currently configured to
|
---|
| 207 | * use cached grammars, false otherwise.
|
---|
| 208 | *
|
---|
| 209 | * @see #useCachedGrammarInParse
|
---|
| 210 | */
|
---|
| 211 | bool isUsingCachedGrammarInParse() const;
|
---|
| 212 |
|
---|
| 213 | /**
|
---|
| 214 | * Retrieve the grammar that is associated with the specified namespace key
|
---|
| 215 | *
|
---|
| 216 | * @param nameSpaceKey Namespace key
|
---|
| 217 | * @return Grammar associated with the Namespace key.
|
---|
| 218 | */
|
---|
| 219 | Grammar* getGrammar(const XMLCh* const nameSpaceKey);
|
---|
| 220 |
|
---|
| 221 | /**
|
---|
| 222 | * Retrieve the grammar where the root element is declared.
|
---|
| 223 | *
|
---|
| 224 | * @return Grammar where root element declared
|
---|
| 225 | */
|
---|
| 226 | Grammar* getRootGrammar();
|
---|
| 227 |
|
---|
| 228 | /**
|
---|
| 229 | * Returns the string corresponding to a URI id from the URI string pool.
|
---|
| 230 | *
|
---|
| 231 | * @param uriId id of the string in the URI string pool.
|
---|
| 232 | * @return URI string corresponding to the URI id.
|
---|
| 233 | */
|
---|
| 234 | const XMLCh* getURIText(unsigned int uriId) const;
|
---|
| 235 |
|
---|
| 236 | /**
|
---|
| 237 | * Returns the current src offset within the input source.
|
---|
| 238 | *
|
---|
| 239 | * @return offset within the input source
|
---|
| 240 | */
|
---|
| 241 | unsigned int getSrcOffset() const;
|
---|
| 242 |
|
---|
| 243 | //@}
|
---|
| 244 |
|
---|
| 245 |
|
---|
| 246 | // -----------------------------------------------------------------------
|
---|
| 247 | // Setter methods
|
---|
| 248 | // -----------------------------------------------------------------------
|
---|
| 249 |
|
---|
| 250 | /** @name Setter methods */
|
---|
| 251 | //@{
|
---|
| 252 |
|
---|
| 253 | /** Set the error handler
|
---|
| 254 | *
|
---|
| 255 | * This method allows applications to install their own error handler
|
---|
| 256 | * to trap error and warning messages.
|
---|
| 257 | *
|
---|
| 258 | * <i>Any previously set handler is merely dropped, since the parser
|
---|
| 259 | * does not own them.</i>
|
---|
| 260 | *
|
---|
| 261 | * @param handler A const pointer to the user supplied error
|
---|
| 262 | * handler.
|
---|
| 263 | *
|
---|
| 264 | * @see #getErrorHandler
|
---|
| 265 | */
|
---|
| 266 | void setErrorHandler(ErrorHandler* const handler);
|
---|
| 267 |
|
---|
| 268 | /** Set the entity resolver
|
---|
| 269 | *
|
---|
| 270 | * This method allows applications to install their own entity
|
---|
| 271 | * resolver. By installing an entity resolver, the applications
|
---|
| 272 | * can trap and potentially redirect references to external
|
---|
| 273 | * entities.
|
---|
| 274 | *
|
---|
| 275 | * <i>Any previously set entity resolver is merely dropped, since the parser
|
---|
| 276 | * does not own them. If both setEntityResolver and setXMLEntityResolver
|
---|
| 277 | * are called, then the last one is used.</i>
|
---|
| 278 | *
|
---|
| 279 | * @param handler A const pointer to the user supplied entity
|
---|
| 280 | * resolver.
|
---|
| 281 | *
|
---|
| 282 | * @see #getEntityResolver
|
---|
| 283 | */
|
---|
| 284 | void setEntityResolver(EntityResolver* const handler);
|
---|
| 285 |
|
---|
| 286 | /**
|
---|
| 287 | * Set the entity resolver
|
---|
| 288 | *
|
---|
| 289 | * This method allows applications to install their own entity
|
---|
| 290 | * resolver. By installing an entity resolver, the applications
|
---|
| 291 | * can trap and potentially redirect references to external
|
---|
| 292 | * entities.
|
---|
| 293 | *
|
---|
| 294 | * <i>Any previously set entity resolver is merely dropped, since the parser
|
---|
| 295 | * does not own them. If both setEntityResolver and setXMLEntityResolver
|
---|
| 296 | * are called, then the last one set is used.</i>
|
---|
| 297 | *
|
---|
| 298 | * @param handler A const pointer to the user supplied entity
|
---|
| 299 | * resolver.
|
---|
| 300 | *
|
---|
| 301 | * @see #getXMLEntityResolver
|
---|
| 302 | */
|
---|
| 303 | void setXMLEntityResolver(XMLEntityResolver* const handler);
|
---|
| 304 |
|
---|
| 305 | /** Set the 'Grammar caching' flag
|
---|
| 306 | *
|
---|
| 307 | * This method allows users to enable or disable caching of grammar when
|
---|
| 308 | * parsing XML documents. When set to true, the parser will cache the
|
---|
| 309 | * resulting grammar for use in subsequent parses.
|
---|
| 310 | *
|
---|
| 311 | * If the flag is set to true, the 'Use cached grammar' flag will also be
|
---|
| 312 | * set to true.
|
---|
| 313 | *
|
---|
| 314 | * The parser's default state is: false.
|
---|
| 315 | *
|
---|
| 316 | * @param newState The value specifying whether we should cache grammars
|
---|
| 317 | * or not.
|
---|
| 318 | *
|
---|
| 319 | * @see #isCachingGrammarFromParse
|
---|
| 320 | * @see #useCachedGrammarInParse
|
---|
| 321 | */
|
---|
| 322 | void cacheGrammarFromParse(const bool newState);
|
---|
| 323 |
|
---|
| 324 | /** Set the 'Use cached grammar' flag
|
---|
| 325 | *
|
---|
| 326 | * This method allows users to enable or disable the use of cached
|
---|
| 327 | * grammars. When set to true, the parser will use the cached grammar,
|
---|
| 328 | * instead of building the grammar from scratch, to validate XML
|
---|
| 329 | * documents.
|
---|
| 330 | *
|
---|
| 331 | * If the 'Grammar caching' flag is set to true, this mehod ignore the
|
---|
| 332 | * value passed in.
|
---|
| 333 | *
|
---|
| 334 | * The parser's default state is: false.
|
---|
| 335 | *
|
---|
| 336 | * @param newState The value specifying whether we should use the cached
|
---|
| 337 | * grammar or not.
|
---|
| 338 | *
|
---|
| 339 | * @see #isUsingCachedGrammarInParse
|
---|
| 340 | * @see #cacheGrammarFromParse
|
---|
| 341 | */
|
---|
| 342 | void useCachedGrammarInParse(const bool newState);
|
---|
| 343 |
|
---|
| 344 | //@}
|
---|
| 345 |
|
---|
| 346 | // -----------------------------------------------------------------------
|
---|
| 347 | // Utility methods
|
---|
| 348 | // -----------------------------------------------------------------------
|
---|
| 349 |
|
---|
| 350 | /** @name Utility methods */
|
---|
| 351 | //@{
|
---|
| 352 | /** Reset the documents vector pool and release all the associated memory
|
---|
| 353 | * back to the system.
|
---|
| 354 | *
|
---|
| 355 | * When parsing a document using a DOM parser, all memory allocated
|
---|
| 356 | * for a DOM tree is associated to the DOM document.
|
---|
| 357 | *
|
---|
| 358 | * If you do multiple parse using the same DOM parser instance, then
|
---|
| 359 | * multiple DOM documents will be generated and saved in a vector pool.
|
---|
| 360 | * All these documents (and thus all the allocated memory)
|
---|
| 361 | * won't be deleted until the parser instance is destroyed.
|
---|
| 362 | *
|
---|
| 363 | * If you don't need these DOM documents anymore and don't want to
|
---|
| 364 | * destroy the DOM parser instance at this moment, then you can call this method
|
---|
| 365 | * to reset the document vector pool and release all the allocated memory
|
---|
| 366 | * back to the system.
|
---|
| 367 | *
|
---|
| 368 | * It is an error to call this method if you are in the middle of a
|
---|
| 369 | * parse (e.g. in the mid of a progressive parse).
|
---|
| 370 | *
|
---|
| 371 | * @exception IOException An exception from the parser if this function
|
---|
| 372 | * is called when a parse is in progress.
|
---|
| 373 | *
|
---|
| 374 | */
|
---|
| 375 | void resetDocumentPool();
|
---|
| 376 |
|
---|
| 377 | //@}
|
---|
| 378 |
|
---|
| 379 | // -----------------------------------------------------------------------
|
---|
| 380 | // Implementation of the XMLErrorReporter interface.
|
---|
| 381 | // -----------------------------------------------------------------------
|
---|
| 382 |
|
---|
| 383 | /** @name Implementation of the XMLErrorReporter interface. */
|
---|
| 384 | //@{
|
---|
| 385 |
|
---|
| 386 | /** Handle errors reported from the parser
|
---|
| 387 | *
|
---|
| 388 | * This method is used to report back errors found while parsing the
|
---|
| 389 | * XML file. This method is also borrowed from the SAX specification.
|
---|
| 390 | * It calls the corresponding user installed Error Handler method:
|
---|
| 391 | * 'fatal', 'error', 'warning' depending on the severity of the error.
|
---|
| 392 | * This classification is defined by the XML specification.
|
---|
| 393 | *
|
---|
| 394 | * @param errCode An integer code for the error.
|
---|
| 395 | * @param msgDomain A const pointer to an Unicode string representing
|
---|
| 396 | * the message domain to use.
|
---|
| 397 | * @param errType An enumeration classifying the severity of the error.
|
---|
| 398 | * @param errorText A const pointer to an Unicode string representing
|
---|
| 399 | * the text of the error message.
|
---|
| 400 | * @param systemId A const pointer to an Unicode string representing
|
---|
| 401 | * the system id of the XML file where this error
|
---|
| 402 | * was discovered.
|
---|
| 403 | * @param publicId A const pointer to an Unicode string representing
|
---|
| 404 | * the public id of the XML file where this error
|
---|
| 405 | * was discovered.
|
---|
| 406 | * @param lineNum The line number where the error occurred.
|
---|
| 407 | * @param colNum The column number where the error occurred.
|
---|
| 408 | * @see ErrorHandler
|
---|
| 409 | */
|
---|
| 410 | virtual void error
|
---|
| 411 | (
|
---|
| 412 | const unsigned int errCode
|
---|
| 413 | , const XMLCh* const msgDomain
|
---|
| 414 | , const XMLErrorReporter::ErrTypes errType
|
---|
| 415 | , const XMLCh* const errorText
|
---|
| 416 | , const XMLCh* const systemId
|
---|
| 417 | , const XMLCh* const publicId
|
---|
| 418 | , const XMLSSize_t lineNum
|
---|
| 419 | , const XMLSSize_t colNum
|
---|
| 420 | );
|
---|
| 421 |
|
---|
| 422 | /** Reset any error data before a new parse
|
---|
| 423 | *
|
---|
| 424 | * This method allows the user installed Error Handler callback to
|
---|
| 425 | * 'reset' itself.
|
---|
| 426 | *
|
---|
| 427 | * <b><font color="#FF0000">This method is a no-op for this DOM
|
---|
| 428 | * implementation.</font></b>
|
---|
| 429 | */
|
---|
| 430 | virtual void resetErrors();
|
---|
| 431 | //@}
|
---|
| 432 |
|
---|
| 433 |
|
---|
| 434 | // -----------------------------------------------------------------------
|
---|
| 435 | // Implementation of the XMLEntityHandler interface.
|
---|
| 436 | // -----------------------------------------------------------------------
|
---|
| 437 |
|
---|
| 438 | /** @name Implementation of the XMLEntityHandler interface. */
|
---|
| 439 | //@{
|
---|
| 440 |
|
---|
| 441 | /** Handle an end of input source event
|
---|
| 442 | *
|
---|
| 443 | * This method is used to indicate the end of parsing of an external
|
---|
| 444 | * entity file.
|
---|
| 445 | *
|
---|
| 446 | * <b><font color="#FF0000">This method is a no-op for this DOM
|
---|
| 447 | * implementation.</font></b>
|
---|
| 448 | *
|
---|
| 449 | * @param inputSource A const reference to the InputSource object
|
---|
| 450 | * which points to the XML file being parsed.
|
---|
| 451 | * @see InputSource
|
---|
| 452 | */
|
---|
| 453 | virtual void endInputSource(const InputSource& inputSource);
|
---|
| 454 |
|
---|
| 455 | /** Expand a system id
|
---|
| 456 | *
|
---|
| 457 | * This method allows an installed XMLEntityHandler to further
|
---|
| 458 | * process any system id's of enternal entities encountered in
|
---|
| 459 | * the XML file being parsed, such as redirection etc.
|
---|
| 460 | *
|
---|
| 461 | * <b><font color="#FF0000">This method always returns 'false'
|
---|
| 462 | * for this DOM implementation.</font></b>
|
---|
| 463 | *
|
---|
| 464 | * @param systemId A const pointer to an Unicode string representing
|
---|
| 465 | * the system id scanned by the parser.
|
---|
| 466 | * @param toFill A pointer to a buffer in which the application
|
---|
| 467 | * processed system id is stored.
|
---|
| 468 | * @return 'true', if any processing is done, 'false' otherwise.
|
---|
| 469 | */
|
---|
| 470 | virtual bool expandSystemId
|
---|
| 471 | (
|
---|
| 472 | const XMLCh* const systemId
|
---|
| 473 | , XMLBuffer& toFill
|
---|
| 474 | );
|
---|
| 475 |
|
---|
| 476 | /** Reset any entity handler information
|
---|
| 477 | *
|
---|
| 478 | * This method allows the installed XMLEntityHandler to reset
|
---|
| 479 | * itself.
|
---|
| 480 | *
|
---|
| 481 | * <b><font color="#FF0000">This method is a no-op for this DOM
|
---|
| 482 | * implementation.</font></b>
|
---|
| 483 | */
|
---|
| 484 | virtual void resetEntities();
|
---|
| 485 |
|
---|
| 486 | /** Resolve a public/system id
|
---|
| 487 | *
|
---|
| 488 | * This method allows a user installed entity handler to further
|
---|
| 489 | * process any pointers to external entities. The applications can
|
---|
| 490 | * implement 'redirection' via this callback. This method is also
|
---|
| 491 | * borrowed from the SAX specification.
|
---|
| 492 | *
|
---|
| 493 | * @deprecated This method is no longer called (the other resolveEntity one is).
|
---|
| 494 | *
|
---|
| 495 | * @param publicId A const pointer to a Unicode string representing the
|
---|
| 496 | * public id of the entity just parsed.
|
---|
| 497 | * @param systemId A const pointer to a Unicode string representing the
|
---|
| 498 | * system id of the entity just parsed.
|
---|
| 499 | * @param baseURI A const pointer to a Unicode string representing the
|
---|
| 500 | * base URI of the entity just parsed,
|
---|
| 501 | * or <code>null</code> if there is no base URI.
|
---|
| 502 | * @return The value returned by the user installed resolveEntity
|
---|
| 503 | * method or NULL otherwise to indicate no processing was done.
|
---|
| 504 | * The returned InputSource is owned by the parser which is
|
---|
| 505 | * responsible to clean up the memory.
|
---|
| 506 | * @see DOMEntityResolver
|
---|
| 507 | * @see XMLEntityHandler
|
---|
| 508 | */
|
---|
| 509 | virtual InputSource* resolveEntity
|
---|
| 510 | (
|
---|
| 511 | const XMLCh* const publicId
|
---|
| 512 | , const XMLCh* const systemId
|
---|
| 513 | , const XMLCh* const baseURI = 0
|
---|
| 514 | );
|
---|
| 515 |
|
---|
| 516 | /** Resolve a public/system id
|
---|
| 517 | *
|
---|
| 518 | * This method allows a user installed entity handler to further
|
---|
| 519 | * process any pointers to external entities. The applications can
|
---|
| 520 | * implement 'redirection' via this callback.
|
---|
| 521 | *
|
---|
| 522 | * @param resourceIdentifier An object containing the type of
|
---|
| 523 | * resource to be resolved and the associated data members
|
---|
| 524 | * corresponding to this type.
|
---|
| 525 | * @return The value returned by the user installed resolveEntity
|
---|
| 526 | * method or NULL otherwise to indicate no processing was done.
|
---|
| 527 | * The returned InputSource is owned by the parser which is
|
---|
| 528 | * responsible to clean up the memory.
|
---|
| 529 | * @see XMLEntityHandler
|
---|
| 530 | * @see XMLEntityResolver
|
---|
| 531 | */
|
---|
| 532 | virtual InputSource* resolveEntity
|
---|
| 533 | (
|
---|
| 534 | XMLResourceIdentifier* resourceIdentifier
|
---|
| 535 | );
|
---|
| 536 |
|
---|
| 537 | /** Handle a 'start input source' event
|
---|
| 538 | *
|
---|
| 539 | * This method is used to indicate the start of parsing an external
|
---|
| 540 | * entity file.
|
---|
| 541 | *
|
---|
| 542 | * <b><font color="#FF0000">This method is a no-op for this DOM parse
|
---|
| 543 | * implementation.</font></b>
|
---|
| 544 | *
|
---|
| 545 | * @param inputSource A const reference to the InputSource object
|
---|
| 546 | * which points to the external entity
|
---|
| 547 | * being parsed.
|
---|
| 548 | */
|
---|
| 549 | virtual void startInputSource(const InputSource& inputSource);
|
---|
| 550 |
|
---|
| 551 | //@}
|
---|
| 552 |
|
---|
| 553 | // -----------------------------------------------------------------------
|
---|
| 554 | // Grammar preparsing interface
|
---|
| 555 | // -----------------------------------------------------------------------
|
---|
| 556 |
|
---|
| 557 | /** @name Implementation of Grammar preparsing interface's. */
|
---|
| 558 | //@{
|
---|
| 559 | /**
|
---|
| 560 | * Preparse schema grammar (XML Schema, DTD, etc.) via an input source
|
---|
| 561 | * object.
|
---|
| 562 | *
|
---|
| 563 | * This method invokes the preparsing process on a schema grammar XML
|
---|
| 564 | * file specified by the SAX InputSource parameter. If the 'toCache' flag
|
---|
| 565 | * is enabled, the parser will cache the grammars for re-use. If a grammar
|
---|
| 566 | * key is found in the pool, no caching of any grammar will take place.
|
---|
| 567 | *
|
---|
| 568 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
| 569 | *
|
---|
| 570 | * @param source A const reference to the SAX InputSource object which
|
---|
| 571 | * points to the schema grammar file to be preparsed.
|
---|
| 572 | * @param grammarType The grammar type (Schema or DTD).
|
---|
| 573 | * @param toCache If <code>true</code>, we cache the preparsed grammar,
|
---|
| 574 | * otherwise, no chaching. Default is <code>false</code>.
|
---|
| 575 | * @return The preparsed schema grammar object (SchemaGrammar or
|
---|
| 576 | * DTDGrammar). That grammar object is owned by the parser.
|
---|
| 577 | *
|
---|
| 578 | * @exception SAXException Any SAX exception, possibly
|
---|
| 579 | * wrapping another exception.
|
---|
| 580 | * @exception XMLException An exception from the parser or client
|
---|
| 581 | * handler code.
|
---|
| 582 | * @exception DOMException A DOM exception as per DOM spec.
|
---|
| 583 | *
|
---|
| 584 | * @see InputSource#InputSource
|
---|
| 585 | */
|
---|
| 586 | Grammar* loadGrammar(const InputSource& source,
|
---|
| 587 | const short grammarType,
|
---|
| 588 | const bool toCache = false);
|
---|
| 589 |
|
---|
| 590 | /**
|
---|
| 591 | * Preparse schema grammar (XML Schema, DTD, etc.) via a file path or URL
|
---|
| 592 | *
|
---|
| 593 | * This method invokes the preparsing process on a schema grammar XML
|
---|
| 594 | * file specified by the file path parameter. If the 'toCache' flag
|
---|
| 595 | * is enabled, the parser will cache the grammars for re-use. If a grammar
|
---|
| 596 | * key is found in the pool, no caching of any grammar will take place.
|
---|
| 597 | *
|
---|
| 598 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
| 599 | *
|
---|
| 600 | * @param systemId A const XMLCh pointer to the Unicode string which
|
---|
| 601 | * contains the path to the XML grammar file to be
|
---|
| 602 | * preparsed.
|
---|
| 603 | * @param grammarType The grammar type (Schema or DTD).
|
---|
| 604 | * @param toCache If <code>true</code>, we cache the preparsed grammar,
|
---|
| 605 | * otherwise, no chaching. Default is <code>false</code>.
|
---|
| 606 | * @return The preparsed schema grammar object (SchemaGrammar or
|
---|
| 607 | * DTDGrammar). That grammar object is owned by the parser.
|
---|
| 608 | *
|
---|
| 609 | * @exception SAXException Any SAX exception, possibly
|
---|
| 610 | * wrapping another exception.
|
---|
| 611 | * @exception XMLException An exception from the parser or client
|
---|
| 612 | * handler code.
|
---|
| 613 | * @exception DOMException A DOM exception as per DOM spec.
|
---|
| 614 | */
|
---|
| 615 | Grammar* loadGrammar(const XMLCh* const systemId,
|
---|
| 616 | const short grammarType,
|
---|
| 617 | const bool toCache = false);
|
---|
| 618 |
|
---|
| 619 | /**
|
---|
| 620 | * Preparse schema grammar (XML Schema, DTD, etc.) via a file path or URL
|
---|
| 621 | *
|
---|
| 622 | * This method invokes the preparsing process on a schema grammar XML
|
---|
| 623 | * file specified by the file path parameter. If the 'toCache' flag
|
---|
| 624 | * is enabled, the parser will cache the grammars for re-use. If a grammar
|
---|
| 625 | * key is found in the pool, no caching of any grammar will take place.
|
---|
| 626 | *
|
---|
| 627 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
| 628 | *
|
---|
| 629 | * @param systemId A const char pointer to a native string which contains
|
---|
| 630 | * the path to the XML grammar file to be preparsed.
|
---|
| 631 | * @param grammarType The grammar type (Schema or DTD).
|
---|
| 632 | * @param toCache If <code>true</code>, we cache the preparsed grammar,
|
---|
| 633 | * otherwise, no chaching. Default is <code>false</code>.
|
---|
| 634 | * @return The preparsed schema grammar object (SchemaGrammar or
|
---|
| 635 | * DTDGrammar). That grammar object is owned by the parser.
|
---|
| 636 | *
|
---|
| 637 | * @exception SAXException Any SAX exception, possibly
|
---|
| 638 | * wrapping another exception.
|
---|
| 639 | * @exception XMLException An exception from the parser or client
|
---|
| 640 | * handler code.
|
---|
| 641 | * @exception DOMException A DOM exception as per DOM spec.
|
---|
| 642 | */
|
---|
| 643 | Grammar* loadGrammar(const char* const systemId,
|
---|
| 644 | const short grammarType,
|
---|
| 645 | const bool toCache = false);
|
---|
| 646 |
|
---|
| 647 | /**
|
---|
| 648 | * This method allows the user to reset the pool of cached grammars.
|
---|
| 649 | */
|
---|
| 650 | void resetCachedGrammarPool();
|
---|
| 651 |
|
---|
| 652 | //@}
|
---|
| 653 |
|
---|
| 654 |
|
---|
| 655 | private :
|
---|
| 656 | // -----------------------------------------------------------------------
|
---|
| 657 | // Unimplemented constructors and operators
|
---|
| 658 | // -----------------------------------------------------------------------
|
---|
| 659 | XercesDOMParser(const XercesDOMParser&);
|
---|
| 660 | XercesDOMParser& operator=(const XercesDOMParser&);
|
---|
| 661 |
|
---|
| 662 | // -----------------------------------------------------------------------
|
---|
| 663 | // Private data members
|
---|
| 664 | //
|
---|
| 665 | // fEntityResolver
|
---|
| 666 | // The installed SAX entity resolver, if any. Null if none.
|
---|
| 667 | //
|
---|
| 668 | // fErrorHandler
|
---|
| 669 | // The installed SAX error handler, if any. Null if none.
|
---|
| 670 | //-----------------------------------------------------------------------
|
---|
| 671 | EntityResolver* fEntityResolver;
|
---|
| 672 | XMLEntityResolver* fXMLEntityResolver;
|
---|
| 673 | ErrorHandler* fErrorHandler;
|
---|
| 674 | };
|
---|
| 675 |
|
---|
| 676 |
|
---|
| 677 |
|
---|
| 678 | // ---------------------------------------------------------------------------
|
---|
| 679 | // XercesDOMParser: Handlers for the XMLEntityHandler interface
|
---|
| 680 | // ---------------------------------------------------------------------------
|
---|
| 681 | inline void XercesDOMParser::endInputSource(const InputSource&)
|
---|
| 682 | {
|
---|
| 683 | // The DOM entity resolver doesn't handle this
|
---|
| 684 | }
|
---|
| 685 |
|
---|
| 686 | inline bool XercesDOMParser::expandSystemId(const XMLCh* const, XMLBuffer&)
|
---|
| 687 | {
|
---|
| 688 | // The DOM entity resolver doesn't handle this
|
---|
| 689 | return false;
|
---|
| 690 | }
|
---|
| 691 |
|
---|
| 692 | inline void XercesDOMParser::resetEntities()
|
---|
| 693 | {
|
---|
| 694 | // Nothing to do on this one
|
---|
| 695 | }
|
---|
| 696 |
|
---|
| 697 | inline void XercesDOMParser::startInputSource(const InputSource&)
|
---|
| 698 | {
|
---|
| 699 | // The DOM entity resolver doesn't handle this
|
---|
| 700 | }
|
---|
| 701 |
|
---|
| 702 |
|
---|
| 703 | // ---------------------------------------------------------------------------
|
---|
| 704 | // XercesDOMParser: Getter methods
|
---|
| 705 | // ---------------------------------------------------------------------------
|
---|
| 706 | inline ErrorHandler* XercesDOMParser::getErrorHandler()
|
---|
| 707 | {
|
---|
| 708 | return fErrorHandler;
|
---|
| 709 | }
|
---|
| 710 |
|
---|
| 711 | inline const ErrorHandler* XercesDOMParser::getErrorHandler() const
|
---|
| 712 | {
|
---|
| 713 | return fErrorHandler;
|
---|
| 714 | }
|
---|
| 715 |
|
---|
| 716 | inline EntityResolver* XercesDOMParser::getEntityResolver()
|
---|
| 717 | {
|
---|
| 718 | return fEntityResolver;
|
---|
| 719 | }
|
---|
| 720 |
|
---|
| 721 | inline const EntityResolver* XercesDOMParser::getEntityResolver() const
|
---|
| 722 | {
|
---|
| 723 | return fEntityResolver;
|
---|
| 724 | }
|
---|
| 725 |
|
---|
| 726 | inline XMLEntityResolver* XercesDOMParser::getXMLEntityResolver()
|
---|
| 727 | {
|
---|
| 728 | return fXMLEntityResolver;
|
---|
| 729 | }
|
---|
| 730 |
|
---|
| 731 | inline const XMLEntityResolver* XercesDOMParser::getXMLEntityResolver() const
|
---|
| 732 | {
|
---|
| 733 | return fXMLEntityResolver;
|
---|
| 734 | }
|
---|
| 735 |
|
---|
| 736 | XERCES_CPP_NAMESPACE_END
|
---|
| 737 |
|
---|
| 738 | #endif
|
---|