|
||||
File indexing completed on 2025-01-30 10:27:08
0001 /* 0002 * Licensed to the Apache Software Foundation (ASF) under one or more 0003 * contributor license agreements. See the NOTICE file distributed with 0004 * this work for additional information regarding copyright ownership. 0005 * The ASF licenses this file to You under the Apache License, Version 2.0 0006 * (the "License"); you may not use this file except in compliance with 0007 * the License. You may obtain a copy of the License at 0008 * 0009 * http://www.apache.org/licenses/LICENSE-2.0 0010 * 0011 * Unless required by applicable law or agreed to in writing, software 0012 * distributed under the License is distributed on an "AS IS" BASIS, 0013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 0014 * See the License for the specific language governing permissions and 0015 * limitations under the License. 0016 */ 0017 0018 /* 0019 * $Id$ 0020 */ 0021 0022 #if !defined(XERCESC_INCLUDE_GUARD_ABSTRACTDOMPARSER_HPP) 0023 #define XERCESC_INCLUDE_GUARD_ABSTRACTDOMPARSER_HPP 0024 0025 #include <xercesc/dom/DOMDocument.hpp> 0026 #include <xercesc/framework/XMLDocumentHandler.hpp> 0027 #include <xercesc/framework/XMLErrorReporter.hpp> 0028 #include <xercesc/framework/XMLEntityHandler.hpp> 0029 #include <xercesc/util/SecurityManager.hpp> 0030 #include <xercesc/util/ValueStackOf.hpp> 0031 #include <xercesc/validators/DTD/DocTypeHandler.hpp> 0032 #include <xercesc/dom/DOMDocumentType.hpp> 0033 #include <xercesc/validators/DTD/DTDElementDecl.hpp> 0034 #include <xercesc/framework/XMLBufferMgr.hpp> 0035 #include <xercesc/framework/psvi/PSVIHandler.hpp> 0036 0037 XERCES_CPP_NAMESPACE_BEGIN 0038 0039 class XMLPScanToken; 0040 class XMLScanner; 0041 class XMLValidator; 0042 class DOMDocumentImpl; 0043 class DOMDocumentTypeImpl; 0044 class DOMEntityImpl; 0045 class DOMElement; 0046 class GrammarResolver; 0047 class XMLGrammarPool; 0048 class PSVIHandler; 0049 0050 /** 0051 * This class implements the Document Object Model (DOM) interface. 0052 * It is used as a base for DOM parsers (i.e. XercesDOMParser, DOMLSParser). 0053 */ 0054 class PARSERS_EXPORT AbstractDOMParser : 0055 0056 public XMemory 0057 , public XMLDocumentHandler 0058 , public XMLErrorReporter 0059 , public XMLEntityHandler 0060 , public DocTypeHandler 0061 , public PSVIHandler 0062 { 0063 public : 0064 // ----------------------------------------------------------------------- 0065 // Class types 0066 // ----------------------------------------------------------------------- 0067 /** @name Public constants */ 0068 //@{ 0069 0070 /** ValScheme enum used in setValidationScheme 0071 * Val_Never: Do not report validation errors. 0072 * Val_Always: The parser will always report validation errors. 0073 * Val_Auto: The parser will report validation errors only if a grammar is specified. 0074 * 0075 * @see #setValidationScheme 0076 */ 0077 enum ValSchemes 0078 { 0079 Val_Never 0080 , Val_Always 0081 , Val_Auto 0082 }; 0083 0084 //@} 0085 0086 0087 // ----------------------------------------------------------------------- 0088 // Constructors and Destructor 0089 // ----------------------------------------------------------------------- 0090 /** @name Destructor */ 0091 //@{ 0092 0093 /** 0094 * Destructor 0095 */ 0096 virtual ~AbstractDOMParser(); 0097 0098 //@} 0099 0100 // ----------------------------------------------------------------------- 0101 // Utility methods 0102 // ----------------------------------------------------------------------- 0103 0104 /** @name Utility methods */ 0105 //@{ 0106 /** Reset the parser 0107 * 0108 * This method resets the state of the DOM driver and makes 0109 * it ready for a fresh parse run. 0110 */ 0111 void reset(); 0112 0113 /** Adopt the DOM document 0114 * 0115 * This method returns the DOMDocument object representing the 0116 * root of the document tree. 0117 * 0118 * The caller will adopt the DOMDocument and thus is responsible to 0119 * call DOMDocument::release() to release the associated memory. 0120 * The parser will not delete it. The ownership is transferred 0121 * from the parser to the caller. 0122 * 0123 * @return The adopted DOMDocument object which represents the entire 0124 * XML document. 0125 */ 0126 DOMDocument* adoptDocument(); 0127 0128 //@} 0129 0130 0131 // ----------------------------------------------------------------------- 0132 // Getter methods 0133 // ----------------------------------------------------------------------- 0134 0135 /** @name Getter methods */ 0136 //@{ 0137 0138 /** Get the DOM document 0139 * 0140 * This method returns the DOMDocument object representing the 0141 * root of the document tree. This object provides the primary 0142 * access to the document's data. 0143 * 0144 * The returned DOMDocument object is owned by the parser. 0145 * 0146 * @return The DOMDocument object which represents the entire 0147 * XML document. 0148 */ 0149 DOMDocument* getDocument(); 0150 0151 /** Get a const reference to the validator 0152 * 0153 * This method returns a reference to the parser's installed 0154 * validator. 0155 * 0156 * @return A const reference to the installed validator object. 0157 */ 0158 const XMLValidator& getValidator() const; 0159 0160 /** 0161 * This method returns an enumerated value that indicates the current 0162 * validation scheme set on this parser. 0163 * 0164 * @return The ValSchemes value current set on this parser. 0165 * @see #setValidationScheme 0166 */ 0167 ValSchemes getValidationScheme() const; 0168 0169 /** Get the 'do schema' flag 0170 * 0171 * This method returns the state of the parser's schema processing 0172 * flag. 0173 * 0174 * @return true, if the parser is currently configured to 0175 * understand schema, false otherwise. 0176 * 0177 * @see #setDoSchema 0178 */ 0179 bool getDoSchema() const; 0180 0181 /** Get the 'full schema constraint checking' flag 0182 * 0183 * This method returns the state of the parser's full schema constraint 0184 * checking flag. 0185 * 0186 * @return true, if the parser is currently configured to 0187 * have full schema constraint checking, false otherwise. 0188 * 0189 * @see #setValidationSchemaFullChecking 0190 */ 0191 bool getValidationSchemaFullChecking() const; 0192 0193 /** Get the identity constraint checking' flag 0194 * 0195 * This method returns the state of the parser's identity constraint 0196 * checking flag. 0197 * 0198 * @return true, if the parser is currently configured to 0199 * have identity constraint checking, false otherwise. 0200 * 0201 * @see setIdentityConstraintChecking 0202 */ 0203 bool getIdentityConstraintChecking() const; 0204 0205 /** Get error count from the last parse operation. 0206 * 0207 * This method returns the error count from the last parse 0208 * operation. Note that this count is actually stored in the 0209 * scanner, so this method simply returns what the 0210 * scanner reports. 0211 * 0212 * @return number of errors encountered during the latest 0213 * parse operation. 0214 * 0215 */ 0216 XMLSize_t getErrorCount() const; 0217 0218 /** Get the 'do namespaces' flag 0219 * 0220 * This method returns the state of the parser's namespace processing 0221 * flag. 0222 * 0223 * @return true, if the parser is currently configured to 0224 * understand namespaces, false otherwise. 0225 * 0226 * @see #setDoNamespaces 0227 */ 0228 bool getDoNamespaces() const; 0229 0230 /** Get the 'exit on first error' flag 0231 * 0232 * This method returns the state of the parser's 0233 * exit-on-First-Fatal-Error flag. If this flag is true, then the 0234 * parse will exit the first time it sees any non-wellformed XML or 0235 * any validity error. The default state is true. 0236 * 0237 * @return true, if the parser is currently configured to 0238 * exit on the first fatal error, false otherwise. 0239 * 0240 * @see #setExitOnFirstFatalError 0241 */ 0242 bool getExitOnFirstFatalError() const; 0243 0244 /** 0245 * This method returns the state of the parser's 0246 * validation-constraint-fatal flag. 0247 * 0248 * @return true, if the parser is currently configured to 0249 * set validation constraint errors as fatal, false 0250 * otherwise. 0251 * 0252 * @see #setValidationConstraintFatal 0253 */ 0254 bool getValidationConstraintFatal() const; 0255 0256 /** Get the 'include entity references' flag 0257 * 0258 * This method returns the flag that specifies whether the parser is 0259 * creating entity reference nodes in the DOM tree being produced. 0260 * 0261 * @return The state of the create entity reference node 0262 * flag. 0263 * @see #setCreateEntityReferenceNodes 0264 */ 0265 bool getCreateEntityReferenceNodes()const; 0266 0267 /** Get the 'include ignorable whitespace' flag. 0268 * 0269 * This method returns the state of the parser's include ignorable 0270 * whitespace flag. 0271 * 0272 * @return 'true' if the include ignorable whitespace flag is set on 0273 * the parser, 'false' otherwise. 0274 * 0275 * @see #setIncludeIgnorableWhitespace 0276 */ 0277 bool getIncludeIgnorableWhitespace() const; 0278 0279 /** Get the set of Namespace/SchemaLocation that is specified externally. 0280 * 0281 * This method returns the list of Namespace/SchemaLocation that was 0282 * specified using setExternalSchemaLocation. 0283 * 0284 * The parser owns the returned string, and the memory allocated for 0285 * the returned string will be destroyed when the parser is deleted. 0286 * 0287 * To ensure accessibility of the returned information after the parser 0288 * is deleted, callers need to copy and store the returned information 0289 * somewhere else. 0290 * 0291 * @return a pointer to the list of Namespace/SchemaLocation that was 0292 * specified externally. The pointer spans the same life-time as 0293 * the parser. A null pointer is returned if nothing 0294 * was specified externally. 0295 * 0296 * @see #setExternalSchemaLocation(const XMLCh* const) 0297 */ 0298 XMLCh* getExternalSchemaLocation() const; 0299 0300 /** Get the noNamespace SchemaLocation that is specified externally. 0301 * 0302 * This method returns the no target namespace XML Schema Location 0303 * that was specified using setExternalNoNamespaceSchemaLocation. 0304 * 0305 * The parser owns the returned string, and the memory allocated for 0306 * the returned string will be destroyed when the parser is deleted. 0307 * 0308 * To ensure accessibility of the returned information after the parser 0309 * is deleted, callers need to copy and store the returned information 0310 * somewhere else. 0311 * 0312 * @return a pointer to the no target namespace Schema Location that was 0313 * specified externally. The pointer spans the same life-time as 0314 * the parser. A null pointer is returned if nothing 0315 * was specified externally. 0316 * 0317 * @see #setExternalNoNamespaceSchemaLocation(const XMLCh* const) 0318 */ 0319 XMLCh* getExternalNoNamespaceSchemaLocation() const; 0320 0321 /** Get the SecurityManager instance attached to this parser. 0322 * 0323 * This method returns the security manager 0324 * that was specified using setSecurityManager. 0325 * 0326 * The SecurityManager instance must have been specified by the application; 0327 * this should not be deleted until after the parser has been deleted (or 0328 * a new SecurityManager instance has been supplied to the parser). 0329 * 0330 * @return a pointer to the SecurityManager instance 0331 * specified externally. A null pointer is returned if nothing 0332 * was specified externally. 0333 * 0334 * @see #setSecurityManager 0335 */ 0336 SecurityManager* getSecurityManager() const; 0337 0338 /** Get the raw buffer low water mark for this parser. 0339 * 0340 * If the number of available bytes in the raw buffer is less than 0341 * the low water mark the parser will attempt to read more data before 0342 * continuing parsing. By default the value for this parameter is 100 0343 * bytes. You may want to set this parameter to 0 if you would like 0344 * the parser to parse the available data immediately without 0345 * potentially blocking while waiting for more date. 0346 * 0347 * @return current low water mark 0348 * 0349 * @see #setSecurityManager 0350 */ 0351 const XMLSize_t& getLowWaterMark() const; 0352 0353 /** Get the 'Disallow DOCTYPE (DTD)' flag 0354 * 0355 * This method returns the state of the parser's disallowed DOCTYPE 0356 * flag. 0357 * 0358 * @return false, if the parser is currently configured to 0359 * allow DOCTYPE, true otherwise. 0360 * 0361 * @see #setDisallowDoctype() 0362 * @see #getLoadExternalDTD 0363 * @see #getValidationScheme 0364 */ 0365 bool getDisallowDoctype() const; 0366 0367 /** Get the 'Loading External DTD' flag 0368 * 0369 * This method returns the state of the parser's loading external DTD 0370 * flag. 0371 * 0372 * @return false, if the parser is currently configured to 0373 * ignore external DTD completely, true otherwise. 0374 * 0375 * @see #setLoadExternalDTD 0376 * @see #getDisallowDoctype 0377 * @see #getValidationScheme 0378 */ 0379 bool getLoadExternalDTD() const; 0380 0381 /** Get the 'Loading Schema' flag 0382 * 0383 * This method returns the state of the parser's loading schema 0384 * flag. 0385 * 0386 * @return true, if the parser is currently configured to 0387 * automatically load schemas that are not in the 0388 * grammar pool, false otherwise. 0389 * 0390 * @see #setLoadSchema 0391 */ 0392 bool getLoadSchema() const; 0393 0394 /** Get the 'create comment node' flag 0395 * 0396 * This method returns the flag that specifies whether the parser is 0397 * creating comment nodes in the DOM tree being produced. 0398 * 0399 * @return The state of the create comment node flag. 0400 * @see #setCreateCommentNodes 0401 */ 0402 bool getCreateCommentNodes()const; 0403 0404 /** 0405 * Get the 'calculate src offset flag' 0406 * 0407 * This method returns the state of the parser's src offset calculation 0408 * when parsing an XML document. 0409 * 0410 * @return true, if the parser is currently configured to 0411 * calculate src offsets, false otherwise. 0412 * 0413 * @see #setCalculateSrcOfs 0414 */ 0415 bool getCalculateSrcOfs() const; 0416 0417 /** 0418 * Get the 'force standard uri flag' 0419 * 0420 * This method returns the state if the parser forces standard uri 0421 * 0422 * @return true, if the parser is currently configured to 0423 * force standard uri, i.e. malformed uri will be rejected. 0424 * 0425 * @see #setStandardUriConformant 0426 */ 0427 bool getStandardUriConformant() const; 0428 0429 /** 0430 * This method returns the installed PSVI handler. Suitable 0431 * for 'lvalue' usages. 0432 * 0433 * @return The pointer to the installed PSVI handler object. 0434 */ 0435 PSVIHandler* getPSVIHandler(); 0436 0437 /** 0438 * This method returns the installed PSVI handler. Suitable 0439 * for 'rvalue' usages. 0440 * 0441 * @return A const pointer to the installed PSVI handler object. 0442 */ 0443 const PSVIHandler* getPSVIHandler() const; 0444 0445 /** Get the 'associate schema info' flag 0446 * 0447 * This method returns the flag that specifies whether 0448 * the parser is storing schema informations in the element 0449 * and attribute nodes in the DOM tree being produced. 0450 * 0451 * @return The state of the associate schema info flag. 0452 * @see #setCreateSchemaInfo 0453 */ 0454 bool getCreateSchemaInfo() const; 0455 0456 /** Get the 'do XInclude' flag 0457 * 0458 * This method returns the flag that specifies whether 0459 * the parser will process XInclude nodes 0460 * in the DOM tree being produced. 0461 * 0462 * @return The state of the 'do XInclude' flag. 0463 * @see #setDoXInclude 0464 */ 0465 bool getDoXInclude() const; 0466 0467 /** Get the 'generate synthetic annotations' flag 0468 * 0469 * @return true, if the parser is currently configured to 0470 * generate synthetic annotations, false otherwise. 0471 * A synthetic XSAnnotation is created when a schema 0472 * component has non-schema attributes but has no 0473 * child annotations so that the non-schema attributes 0474 * can be recovered under PSVI. 0475 * 0476 * @see #setGenerateSyntheticAnnotations 0477 */ 0478 bool getGenerateSyntheticAnnotations() const; 0479 0480 /** Get the 'validate annotations' flag 0481 * 0482 * @return true, if the parser is currently configured to 0483 * validate annotations, false otherwise. 0484 * 0485 * @see #setValidateAnnotations 0486 */ 0487 bool getValidateAnnotations() const; 0488 0489 /** Get the 'ignore annotations' flag 0490 * 0491 * @return true, if the parser is currently configured to 0492 * ignore annotations, false otherwise. 0493 * 0494 * @see #setIgnoreAnnotations 0495 */ 0496 bool getIgnoreAnnotations() const; 0497 0498 /** Get the 'disable default entity resolution' flag 0499 * 0500 * @return true, if the parser is currently configured to 0501 * not perform default entity resolution, false otherwise. 0502 * 0503 * @see #setDisableDefaultEntityResolution 0504 */ 0505 bool getDisableDefaultEntityResolution() const; 0506 0507 /** Get the 'skip DTD validation' flag 0508 * 0509 * @return true, if the parser is currently configured to 0510 * skip DTD validation, false otherwise. 0511 * 0512 * @see #setSkipDTDValidation 0513 */ 0514 bool getSkipDTDValidation() const; 0515 0516 /** Get the 'handle multiple schema imports' flag 0517 * 0518 * @return true, if the parser is currently configured to 0519 * import multiple schemas with the same namespace, false otherwise. 0520 * 0521 * @see #setHandleMultipleImports 0522 */ 0523 bool getHandleMultipleImports() const; 0524 //@} 0525 0526 0527 // ----------------------------------------------------------------------- 0528 // Setter methods 0529 // ----------------------------------------------------------------------- 0530 0531 /** @name Setter methods */ 0532 //@{ 0533 /** set the 'generate synthetic annotations' flag 0534 * 0535 * @param newValue The value for specifying whether Synthetic Annotations 0536 * should be generated or not. 0537 * A synthetic XSAnnotation is created when a schema 0538 * component has non-schema attributes but has no 0539 * child annotations so that the non-schema attributes 0540 * can be recovered under PSVI. 0541 * 0542 * @see #getGenerateSyntheticAnnotations 0543 */ 0544 void setGenerateSyntheticAnnotations(const bool newValue); 0545 0546 /** set the 'validlate annotations' flag 0547 * 0548 * @param newValue The value for specifying whether Annotations 0549 * should be validated or not. 0550 * 0551 * @see #getValidateAnnotations 0552 */ 0553 void setValidateAnnotations(const bool newValue); 0554 0555 /** Set the 'do namespaces' flag 0556 * 0557 * This method allows users to enable or disable the parser's 0558 * namespace processing. When set to true, parser starts enforcing 0559 * all the constraints and rules specified by the NameSpace 0560 * specification. 0561 * 0562 * The parser's default state is: false. 0563 * 0564 * @param newState The value specifying whether NameSpace rules should 0565 * be enforced or not. 0566 * 0567 * @see #getDoNamespaces 0568 */ 0569 void setDoNamespaces(const bool newState); 0570 0571 /** Set the 'exit on first error' flag 0572 * 0573 * This method allows users to set the parser's behaviour when it 0574 * encounters the first fatal error. If set to true, the parser 0575 * will exit at the first fatal error. If false, then it will 0576 * report the error and continue processing. 0577 * 0578 * The default value is 'true' and the parser exits on the 0579 * first fatal error. 0580 * 0581 * @param newState The value specifying whether the parser should 0582 * continue or exit when it encounters the first 0583 * fatal error. 0584 * 0585 * @see #getExitOnFirstFatalError 0586 */ 0587 void setExitOnFirstFatalError(const bool newState); 0588 0589 /** 0590 * This method allows users to set the parser's behaviour when it 0591 * encounters a validation constraint error. If set to true, and the 0592 * the parser will treat validation error as fatal and will exit depends on the 0593 * state of "getExitOnFirstFatalError". If false, then it will 0594 * report the error and continue processing. 0595 * 0596 * Note: setting this true does not mean the validation error will be printed with 0597 * the word "Fatal Error". It is still printed as "Error", but the parser 0598 * will exit if "setExitOnFirstFatalError" is set to true. 0599 * 0600 * <p>The default value is 'false'.</p> 0601 * 0602 * @param newState If true, the parser will exit if "setExitOnFirstFatalError" 0603 * is set to true. 0604 * 0605 * @see #getValidationConstraintFatal 0606 * @see #setExitOnFirstFatalError 0607 */ 0608 void setValidationConstraintFatal(const bool newState); 0609 0610 /** Set the 'include entity references' flag 0611 * 0612 * This method allows the user to specify whether the parser should 0613 * create entity reference nodes in the DOM tree being produced. 0614 * When the 'create' flag is 0615 * true, the parser will create EntityReference nodes in the DOM tree. 0616 * The EntityReference nodes and their child nodes will be read-only. 0617 * When the 'create' flag is false, no EntityReference nodes will be created. 0618 * <p>The replacement text 0619 * of the entity is included in either case, either as a 0620 * child of the Entity Reference node or in place at the location 0621 * of the reference. 0622 * <p>The default value is 'true'. 0623 * 0624 * @param create The new state of the create entity reference nodes 0625 * flag. 0626 * @see #getCreateEntityReferenceNodes 0627 */ 0628 void setCreateEntityReferenceNodes(const bool create); 0629 0630 /** Set the 'include ignorable whitespace' flag 0631 * 0632 * This method allows the user to specify whether a validating parser 0633 * should include ignorable whitespaces as text nodes. It has no effect 0634 * on non-validating parsers which always include non-markup text. 0635 * <p>When set to true (also the default), ignorable whitespaces will be 0636 * added to the DOM tree as text nodes. The method 0637 * DOMText::isIgnorableWhitespace() will return true for those text 0638 * nodes only. 0639 * <p>When set to false, all ignorable whitespace will be discarded and 0640 * no text node is added to the DOM tree. Note: applications intended 0641 * to process the "xml:space" attribute should not set this flag to false. 0642 * And this flag also overrides any schema datateye whitespace facets, 0643 * that is, all ignorable whitespace will be discarded even though 0644 * 'preserve' is set in schema datatype whitespace facets. 0645 * 0646 * @param include The new state of the include ignorable whitespace 0647 * flag. 0648 * 0649 * @see #getIncludeIgnorableWhitespace 0650 */ 0651 void setIncludeIgnorableWhitespace(const bool include); 0652 0653 /** 0654 * This method allows users to set the validation scheme to be used 0655 * by this parser. The value is one of the ValSchemes enumerated values 0656 * defined by this class: 0657 * 0658 * <br> Val_Never - turn off validation 0659 * <br> Val_Always - turn on validation 0660 * <br> Val_Auto - turn on validation if any internal/external 0661 * DTD subset have been seen 0662 * 0663 * <p>The parser's default state is: Val_Never.</p> 0664 * 0665 * @param newScheme The new validation scheme to use. 0666 * 0667 * @see #getValidationScheme 0668 */ 0669 void setValidationScheme(const ValSchemes newScheme); 0670 0671 /** Set the 'do schema' flag 0672 * 0673 * This method allows users to enable or disable the parser's 0674 * schema processing. When set to false, parser will not process 0675 * any schema found. 0676 * 0677 * The parser's default state is: false. 0678 * 0679 * Note: If set to true, namespace processing must also be turned on. 0680 * 0681 * @param newState The value specifying whether schema support should 0682 * be enforced or not. 0683 * 0684 * @see #getDoSchema 0685 */ 0686 void setDoSchema(const bool newState); 0687 0688 /** 0689 * This method allows the user to turn full Schema constraint checking on/off. 0690 * Only takes effect if Schema validation is enabled. 0691 * If turned off, partial constraint checking is done. 0692 * 0693 * Full schema constraint checking includes those checking that may 0694 * be time-consuming or memory intensive. Currently, particle unique 0695 * attribution constraint checking and particle derivation restriction checking 0696 * are controlled by this option. 0697 * 0698 * The parser's default state is: false. 0699 * 0700 * @param schemaFullChecking True to turn on full schema constraint checking. 0701 * 0702 * @see #getValidationSchemaFullChecking 0703 */ 0704 void setValidationSchemaFullChecking(const bool schemaFullChecking); 0705 0706 /** 0707 * This method allows users to enable or disable the parser's identity 0708 * constraint checks. 0709 * 0710 * <p>By default, the parser does identity constraint checks. 0711 * The default value is true.</p> 0712 * 0713 * @param newState The value specifying whether the parser should 0714 * do identity constraint checks or not in the 0715 * input XML document. 0716 * 0717 * @see #getIdentityConstraintChecking 0718 */ 0719 void setIdentityConstraintChecking(const bool newState); 0720 0721 /** 0722 * This method allows the user to specify a list of schemas to use. 0723 * If the targetNamespace of a schema specified using this method matches 0724 * the targetNamespace of a schema occurring in the instance document in 0725 * the schemaLocation attribute, or if the targetNamespace matches the 0726 * namespace attribute of the "import" element, the schema specified by the 0727 * user using this method will be used (i.e., the schemaLocation attribute 0728 * in the instance document or on the "import" element will be effectively ignored). 0729 * 0730 * If this method is called more than once, only the last one takes effect. 0731 * 0732 * The syntax is the same as for schemaLocation attributes in instance 0733 * documents: e.g, "http://www.example.com file_name.xsd". The user can 0734 * specify more than one XML Schema in the list. 0735 * 0736 * @param schemaLocation the list of schemas to use 0737 * 0738 * @see #getExternalSchemaLocation 0739 */ 0740 0741 void setExternalSchemaLocation(const XMLCh* const schemaLocation); 0742 0743 /** 0744 * This method is same as setExternalSchemaLocation(const XMLCh* const). 0745 * It takes native char string as parameter 0746 * 0747 * @param schemaLocation the list of schemas to use 0748 * 0749 * @see #setExternalSchemaLocation(const XMLCh* const) 0750 */ 0751 void setExternalSchemaLocation(const char* const schemaLocation); 0752 0753 /** 0754 * This method allows the user to specify the no target namespace XML 0755 * Schema Location externally. If specified, the instance document's 0756 * noNamespaceSchemaLocation attribute will be effectively ignored. 0757 * 0758 * If this method is called more than once, only the last one takes effect. 0759 * 0760 * The syntax is the same as for the noNamespaceSchemaLocation attribute 0761 * that may occur in an instance document: e.g."file_name.xsd". 0762 * 0763 * @param noNamespaceSchemaLocation the XML Schema Location with no target namespace 0764 * 0765 * @see #getExternalNoNamespaceSchemaLocation 0766 */ 0767 void setExternalNoNamespaceSchemaLocation(const XMLCh* const noNamespaceSchemaLocation); 0768 0769 /** 0770 * This method is same as setExternalNoNamespaceSchemaLocation(const XMLCh* const). 0771 * It takes native char string as parameter 0772 * 0773 * @param noNamespaceSchemaLocation the XML Schema Location with no target namespace 0774 * 0775 * @see #setExternalNoNamespaceSchemaLocation(const XMLCh* const) 0776 */ 0777 void setExternalNoNamespaceSchemaLocation(const char* const noNamespaceSchemaLocation); 0778 0779 /** 0780 * This allows an application to set a SecurityManager on 0781 * the parser; this object stores information that various 0782 * components use to limit their consumption of system 0783 * resources while processing documents. 0784 * 0785 * If this method is called more than once, only the last one takes effect. 0786 * It may not be reset during a parse. 0787 * 0788 * 0789 * @param securityManager the SecurityManager instance to 0790 * be used by this parser 0791 * 0792 * @see #getSecurityManager 0793 */ 0794 void setSecurityManager(SecurityManager* const securityManager); 0795 0796 /** Set the raw buffer low water mark for this parser. 0797 * 0798 * If the number of available bytes in the raw buffer is less than 0799 * the low water mark the parser will attempt to read more data before 0800 * continuing parsing. By default the value for this parameter is 100 0801 * bytes. You may want to set this parameter to 0 if you would like 0802 * the parser to parse the available data immediately without 0803 * potentially blocking while waiting for more date. 0804 * 0805 * @param lwm new low water mark 0806 * 0807 * @see #getSecurityManager 0808 */ 0809 void setLowWaterMark(XMLSize_t lwm); 0810 0811 /** Set the 'Disallow DOCTYPE (DTD)' flag 0812 * 0813 * This method allows users to disable the processing of DOCTYPE (DTD). 0814 * When set to true, the parser will throw an exception if the document 0815 * contains the DOCTYPE node. 0816 * 0817 * The parser's default state is: false. 0818 * 0819 * @param newState The value specifying whether to disallow DOCTYPE 0820 * or not. 0821 * 0822 * @see #setDisallowDoctype() 0823 * @see #getLoadExternalDTD 0824 * @see #getValidationScheme 0825 */ 0826 void setDisallowDoctype(const bool newState); 0827 0828 /** Set the 'Loading External DTD' flag 0829 * 0830 * This method allows users to enable or disable the loading of external DTD. 0831 * When set to false, the parser will ignore any external DTD completely 0832 * if the validationScheme is set to Val_Never. 0833 * 0834 * The parser's default state is: true. 0835 * 0836 * This flag is ignored if the validationScheme is set to Val_Always or Val_Auto. 0837 * 0838 * @param newState The value specifying whether external DTD should 0839 * be loaded or not. 0840 * 0841 * @see #getLoadExternalDTD 0842 * @see #setDisallowDoctype 0843 * @see #setValidationScheme 0844 */ 0845 void setLoadExternalDTD(const bool newState); 0846 0847 /** Set the 'Loading Schema' flag 0848 * 0849 * This method allows users to enable or disable the loading of schemas. 0850 * When set to false, the parser not attempt to load schemas beyond 0851 * querying the grammar pool for them. 0852 * 0853 * The parser's default state is: true. 0854 * 0855 * @param newState The value specifying whether schemas should 0856 * be loaded if they're not found in the grammar 0857 * pool. 0858 * 0859 * @see #getLoadSchema 0860 * @see #setDoSchema 0861 */ 0862 void setLoadSchema(const bool newState); 0863 0864 /** Set the 'create comment nodes' flag 0865 * 0866 * This method allows the user to specify whether the parser should 0867 * create comment nodes in the DOM tree being produced. 0868 * <p>The default value is 'true'. 0869 * 0870 * @param create The new state of the create comment nodes 0871 * flag. 0872 * @see #getCreateCommentNodes 0873 */ 0874 void setCreateCommentNodes(const bool create); 0875 0876 /** Enable/disable src offset calculation 0877 * 0878 * This method allows users to enable/disable src offset calculation. 0879 * Disabling the calculation will improve performance. 0880 * 0881 * The parser's default state is: false. 0882 * 0883 * @param newState The value specifying whether we should enable or 0884 * disable src offset calculation 0885 * 0886 * @see #getCalculateSrcOfs 0887 */ 0888 void setCalculateSrcOfs(const bool newState); 0889 0890 /** Force standard uri 0891 * 0892 * This method allows users to tell the parser to force standard uri conformance. 0893 * 0894 * The parser's default state is: false. 0895 * 0896 * @param newState The value specifying whether the parser should reject malformed URI. 0897 * 0898 * @see #getStandardUriConformant 0899 */ 0900 void setStandardUriConformant(const bool newState); 0901 0902 /** Set the scanner to use when scanning the XML document 0903 * 0904 * This method allows users to set the scanner to use 0905 * when scanning a given XML document. 0906 * 0907 * @param scannerName The name of the desired scanner 0908 */ 0909 void useScanner(const XMLCh* const scannerName); 0910 0911 /** Set the implementation to use when creating the document 0912 * 0913 * This method allows users to set the implementation to use 0914 * to create the document when parseing. 0915 * 0916 * @param implementationFeatures The names of the desired features the implementation should have. 0917 */ 0918 void useImplementation(const XMLCh* const implementationFeatures); 0919 0920 /** 0921 * This method installs the user specified PSVI handler on 0922 * the parser. 0923 * 0924 * @param handler A pointer to the PSVI handler to be called 0925 * when the parser comes across 'PSVI' events 0926 * as per the schema specification. 0927 */ 0928 virtual void setPSVIHandler(PSVIHandler* const handler); 0929 0930 /** Set the 'associate schema info' flag 0931 * 0932 * This method allows users to specify whether 0933 * the parser should store schema informations in the element 0934 * and attribute nodes in the DOM tree being produced. 0935 * 0936 * @param newState The state to set 0937 * @see #getCreateSchemaInfo 0938 */ 0939 void setCreateSchemaInfo(const bool newState); 0940 0941 /** Set the 'do XInclude' flag 0942 * 0943 * This method allows users to specify whether 0944 * the parser should process XInclude nodes 0945 * in the DOM tree being produced. 0946 * 0947 * @param newState The state to set 0948 * @see #getDoXInclude 0949 */ 0950 void setDoXInclude(const bool newState); 0951 0952 /** Set the 'ignore annotation' flag 0953 * 0954 * This method gives users the option to not generate XSAnnotations 0955 * when "traversing" a schema. 0956 * 0957 * The parser's default state is false 0958 * 0959 * @param newValue The state to set 0960 */ 0961 void setIgnoreAnnotations(const bool newValue); 0962 0963 /** Set the 'disable default entity resolution' flag 0964 * 0965 * This method gives users the option to not perform default entity 0966 * resolution. If the user's resolveEntity method returns NULL the 0967 * parser will try to resolve the entity on its own. When this option 0968 * is set to true, the parser will not attempt to resolve the entity 0969 * when the resolveEntity method returns NULL. 0970 * 0971 * The parser's default state is false 0972 * 0973 * @param newValue The state to set 0974 * 0975 * @see #EntityResolver 0976 */ 0977 void setDisableDefaultEntityResolution(const bool newValue); 0978 0979 /** Set the 'skip DTD validation' flag 0980 * 0981 * This method gives users the option to skip DTD validation only when 0982 * schema validation is on (i.e. when performing validation, we will 0983 * ignore the DTD, except for entities, when schema validation is enabled). 0984 * 0985 * NOTE: This option is ignored if schema validation is disabled. 0986 * 0987 * The parser's default state is false 0988 * 0989 * @param newValue The state to set 0990 */ 0991 void setSkipDTDValidation(const bool newValue); 0992 0993 /** Set the 'handle multiple schema imports' flag 0994 * 0995 * This method gives users the ability to import multiple schemas that 0996 * have the same namespace. 0997 * 0998 * NOTE: This option is ignored if schema validation is disabled. 0999 * 1000 * The parser's default state is false 1001 * 1002 * @param newValue The state to set 1003 */ 1004 void setHandleMultipleImports(const bool newValue); 1005 //@} 1006 1007 1008 // ----------------------------------------------------------------------- 1009 // Parsing methods 1010 // ----------------------------------------------------------------------- 1011 1012 /** @name Parsing methods */ 1013 //@{ 1014 1015 /** Parse via an input source object 1016 * 1017 * This method invokes the parsing process on the XML file specified 1018 * by the InputSource parameter. This API is borrowed from the 1019 * SAX Parser interface. 1020 * 1021 * @param source A const reference to the InputSource object which 1022 * points to the XML file to be parsed. 1023 * @exception SAXException Any SAX exception, possibly 1024 * wrapping another exception. 1025 * @exception XMLException An exception from the parser or client 1026 * handler code. 1027 * @exception DOMException A DOM exception as per DOM spec. 1028 * @see InputSource#InputSource 1029 */ 1030 void parse(const InputSource& source); 1031 1032 /** Parse via a file path or URL 1033 * 1034 * This method invokes the parsing process on the XML file specified by 1035 * the Unicode string parameter 'systemId'. This method is borrowed 1036 * from the SAX Parser interface. 1037 * 1038 * @param systemId A const XMLCh pointer to the Unicode string which 1039 * contains the path to the XML file to be parsed. 1040 * 1041 * @exception SAXException Any SAX exception, possibly 1042 * wrapping another exception. 1043 * @exception XMLException An exception from the parser or client 1044 * handler code. 1045 * @exception DOMException A DOM exception as per DOM spec. 1046 * @see #parse(InputSource,...) 1047 */ 1048 void parse(const XMLCh* const systemId); 1049 1050 /** Parse via a file path or URL (in the local code page) 1051 * 1052 * This method invokes the parsing process on the XML file specified by 1053 * the native char* string parameter 'systemId'. 1054 * 1055 * @param systemId A const char pointer to a native string which 1056 * contains the path to the XML file to be parsed. 1057 * 1058 * @exception SAXException Any SAX exception, possibly 1059 * wrapping another exception. 1060 * @exception XMLException An exception from the parser or client 1061 * handler code. 1062 * @exception DOMException A DOM exception as per DOM spec. 1063 * @see #parse(InputSource,...) 1064 */ 1065 void parse(const char* const systemId); 1066 1067 /** Begin a progressive parse operation 1068 * 1069 * This method is used to start a progressive parse on a XML file. 1070 * To continue parsing, subsequent calls must be to the parseNext 1071 * method. 1072 * 1073 * It scans through the prolog and returns a token to be used on 1074 * subsequent scanNext() calls. If the return value is true, then the 1075 * token is legal and ready for further use. If it returns false, then 1076 * the scan of the prolog failed and the token is not going to work on 1077 * subsequent scanNext() calls. 1078 * 1079 * @param systemId A pointer to a Unicode string representing the path 1080 * to the XML file to be parsed. 1081 * @param toFill A token maintaing state information to maintain 1082 * internal consistency between invocation of 'parseNext' 1083 * calls. 1084 * @return 'true', if successful in parsing the prolog. It indicates the 1085 * user can go ahead with parsing the rest of the file. It 1086 * returns 'false' to indicate that the parser could not parse 1087 * the prolog. 1088 * 1089 * @see #parseNext 1090 * @see #parseFirst(char*,...) 1091 * @see #parseFirst(InputSource&,...) 1092 */ 1093 bool parseFirst 1094 ( 1095 const XMLCh* const systemId 1096 , XMLPScanToken& toFill 1097 ); 1098 1099 /** Begin a progressive parse operation 1100 * 1101 * This method is used to start a progressive parse on a XML file. 1102 * To continue parsing, subsequent calls must be to the parseNext 1103 * method. 1104 * 1105 * It scans through the prolog and returns a token to be used on 1106 * subsequent scanNext() calls. If the return value is true, then the 1107 * token is legal and ready for further use. If it returns false, then 1108 * the scan of the prolog failed and the token is not going to work on 1109 * subsequent scanNext() calls. 1110 * 1111 * @param systemId A pointer to a regular native string representing 1112 * the path to the XML file to be parsed. 1113 * @param toFill A token maintaing state information to maintain 1114 * internal consistency between invocation of 'parseNext' 1115 * calls. 1116 * 1117 * @return 'true', if successful in parsing the prolog. It indicates the 1118 * user can go ahead with parsing the rest of the file. It 1119 * returns 'false' to indicate that the parser could not parse 1120 * the prolog. 1121 * 1122 * @see #parseNext 1123 * @see #parseFirst(XMLCh*,...) 1124 * @see #parseFirst(InputSource&,...) 1125 */ 1126 bool parseFirst 1127 ( 1128 const char* const systemId 1129 , XMLPScanToken& toFill 1130 ); 1131 1132 /** Begin a progressive parse operation 1133 * 1134 * This method is used to start a progressive parse on a XML file. 1135 * To continue parsing, subsequent calls must be to the parseNext 1136 * method. 1137 * 1138 * It scans through the prolog and returns a token to be used on 1139 * subsequent scanNext() calls. If the return value is true, then the 1140 * token is legal and ready for further use. If it returns false, then 1141 * the scan of the prolog failed and the token is not going to work on 1142 * subsequent scanNext() calls. 1143 * 1144 * @param source A const reference to the InputSource object which 1145 * points to the XML file to be parsed. 1146 * @param toFill A token maintaing state information to maintain 1147 * internal consistency between invocation of 'parseNext' 1148 * calls. 1149 * 1150 * @return 'true', if successful in parsing the prolog. It indicates the 1151 * user can go ahead with parsing the rest of the file. It 1152 * returns 'false' to indicate that the parser could not parse 1153 * the prolog. 1154 * 1155 * @see #parseNext 1156 * @see #parseFirst(XMLCh*,...) 1157 * @see #parseFirst(char*,...) 1158 */ 1159 bool parseFirst 1160 ( 1161 const InputSource& source 1162 , XMLPScanToken& toFill 1163 ); 1164 1165 /** Continue a progressive parse operation 1166 * 1167 * This method is used to continue with progressive parsing of 1168 * XML files started by a call to 'parseFirst' method. 1169 * 1170 * It parses the XML file and stops as soon as it comes across 1171 * a XML token (as defined in the XML specification). 1172 * 1173 * @param token A token maintaing state information to maintain 1174 * internal consistency between invocation of 'parseNext' 1175 * calls. 1176 * 1177 * @return 'true', if successful in parsing the next XML token. 1178 * It indicates the user can go ahead with parsing the rest 1179 * of the file. It returns 'false' to indicate that the parser 1180 * could not find next token as per the XML specification 1181 * production rule. 1182 * 1183 * @see #parseFirst(XMLCh*,...) 1184 * @see #parseFirst(char*,...) 1185 * @see #parseFirst(InputSource&,...) 1186 */ 1187 bool parseNext(XMLPScanToken& token); 1188 1189 /** Reset the parser after a progressive parse 1190 * 1191 * If a progressive parse loop exits before the end of the document 1192 * is reached, the parser has no way of knowing this. So it will leave 1193 * open any files or sockets or memory buffers that were in use at 1194 * the time that the parse loop exited. 1195 * 1196 * The next parse operation will cause these open files and such to 1197 * be closed, but the next parse operation might occur at some unknown 1198 * future point. To avoid this problem, you should reset the parser if 1199 * you exit the loop early. 1200 * 1201 * If you exited because of an error, then this cleanup will be done 1202 * for you. Its only when you exit the file prematurely of your own 1203 * accord, because you've found what you wanted in the file most 1204 * likely. 1205 * 1206 * @param token A token maintaing state information to maintain 1207 * internal consistency between invocation of 'parseNext' 1208 * calls. 1209 * 1210 * @see #parseFirst(XMLCh*,...) 1211 * @see #parseFirst(char*,...) 1212 * @see #parseFirst(InputSource&,...) 1213 */ 1214 void parseReset(XMLPScanToken& token); 1215 1216 //@} 1217 1218 // ----------------------------------------------------------------------- 1219 // Implementation of the PSVIHandler interface. 1220 // ----------------------------------------------------------------------- 1221 1222 /** @name Implementation of the PSVIHandler interface. */ 1223 //@{ 1224 1225 /** Receive notification of the PSVI properties of an element. 1226 * The scanner will issue this call after the XMLDocumentHandler 1227 * endElement call. Since the scanner will issue the psviAttributes 1228 * call immediately after reading the start tag of an element, all element 1229 * content will be effectively bracketed by these two calls. 1230 * @param localName The name of the element whose end tag was just 1231 * parsed. 1232 * @param uri The namespace to which the element is bound 1233 * @param elementInfo Object containing the element's PSVI properties 1234 */ 1235 virtual void handleElementPSVI 1236 ( 1237 const XMLCh* const localName 1238 , const XMLCh* const uri 1239 , PSVIElement * elementInfo 1240 ); 1241 1242 virtual void handlePartialElementPSVI 1243 ( 1244 const XMLCh* const localName 1245 , const XMLCh* const uri 1246 , PSVIElement * elementInfo 1247 ); 1248 /** 1249 * Enables PSVI information about attributes to be passed back to the 1250 * application. This callback will be made on *all* 1251 * elements; on elements with no attributes, the final parameter will 1252 * be null. 1253 * @param localName The name of the element upon which start tag 1254 * these attributes were encountered. 1255 * @param uri The namespace to which the element is bound 1256 * @param psviAttributes Object containing the attributes' PSVI properties 1257 * with information to identify them. 1258 */ 1259 virtual void handleAttributesPSVI 1260 ( 1261 const XMLCh* const localName 1262 , const XMLCh* const uri 1263 , PSVIAttributeList * psviAttributes 1264 ); 1265 //@} 1266 1267 // ----------------------------------------------------------------------- 1268 // Implementation of the XMLDocumentHandler interface. 1269 // ----------------------------------------------------------------------- 1270 1271 /** @name Implementation of the XMLDocumentHandler interface. */ 1272 //@{ 1273 1274 /** Handle document character events 1275 * 1276 * This method is used to report all the characters scanned by the 1277 * parser. This DOM implementation stores this data in the appropriate 1278 * DOM node, creating one if necessary. 1279 * 1280 * @param chars A const pointer to a Unicode string representing the 1281 * character data. 1282 * @param length The length of the Unicode string returned in 'chars'. 1283 * @param cdataSection A flag indicating if the characters represent 1284 * content from the CDATA section. 1285 */ 1286 virtual void docCharacters 1287 ( 1288 const XMLCh* const chars 1289 , const XMLSize_t length 1290 , const bool cdataSection 1291 ); 1292 1293 /** Handle a document comment event 1294 * 1295 * This method is used to report any comments scanned by the parser. 1296 * A new comment node is created which stores this data. 1297 * 1298 * @param comment A const pointer to a null terminated Unicode 1299 * string representing the comment text. 1300 */ 1301 virtual void docComment 1302 ( 1303 const XMLCh* const comment 1304 ); 1305 1306 /** Handle a document PI event 1307 * 1308 * This method is used to report any PI scanned by the parser. A new 1309 * PI node is created and appended as a child of the current node in 1310 * the tree. 1311 * 1312 * @param target A const pointer to a Unicode string representing the 1313 * target of the PI declaration. 1314 * @param data A const pointer to a Unicode string representing the 1315 * data of the PI declaration. See the PI production rule 1316 * in the XML specification for details. 1317 */ 1318 virtual void docPI 1319 ( 1320 const XMLCh* const target 1321 , const XMLCh* const data 1322 ); 1323 1324 /** Handle the end of document event 1325 * 1326 * This method is used to indicate the end of the current document. 1327 */ 1328 virtual void endDocument(); 1329 1330 /** Handle and end of element event 1331 * 1332 * This method is used to indicate the end tag of an element. The 1333 * DOM parser pops the current element off the top of the element 1334 * stack, and make it the new current element. 1335 * 1336 * @param elemDecl A const reference to the object containing element 1337 * declaration information. 1338 * @param urlId An id referring to the namespace prefix, if 1339 * namespaces setting is switched on. 1340 * @param isRoot A flag indicating whether this element was the 1341 * root element. 1342 * @param elemPrefix A const pointer to a Unicode string containing 1343 * the namespace prefix for this element. Applicable 1344 * only when namespace processing is enabled. 1345 */ 1346 virtual void endElement 1347 ( 1348 const XMLElementDecl& elemDecl 1349 , const unsigned int urlId 1350 , const bool isRoot 1351 , const XMLCh* const elemPrefix 1352 ); 1353 1354 /** Handle and end of entity reference event 1355 * 1356 * This method is used to indicate that an end of an entity reference 1357 * was just scanned. 1358 * 1359 * @param entDecl A const reference to the object containing the 1360 * entity declaration information. 1361 */ 1362 virtual void endEntityReference 1363 ( 1364 const XMLEntityDecl& entDecl 1365 ); 1366 1367 /** Handle an ignorable whitespace vent 1368 * 1369 * This method is used to report all the whitespace characters, which 1370 * are determined to be 'ignorable'. This distinction between characters 1371 * is only made, if validation is enabled. 1372 * 1373 * Any whitespace before content is ignored. If the current node is 1374 * already of type DOMNode::TEXT_NODE, then these whitespaces are 1375 * appended, otherwise a new Text node is created which stores this 1376 * data. Essentially all contiguous ignorable characters are collected 1377 * in one node. 1378 * 1379 * @param chars A const pointer to a Unicode string representing the 1380 * ignorable whitespace character data. 1381 * @param length The length of the Unicode string 'chars'. 1382 * @param cdataSection A flag indicating if the characters represent 1383 * content from the CDATA section. 1384 */ 1385 virtual void ignorableWhitespace 1386 ( 1387 const XMLCh* const chars 1388 , const XMLSize_t length 1389 , const bool cdataSection 1390 ); 1391 1392 /** Handle a document reset event 1393 * 1394 * This method allows the user installed Document Handler to 'reset' 1395 * itself, freeing all the memory resources. The scanner calls this 1396 * method before starting a new parse event. 1397 */ 1398 virtual void resetDocument(); 1399 1400 /** Handle a start document event 1401 * 1402 * This method is used to report the start of the parsing process. 1403 */ 1404 virtual void startDocument(); 1405 1406 /** Handle a start element event 1407 * 1408 * This method is used to report the start of an element. It is 1409 * called at the end of the element, by which time all attributes 1410 * specified are also parsed. A new DOM Element node is created 1411 * along with as many attribute nodes as required. This new element 1412 * is added appended as a child of the current node in the tree, and 1413 * then replaces it as the current node (if the isEmpty flag is false.) 1414 * 1415 * @param elemDecl A const reference to the object containing element 1416 * declaration information. 1417 * @param urlId An id referring to the namespace prefix, if 1418 * namespaces setting is switched on. 1419 * @param elemPrefix A const pointer to a Unicode string containing 1420 * the namespace prefix for this element. Applicable 1421 * only when namespace processing is enabled. 1422 * @param attrList A const reference to the object containing the 1423 * list of attributes just scanned for this element. 1424 * @param attrCount A count of number of attributes in the list 1425 * specified by the parameter 'attrList'. 1426 * @param isEmpty A flag indicating whether this is an empty element 1427 * or not. If empty, then no endElement() call will 1428 * be made. 1429 * @param isRoot A flag indicating whether this element was the 1430 * root element. 1431 * @see DocumentHandler#startElement 1432 */ 1433 virtual void startElement 1434 ( 1435 const XMLElementDecl& elemDecl 1436 , const unsigned int urlId 1437 , const XMLCh* const elemPrefix 1438 , const RefVectorOf<XMLAttr>& attrList 1439 , const XMLSize_t attrCount 1440 , const bool isEmpty 1441 , const bool isRoot 1442 ); 1443 1444 /** Handle a start entity reference event 1445 * 1446 * This method is used to indicate the start of an entity reference. 1447 * If the expand entity reference flag is true, then a new 1448 * DOM Entity reference node is created. 1449 * 1450 * @param entDecl A const reference to the object containing the 1451 * entity declaration information. 1452 */ 1453 virtual void startEntityReference 1454 ( 1455 const XMLEntityDecl& entDecl 1456 ); 1457 1458 /** Handle an XMLDecl event 1459 * 1460 * This method is used to report the XML decl scanned by the parser. 1461 * Refer to the XML specification to see the meaning of parameters. 1462 * 1463 * <b>This method is a no-op for this DOM 1464 * implementation.</b> 1465 * 1466 * @param versionStr A const pointer to a Unicode string representing 1467 * version string value. 1468 * @param encodingStr A const pointer to a Unicode string representing 1469 * the encoding string value. 1470 * @param standaloneStr A const pointer to a Unicode string 1471 * representing the standalone string value. 1472 * @param actualEncStr A const pointer to a Unicode string 1473 * representing the actual encoding string 1474 * value. 1475 */ 1476 virtual void XMLDecl 1477 ( 1478 const XMLCh* const versionStr 1479 , const XMLCh* const encodingStr 1480 , const XMLCh* const standaloneStr 1481 , const XMLCh* const actualEncStr 1482 ); 1483 1484 //@} 1485 1486 1487 // ----------------------------------------------------------------------- 1488 // Implementation of the deprecated DocTypeHandler interface. 1489 // ----------------------------------------------------------------------- 1490 /** @name Deprecated DocTypeHandler Interfaces */ 1491 //@{ 1492 virtual void attDef 1493 ( 1494 const DTDElementDecl& elemDecl 1495 , const DTDAttDef& attDef 1496 , const bool ignoring 1497 ); 1498 1499 virtual void doctypeComment 1500 ( 1501 const XMLCh* const comment 1502 ); 1503 1504 virtual void doctypeDecl 1505 ( 1506 const DTDElementDecl& elemDecl 1507 , const XMLCh* const publicId 1508 , const XMLCh* const systemId 1509 , const bool hasIntSubset 1510 , const bool hasExtSubset = false 1511 ); 1512 1513 virtual void doctypePI 1514 ( 1515 const XMLCh* const target 1516 , const XMLCh* const data 1517 ); 1518 1519 virtual void doctypeWhitespace 1520 ( 1521 const XMLCh* const chars 1522 , const XMLSize_t length 1523 ); 1524 1525 virtual void elementDecl 1526 ( 1527 const DTDElementDecl& decl 1528 , const bool isIgnored 1529 ); 1530 1531 virtual void endAttList 1532 ( 1533 const DTDElementDecl& elemDecl 1534 ); 1535 1536 virtual void endIntSubset(); 1537 1538 virtual void endExtSubset(); 1539 1540 virtual void entityDecl 1541 ( 1542 const DTDEntityDecl& entityDecl 1543 , const bool isPEDecl 1544 , const bool isIgnored 1545 ); 1546 1547 virtual void resetDocType(); 1548 1549 virtual void notationDecl 1550 ( 1551 const XMLNotationDecl& notDecl 1552 , const bool isIgnored 1553 ); 1554 1555 virtual void startAttList 1556 ( 1557 const DTDElementDecl& elemDecl 1558 ); 1559 1560 virtual void startIntSubset(); 1561 1562 virtual void startExtSubset(); 1563 1564 virtual void TextDecl 1565 ( 1566 const XMLCh* const versionStr 1567 , const XMLCh* const encodingStr 1568 ); 1569 1570 //@} 1571 1572 protected: 1573 // DOM node creation hooks. Override them if you are using your own 1574 // DOM node types. 1575 // 1576 virtual DOMCDATASection* createCDATASection (const XMLCh*, XMLSize_t); 1577 virtual DOMText* createText (const XMLCh*, XMLSize_t); 1578 1579 virtual DOMElement* createElement (const XMLCh* name); 1580 virtual DOMElement* createElementNS (const XMLCh* namespaceURI, 1581 const XMLCh* elemPrefix, 1582 const XMLCh* localName, 1583 const XMLCh* qName); 1584 1585 virtual DOMAttr* createAttr (const XMLCh* name); 1586 virtual DOMAttr* createAttrNS (const XMLCh* namespaceURI, 1587 const XMLCh* elemPrefix, 1588 const XMLCh* localName, 1589 const XMLCh* qName); 1590 1591 1592 1593 1594 protected : 1595 // ----------------------------------------------------------------------- 1596 // Protected Constructor Methods 1597 // ----------------------------------------------------------------------- 1598 /** @name Constructors */ 1599 //@{ 1600 /** Construct a AbstractDOMParser, with an optional validator 1601 * 1602 * Constructor with an instance of validator class to use for 1603 * validation. If you don't provide a validator, a default one will 1604 * be created for you in the scanner. 1605 * 1606 * @param valToAdopt Pointer to the validator instance to use. The 1607 * parser is responsible for freeing the memory. 1608 * 1609 * @param gramPool Pointer to the grammar pool instance from 1610 * external application (through derivatives). 1611 * The parser does NOT own it. 1612 * 1613 * @param manager Pointer to the memory manager to be used to 1614 * allocate objects. 1615 */ 1616 AbstractDOMParser 1617 ( 1618 XMLValidator* const valToAdopt = 0 1619 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager 1620 , XMLGrammarPool* const gramPool = 0 1621 ); 1622 1623 //@} 1624 1625 // ----------------------------------------------------------------------- 1626 // Protected getter methods 1627 // ----------------------------------------------------------------------- 1628 /** @name Protected getter methods */ 1629 //@{ 1630 /** Get the current DOM node 1631 * 1632 * This provides derived classes with access to the current node, i.e. 1633 * the node to which new nodes are being added. 1634 */ 1635 DOMNode* getCurrentNode(); 1636 1637 /** Get the XML scanner 1638 * 1639 * This provides derived classes with access to the XML scanner. 1640 */ 1641 XMLScanner* getScanner() const; 1642 1643 /** Get the Grammar resolver 1644 * 1645 * This provides derived classes with access to the grammar resolver. 1646 */ 1647 GrammarResolver* getGrammarResolver() const; 1648 1649 /** Get the parse in progress flag 1650 * 1651 * This provides derived classes with access to the parse in progress 1652 * flag. 1653 */ 1654 bool getParseInProgress() const; 1655 1656 MemoryManager* getMemoryManager() const; 1657 1658 //@} 1659 1660 1661 // ----------------------------------------------------------------------- 1662 // Protected setter methods 1663 // ----------------------------------------------------------------------- 1664 1665 /** @name Protected setter methods */ 1666 //@{ 1667 1668 /** Set the current DOM node 1669 * 1670 * This method sets the current node maintained inside the parser to 1671 * the one specified. 1672 * 1673 * @param toSet The DOM node which will be the current node. 1674 */ 1675 void setCurrentNode(DOMNode* toSet); 1676 1677 /** Set the document node 1678 * 1679 * This method sets the DOM Document node to the one specified. 1680 * 1681 * @param toSet The new DOM Document node for this XML document. 1682 */ 1683 void setDocument(DOMDocument* toSet); 1684 1685 /** Set the parse in progress flag 1686 * 1687 * This method sets the parse in progress flag to true or false. 1688 * 1689 * @param toSet The value of the flag to be set. 1690 */ 1691 void setParseInProgress(const bool toSet); 1692 //@} 1693 1694 // ----------------------------------------------------------------------- 1695 // Protected Helper methods 1696 // ----------------------------------------------------------------------- 1697 /** @name Protected helper methods */ 1698 //@{ 1699 void resetPool(); 1700 1701 /** 1702 * Returns true if the user has adopted the document 1703 */ 1704 bool isDocumentAdopted() const; 1705 1706 //@} 1707 1708 1709 private : 1710 // ----------------------------------------------------------------------- 1711 // Initialize/Cleanup methods 1712 // ----------------------------------------------------------------------- 1713 void initialize(); 1714 void cleanUp(); 1715 void resetInProgress(); 1716 1717 // ----------------------------------------------------------------------- 1718 // Unimplemented constructors and operators 1719 // ----------------------------------------------------------------------- 1720 AbstractDOMParser(const AbstractDOMParser&); 1721 AbstractDOMParser& operator=(const AbstractDOMParser&); 1722 1723 protected: 1724 // ----------------------------------------------------------------------- 1725 // Protected data members 1726 // 1727 // fCurrentNode 1728 // fCurrentParent 1729 // Used to track the current node during nested element events. Since 1730 // the tree must be built from a set of disjoint callbacks, we need 1731 // these to keep up with where we currently are. 1732 // 1733 // fCurrentEntity 1734 // Used to track the current entity decl. If a text decl is seen later on, 1735 // it is used to update the encoding and version information. 1736 // 1737 // fDocument 1738 // The root document object, filled with the document contents. 1739 // 1740 // fCreateEntityReferenceNodes 1741 // Indicates whether entity reference nodes should be created. 1742 // 1743 // fIncludeIgnorableWhitespace 1744 // Indicates whether ignorable whitespace should be added to 1745 // the DOM tree for validating parsers. 1746 // 1747 // fScanner 1748 // The scanner used for this parser. This is created during the 1749 // constructor. 1750 // 1751 // fImplementationFeatures 1752 // The implementation features that we use to get an implementation 1753 // for use in creating the DOMDocument used during parse. If this is 1754 // null then the default DOMImplementation is used 1755 // 1756 // fParseInProgress 1757 // Used to prevent multiple entrance to the parser while its doing 1758 // a parse. 1759 // 1760 // fWithinElement 1761 // A flag to indicate that the parser is within at least one level 1762 // of element processing. 1763 // 1764 // fDocumentType 1765 // Used to store and update the documentType variable information 1766 // in fDocument 1767 // 1768 // fDocumentVector 1769 // Store all the previous fDocument(s) (thus not the current fDocument) 1770 // created in this parser. It is destroyed when the parser is destructed. 1771 // 1772 // fCreateCommentNodes 1773 // Indicates whether comment nodes should be created. 1774 // 1775 // fDocumentAdoptedByUser 1776 // The DOMDocument ownership has been transferred to application 1777 // If set to true, the parser does not own the document anymore 1778 // and thus will not release its memory. 1779 // 1780 // fInternalSubset 1781 // Buffer for storing the internal subset information. 1782 // Once complete (after DOCTYPE is finished scanning), send 1783 // it to DocumentType Node 1784 // 1785 // fGrammarPool 1786 // The grammar pool passed from external application (through derivatives). 1787 // which could be 0, not owned. 1788 // 1789 // fCreateSchemaInfo 1790 // Indicates whether element and attributes will have schema info associated 1791 // 1792 // fDoXinclude 1793 // A bool used to request that XInlcude processing occur on the 1794 // Document the parser parses. 1795 // ----------------------------------------------------------------------- 1796 bool fCreateEntityReferenceNodes; 1797 bool fIncludeIgnorableWhitespace; 1798 bool fWithinElement; 1799 bool fParseInProgress; 1800 bool fCreateCommentNodes; 1801 bool fDocumentAdoptedByUser; 1802 bool fCreateSchemaInfo; 1803 bool fDoXInclude; 1804 XMLScanner* fScanner; 1805 XMLCh* fImplementationFeatures; 1806 DOMNode* fCurrentParent; 1807 DOMNode* fCurrentNode; 1808 DOMEntityImpl* fCurrentEntity; 1809 DOMDocumentImpl* fDocument; 1810 DOMDocumentTypeImpl* fDocumentType; 1811 RefVectorOf<DOMDocumentImpl>* fDocumentVector; 1812 GrammarResolver* fGrammarResolver; 1813 XMLStringPool* fURIStringPool; 1814 XMLValidator* fValidator; 1815 MemoryManager* fMemoryManager; 1816 XMLGrammarPool* fGrammarPool; 1817 XMLBufferMgr fBufMgr; 1818 XMLBuffer& fInternalSubset; 1819 PSVIHandler* fPSVIHandler; 1820 }; 1821 1822 1823 1824 // --------------------------------------------------------------------------- 1825 // AbstractDOMParser: Getter methods 1826 // --------------------------------------------------------------------------- 1827 inline bool AbstractDOMParser::getCreateEntityReferenceNodes() const 1828 { 1829 return fCreateEntityReferenceNodes; 1830 } 1831 1832 inline bool AbstractDOMParser::getIncludeIgnorableWhitespace() const 1833 { 1834 return fIncludeIgnorableWhitespace; 1835 } 1836 1837 inline bool AbstractDOMParser::getParseInProgress() const 1838 { 1839 return fParseInProgress; 1840 } 1841 1842 inline XMLScanner* AbstractDOMParser::getScanner() const 1843 { 1844 return fScanner; 1845 } 1846 1847 inline GrammarResolver* AbstractDOMParser::getGrammarResolver() const 1848 { 1849 return fGrammarResolver; 1850 } 1851 1852 inline bool AbstractDOMParser::getCreateCommentNodes() const 1853 { 1854 return fCreateCommentNodes; 1855 } 1856 1857 inline PSVIHandler* AbstractDOMParser::getPSVIHandler() 1858 { 1859 return fPSVIHandler; 1860 } 1861 1862 inline const PSVIHandler* AbstractDOMParser::getPSVIHandler() const 1863 { 1864 return fPSVIHandler; 1865 } 1866 1867 inline bool AbstractDOMParser::getCreateSchemaInfo() const 1868 { 1869 return fCreateSchemaInfo; 1870 } 1871 1872 inline bool AbstractDOMParser::getDoXInclude() const 1873 { 1874 return fDoXInclude; 1875 } 1876 // --------------------------------------------------------------------------- 1877 // AbstractDOMParser: Setter methods 1878 // --------------------------------------------------------------------------- 1879 inline void AbstractDOMParser::setCreateEntityReferenceNodes(const bool create) 1880 { 1881 fCreateEntityReferenceNodes = create; 1882 } 1883 1884 inline void AbstractDOMParser::setIncludeIgnorableWhitespace(const bool include) 1885 { 1886 fIncludeIgnorableWhitespace = include; 1887 } 1888 1889 inline void AbstractDOMParser::setCreateCommentNodes(const bool create) 1890 { 1891 fCreateCommentNodes = create; 1892 } 1893 1894 inline void AbstractDOMParser::useImplementation(const XMLCh* const implementationFeatures) 1895 { 1896 fMemoryManager->deallocate(fImplementationFeatures); 1897 fImplementationFeatures = XMLString::replicate(implementationFeatures, fMemoryManager); 1898 } 1899 1900 inline void AbstractDOMParser::setDoXInclude(const bool newState) 1901 { 1902 fDoXInclude = newState; 1903 } 1904 1905 // --------------------------------------------------------------------------- 1906 // AbstractDOMParser: Protected getter methods 1907 // --------------------------------------------------------------------------- 1908 inline DOMNode* AbstractDOMParser::getCurrentNode() 1909 { 1910 return fCurrentNode; 1911 } 1912 1913 inline MemoryManager* AbstractDOMParser::getMemoryManager() const 1914 { 1915 return fMemoryManager; 1916 } 1917 1918 // --------------------------------------------------------------------------- 1919 // AbstractDOMParser: Protected setter methods 1920 // --------------------------------------------------------------------------- 1921 inline void AbstractDOMParser::setCurrentNode(DOMNode* toSet) 1922 { 1923 fCurrentNode = toSet; 1924 } 1925 1926 inline void AbstractDOMParser::setParseInProgress(const bool toSet) 1927 { 1928 fParseInProgress = toSet; 1929 } 1930 1931 XERCES_CPP_NAMESPACE_END 1932 1933 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |