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