[188] | 1 | /*
|
---|
| 2 | * The Apache Software License, Version 1.1
|
---|
| 3 | *
|
---|
| 4 | * Copyright (c) 2002, 2003 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: AbstractDOMParser.hpp,v 1.27 2004/01/29 11:46:32 cargilld Exp $
|
---|
| 59 | *
|
---|
| 60 | */
|
---|
| 61 | #if !defined(ABSTRACTDOMPARSER_HPP)
|
---|
| 62 | #define ABSTRACTDOMPARSER_HPP
|
---|
| 63 |
|
---|
| 64 | #include <xercesc/dom/DOMDocument.hpp>
|
---|
| 65 | #include <xercesc/framework/XMLDocumentHandler.hpp>
|
---|
| 66 | #include <xercesc/framework/XMLErrorReporter.hpp>
|
---|
| 67 | #include <xercesc/framework/XMLEntityHandler.hpp>
|
---|
| 68 | #include <xercesc/util/SecurityManager.hpp>
|
---|
| 69 | #include <xercesc/util/ValueStackOf.hpp>
|
---|
| 70 | #include <xercesc/validators/DTD/DocTypeHandler.hpp>
|
---|
| 71 | #include <xercesc/dom/DOMDocumentType.hpp>
|
---|
| 72 | #include <xercesc/validators/DTD/DTDElementDecl.hpp>
|
---|
| 73 | #include <xercesc/framework/XMLBufferMgr.hpp>
|
---|
| 74 |
|
---|
| 75 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
| 76 |
|
---|
| 77 | class XMLPScanToken;
|
---|
| 78 | class XMLScanner;
|
---|
| 79 | class XMLValidator;
|
---|
| 80 | class DOMDocumentImpl;
|
---|
| 81 | class DOMDocumentTypeImpl;
|
---|
| 82 | class DOMElement;
|
---|
| 83 | class GrammarResolver;
|
---|
| 84 | class XMLGrammarPool;
|
---|
| 85 | class PSVIHandler;
|
---|
| 86 |
|
---|
| 87 | /**
|
---|
| 88 | * This class implements the Document Object Model (DOM) interface.
|
---|
| 89 | * It is used as a base for DOM parsers (i.e. XercesDOMParser, DOMBuilder).
|
---|
| 90 | */
|
---|
| 91 | class PARSERS_EXPORT AbstractDOMParser :
|
---|
| 92 |
|
---|
| 93 | public XMemory
|
---|
| 94 | , public XMLDocumentHandler
|
---|
| 95 | , public XMLErrorReporter
|
---|
| 96 | , public XMLEntityHandler
|
---|
| 97 | , public DocTypeHandler
|
---|
| 98 | {
|
---|
| 99 | public :
|
---|
| 100 | // -----------------------------------------------------------------------
|
---|
| 101 | // Class types
|
---|
| 102 | // -----------------------------------------------------------------------
|
---|
| 103 | /** @name Public constants */
|
---|
| 104 | //@{
|
---|
| 105 |
|
---|
| 106 | /** ValScheme enum used in setValidationScheme
|
---|
| 107 | * Val_Never: Do not report validation errors.
|
---|
| 108 | * Val_Always: The parser will always report validation errors.
|
---|
| 109 | * Val_Auto: The parser will report validation errors only if a grammar is specified.
|
---|
| 110 | *
|
---|
| 111 | * @see #setValidationScheme
|
---|
| 112 | */
|
---|
| 113 | enum ValSchemes
|
---|
| 114 | {
|
---|
| 115 | Val_Never
|
---|
| 116 | , Val_Always
|
---|
| 117 | , Val_Auto
|
---|
| 118 | };
|
---|
| 119 | //@}
|
---|
| 120 |
|
---|
| 121 |
|
---|
| 122 | // -----------------------------------------------------------------------
|
---|
| 123 | // Constructors and Detructor
|
---|
| 124 | // -----------------------------------------------------------------------
|
---|
| 125 | /** @name Destructor */
|
---|
| 126 | //@{
|
---|
| 127 |
|
---|
| 128 | /**
|
---|
| 129 | * Destructor
|
---|
| 130 | */
|
---|
| 131 | virtual ~AbstractDOMParser();
|
---|
| 132 |
|
---|
| 133 | //@}
|
---|
| 134 |
|
---|
| 135 | // -----------------------------------------------------------------------
|
---|
| 136 | // Utility methods
|
---|
| 137 | // -----------------------------------------------------------------------
|
---|
| 138 |
|
---|
| 139 | /** @name Utility methods */
|
---|
| 140 | //@{
|
---|
| 141 | /** Reset the parser
|
---|
| 142 | *
|
---|
| 143 | * This method resets the state of the DOM driver and makes
|
---|
| 144 | * it ready for a fresh parse run.
|
---|
| 145 | */
|
---|
| 146 | void reset();
|
---|
| 147 |
|
---|
| 148 | /** Adopt the DOM document
|
---|
| 149 | *
|
---|
| 150 | * This method returns the DOMDocument object representing the
|
---|
| 151 | * root of the document tree.
|
---|
| 152 | *
|
---|
| 153 | * The caller will adopt the DOMDocument and thus is responsible to
|
---|
| 154 | * call DOMDocument::release() to release the associated memory.
|
---|
| 155 | * The parser will not delete it. The ownership is transferred
|
---|
| 156 | * from the parser to the caller.
|
---|
| 157 | *
|
---|
| 158 | * @return The adopted DOMDocument object which represents the entire
|
---|
| 159 | * XML document.
|
---|
| 160 | */
|
---|
| 161 | DOMDocument* adoptDocument();
|
---|
| 162 |
|
---|
| 163 | //@}
|
---|
| 164 |
|
---|
| 165 |
|
---|
| 166 | // -----------------------------------------------------------------------
|
---|
| 167 | // Getter methods
|
---|
| 168 | // -----------------------------------------------------------------------
|
---|
| 169 |
|
---|
| 170 | /** @name Getter methods */
|
---|
| 171 | //@{
|
---|
| 172 |
|
---|
| 173 | /** Get the DOM document
|
---|
| 174 | *
|
---|
| 175 | * This method returns the DOMDocument object representing the
|
---|
| 176 | * root of the document tree. This object provides the primary
|
---|
| 177 | * access to the document's data.
|
---|
| 178 | *
|
---|
| 179 | * The returned DOMDocument object is owned by the parser.
|
---|
| 180 | *
|
---|
| 181 | * @return The DOMDocument object which represents the entire
|
---|
| 182 | * XML document.
|
---|
| 183 | */
|
---|
| 184 | DOMDocument* getDocument();
|
---|
| 185 |
|
---|
| 186 | /** Get a const reference to the validator
|
---|
| 187 | *
|
---|
| 188 | * This method returns a reference to the parser's installed
|
---|
| 189 | * validator.
|
---|
| 190 | *
|
---|
| 191 | * @return A const reference to the installed validator object.
|
---|
| 192 | */
|
---|
| 193 | const XMLValidator& getValidator() const;
|
---|
| 194 |
|
---|
| 195 | /**
|
---|
| 196 | * This method returns an enumerated value that indicates the current
|
---|
| 197 | * validation scheme set on this parser.
|
---|
| 198 | *
|
---|
| 199 | * @return The ValSchemes value current set on this parser.
|
---|
| 200 | * @see #setValidationScheme
|
---|
| 201 | */
|
---|
| 202 | ValSchemes getValidationScheme() const;
|
---|
| 203 |
|
---|
| 204 | /** Get the 'do schema' flag
|
---|
| 205 | *
|
---|
| 206 | * This method returns the state of the parser's schema processing
|
---|
| 207 | * flag.
|
---|
| 208 | *
|
---|
| 209 | * @return true, if the parser is currently configured to
|
---|
| 210 | * understand schema, false otherwise.
|
---|
| 211 | *
|
---|
| 212 | * @see #setDoSchema
|
---|
| 213 | */
|
---|
| 214 | bool getDoSchema() const;
|
---|
| 215 |
|
---|
| 216 | /** Get the 'full schema constraint checking' flag
|
---|
| 217 | *
|
---|
| 218 | * This method returns the state of the parser's full schema constraint
|
---|
| 219 | * checking flag.
|
---|
| 220 | *
|
---|
| 221 | * @return true, if the parser is currently configured to
|
---|
| 222 | * have full schema constraint checking, false otherwise.
|
---|
| 223 | *
|
---|
| 224 | * @see #setValidationSchemaFullChecking
|
---|
| 225 | */
|
---|
| 226 | bool getValidationSchemaFullChecking() const;
|
---|
| 227 |
|
---|
| 228 | /** Get error count from the last parse operation.
|
---|
| 229 | *
|
---|
| 230 | * This method returns the error count from the last parse
|
---|
| 231 | * operation. Note that this count is actually stored in the
|
---|
| 232 | * scanner, so this method simply returns what the
|
---|
| 233 | * scanner reports.
|
---|
| 234 | *
|
---|
| 235 | * @return number of errors encountered during the latest
|
---|
| 236 | * parse operation.
|
---|
| 237 | *
|
---|
| 238 | */
|
---|
| 239 | int getErrorCount() const;
|
---|
| 240 |
|
---|
| 241 | /** Get the 'do namespaces' flag
|
---|
| 242 | *
|
---|
| 243 | * This method returns the state of the parser's namespace processing
|
---|
| 244 | * flag.
|
---|
| 245 | *
|
---|
| 246 | * @return true, if the parser is currently configured to
|
---|
| 247 | * understand namespaces, false otherwise.
|
---|
| 248 | *
|
---|
| 249 | * @see #setDoNamespaces
|
---|
| 250 | */
|
---|
| 251 | bool getDoNamespaces() const;
|
---|
| 252 |
|
---|
| 253 | /** Get the 'exit on first error' flag
|
---|
| 254 | *
|
---|
| 255 | * This method returns the state of the parser's
|
---|
| 256 | * exit-on-First-Fatal-Error flag. If this flag is true, then the
|
---|
| 257 | * parse will exit the first time it sees any non-wellformed XML or
|
---|
| 258 | * any validity error. The default state is true.
|
---|
| 259 | *
|
---|
| 260 | * @return true, if the parser is currently configured to
|
---|
| 261 | * exit on the first fatal error, false otherwise.
|
---|
| 262 | *
|
---|
| 263 | * @see #setExitOnFirstFatalError
|
---|
| 264 | */
|
---|
| 265 | bool getExitOnFirstFatalError() const;
|
---|
| 266 |
|
---|
| 267 | /**
|
---|
| 268 | * This method returns the state of the parser's
|
---|
| 269 | * validation-constraint-fatal flag.
|
---|
| 270 | *
|
---|
| 271 | * @return true, if the parser is currently configured to
|
---|
| 272 | * set validation constraint errors as fatal, false
|
---|
| 273 | * otherwise.
|
---|
| 274 | *
|
---|
| 275 | * @see #setValidationContraintFatal
|
---|
| 276 | */
|
---|
| 277 | bool getValidationConstraintFatal() const;
|
---|
| 278 |
|
---|
| 279 | /** Get the 'include entity references' flag
|
---|
| 280 | *
|
---|
| 281 | * This method returns the flag that specifies whether the parser is
|
---|
| 282 | * creating entity reference nodes in the DOM tree being produced.
|
---|
| 283 | *
|
---|
| 284 | * @return The state of the create entity reference node
|
---|
| 285 | * flag.
|
---|
| 286 | * @see #setCreateEntityReferenceNodes
|
---|
| 287 | */
|
---|
| 288 | bool getCreateEntityReferenceNodes()const;
|
---|
| 289 |
|
---|
| 290 | /** Get the 'include ignorable whitespace' flag.
|
---|
| 291 | *
|
---|
| 292 | * This method returns the state of the parser's include ignorable
|
---|
| 293 | * whitespace flag.
|
---|
| 294 | *
|
---|
| 295 | * @return 'true' if the include ignorable whitespace flag is set on
|
---|
| 296 | * the parser, 'false' otherwise.
|
---|
| 297 | *
|
---|
| 298 | * @see #setIncludeIgnorableWhitespace
|
---|
| 299 | */
|
---|
| 300 | bool getIncludeIgnorableWhitespace() const;
|
---|
| 301 |
|
---|
| 302 | /** Get the set of Namespace/SchemaLocation that is specified externaly.
|
---|
| 303 | *
|
---|
| 304 | * This method returns the list of Namespace/SchemaLocation that was
|
---|
| 305 | * specified using setExternalSchemaLocation.
|
---|
| 306 | *
|
---|
| 307 | * The parser owns the returned string, and the memory allocated for
|
---|
| 308 | * the returned string will be destroyed when the parser is deleted.
|
---|
| 309 | *
|
---|
| 310 | * To ensure assessiblity of the returned information after the parser
|
---|
| 311 | * is deleted, callers need to copy and store the returned information
|
---|
| 312 | * somewhere else.
|
---|
| 313 | *
|
---|
| 314 | * @return a pointer to the list of Namespace/SchemaLocation that was
|
---|
| 315 | * specified externally. The pointer spans the same life-time as
|
---|
| 316 | * the parser. A null pointer is returned if nothing
|
---|
| 317 | * was specified externally.
|
---|
| 318 | *
|
---|
| 319 | * @see #setExternalSchemaLocation(const XMLCh* const)
|
---|
| 320 | */
|
---|
| 321 | XMLCh* getExternalSchemaLocation() const;
|
---|
| 322 |
|
---|
| 323 | /** Get the noNamespace SchemaLocation that is specified externaly.
|
---|
| 324 | *
|
---|
| 325 | * This method returns the no target namespace XML Schema Location
|
---|
| 326 | * that was specified using setExternalNoNamespaceSchemaLocation.
|
---|
| 327 | *
|
---|
| 328 | * The parser owns the returned string, and the memory allocated for
|
---|
| 329 | * the returned string will be destroyed when the parser is deleted.
|
---|
| 330 | *
|
---|
| 331 | * To ensure assessiblity of the returned information after the parser
|
---|
| 332 | * is deleted, callers need to copy and store the returned information
|
---|
| 333 | * somewhere else.
|
---|
| 334 | *
|
---|
| 335 | * @return a pointer to the no target namespace Schema Location that was
|
---|
| 336 | * specified externally. The pointer spans the same life-time as
|
---|
| 337 | * the parser. A null pointer is returned if nothing
|
---|
| 338 | * was specified externally.
|
---|
| 339 | *
|
---|
| 340 | * @see #setExternalNoNamespaceSchemaLocation(const XMLCh* const)
|
---|
| 341 | */
|
---|
| 342 | XMLCh* getExternalNoNamespaceSchemaLocation() const;
|
---|
| 343 |
|
---|
| 344 | /** Get the SecurityManager instance attached to this parser.
|
---|
| 345 | *
|
---|
| 346 | * This method returns the security manager
|
---|
| 347 | * that was specified using setSecurityManager.
|
---|
| 348 | *
|
---|
| 349 | * The SecurityManager instance must have been specified by the application;
|
---|
| 350 | * this should not be deleted until after the parser has been deleted (or
|
---|
| 351 | * a new SecurityManager instance has been supplied to the parser).
|
---|
| 352 | *
|
---|
| 353 | * @return a pointer to the SecurityManager instance
|
---|
| 354 | * specified externally. A null pointer is returned if nothing
|
---|
| 355 | * was specified externally.
|
---|
| 356 | *
|
---|
| 357 | * @see #setSecurityManager(const SecurityManager* const)
|
---|
| 358 | */
|
---|
| 359 | SecurityManager* getSecurityManager() const;
|
---|
| 360 |
|
---|
| 361 | /** Get the 'Loading External DTD' flag
|
---|
| 362 | *
|
---|
| 363 | * This method returns the state of the parser's loading external DTD
|
---|
| 364 | * flag.
|
---|
| 365 | *
|
---|
| 366 | * @return false, if the parser is currently configured to
|
---|
| 367 | * ignore external DTD completely, true otherwise.
|
---|
| 368 | *
|
---|
| 369 | * @see #setLoadExternalDTD
|
---|
| 370 | * @see #getValidationScheme
|
---|
| 371 | */
|
---|
| 372 | bool getLoadExternalDTD() const;
|
---|
| 373 |
|
---|
| 374 | /** Get the 'create comment node' flag
|
---|
| 375 | *
|
---|
| 376 | * This method returns the flag that specifies whether the parser is
|
---|
| 377 | * creating comment nodes in the DOM tree being produced.
|
---|
| 378 | *
|
---|
| 379 | * @return The state of the create comment node flag.
|
---|
| 380 | * @see #setCreateCommentNodes
|
---|
| 381 | */
|
---|
| 382 | bool getCreateCommentNodes()const;
|
---|
| 383 |
|
---|
| 384 | /**
|
---|
| 385 | * Get the 'calculate src offset flag'
|
---|
| 386 | *
|
---|
| 387 | * This method returns the state of the parser's src offset calculation
|
---|
| 388 | * when parsing an XML document.
|
---|
| 389 | *
|
---|
| 390 | * @return true, if the parser is currently configured to
|
---|
| 391 | * calculate src offsets, false otherwise.
|
---|
| 392 | *
|
---|
| 393 | * @see #setCalculateSrcOfs
|
---|
| 394 | */
|
---|
| 395 | bool getCalculateSrcOfs() const;
|
---|
| 396 |
|
---|
| 397 | /**
|
---|
| 398 | * Get the 'force standard uri flag'
|
---|
| 399 | *
|
---|
| 400 | * This method returns the state if the parser forces standard uri
|
---|
| 401 | *
|
---|
| 402 | * @return true, if the parser is currently configured to
|
---|
| 403 | * force standard uri, i.e. malformed uri will be rejected.
|
---|
| 404 | *
|
---|
| 405 | * @see #setStandardUriConformant
|
---|
| 406 | */
|
---|
| 407 | bool getStandardUriConformant() const;
|
---|
| 408 |
|
---|
| 409 | /**
|
---|
| 410 | * This method returns the installed PSVI handler. Suitable
|
---|
| 411 | * for 'lvalue' usages.
|
---|
| 412 | *
|
---|
| 413 | * @return The pointer to the installed PSVI handler object.
|
---|
| 414 | */
|
---|
| 415 | PSVIHandler* getPSVIHandler();
|
---|
| 416 |
|
---|
| 417 | /**
|
---|
| 418 | * This method returns the installed PSVI handler. Suitable
|
---|
| 419 | * for 'rvalue' usages.
|
---|
| 420 | *
|
---|
| 421 | * @return A const pointer to the installed PSVI handler object.
|
---|
| 422 | */
|
---|
| 423 | const PSVIHandler* getPSVIHandler() const;
|
---|
| 424 |
|
---|
| 425 | //@}
|
---|
| 426 |
|
---|
| 427 |
|
---|
| 428 | // -----------------------------------------------------------------------
|
---|
| 429 | // Setter methods
|
---|
| 430 | // -----------------------------------------------------------------------
|
---|
| 431 |
|
---|
| 432 | /** @name Setter methods */
|
---|
| 433 | //@{
|
---|
| 434 |
|
---|
| 435 | /** Set the 'do namespaces' flag
|
---|
| 436 | *
|
---|
| 437 | * This method allows users to enable or disable the parser's
|
---|
| 438 | * namespace processing. When set to true, parser starts enforcing
|
---|
| 439 | * all the constraints and rules specified by the NameSpace
|
---|
| 440 | * specification.
|
---|
| 441 | *
|
---|
| 442 | * The parser's default state is: false.
|
---|
| 443 | *
|
---|
| 444 | * @param newState The value specifying whether NameSpace rules should
|
---|
| 445 | * be enforced or not.
|
---|
| 446 | *
|
---|
| 447 | * @see #getDoNamespaces
|
---|
| 448 | */
|
---|
| 449 | void setDoNamespaces(const bool newState);
|
---|
| 450 |
|
---|
| 451 | /** Set the 'exit on first error' flag
|
---|
| 452 | *
|
---|
| 453 | * This method allows users to set the parser's behaviour when it
|
---|
| 454 | * encounters the first fatal error. If set to true, the parser
|
---|
| 455 | * will exit at the first fatal error. If false, then it will
|
---|
| 456 | * report the error and continue processing.
|
---|
| 457 | *
|
---|
| 458 | * The default value is 'true' and the parser exits on the
|
---|
| 459 | * first fatal error.
|
---|
| 460 | *
|
---|
| 461 | * @param newState The value specifying whether the parser should
|
---|
| 462 | * continue or exit when it encounters the first
|
---|
| 463 | * fatal error.
|
---|
| 464 | *
|
---|
| 465 | * @see #getExitOnFirstFatalError
|
---|
| 466 | */
|
---|
| 467 | void setExitOnFirstFatalError(const bool newState);
|
---|
| 468 |
|
---|
| 469 | /**
|
---|
| 470 | * This method allows users to set the parser's behaviour when it
|
---|
| 471 | * encounters a validtion constraint error. If set to true, and the
|
---|
| 472 | * the parser will treat validation error as fatal and will exit depends on the
|
---|
| 473 | * state of "getExitOnFirstFatalError". If false, then it will
|
---|
| 474 | * report the error and continue processing.
|
---|
| 475 | *
|
---|
| 476 | * Note: setting this true does not mean the validation error will be printed with
|
---|
| 477 | * the word "Fatal Error". It is still printed as "Error", but the parser
|
---|
| 478 | * will exit if "setExitOnFirstFatalError" is set to true.
|
---|
| 479 | *
|
---|
| 480 | * <p>The default value is 'false'.</p>
|
---|
| 481 | *
|
---|
| 482 | * @param newState If true, the parser will exit if "setExitOnFirstFatalError"
|
---|
| 483 | * is set to true.
|
---|
| 484 | *
|
---|
| 485 | * @see #getValidationConstraintFatal
|
---|
| 486 | * @see #setExitOnFirstFatalError
|
---|
| 487 | */
|
---|
| 488 | void setValidationConstraintFatal(const bool newState);
|
---|
| 489 |
|
---|
| 490 | /** Set the 'include entity references' flag
|
---|
| 491 | *
|
---|
| 492 | * This method allows the user to specify whether the parser should
|
---|
| 493 | * create entity reference nodes in the DOM tree being produced.
|
---|
| 494 | * When the 'create' flag is
|
---|
| 495 | * true, the parser will create EntityReference nodes in the DOM tree.
|
---|
| 496 | * The EntityReference nodes and their child nodes will be read-only.
|
---|
| 497 | * When the 'create' flag is false, no EntityReference nodes will be created.
|
---|
| 498 | * <p>The replacement text
|
---|
| 499 | * of the entity is included in either case, either as a
|
---|
| 500 | * child of the Entity Reference node or in place at the location
|
---|
| 501 | * of the reference.
|
---|
| 502 | * <p>The default value is 'true'.
|
---|
| 503 | *
|
---|
| 504 | * @param create The new state of the create entity reference nodes
|
---|
| 505 | * flag.
|
---|
| 506 | * @see #getCreateEntityReferenceNodes
|
---|
| 507 | */
|
---|
| 508 | void setCreateEntityReferenceNodes(const bool create);
|
---|
| 509 |
|
---|
| 510 | /** Set the 'include ignorable whitespace' flag
|
---|
| 511 | *
|
---|
| 512 | * This method allows the user to specify whether a validating parser
|
---|
| 513 | * should include ignorable whitespaces as text nodes. It has no effect
|
---|
| 514 | * on non-validating parsers which always include non-markup text.
|
---|
| 515 | * <p>When set to true (also the default), ignorable whitespaces will be
|
---|
| 516 | * added to the DOM tree as text nodes. The method
|
---|
| 517 | * DOMText::isIgnorableWhitespace() will return true for those text
|
---|
| 518 | * nodes only.
|
---|
| 519 | * <p>When set to false, all ignorable whitespace will be discarded and
|
---|
| 520 | * no text node is added to the DOM tree. Note: applications intended
|
---|
| 521 | * to process the "xml:space" attribute should not set this flag to false.
|
---|
| 522 | * And this flag also overrides any schema datateye whitespace facets,
|
---|
| 523 | * that is, all ignorable whitespace will be discarded even though
|
---|
| 524 | * 'preserve' is set in schema datatype whitespace facets.
|
---|
| 525 | *
|
---|
| 526 | * @param include The new state of the include ignorable whitespace
|
---|
| 527 | * flag.
|
---|
| 528 | *
|
---|
| 529 | * @see #getIncludeIgnorableWhitespace
|
---|
| 530 | */
|
---|
| 531 | void setIncludeIgnorableWhitespace(const bool include);
|
---|
| 532 |
|
---|
| 533 | /**
|
---|
| 534 | * This method allows users to set the validation scheme to be used
|
---|
| 535 | * by this parser. The value is one of the ValSchemes enumerated values
|
---|
| 536 | * defined by this class:
|
---|
| 537 | *
|
---|
| 538 | * <br> Val_Never - turn off validation
|
---|
| 539 | * <br> Val_Always - turn on validation
|
---|
| 540 | * <br> Val_Auto - turn on validation if any internal/external
|
---|
| 541 | * DTD subset have been seen
|
---|
| 542 | *
|
---|
| 543 | * <p>The parser's default state is: Val_Auto.</p>
|
---|
| 544 | *
|
---|
| 545 | * @param newScheme The new validation scheme to use.
|
---|
| 546 | *
|
---|
| 547 | * @see #getValidationScheme
|
---|
| 548 | */
|
---|
| 549 | void setValidationScheme(const ValSchemes newScheme);
|
---|
| 550 |
|
---|
| 551 | /** Set the 'do schema' flag
|
---|
| 552 | *
|
---|
| 553 | * This method allows users to enable or disable the parser's
|
---|
| 554 | * schema processing. When set to false, parser will not process
|
---|
| 555 | * any schema found.
|
---|
| 556 | *
|
---|
| 557 | * The parser's default state is: false.
|
---|
| 558 | *
|
---|
| 559 | * Note: If set to true, namespace processing must also be turned on.
|
---|
| 560 | *
|
---|
| 561 | * @param newState The value specifying whether schema support should
|
---|
| 562 | * be enforced or not.
|
---|
| 563 | *
|
---|
| 564 | * @see #getDoSchema
|
---|
| 565 | */
|
---|
| 566 | void setDoSchema(const bool newState);
|
---|
| 567 |
|
---|
| 568 | /**
|
---|
| 569 | * This method allows the user to turn full Schema constraint checking on/off.
|
---|
| 570 | * Only takes effect if Schema validation is enabled.
|
---|
| 571 | * If turned off, partial constraint checking is done.
|
---|
| 572 | *
|
---|
| 573 | * Full schema constraint checking includes those checking that may
|
---|
| 574 | * be time-consuming or memory intensive. Currently, particle unique
|
---|
| 575 | * attribution constraint checking and particle derivation resriction checking
|
---|
| 576 | * are controlled by this option.
|
---|
| 577 | *
|
---|
| 578 | * The parser's default state is: false.
|
---|
| 579 | *
|
---|
| 580 | * @param schemaFullChecking True to turn on full schema constraint checking.
|
---|
| 581 | *
|
---|
| 582 | * @see #getValidationSchemaFullChecking
|
---|
| 583 | */
|
---|
| 584 | void setValidationSchemaFullChecking(const bool schemaFullChecking);
|
---|
| 585 |
|
---|
| 586 | /**
|
---|
| 587 | * This method allows the user to specify a list of schemas to use.
|
---|
| 588 | * If the targetNamespace of a schema specified using this method matches
|
---|
| 589 | * the targetNamespace of a schema occuring in the instance document in
|
---|
| 590 | * the schemaLocation attribute, or if the targetNamespace matches the
|
---|
| 591 | * namespace attribute of the "import" element, the schema specified by the
|
---|
| 592 | * user using this method will be used (i.e., the schemaLocation attribute
|
---|
| 593 | * in the instance document or on the "import" element will be effectively ignored).
|
---|
| 594 | *
|
---|
| 595 | * If this method is called more than once, only the last one takes effect.
|
---|
| 596 | *
|
---|
| 597 | * The syntax is the same as for schemaLocation attributes in instance
|
---|
| 598 | * documents: e.g, "http://www.example.com file_name.xsd". The user can
|
---|
| 599 | * specify more than one XML Schema in the list.
|
---|
| 600 | *
|
---|
| 601 | * @param schemaLocation the list of schemas to use
|
---|
| 602 | *
|
---|
| 603 | * @see #getExternalSchemaLocation
|
---|
| 604 | */
|
---|
| 605 |
|
---|
| 606 | void setExternalSchemaLocation(const XMLCh* const schemaLocation);
|
---|
| 607 |
|
---|
| 608 | /**
|
---|
| 609 | * This method is same as setExternalSchemaLocation(const XMLCh* const).
|
---|
| 610 | * It takes native char string as parameter
|
---|
| 611 | *
|
---|
| 612 | * @param schemaLocation the list of schemas to use
|
---|
| 613 | *
|
---|
| 614 | * @see #setExternalSchemaLocation(const XMLCh* const)
|
---|
| 615 | */
|
---|
| 616 | void setExternalSchemaLocation(const char* const schemaLocation);
|
---|
| 617 |
|
---|
| 618 | /**
|
---|
| 619 | * This method allows the user to specify the no target namespace XML
|
---|
| 620 | * Schema Location externally. If specified, the instance document's
|
---|
| 621 | * noNamespaceSchemaLocation attribute will be effectively ignored.
|
---|
| 622 | *
|
---|
| 623 | * If this method is called more than once, only the last one takes effect.
|
---|
| 624 | *
|
---|
| 625 | * The syntax is the same as for the noNamespaceSchemaLocation attribute
|
---|
| 626 | * that may occur in an instance document: e.g."file_name.xsd".
|
---|
| 627 | *
|
---|
| 628 | * @param noNamespaceSchemaLocation the XML Schema Location with no target namespace
|
---|
| 629 | *
|
---|
| 630 | * @see #getExternalNoNamespaceSchemaLocation
|
---|
| 631 | */
|
---|
| 632 | void setExternalNoNamespaceSchemaLocation(const XMLCh* const noNamespaceSchemaLocation);
|
---|
| 633 |
|
---|
| 634 | /**
|
---|
| 635 | * This method is same as setExternalNoNamespaceSchemaLocation(const XMLCh* const).
|
---|
| 636 | * It takes native char string as parameter
|
---|
| 637 | *
|
---|
| 638 | * @param noNamespaceSchemaLocation the XML Schema Location with no target namespace
|
---|
| 639 | *
|
---|
| 640 | * @see #setExternalNoNamespaceSchemaLocation(const XMLCh* const)
|
---|
| 641 | */
|
---|
| 642 | void setExternalNoNamespaceSchemaLocation(const char* const noNamespaceSchemaLocation);
|
---|
| 643 |
|
---|
| 644 | /**
|
---|
| 645 | * This allows an application to set a SecurityManager on
|
---|
| 646 | * the parser; this object stores information that various
|
---|
| 647 | * components use to limit their consumption of system
|
---|
| 648 | * resources while processing documents.
|
---|
| 649 | *
|
---|
| 650 | * If this method is called more than once, only the last one takes effect.
|
---|
| 651 | * It may not be reset during a parse.
|
---|
| 652 | *
|
---|
| 653 | *
|
---|
| 654 | * @param securityManager the SecurityManager instance to
|
---|
| 655 | * be used by this parser
|
---|
| 656 | *
|
---|
| 657 | * @see #getSecurityManager
|
---|
| 658 | */
|
---|
| 659 | void setSecurityManager(SecurityManager* const securityManager);
|
---|
| 660 |
|
---|
| 661 | /** Set the 'Loading External DTD' flag
|
---|
| 662 | *
|
---|
| 663 | * This method allows users to enable or disable the loading of external DTD.
|
---|
| 664 | * When set to false, the parser will ignore any external DTD completely
|
---|
| 665 | * if the validationScheme is set to Val_Never.
|
---|
| 666 | *
|
---|
| 667 | * The parser's default state is: true.
|
---|
| 668 | *
|
---|
| 669 | * This flag is ignored if the validationScheme is set to Val_Always or Val_Auto.
|
---|
| 670 | *
|
---|
| 671 | * @param newState The value specifying whether external DTD should
|
---|
| 672 | * be loaded or not.
|
---|
| 673 | *
|
---|
| 674 | * @see #getLoadExternalDTD
|
---|
| 675 | * @see #setValidationScheme
|
---|
| 676 | */
|
---|
| 677 | void setLoadExternalDTD(const bool newState);
|
---|
| 678 |
|
---|
| 679 | /** Set the 'create comment nodes' flag
|
---|
| 680 | *
|
---|
| 681 | * This method allows the user to specify whether the parser should
|
---|
| 682 | * create comment nodes in the DOM tree being produced.
|
---|
| 683 | * <p>The default value is 'true'.
|
---|
| 684 | *
|
---|
| 685 | * @param create The new state of the create comment nodes
|
---|
| 686 | * flag.
|
---|
| 687 | * @see #getCreateCommentNodes
|
---|
| 688 | */
|
---|
| 689 | void setCreateCommentNodes(const bool create);
|
---|
| 690 |
|
---|
| 691 | /** Enable/disable src offset calculation
|
---|
| 692 | *
|
---|
| 693 | * This method allows users to enable/disable src offset calculation.
|
---|
| 694 | * Disabling the calculation will improve performance.
|
---|
| 695 | *
|
---|
| 696 | * The parser's default state is: false.
|
---|
| 697 | *
|
---|
| 698 | * @param newState The value specifying whether we should enable or
|
---|
| 699 | * disable src offset calculation
|
---|
| 700 | *
|
---|
| 701 | * @see #getCalculateSrcOfs
|
---|
| 702 | */
|
---|
| 703 | void setCalculateSrcOfs(const bool newState);
|
---|
| 704 |
|
---|
| 705 | /** Force standard uri
|
---|
| 706 | *
|
---|
| 707 | * This method allows users to tell the parser to force standard uri conformance.
|
---|
| 708 | *
|
---|
| 709 | * The parser's default state is: false.
|
---|
| 710 | *
|
---|
| 711 | * @param newState The value specifying whether the parser should reject malformed URI.
|
---|
| 712 | *
|
---|
| 713 | * @see #getStandardUriConformant
|
---|
| 714 | */
|
---|
| 715 | void setStandardUriConformant(const bool newState);
|
---|
| 716 |
|
---|
| 717 | /** Set the scanner to use when scanning the XML document
|
---|
| 718 | *
|
---|
| 719 | * This method allows users to set the scanner to use
|
---|
| 720 | * when scanning a given XML document.
|
---|
| 721 | *
|
---|
| 722 | * @param scannerName The name of the desired scanner
|
---|
| 723 | */
|
---|
| 724 | void useScanner(const XMLCh* const scannerName);
|
---|
| 725 |
|
---|
| 726 | /** Set the implementation to use when creating the document
|
---|
| 727 | *
|
---|
| 728 | * This method allows users to set the implementation to use
|
---|
| 729 | * to create the document when parseing.
|
---|
| 730 | *
|
---|
| 731 | * @param implementationFeatures The names of the desired features the implementation should have.
|
---|
| 732 | */
|
---|
| 733 | void useImplementation(const XMLCh* const implementationFeatures);
|
---|
| 734 |
|
---|
| 735 | /**
|
---|
| 736 | * This method installs the user specified PSVI handler on
|
---|
| 737 | * the parser.
|
---|
| 738 | *
|
---|
| 739 | * @param handler A pointer to the PSVI handler to be called
|
---|
| 740 | * when the parser comes across 'PSVI' events
|
---|
| 741 | * as per the schema specification.
|
---|
| 742 | */
|
---|
| 743 | virtual void setPSVIHandler(PSVIHandler* const handler);
|
---|
| 744 |
|
---|
| 745 | //@}
|
---|
| 746 |
|
---|
| 747 |
|
---|
| 748 | // -----------------------------------------------------------------------
|
---|
| 749 | // Parsing methods
|
---|
| 750 | // -----------------------------------------------------------------------
|
---|
| 751 |
|
---|
| 752 | /** @name Parsing methods */
|
---|
| 753 | //@{
|
---|
| 754 |
|
---|
| 755 | /** Parse via an input source object
|
---|
| 756 | *
|
---|
| 757 | * This method invokes the parsing process on the XML file specified
|
---|
| 758 | * by the InputSource parameter. This API is borrowed from the
|
---|
| 759 | * SAX Parser interface.
|
---|
| 760 | *
|
---|
| 761 | * @param source A const reference to the InputSource object which
|
---|
| 762 | * points to the XML file to be parsed.
|
---|
| 763 | * @exception SAXException Any SAX exception, possibly
|
---|
| 764 | * wrapping another exception.
|
---|
| 765 | * @exception XMLException An exception from the parser or client
|
---|
| 766 | * handler code.
|
---|
| 767 | * @exception DOMException A DOM exception as per DOM spec.
|
---|
| 768 | * @see InputSource#InputSource
|
---|
| 769 | */
|
---|
| 770 | void parse(const InputSource& source);
|
---|
| 771 |
|
---|
| 772 | /** Parse via a file path or URL
|
---|
| 773 | *
|
---|
| 774 | * This method invokes the parsing process on the XML file specified by
|
---|
| 775 | * the Unicode string parameter 'systemId'. This method is borrowed
|
---|
| 776 | * from the SAX Parser interface.
|
---|
| 777 | *
|
---|
| 778 | * @param systemId A const XMLCh pointer to the Unicode string which
|
---|
| 779 | * contains the path to the XML file to be parsed.
|
---|
| 780 | *
|
---|
| 781 | * @exception SAXException Any SAX exception, possibly
|
---|
| 782 | * wrapping another exception.
|
---|
| 783 | * @exception XMLException An exception from the parser or client
|
---|
| 784 | * handler code.
|
---|
| 785 | * @exception DOMException A DOM exception as per DOM spec.
|
---|
| 786 | * @see #parse(InputSource,...)
|
---|
| 787 | */
|
---|
| 788 | void parse(const XMLCh* const systemId);
|
---|
| 789 |
|
---|
| 790 | /** Parse via a file path or URL (in the local code page)
|
---|
| 791 | *
|
---|
| 792 | * This method invokes the parsing process on the XML file specified by
|
---|
| 793 | * the native char* string parameter 'systemId'.
|
---|
| 794 | *
|
---|
| 795 | * @param systemId A const char pointer to a native string which
|
---|
| 796 | * contains the path to the XML file to be parsed.
|
---|
| 797 | *
|
---|
| 798 | * @exception SAXException Any SAX exception, possibly
|
---|
| 799 | * wrapping another exception.
|
---|
| 800 | * @exception XMLException An exception from the parser or client
|
---|
| 801 | * handler code.
|
---|
| 802 | * @exception DOMException A DOM exception as per DOM spec.
|
---|
| 803 | * @see #parse(InputSource,...)
|
---|
| 804 | */
|
---|
| 805 | void parse(const char* const systemId);
|
---|
| 806 |
|
---|
| 807 | /** Begin a progressive parse operation
|
---|
| 808 | *
|
---|
| 809 | * This method is used to start a progressive parse on a XML file.
|
---|
| 810 | * To continue parsing, subsequent calls must be to the parseNext
|
---|
| 811 | * method.
|
---|
| 812 | *
|
---|
| 813 | * It scans through the prolog and returns a token to be used on
|
---|
| 814 | * subsequent scanNext() calls. If the return value is true, then the
|
---|
| 815 | * token is legal and ready for further use. If it returns false, then
|
---|
| 816 | * the scan of the prolog failed and the token is not going to work on
|
---|
| 817 | * subsequent scanNext() calls.
|
---|
| 818 | *
|
---|
| 819 | * @param systemId A pointer to a Unicode string represting the path
|
---|
| 820 | * to the XML file to be parsed.
|
---|
| 821 | * @param toFill A token maintaing state information to maintain
|
---|
| 822 | * internal consistency between invocation of 'parseNext'
|
---|
| 823 | * calls.
|
---|
| 824 | * @return 'true', if successful in parsing the prolog. It indicates the
|
---|
| 825 | * user can go ahead with parsing the rest of the file. It
|
---|
| 826 | * returns 'false' to indicate that the parser could not parse
|
---|
| 827 | * the prolog.
|
---|
| 828 | *
|
---|
| 829 | * @see #parseNext
|
---|
| 830 | * @see #parseFirst(char*,...)
|
---|
| 831 | * @see #parseFirst(InputSource&,...)
|
---|
| 832 | */
|
---|
| 833 | bool parseFirst
|
---|
| 834 | (
|
---|
| 835 | const XMLCh* const systemId
|
---|
| 836 | , XMLPScanToken& toFill
|
---|
| 837 | );
|
---|
| 838 |
|
---|
| 839 | /** Begin a progressive parse operation
|
---|
| 840 | *
|
---|
| 841 | * This method is used to start a progressive parse on a XML file.
|
---|
| 842 | * To continue parsing, subsequent calls must be to the parseNext
|
---|
| 843 | * method.
|
---|
| 844 | *
|
---|
| 845 | * It scans through the prolog and returns a token to be used on
|
---|
| 846 | * subsequent scanNext() calls. If the return value is true, then the
|
---|
| 847 | * token is legal and ready for further use. If it returns false, then
|
---|
| 848 | * the scan of the prolog failed and the token is not going to work on
|
---|
| 849 | * subsequent scanNext() calls.
|
---|
| 850 | *
|
---|
| 851 | * @param systemId A pointer to a regular native string represting
|
---|
| 852 | * the path to the XML file to be parsed.
|
---|
| 853 | * @param toFill A token maintaing state information to maintain
|
---|
| 854 | * internal consistency between invocation of 'parseNext'
|
---|
| 855 | * calls.
|
---|
| 856 | *
|
---|
| 857 | * @return 'true', if successful in parsing the prolog. It indicates the
|
---|
| 858 | * user can go ahead with parsing the rest of the file. It
|
---|
| 859 | * returns 'false' to indicate that the parser could not parse
|
---|
| 860 | * the prolog.
|
---|
| 861 | *
|
---|
| 862 | * @see #parseNext
|
---|
| 863 | * @see #parseFirst(XMLCh*,...)
|
---|
| 864 | * @see #parseFirst(InputSource&,...)
|
---|
| 865 | */
|
---|
| 866 | bool parseFirst
|
---|
| 867 | (
|
---|
| 868 | const char* const systemId
|
---|
| 869 | , XMLPScanToken& toFill
|
---|
| 870 | );
|
---|
| 871 |
|
---|
| 872 | /** Begin a progressive parse operation
|
---|
| 873 | *
|
---|
| 874 | * This method is used to start a progressive parse on a XML file.
|
---|
| 875 | * To continue parsing, subsequent calls must be to the parseNext
|
---|
| 876 | * method.
|
---|
| 877 | *
|
---|
| 878 | * It scans through the prolog and returns a token to be used on
|
---|
| 879 | * subsequent scanNext() calls. If the return value is true, then the
|
---|
| 880 | * token is legal and ready for further use. If it returns false, then
|
---|
| 881 | * the scan of the prolog failed and the token is not going to work on
|
---|
| 882 | * subsequent scanNext() calls.
|
---|
| 883 | *
|
---|
| 884 | * @param source A const reference to the InputSource object which
|
---|
| 885 | * points to the XML file to be parsed.
|
---|
| 886 | * @param toFill A token maintaing state information to maintain
|
---|
| 887 | * internal consistency between invocation of 'parseNext'
|
---|
| 888 | * calls.
|
---|
| 889 | *
|
---|
| 890 | * @return 'true', if successful in parsing the prolog. It indicates the
|
---|
| 891 | * user can go ahead with parsing the rest of the file. It
|
---|
| 892 | * returns 'false' to indicate that the parser could not parse
|
---|
| 893 | * the prolog.
|
---|
| 894 | *
|
---|
| 895 | * @see #parseNext
|
---|
| 896 | * @see #parseFirst(XMLCh*,...)
|
---|
| 897 | * @see #parseFirst(char*,...)
|
---|
| 898 | */
|
---|
| 899 | bool parseFirst
|
---|
| 900 | (
|
---|
| 901 | const InputSource& source
|
---|
| 902 | , XMLPScanToken& toFill
|
---|
| 903 | );
|
---|
| 904 |
|
---|
| 905 | /** Continue a progressive parse operation
|
---|
| 906 | *
|
---|
| 907 | * This method is used to continue with progressive parsing of
|
---|
| 908 | * XML files started by a call to 'parseFirst' method.
|
---|
| 909 | *
|
---|
| 910 | * It parses the XML file and stops as soon as it comes across
|
---|
| 911 | * a XML token (as defined in the XML specification).
|
---|
| 912 | *
|
---|
| 913 | * @param token A token maintaing state information to maintain
|
---|
| 914 | * internal consistency between invocation of 'parseNext'
|
---|
| 915 | * calls.
|
---|
| 916 | *
|
---|
| 917 | * @return 'true', if successful in parsing the next XML token.
|
---|
| 918 | * It indicates the user can go ahead with parsing the rest
|
---|
| 919 | * of the file. It returns 'false' to indicate that the parser
|
---|
| 920 | * could not find next token as per the XML specification
|
---|
| 921 | * production rule.
|
---|
| 922 | *
|
---|
| 923 | * @see #parseFirst(XMLCh*,...)
|
---|
| 924 | * @see #parseFirst(char*,...)
|
---|
| 925 | * @see #parseFirst(InputSource&,...)
|
---|
| 926 | */
|
---|
| 927 | bool parseNext(XMLPScanToken& token);
|
---|
| 928 |
|
---|
| 929 | /** Reset the parser after a progressive parse
|
---|
| 930 | *
|
---|
| 931 | * If a progressive parse loop exits before the end of the document
|
---|
| 932 | * is reached, the parser has no way of knowing this. So it will leave
|
---|
| 933 | * open any files or sockets or memory buffers that were in use at
|
---|
| 934 | * the time that the parse loop exited.
|
---|
| 935 | *
|
---|
| 936 | * The next parse operation will cause these open files and such to
|
---|
| 937 | * be closed, but the next parse operation might occur at some unknown
|
---|
| 938 | * future point. To avoid this problem, you should reset the parser if
|
---|
| 939 | * you exit the loop early.
|
---|
| 940 | *
|
---|
| 941 | * If you exited because of an error, then this cleanup will be done
|
---|
| 942 | * for you. Its only when you exit the file prematurely of your own
|
---|
| 943 | * accord, because you've found what you wanted in the file most
|
---|
| 944 | * likely.
|
---|
| 945 | *
|
---|
| 946 | * @param token A token maintaing state information to maintain
|
---|
| 947 | * internal consistency between invocation of 'parseNext'
|
---|
| 948 | * calls.
|
---|
| 949 | *
|
---|
| 950 | * @see #parseFirst(XMLCh*,...)
|
---|
| 951 | * @see #parseFirst(char*,...)
|
---|
| 952 | * @see #parseFirst(InputSource&,...)
|
---|
| 953 | */
|
---|
| 954 | void parseReset(XMLPScanToken& token);
|
---|
| 955 |
|
---|
| 956 | //@}
|
---|
| 957 |
|
---|
| 958 | // -----------------------------------------------------------------------
|
---|
| 959 | // Implementation of the XMLDocumentHandler interface.
|
---|
| 960 | // -----------------------------------------------------------------------
|
---|
| 961 |
|
---|
| 962 | /** @name Implementation of the XMLDocumentHandler interface. */
|
---|
| 963 | //@{
|
---|
| 964 |
|
---|
| 965 | /** Handle document character events
|
---|
| 966 | *
|
---|
| 967 | * This method is used to report all the characters scanned by the
|
---|
| 968 | * parser. This DOM implementation stores this data in the appropriate
|
---|
| 969 | * DOM node, creating one if necessary.
|
---|
| 970 | *
|
---|
| 971 | * @param chars A const pointer to a Unicode string representing the
|
---|
| 972 | * character data.
|
---|
| 973 | * @param length The length of the Unicode string returned in 'chars'.
|
---|
| 974 | * @param cdataSection A flag indicating if the characters represent
|
---|
| 975 | * content from the CDATA section.
|
---|
| 976 | */
|
---|
| 977 | virtual void docCharacters
|
---|
| 978 | (
|
---|
| 979 | const XMLCh* const chars
|
---|
| 980 | , const unsigned int length
|
---|
| 981 | , const bool cdataSection
|
---|
| 982 | );
|
---|
| 983 |
|
---|
| 984 | /** Handle a document comment event
|
---|
| 985 | *
|
---|
| 986 | * This method is used to report any comments scanned by the parser.
|
---|
| 987 | * A new comment node is created which stores this data.
|
---|
| 988 | *
|
---|
| 989 | * @param comment A const pointer to a null terminated Unicode
|
---|
| 990 | * string representing the comment text.
|
---|
| 991 | */
|
---|
| 992 | virtual void docComment
|
---|
| 993 | (
|
---|
| 994 | const XMLCh* const comment
|
---|
| 995 | );
|
---|
| 996 |
|
---|
| 997 | /** Handle a document PI event
|
---|
| 998 | *
|
---|
| 999 | * This method is used to report any PI scanned by the parser. A new
|
---|
| 1000 | * PI node is created and appended as a child of the current node in
|
---|
| 1001 | * the tree.
|
---|
| 1002 | *
|
---|
| 1003 | * @param target A const pointer to a Unicode string representing the
|
---|
| 1004 | * target of the PI declaration.
|
---|
| 1005 | * @param data A const pointer to a Unicode string representing the
|
---|
| 1006 | * data of the PI declaration. See the PI production rule
|
---|
| 1007 | * in the XML specification for details.
|
---|
| 1008 | */
|
---|
| 1009 | virtual void docPI
|
---|
| 1010 | (
|
---|
| 1011 | const XMLCh* const target
|
---|
| 1012 | , const XMLCh* const data
|
---|
| 1013 | );
|
---|
| 1014 |
|
---|
| 1015 | /** Handle the end of document event
|
---|
| 1016 | *
|
---|
| 1017 | * This method is used to indicate the end of the current document.
|
---|
| 1018 | */
|
---|
| 1019 | virtual void endDocument();
|
---|
| 1020 |
|
---|
| 1021 | /** Handle and end of element event
|
---|
| 1022 | *
|
---|
| 1023 | * This method is used to indicate the end tag of an element. The
|
---|
| 1024 | * DOM parser pops the current element off the top of the element
|
---|
| 1025 | * stack, and make it the new current element.
|
---|
| 1026 | *
|
---|
| 1027 | * @param elemDecl A const reference to the object containing element
|
---|
| 1028 | * declaration information.
|
---|
| 1029 | * @param urlId An id referring to the namespace prefix, if
|
---|
| 1030 | * namespaces setting is switched on.
|
---|
| 1031 | * @param isRoot A flag indicating whether this element was the
|
---|
| 1032 | * root element.
|
---|
| 1033 | * @param elemPrefix A const pointer to a Unicode string containing
|
---|
| 1034 | * the namespace prefix for this element. Applicable
|
---|
| 1035 | * only when namespace processing is enabled.
|
---|
| 1036 | */
|
---|
| 1037 | virtual void endElement
|
---|
| 1038 | (
|
---|
| 1039 | const XMLElementDecl& elemDecl
|
---|
| 1040 | , const unsigned int urlId
|
---|
| 1041 | , const bool isRoot
|
---|
| 1042 | , const XMLCh* const elemPrefix
|
---|
| 1043 | );
|
---|
| 1044 |
|
---|
| 1045 | /** Handle and end of entity reference event
|
---|
| 1046 | *
|
---|
| 1047 | * This method is used to indicate that an end of an entity reference
|
---|
| 1048 | * was just scanned.
|
---|
| 1049 | *
|
---|
| 1050 | * @param entDecl A const reference to the object containing the
|
---|
| 1051 | * entity declaration information.
|
---|
| 1052 | */
|
---|
| 1053 | virtual void endEntityReference
|
---|
| 1054 | (
|
---|
| 1055 | const XMLEntityDecl& entDecl
|
---|
| 1056 | );
|
---|
| 1057 |
|
---|
| 1058 | /** Handle an ignorable whitespace vent
|
---|
| 1059 | *
|
---|
| 1060 | * This method is used to report all the whitespace characters, which
|
---|
| 1061 | * are determined to be 'ignorable'. This distinction between characters
|
---|
| 1062 | * is only made, if validation is enabled.
|
---|
| 1063 | *
|
---|
| 1064 | * Any whitespace before content is ignored. If the current node is
|
---|
| 1065 | * already of type DOMNode::TEXT_NODE, then these whitespaces are
|
---|
| 1066 | * appended, otherwise a new Text node is created which stores this
|
---|
| 1067 | * data. Essentially all contiguous ignorable characters are collected
|
---|
| 1068 | * in one node.
|
---|
| 1069 | *
|
---|
| 1070 | * @param chars A const pointer to a Unicode string representing the
|
---|
| 1071 | * ignorable whitespace character data.
|
---|
| 1072 | * @param length The length of the Unicode string 'chars'.
|
---|
| 1073 | * @param cdataSection A flag indicating if the characters represent
|
---|
| 1074 | * content from the CDATA section.
|
---|
| 1075 | */
|
---|
| 1076 | virtual void ignorableWhitespace
|
---|
| 1077 | (
|
---|
| 1078 | const XMLCh* const chars
|
---|
| 1079 | , const unsigned int length
|
---|
| 1080 | , const bool cdataSection
|
---|
| 1081 | );
|
---|
| 1082 |
|
---|
| 1083 | /** Handle a document reset event
|
---|
| 1084 | *
|
---|
| 1085 | * This method allows the user installed Document Handler to 'reset'
|
---|
| 1086 | * itself, freeing all the memory resources. The scanner calls this
|
---|
| 1087 | * method before starting a new parse event.
|
---|
| 1088 | */
|
---|
| 1089 | virtual void resetDocument();
|
---|
| 1090 |
|
---|
| 1091 | /** Handle a start document event
|
---|
| 1092 | *
|
---|
| 1093 | * This method is used to report the start of the parsing process.
|
---|
| 1094 | */
|
---|
| 1095 | virtual void startDocument();
|
---|
| 1096 |
|
---|
| 1097 | /** Handle a start element event
|
---|
| 1098 | *
|
---|
| 1099 | * This method is used to report the start of an element. It is
|
---|
| 1100 | * called at the end of the element, by which time all attributes
|
---|
| 1101 | * specified are also parsed. A new DOM Element node is created
|
---|
| 1102 | * along with as many attribute nodes as required. This new element
|
---|
| 1103 | * is added appended as a child of the current node in the tree, and
|
---|
| 1104 | * then replaces it as the current node (if the isEmpty flag is false.)
|
---|
| 1105 | *
|
---|
| 1106 | * @param elemDecl A const reference to the object containing element
|
---|
| 1107 | * declaration information.
|
---|
| 1108 | * @param urlId An id referring to the namespace prefix, if
|
---|
| 1109 | * namespaces setting is switched on.
|
---|
| 1110 | * @param elemPrefix A const pointer to a Unicode string containing
|
---|
| 1111 | * the namespace prefix for this element. Applicable
|
---|
| 1112 | * only when namespace processing is enabled.
|
---|
| 1113 | * @param attrList A const reference to the object containing the
|
---|
| 1114 | * list of attributes just scanned for this element.
|
---|
| 1115 | * @param attrCount A count of number of attributes in the list
|
---|
| 1116 | * specified by the parameter 'attrList'.
|
---|
| 1117 | * @param isEmpty A flag indicating whether this is an empty element
|
---|
| 1118 | * or not. If empty, then no endElement() call will
|
---|
| 1119 | * be made.
|
---|
| 1120 | * @param isRoot A flag indicating whether this element was the
|
---|
| 1121 | * root element.
|
---|
| 1122 | * @see DocumentHandler#startElement
|
---|
| 1123 | */
|
---|
| 1124 | virtual void startElement
|
---|
| 1125 | (
|
---|
| 1126 | const XMLElementDecl& elemDecl
|
---|
| 1127 | , const unsigned int urlId
|
---|
| 1128 | , const XMLCh* const elemPrefix
|
---|
| 1129 | , const RefVectorOf<XMLAttr>& attrList
|
---|
| 1130 | , const unsigned int attrCount
|
---|
| 1131 | , const bool isEmpty
|
---|
| 1132 | , const bool isRoot
|
---|
| 1133 | );
|
---|
| 1134 |
|
---|
| 1135 | /** Handle a start entity reference event
|
---|
| 1136 | *
|
---|
| 1137 | * This method is used to indicate the start of an entity reference.
|
---|
| 1138 | * If the expand entity reference flag is true, then a new
|
---|
| 1139 | * DOM Entity reference node is created.
|
---|
| 1140 | *
|
---|
| 1141 | * @param entDecl A const reference to the object containing the
|
---|
| 1142 | * entity declaration information.
|
---|
| 1143 | */
|
---|
| 1144 | virtual void startEntityReference
|
---|
| 1145 | (
|
---|
| 1146 | const XMLEntityDecl& entDecl
|
---|
| 1147 | );
|
---|
| 1148 |
|
---|
| 1149 | /** Handle an XMLDecl event
|
---|
| 1150 | *
|
---|
| 1151 | * This method is used to report the XML decl scanned by the parser.
|
---|
| 1152 | * Refer to the XML specification to see the meaning of parameters.
|
---|
| 1153 | *
|
---|
| 1154 | * <b><font color="#FF0000">This method is a no-op for this DOM
|
---|
| 1155 | * implementation.</font></b>
|
---|
| 1156 | *
|
---|
| 1157 | * @param versionStr A const pointer to a Unicode string representing
|
---|
| 1158 | * version string value.
|
---|
| 1159 | * @param encodingStr A const pointer to a Unicode string representing
|
---|
| 1160 | * the encoding string value.
|
---|
| 1161 | * @param standaloneStr A const pointer to a Unicode string
|
---|
| 1162 | * representing the standalone string value.
|
---|
| 1163 | * @param actualEncStr A const pointer to a Unicode string
|
---|
| 1164 | * representing the actual encoding string
|
---|
| 1165 | * value.
|
---|
| 1166 | */
|
---|
| 1167 | virtual void XMLDecl
|
---|
| 1168 | (
|
---|
| 1169 | const XMLCh* const versionStr
|
---|
| 1170 | , const XMLCh* const encodingStr
|
---|
| 1171 | , const XMLCh* const standaloneStr
|
---|
| 1172 | , const XMLCh* const actualEncStr
|
---|
| 1173 | );
|
---|
| 1174 |
|
---|
| 1175 | /** Receive notification of the name and namespace of the type that validated
|
---|
| 1176 | * the element corresponding to the most recent endElement event.
|
---|
| 1177 | * This event will be fired immediately after the
|
---|
| 1178 | * endElement() event that signifies the end of the element
|
---|
| 1179 | * to which it applies; no other events will intervene.
|
---|
| 1180 | * This method is <emEXPERIMENTAL</em> and may change, disappear
|
---|
| 1181 | * or become pure virtual at any time.
|
---|
| 1182 | *
|
---|
| 1183 | * This corresponds to a part of the information required by DOM Core
|
---|
| 1184 | * level 3's TypeInfo interface.
|
---|
| 1185 | *
|
---|
| 1186 | * @param typeName local name of the type that actually validated
|
---|
| 1187 | * the content of the element corresponding to the
|
---|
| 1188 | * most recent endElement() callback
|
---|
| 1189 | * @param typeURI namespace of the type that actually validated
|
---|
| 1190 | * the content of the element corresponding to the
|
---|
| 1191 | * most recent endElement() callback
|
---|
| 1192 | * @experimental
|
---|
| 1193 | */
|
---|
| 1194 | virtual void elementTypeInfo
|
---|
| 1195 | (
|
---|
| 1196 | const XMLCh* const typeName
|
---|
| 1197 | , const XMLCh* const typeURI
|
---|
| 1198 | );
|
---|
| 1199 | //@}
|
---|
| 1200 |
|
---|
| 1201 |
|
---|
| 1202 | // -----------------------------------------------------------------------
|
---|
| 1203 | // Implementation of the deprecated DocTypeHandler interface.
|
---|
| 1204 | // -----------------------------------------------------------------------
|
---|
| 1205 | /** @name Deprecated DocTypeHandler Interfaces */
|
---|
| 1206 | //@{
|
---|
| 1207 | virtual void attDef
|
---|
| 1208 | (
|
---|
| 1209 | const DTDElementDecl& elemDecl
|
---|
| 1210 | , const DTDAttDef& attDef
|
---|
| 1211 | , const bool ignoring
|
---|
| 1212 | );
|
---|
| 1213 |
|
---|
| 1214 | virtual void doctypeComment
|
---|
| 1215 | (
|
---|
| 1216 | const XMLCh* const comment
|
---|
| 1217 | );
|
---|
| 1218 |
|
---|
| 1219 | virtual void doctypeDecl
|
---|
| 1220 | (
|
---|
| 1221 | const DTDElementDecl& elemDecl
|
---|
| 1222 | , const XMLCh* const publicId
|
---|
| 1223 | , const XMLCh* const systemId
|
---|
| 1224 | , const bool hasIntSubset
|
---|
| 1225 | , const bool hasExtSubset = false
|
---|
| 1226 | );
|
---|
| 1227 |
|
---|
| 1228 | virtual void doctypePI
|
---|
| 1229 | (
|
---|
| 1230 | const XMLCh* const target
|
---|
| 1231 | , const XMLCh* const data
|
---|
| 1232 | );
|
---|
| 1233 |
|
---|
| 1234 | virtual void doctypeWhitespace
|
---|
| 1235 | (
|
---|
| 1236 | const XMLCh* const chars
|
---|
| 1237 | , const unsigned int length
|
---|
| 1238 | );
|
---|
| 1239 |
|
---|
| 1240 | virtual void elementDecl
|
---|
| 1241 | (
|
---|
| 1242 | const DTDElementDecl& decl
|
---|
| 1243 | , const bool isIgnored
|
---|
| 1244 | );
|
---|
| 1245 |
|
---|
| 1246 | virtual void endAttList
|
---|
| 1247 | (
|
---|
| 1248 | const DTDElementDecl& elemDecl
|
---|
| 1249 | );
|
---|
| 1250 |
|
---|
| 1251 | virtual void endIntSubset();
|
---|
| 1252 |
|
---|
| 1253 | virtual void endExtSubset();
|
---|
| 1254 |
|
---|
| 1255 | virtual void entityDecl
|
---|
| 1256 | (
|
---|
| 1257 | const DTDEntityDecl& entityDecl
|
---|
| 1258 | , const bool isPEDecl
|
---|
| 1259 | , const bool isIgnored
|
---|
| 1260 | );
|
---|
| 1261 |
|
---|
| 1262 | virtual void resetDocType();
|
---|
| 1263 |
|
---|
| 1264 | virtual void notationDecl
|
---|
| 1265 | (
|
---|
| 1266 | const XMLNotationDecl& notDecl
|
---|
| 1267 | , const bool isIgnored
|
---|
| 1268 | );
|
---|
| 1269 |
|
---|
| 1270 | virtual void startAttList
|
---|
| 1271 | (
|
---|
| 1272 | const DTDElementDecl& elemDecl
|
---|
| 1273 | );
|
---|
| 1274 |
|
---|
| 1275 | virtual void startIntSubset();
|
---|
| 1276 |
|
---|
| 1277 | virtual void startExtSubset();
|
---|
| 1278 |
|
---|
| 1279 | virtual void TextDecl
|
---|
| 1280 | (
|
---|
| 1281 | const XMLCh* const versionStr
|
---|
| 1282 | , const XMLCh* const encodingStr
|
---|
| 1283 | );
|
---|
| 1284 |
|
---|
| 1285 |
|
---|
| 1286 | //@}
|
---|
| 1287 |
|
---|
| 1288 |
|
---|
| 1289 | // -----------------------------------------------------------------------
|
---|
| 1290 | // Deprecated Methods
|
---|
| 1291 | // -----------------------------------------------------------------------
|
---|
| 1292 | /** @name Deprecated Methods */
|
---|
| 1293 | //@{
|
---|
| 1294 | /**
|
---|
| 1295 | * This method returns the state of the parser's validation
|
---|
| 1296 | * handling flag which controls whether validation checks
|
---|
| 1297 | * are enforced or not.
|
---|
| 1298 | *
|
---|
| 1299 | * @return true, if the parser is currently configured to
|
---|
| 1300 | * do validation, false otherwise.
|
---|
| 1301 | *
|
---|
| 1302 | * @see #setDoValidation
|
---|
| 1303 | */
|
---|
| 1304 | bool getDoValidation() const;
|
---|
| 1305 |
|
---|
| 1306 | /**
|
---|
| 1307 | * This method allows users to enable or disable the parser's validation
|
---|
| 1308 | * checks.
|
---|
| 1309 | *
|
---|
| 1310 | * <p>By default, the parser does not to any validation. The default
|
---|
| 1311 | * value is false.</p>
|
---|
| 1312 | *
|
---|
| 1313 | * @param newState The value specifying whether the parser should
|
---|
| 1314 | * do validity checks or not against the DTD in the
|
---|
| 1315 | * input XML document.
|
---|
| 1316 | *
|
---|
| 1317 | * @see #getDoValidation
|
---|
| 1318 | */
|
---|
| 1319 | void setDoValidation(const bool newState);
|
---|
| 1320 |
|
---|
| 1321 | /** Get the 'expand entity references' flag.
|
---|
| 1322 | * DEPRECATED Use getCreateEntityReferenceNodes() instead.
|
---|
| 1323 | *
|
---|
| 1324 | * This method returns the state of the parser's expand entity
|
---|
| 1325 | * references flag.
|
---|
| 1326 | *
|
---|
| 1327 | * @return 'true' if the expand entity reference flag is set on
|
---|
| 1328 | * the parser, 'false' otherwise.
|
---|
| 1329 | *
|
---|
| 1330 | * @see #setExpandEntityReferences
|
---|
| 1331 | * @see #setCreateEntityReferenceNodes
|
---|
| 1332 | * @see #getCreateEntityReferenceNodes
|
---|
| 1333 | */
|
---|
| 1334 | bool getExpandEntityReferences() const;
|
---|
| 1335 |
|
---|
| 1336 | /** Set the 'expand entity references' flag
|
---|
| 1337 | *
|
---|
| 1338 | * DEPRECATED. USE setCreateEntityReferenceNodes instead.
|
---|
| 1339 | * This method allows the user to specify whether the parser should
|
---|
| 1340 | * expand all entity reference nodes. When the 'do expansion' flag is
|
---|
| 1341 | * true, the DOM tree does not have any entity reference nodes. It is
|
---|
| 1342 | * replaced by the sub-tree representing the replacement text of the
|
---|
| 1343 | * entity. When the 'do expansion' flag is false, the DOM tree
|
---|
| 1344 | * contains an extra entity reference node, whose children is the
|
---|
| 1345 | * sub tree of the replacement text.
|
---|
| 1346 | * <p>The default value is 'false'.
|
---|
| 1347 | *
|
---|
| 1348 | * @param expand The new state of the expand entity reference
|
---|
| 1349 | * flag.
|
---|
| 1350 | * @see #setCreateEntityReferenceNodes
|
---|
| 1351 | */
|
---|
| 1352 | void setExpandEntityReferences(const bool expand);
|
---|
| 1353 |
|
---|
| 1354 | //@}
|
---|
| 1355 |
|
---|
| 1356 | protected :
|
---|
| 1357 | // -----------------------------------------------------------------------
|
---|
| 1358 | // Protected Constructor Methods
|
---|
| 1359 | // -----------------------------------------------------------------------
|
---|
| 1360 | /** @name Constructors */
|
---|
| 1361 | //@{
|
---|
| 1362 | /** Construct a AbstractDOMParser, with an optional validator
|
---|
| 1363 | *
|
---|
| 1364 | * Constructor with an instance of validator class to use for
|
---|
| 1365 | * validation. If you don't provide a validator, a default one will
|
---|
| 1366 | * be created for you in the scanner.
|
---|
| 1367 | *
|
---|
| 1368 | * @param valToAdopt Pointer to the validator instance to use. The
|
---|
| 1369 | * parser is responsible for freeing the memory.
|
---|
| 1370 | *
|
---|
| 1371 | * @param gramPool Pointer to the grammar pool instance from
|
---|
| 1372 | * external application (through derivatives).
|
---|
| 1373 | * The parser does NOT own it.
|
---|
| 1374 | *
|
---|
| 1375 | * @param manager Pointer to the memory manager to be used to
|
---|
| 1376 | * allocate objects.
|
---|
| 1377 | */
|
---|
| 1378 | AbstractDOMParser
|
---|
| 1379 | (
|
---|
| 1380 | XMLValidator* const valToAdopt = 0
|
---|
| 1381 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
|
---|
| 1382 | , XMLGrammarPool* const gramPool = 0
|
---|
| 1383 | );
|
---|
| 1384 |
|
---|
| 1385 | //@}
|
---|
| 1386 |
|
---|
| 1387 | // -----------------------------------------------------------------------
|
---|
| 1388 | // Protected getter methods
|
---|
| 1389 | // -----------------------------------------------------------------------
|
---|
| 1390 | /** @name Protected getter methods */
|
---|
| 1391 | //@{
|
---|
| 1392 | /** Get the current DOM node
|
---|
| 1393 | *
|
---|
| 1394 | * This provides derived classes with access to the current node, i.e.
|
---|
| 1395 | * the node to which new nodes are being added.
|
---|
| 1396 | */
|
---|
| 1397 | DOMNode* getCurrentNode();
|
---|
| 1398 |
|
---|
| 1399 | /** Get the XML scanner
|
---|
| 1400 | *
|
---|
| 1401 | * This provides derived classes with access to the XML scanner.
|
---|
| 1402 | */
|
---|
| 1403 | XMLScanner* getScanner() const;
|
---|
| 1404 |
|
---|
| 1405 | /** Get the Grammar resolver
|
---|
| 1406 | *
|
---|
| 1407 | * This provides derived classes with access to the grammar resolver.
|
---|
| 1408 | */
|
---|
| 1409 | GrammarResolver* getGrammarResolver() const;
|
---|
| 1410 |
|
---|
| 1411 | /** Get the parse in progress flag
|
---|
| 1412 | *
|
---|
| 1413 | * This provides derived classes with access to the parse in progress
|
---|
| 1414 | * flag.
|
---|
| 1415 | */
|
---|
| 1416 | bool getParseInProgress() const;
|
---|
| 1417 |
|
---|
| 1418 | MemoryManager* getMemoryManager() const;
|
---|
| 1419 |
|
---|
| 1420 | //@}
|
---|
| 1421 |
|
---|
| 1422 |
|
---|
| 1423 | // -----------------------------------------------------------------------
|
---|
| 1424 | // Protected setter methods
|
---|
| 1425 | // -----------------------------------------------------------------------
|
---|
| 1426 |
|
---|
| 1427 | /** @name Protected setter methods */
|
---|
| 1428 | //@{
|
---|
| 1429 |
|
---|
| 1430 | /** Set the current DOM node
|
---|
| 1431 | *
|
---|
| 1432 | * This method sets the current node maintained inside the parser to
|
---|
| 1433 | * the one specified.
|
---|
| 1434 | *
|
---|
| 1435 | * @param toSet The DOM node which will be the current node.
|
---|
| 1436 | */
|
---|
| 1437 | void setCurrentNode(DOMNode* toSet);
|
---|
| 1438 |
|
---|
| 1439 | /** Set the document node
|
---|
| 1440 | *
|
---|
| 1441 | * This method sets the DOM Document node to the one specified.
|
---|
| 1442 | *
|
---|
| 1443 | * @param toSet The new DOM Document node for this XML document.
|
---|
| 1444 | */
|
---|
| 1445 | void setDocument(DOMDocument* toSet);
|
---|
| 1446 |
|
---|
| 1447 | /** Set the parse in progress flag
|
---|
| 1448 | *
|
---|
| 1449 | * This method sets the parse in progress flag to true or false.
|
---|
| 1450 | *
|
---|
| 1451 | * @param toSet The value of the flag to be set.
|
---|
| 1452 | */
|
---|
| 1453 | void setParseInProgress(const bool toSet);
|
---|
| 1454 | //@}
|
---|
| 1455 |
|
---|
| 1456 | // -----------------------------------------------------------------------
|
---|
| 1457 | // Protected Helper methods
|
---|
| 1458 | // -----------------------------------------------------------------------
|
---|
| 1459 | /** @name Protected helper methods */
|
---|
| 1460 | //@{
|
---|
| 1461 | virtual DOMElement* createElementNSNode(const XMLCh *fNamespaceURI,
|
---|
| 1462 | const XMLCh *qualifiedName);
|
---|
| 1463 |
|
---|
| 1464 | void resetPool();
|
---|
| 1465 |
|
---|
| 1466 | /**
|
---|
| 1467 | * Returns true if the user has adopted the document
|
---|
| 1468 | */
|
---|
| 1469 | bool isDocumentAdopted() const;
|
---|
| 1470 |
|
---|
| 1471 | //@}
|
---|
| 1472 |
|
---|
| 1473 |
|
---|
| 1474 | private :
|
---|
| 1475 | // -----------------------------------------------------------------------
|
---|
| 1476 | // Initialize/Cleanup methods
|
---|
| 1477 | // -----------------------------------------------------------------------
|
---|
| 1478 | void initialize();
|
---|
| 1479 | void cleanUp();
|
---|
| 1480 |
|
---|
| 1481 | // -----------------------------------------------------------------------
|
---|
| 1482 | // Unimplemented constructors and operators
|
---|
| 1483 | // -----------------------------------------------------------------------
|
---|
| 1484 | AbstractDOMParser(const AbstractDOMParser&);
|
---|
| 1485 | AbstractDOMParser& operator=(const AbstractDOMParser&);
|
---|
| 1486 |
|
---|
| 1487 | protected:
|
---|
| 1488 | // -----------------------------------------------------------------------
|
---|
| 1489 | // Protected data members
|
---|
| 1490 | //
|
---|
| 1491 | // fCurrentNode
|
---|
| 1492 | // fCurrentParent
|
---|
| 1493 | // Used to track the current node during nested element events. Since
|
---|
| 1494 | // the tree must be built from a set of disjoint callbacks, we need
|
---|
| 1495 | // these to keep up with where we currently are.
|
---|
| 1496 | //
|
---|
| 1497 | // fCurrentEntity
|
---|
| 1498 | // Used to track the current entity decl. If a text decl is seen later on,
|
---|
| 1499 | // it is used to update the encoding and version information.
|
---|
| 1500 | //
|
---|
| 1501 | // fDocument
|
---|
| 1502 | // The root document object, filled with the document contents.
|
---|
| 1503 | //
|
---|
| 1504 | // fCreateEntityReferenceNodes
|
---|
| 1505 | // Indicates whether entity reference nodes should be created.
|
---|
| 1506 | //
|
---|
| 1507 | // fIncludeIgnorableWhitespace
|
---|
| 1508 | // Indicates whether ignorable whiltespace should be added to
|
---|
| 1509 | // the DOM tree for validating parsers.
|
---|
| 1510 | //
|
---|
| 1511 | // fScanner
|
---|
| 1512 | // The scanner used for this parser. This is created during the
|
---|
| 1513 | // constructor.
|
---|
| 1514 | //
|
---|
| 1515 | // fImplementationFeatures
|
---|
| 1516 | // The implementation features that we use to get an implementation
|
---|
| 1517 | // for use in creating the DOMDocument used during parse. If this is
|
---|
| 1518 | // null then the default DOMImplementation is used
|
---|
| 1519 | //
|
---|
| 1520 | // fNodeStack
|
---|
| 1521 | // Used to track previous parent nodes during nested element events.
|
---|
| 1522 | //
|
---|
| 1523 | // fParseInProgress
|
---|
| 1524 | // Used to prevent multiple entrance to the parser while its doing
|
---|
| 1525 | // a parse.
|
---|
| 1526 | //
|
---|
| 1527 | // fWithinElement
|
---|
| 1528 | // A flag to indicate that the parser is within at least one level
|
---|
| 1529 | // of element processing.
|
---|
| 1530 | //
|
---|
| 1531 | // fDocumentType
|
---|
| 1532 | // Used to store and update the documentType variable information
|
---|
| 1533 | // in fDocument
|
---|
| 1534 | //
|
---|
| 1535 | // fDocumentVector
|
---|
| 1536 | // Store all the previous fDocument(s) (thus not the current fDocument)
|
---|
| 1537 | // created in this parser. It is destroyed when the parser is destructed.
|
---|
| 1538 | //
|
---|
| 1539 | // fCreateCommentNodes
|
---|
| 1540 | // Indicates whether comment nodes should be created.
|
---|
| 1541 | //
|
---|
| 1542 | // fDocumentAdoptedByUser
|
---|
| 1543 | // The DOMDocument ownership has been transferred to application
|
---|
| 1544 | // If set to true, the parser does not own the document anymore
|
---|
| 1545 | // and thus will not release its memory.
|
---|
| 1546 | //
|
---|
| 1547 | // fInternalSubset
|
---|
| 1548 | // Buffer for storing the internal subset information.
|
---|
| 1549 | // Once complete (after DOCTYPE is finished scanning), send
|
---|
| 1550 | // it to DocumentType Node
|
---|
| 1551 | //
|
---|
| 1552 | // fGrammarPool
|
---|
| 1553 | // The grammar pool passed from external application (through derivatives).
|
---|
| 1554 | // which could be 0, not owned.
|
---|
| 1555 | //
|
---|
| 1556 | // -----------------------------------------------------------------------
|
---|
| 1557 | bool fCreateEntityReferenceNodes;
|
---|
| 1558 | bool fIncludeIgnorableWhitespace;
|
---|
| 1559 | bool fWithinElement;
|
---|
| 1560 | bool fParseInProgress;
|
---|
| 1561 | bool fCreateCommentNodes;
|
---|
| 1562 | bool fDocumentAdoptedByUser;
|
---|
| 1563 | XMLScanner* fScanner;
|
---|
| 1564 | XMLCh* fImplementationFeatures;
|
---|
| 1565 | DOMNode* fCurrentParent;
|
---|
| 1566 | DOMNode* fCurrentNode;
|
---|
| 1567 | DOMEntity* fCurrentEntity;
|
---|
| 1568 | DOMDocumentImpl* fDocument;
|
---|
| 1569 | ValueStackOf<DOMNode*>* fNodeStack;
|
---|
| 1570 | DOMDocumentTypeImpl* fDocumentType;
|
---|
| 1571 | RefVectorOf<DOMDocumentImpl>* fDocumentVector;
|
---|
| 1572 | GrammarResolver* fGrammarResolver;
|
---|
| 1573 | XMLStringPool* fURIStringPool;
|
---|
| 1574 | XMLValidator* fValidator;
|
---|
| 1575 | MemoryManager* fMemoryManager;
|
---|
| 1576 | XMLGrammarPool* fGrammarPool;
|
---|
| 1577 | XMLBufferMgr fBufMgr;
|
---|
| 1578 | XMLBuffer& fInternalSubset;
|
---|
| 1579 | PSVIHandler* fPSVIHandler;
|
---|
| 1580 | };
|
---|
| 1581 |
|
---|
| 1582 |
|
---|
| 1583 |
|
---|
| 1584 | // ---------------------------------------------------------------------------
|
---|
| 1585 | // AbstractDOMParser: Getter methods
|
---|
| 1586 | // ---------------------------------------------------------------------------
|
---|
| 1587 | inline bool AbstractDOMParser::getExpandEntityReferences() const
|
---|
| 1588 | {
|
---|
| 1589 | return !fCreateEntityReferenceNodes;
|
---|
| 1590 | }
|
---|
| 1591 | inline bool AbstractDOMParser::getCreateEntityReferenceNodes() const
|
---|
| 1592 | {
|
---|
| 1593 | return fCreateEntityReferenceNodes;
|
---|
| 1594 | }
|
---|
| 1595 |
|
---|
| 1596 | inline bool AbstractDOMParser::getIncludeIgnorableWhitespace() const
|
---|
| 1597 | {
|
---|
| 1598 | return fIncludeIgnorableWhitespace;
|
---|
| 1599 | }
|
---|
| 1600 |
|
---|
| 1601 | inline bool AbstractDOMParser::getParseInProgress() const
|
---|
| 1602 | {
|
---|
| 1603 | return fParseInProgress;
|
---|
| 1604 | }
|
---|
| 1605 |
|
---|
| 1606 | inline XMLScanner* AbstractDOMParser::getScanner() const
|
---|
| 1607 | {
|
---|
| 1608 | return fScanner;
|
---|
| 1609 | }
|
---|
| 1610 |
|
---|
| 1611 | inline GrammarResolver* AbstractDOMParser::getGrammarResolver() const
|
---|
| 1612 | {
|
---|
| 1613 | return fGrammarResolver;
|
---|
| 1614 | }
|
---|
| 1615 |
|
---|
| 1616 | inline bool AbstractDOMParser::getCreateCommentNodes() const
|
---|
| 1617 | {
|
---|
| 1618 | return fCreateCommentNodes;
|
---|
| 1619 | }
|
---|
| 1620 |
|
---|
| 1621 | inline PSVIHandler* AbstractDOMParser::getPSVIHandler()
|
---|
| 1622 | {
|
---|
| 1623 | return fPSVIHandler;
|
---|
| 1624 | }
|
---|
| 1625 |
|
---|
| 1626 | inline const PSVIHandler* AbstractDOMParser::getPSVIHandler() const
|
---|
| 1627 | {
|
---|
| 1628 | return fPSVIHandler;
|
---|
| 1629 | }
|
---|
| 1630 | // ---------------------------------------------------------------------------
|
---|
| 1631 | // AbstractDOMParser: Setter methods
|
---|
| 1632 | // ---------------------------------------------------------------------------
|
---|
| 1633 | inline void AbstractDOMParser::setExpandEntityReferences(const bool expand)
|
---|
| 1634 | {
|
---|
| 1635 | fCreateEntityReferenceNodes = !expand;
|
---|
| 1636 | }
|
---|
| 1637 |
|
---|
| 1638 | inline void AbstractDOMParser::setCreateEntityReferenceNodes(const bool create)
|
---|
| 1639 | {
|
---|
| 1640 | fCreateEntityReferenceNodes = create;
|
---|
| 1641 | }
|
---|
| 1642 |
|
---|
| 1643 | inline void AbstractDOMParser::setIncludeIgnorableWhitespace(const bool include)
|
---|
| 1644 | {
|
---|
| 1645 | fIncludeIgnorableWhitespace = include;
|
---|
| 1646 | }
|
---|
| 1647 |
|
---|
| 1648 | inline void AbstractDOMParser::setCreateCommentNodes(const bool create)
|
---|
| 1649 | {
|
---|
| 1650 | fCreateCommentNodes = create;
|
---|
| 1651 | }
|
---|
| 1652 |
|
---|
| 1653 | inline void AbstractDOMParser::useImplementation(const XMLCh* const implementationFeatures)
|
---|
| 1654 | {
|
---|
| 1655 | fMemoryManager->deallocate(fImplementationFeatures);
|
---|
| 1656 | fImplementationFeatures = XMLString::replicate(implementationFeatures, fMemoryManager);
|
---|
| 1657 | }
|
---|
| 1658 |
|
---|
| 1659 | // ---------------------------------------------------------------------------
|
---|
| 1660 | // AbstractDOMParser: Protected getter methods
|
---|
| 1661 | // ---------------------------------------------------------------------------
|
---|
| 1662 | inline DOMNode* AbstractDOMParser::getCurrentNode()
|
---|
| 1663 | {
|
---|
| 1664 | return fCurrentNode;
|
---|
| 1665 | }
|
---|
| 1666 |
|
---|
| 1667 | inline MemoryManager* AbstractDOMParser::getMemoryManager() const
|
---|
| 1668 | {
|
---|
| 1669 | return fMemoryManager;
|
---|
| 1670 | }
|
---|
| 1671 |
|
---|
| 1672 | // ---------------------------------------------------------------------------
|
---|
| 1673 | // AbstractDOMParser: Protected setter methods
|
---|
| 1674 | // ---------------------------------------------------------------------------
|
---|
| 1675 | inline void AbstractDOMParser::setCurrentNode(DOMNode* toSet)
|
---|
| 1676 | {
|
---|
| 1677 | fCurrentNode = toSet;
|
---|
| 1678 | }
|
---|
| 1679 |
|
---|
| 1680 | inline void AbstractDOMParser::setDocument(DOMDocument* toSet)
|
---|
| 1681 | {
|
---|
| 1682 | fDocument = (DOMDocumentImpl *)toSet;
|
---|
| 1683 | }
|
---|
| 1684 |
|
---|
| 1685 | inline void AbstractDOMParser::setParseInProgress(const bool toSet)
|
---|
| 1686 | {
|
---|
| 1687 | fParseInProgress = toSet;
|
---|
| 1688 | }
|
---|
| 1689 |
|
---|
| 1690 | XERCES_CPP_NAMESPACE_END
|
---|
| 1691 |
|
---|
| 1692 | #endif
|
---|
| 1693 |
|
---|
| 1694 |
|
---|
| 1695 |
|
---|