Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:27:03

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 
0023 #if !defined(XERCESC_INCLUDE_GUARD_DOMLSPARSER_HPP)
0024 #define XERCESC_INCLUDE_GUARD_DOMLSPARSER_HPP
0025 
0026 #include <xercesc/dom/DOMConfiguration.hpp>
0027 #include <xercesc/dom/DOMLSParserFilter.hpp>
0028 #include <xercesc/util/XercesDefs.hpp>
0029 #include <xercesc/validators/common/Grammar.hpp>
0030 
0031 XERCES_CPP_NAMESPACE_BEGIN
0032 
0033 
0034 class DOMErrorHandler;
0035 class DOMLSInput;
0036 class DOMNode;
0037 class DOMDocument;
0038 
0039 /**
0040  * DOMLSParser provides an API for parsing XML documents and building the
0041  * corresponding DOM document tree. A DOMLSParser instance is obtained from
0042  * the DOMImplementationLS interface by invoking its createLSParser method.
0043  *
0044  * @since DOM Level 3
0045  *
0046  */
0047 class CDOM_EXPORT DOMLSParser
0048 {
0049 protected :
0050     // -----------------------------------------------------------------------
0051     //  Hidden constructors
0052     // -----------------------------------------------------------------------
0053     /** @name Hidden constructors */
0054     //@{
0055     DOMLSParser() {};
0056     //@}
0057 
0058 private:
0059     // -----------------------------------------------------------------------
0060     // Unimplemented constructors and operators
0061     // -----------------------------------------------------------------------
0062     /** @name Unimplemented constructors and operators */
0063     //@{
0064     DOMLSParser(const DOMLSParser &);
0065     DOMLSParser & operator = (const DOMLSParser &);
0066     //@}
0067 
0068 public:
0069     // -----------------------------------------------------------------------
0070     //  All constructors are hidden, just the destructor is available
0071     // -----------------------------------------------------------------------
0072     /** @name Destructor */
0073     //@{
0074     /**
0075      * Destructor
0076      *
0077      */
0078     virtual ~DOMLSParser() {};
0079     //@}
0080 
0081     // -----------------------------------------------------------------------
0082     //  Class types
0083     // -----------------------------------------------------------------------
0084     /** @name Public Constants */
0085     //@{
0086     /**
0087      * A set of possible actions for the parseWithContext method.
0088      *
0089      * <p><code>ACTION_APPEND_AS_CHILDREN</code>:
0090      * Append the result of the parse operation as children of the context node.
0091      * For this action to work, the context node must be a <code>DOMElement</code>
0092      * or a <code>DOMDocumentFragment</code>. </p>
0093      *
0094      * <p><code>ACTION_INSERT_AFTER</code>:
0095      * Insert the result of the parse operation as the immediately following sibling
0096      * of the context node. For this action to work the context node's parent must
0097      * be a <code>DOMElement</code> or a <code>DOMDocumentFragment</code>. </p>
0098      *
0099      * <p><code>ACTION_INSERT_BEFORE</code>:
0100      * Insert the result of the parse operation as the immediately preceding sibling
0101      * of the context node. For this action to work the context node's parent must
0102      * be a <code>DOMElement</code> or a <code>DOMDocumentFragment</code>. </p>
0103      *
0104      * <p><code>ACTION_REPLACE</code>:
0105      * Replace the context node with the result of the parse operation. For this
0106      * action to work, the context node must have a parent, and the parent must be
0107      * a <code>DOMElement</code> or a <code>DOMDocumentFragment</code>. </p>
0108      *
0109      * <p><code>ACTION_REPLACE_CHILDREN</code>:
0110      * Replace all the children of the context node with the result of the parse
0111      * operation. For this action to work, the context node must be a <code>DOMElement</code>,
0112      * a <code>DOMDocument</code>, or a <code>DOMDocumentFragment</code>. </p>
0113      *
0114      * @see parseWithContext(...)
0115      * @since DOM Level 3
0116      */
0117     enum ActionType
0118     {
0119         ACTION_APPEND_AS_CHILDREN = 1,
0120         ACTION_REPLACE_CHILDREN   = 2,
0121         ACTION_INSERT_BEFORE      = 3,
0122         ACTION_INSERT_AFTER       = 4,
0123         ACTION_REPLACE            = 5
0124     };
0125     //@}
0126 
0127     // -----------------------------------------------------------------------
0128     //  Virtual DOMLSParser interface
0129     // -----------------------------------------------------------------------
0130     /** @name Functions introduced in DOM Level 3 */
0131     //@{
0132 
0133     // -----------------------------------------------------------------------
0134     //  Getter methods
0135     // -----------------------------------------------------------------------
0136 
0137     /**
0138       * Get a pointer to the <code>DOMConfiguration</code> object used when parsing
0139       * an input source.
0140       * This <code>DOMConfiguration</code> is specific to the parse operation.
0141       * No parameter values from this <code>DOMConfiguration</code> object are passed
0142       * automatically to the <code>DOMConfiguration</code> object on the
0143       * <code>DOMDocument</code> that is created, or used, by the parse operation.
0144       * The DOM application is responsible for passing any needed parameter values
0145       * from this <code>DOMConfiguration</code> object to the <code>DOMConfiguration</code>
0146       * object referenced by the <code>DOMDocument</code> object.
0147       *
0148       * In addition to the parameters recognized in on the <code>DOMConfiguration</code>
0149       * interface defined in [DOM Level 3 Core], the <code>DOMConfiguration</code> objects
0150       * for <code>DOMLSParser</code> add or modify the following parameters:
0151       *
0152       * "charset-overrides-xml-encoding"
0153       *     true [optional] (default)
0154       *         If a higher level protocol such as HTTP [IETF RFC 2616] provides an
0155       *         indication of the character encoding of the input stream being processed,
0156       *         that will override any encoding specified in the XML declaration or the
0157       *         Text declaration (see also section 4.3.3, "Character Encoding in Entities",
0158       *         in [XML 1.0]). Explicitly setting an encoding in the <code>DOMLSInput</code>
0159       *          overrides any encoding from the protocol.
0160       *     false [required]
0161       *         The parser ignores any character set encoding information from higher-level
0162       *         protocols.
0163       *
0164       * "disallow-doctype"
0165       *     true
0166       *         Throw a fatal "doctype-not-allowed" error if a doctype node is found while
0167       *         parsing the document. This is useful when dealing with things like SOAP
0168       *         envelopes where doctype nodes are not allowed.
0169       *     false (default)
0170       *         Allow doctype nodes in the document.
0171       *
0172       * "ignore-unknown-character-denormalizations"
0173       *     true [required] (default)
0174       *         If, while verifying full normalization when [XML 1.1] is supported, a
0175       *         processor encounters characters for which it cannot determine the normalization
0176       *         properties, then the processor will ignore any possible denormalizations
0177       *         caused by these characters.
0178       *         This parameter is ignored for [XML 1.0].
0179       *     false [optional]
0180       *         Report an fatal "unknown-character-denormalization" error if a character
0181       *         is encountered for which the processor cannot determine the normalization
0182       *         properties.
0183       *
0184       * "infoset"
0185       *     See the definition of DOMConfiguration for a description of this parameter.
0186       *     Unlike in [DOM Level 3 Core], this parameter will default to true for DOMLSParser.
0187       *
0188       * "namespaces"
0189       *     true [required] (default)
0190       *         Perform the namespace processing as defined in [XML Namespaces] and
0191       *         [XML Namespaces 1.1].
0192       *     false [optional]
0193       *         Do not perform the namespace processing.
0194       *
0195       * "resource-resolver" [required]
0196       *     A pointer to a DOMLSResourceResolver object, or NULL. If the value of this parameter
0197       *     is not null when an external resource (such as an external XML entity or an XML schema
0198       *     location) is encountered, the implementation will request that the DOMLSResourceResolver
0199       *     referenced in this parameter resolves the resource.
0200       *
0201       * "supported-media-types-only"
0202       *     true [optional]
0203       *         Check that the media type of the parsed resource is a supported media type. If
0204       *         an unsupported media type is encountered, a fatal error of type "unsupported-media-type"
0205       *         will be raised. The media types defined in [IETF RFC 3023] must always be accepted.
0206       *     false [required] (default)
0207       *         Accept any media type.
0208       *
0209       * "validate"
0210       *     See the definition of <code>DOMConfiguration</code> for a description of this parameter.
0211       *     Unlike in [DOM Level 3 Core], the processing of the internal subset is always accomplished, even
0212       *     if this parameter is set to false.
0213       *
0214       * "validate-if-schema"
0215       *     See the definition of <code>DOMConfiguration</code> for a description of this parameter.
0216       *     Unlike in [DOM Level 3 Core], the processing of the internal subset is always accomplished, even
0217       *     if this parameter is set to false.
0218       *
0219       * "well-formed"
0220       *     See the definition of <code>DOMConfiguration</code> for a description of this parameter.
0221       *     Unlike in [DOM Level 3 Core], this parameter cannot be set to false.
0222       *
0223       * In addition to these, Xerces adds these non standard parameters:
0224       *
0225       * "http://apache.org/xml/properties/entity-resolver"
0226       *     A pointer to a XMLEntityResolver object, or NULL. If the value of this parameter
0227       *     is not null when an external resource (such as an external XML entity or an XML schema
0228       *     location) is encountered, the implementation will request that the XMLEntityResolver
0229       *     referenced in this parameter resolves the resource.
0230       *
0231       * "http://apache.org/xml/properties/schema/external-schemaLocation"
0232       *     A string holding a set of [namespaceUri schemaLocation] entries that will be treated as
0233       *     the content of the attribute xsi:schemaLocation of the root element
0234       *
0235       * "http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation"
0236       *     A string holding the schemaLocation for the empty namespace URI that will be treated as
0237       *     the content of the attribute xsi:noNamespaceSchemaLocation of the root element
0238       *
0239       * "http://apache.org/xml/properties/security-manager"
0240       *     A pointer to a SecurityManager object that will control how many entity references will be
0241       *     expanded during parsing
0242       *
0243       * "http://apache.org/xml/properties/scannerName"
0244       *     A string holding the type of scanner used while parsing. The valid names are:
0245       *      <ul>
0246       *       <li>IGXMLScanner: the default one, capable of both XMLSchema and DTD validation</li>
0247       *       <li>SGXMLScanner: a scanner that can only perform XMLSchema validation</li>
0248       *       <li>DGXMLScanner: a scanner that can only perform DTD validation</li>
0249       *       <li>WFXMLScanner: a scanner that cannot perform any type validation, only well-formedness</li>
0250       *      </ul>
0251       *
0252       * "http://apache.org/xml/properties/parser-use-DOMDocument-from-Implementation"
0253       *     A string holding the capabilities of the DOM implementation to be used to create the DOMDocument
0254       *     resulting from the parse operation. For instance, "LS" or "Core"
0255       *
0256       * "http://apache.org/xml/features/validation/schema"
0257       *     true
0258       *         Enable XMLSchema validation (note that also namespace processing should be enabled)
0259       *     false (default)
0260       *         Don't perform XMLSchema validation
0261       *
0262       * "http://apache.org/xml/features/validation/schema-full-checking"
0263       *     true
0264       *         Turn on full XMLSchema checking (e.g. Unique Particle Attribution)
0265       *     false (default)
0266       *         Don't perform full XMLSchema checking
0267       *
0268       * "http://apache.org/xml/features/validating/load-schema"
0269       *     true (default)
0270       *         Allow the parser to load schemas that are not in the grammar pool
0271       *     false
0272       *         Schemas that are not in the grammar pool are ignored
0273       *
0274       * "http://apache.org/xml/features/dom/user-adopts-DOMDocument"
0275       *     true
0276       *         The DOMDocument objects returned by <code>parse</code> will be owned by the caller
0277       *     false (default)
0278       *         The DOMDocument objects returned by <code>parse</code> will be owned by this <code>DOMLSParser</code>
0279       *         and deleted when released
0280       *
0281       * "http://apache.org/xml/features/nonvalidating/load-external-dtd"
0282       *     true (default)
0283       *         Allow the parser to load external DTDs
0284       *     false
0285       *         References to external DTDs will be ignored
0286       *
0287       * "http://apache.org/xml/features/continue-after-fatal-error"
0288       *     true
0289       *         Parsing should try to continue even if a fatal error has been triggered, trying to generate a DOM tree
0290       *         from a non well-formed XML
0291       *     false (default)
0292       *         Violation of XML rules will abort parsing
0293       *
0294       * "http://apache.org/xml/features/validation-error-as-fatal"
0295       *     true
0296       *         Validation errors are treated as fatal errors, and abort parsing (unless "continue-after-fatal-error"
0297       *         has been specified)
0298       *     false (default)
0299       *         Validation errors are normal errors
0300       *
0301       * "http://apache.org/xml/features/validation/cache-grammarFromParse"
0302       *     true
0303       *         XMLSchemas referenced by an XML file are cached in order to be reused by other parse operations
0304       *     false (default)
0305       *         XMLSchemas loaded during a parse operation will be discarded before the next one
0306       *
0307       * "http://apache.org/xml/features/validation/use-cachedGrammarInParse"
0308       *     true
0309       *         During this parse operation, reuse the XMLSchemas found in the cache
0310       *     false (default)
0311       *         Don't reuse the XMLSchemas found in the cache
0312       *
0313       * "http://apache.org/xml/features/calculate-src-ofs"
0314       *     true
0315       *         During parsing update the position in the source stream
0316       *     false (default)
0317       *         Don't waste time computing the position in the source stream
0318       *
0319       * "http://apache.org/xml/features/standard-uri-conformant"
0320       *     true
0321       *         Require that every URL being resolved is made of valid URL characters only
0322       *     false (default)
0323       *         Allow invalid URL characters in URL (e.g. spaces)
0324       *
0325       * "http://apache.org/xml/features/dom-has-psvi-info"
0326       *     true
0327       *         Add schema informations to DOMElement and DOMAttr nodes in the output DOM tree
0328       *     false (default)
0329       *         Don't store schema informations in the output DOM tree
0330       *
0331       * "http://apache.org/xml/features/generate-synthetic-annotations"
0332       *     true
0333       *         Create annotation objects in the representation of the loaded XMLSchemas
0334       *     false (default)
0335       *         Discard annotations found in the loaded XMLSchemas
0336       *
0337       * "http://apache.org/xml/features/validate-annotations"
0338       *     true
0339       *         Check that annotations are valid according to their XMLSchema definition
0340       *     false (default)
0341       *         Don't validate annotations
0342       *
0343       * "http://apache.org/xml/features/validation/identity-constraint-checking"
0344       *     true (default)
0345       *         Enforce identity constraints specified in the XMLSchema
0346       *     false
0347       *         Don't enforce identity constraints
0348       *
0349       * "http://apache.org/xml/features/validation/ignoreCachedDTD"
0350       *     true
0351       *         Don't reuse DTDs found in the cache, even if use-cachedGrammarInParse is <code>true</code>
0352       *     false (default)
0353       *         Reuse DTDs found in the cache, if use-cachedGrammarInParse is <code>true</code>
0354       *
0355       * "http://apache.org/xml/features/schema/ignore-annotations"
0356       *     true
0357       *         Don't process annotations found in an XMLSchema
0358       *     false (default)
0359       *         Process the annotations found in an XMLSchema
0360       *
0361       * "http://apache.org/xml/features/disable-default-entity-resolution"
0362       *     true
0363       *         Entities will be resolved only by a resolver installed by the user
0364       *     false (default)
0365       *         If the entity resolver has not been installed, or it refuses to resolve the given entity, the
0366       *         parser will try to locate it himself
0367       *
0368       * "http://apache.org/xml/features/validation/schema/skip-dtd-validation"
0369       *     true
0370       *         If XMLSchema validation is <code>true</code>, DTD validation will not be performed
0371       *     false (default)
0372       *         If a DTD is found, it will be used to validate the XML
0373       *
0374       * @return The pointer to the configuration object.
0375       * @since DOM Level 3
0376       */
0377     virtual DOMConfiguration* getDomConfig() = 0;
0378 
0379     /**
0380       * Get a const pointer to the application filter
0381       *
0382       * This method returns the installed application filter. If no filter
0383       * has been installed, then it will be a zero pointer.
0384       *
0385       * @return A const pointer to the installed application filter
0386       * @since DOM Level 3
0387       */
0388     virtual const DOMLSParserFilter* getFilter() const = 0;
0389 
0390     /**
0391       * Return whether the parser is asynchronous
0392       *
0393       * @return <code>true</code> if the <code>DOMLSParser</code> is asynchronous,
0394       *         <code>false</code> if it is synchronous
0395       * @since DOM Level 3
0396       */
0397     virtual bool getAsync() const = 0;
0398 
0399     /**
0400       * Return whether the parser is busy parsing
0401       *
0402       * @return <code>true</code> if the <code>DOMLSParser</code> is currently busy
0403       *         loading a document, otherwise <code>false</code>.
0404       * @since DOM Level 3
0405       */
0406     virtual bool getBusy() const = 0;
0407 
0408     // -----------------------------------------------------------------------
0409     //  Setter methods
0410     // -----------------------------------------------------------------------
0411     /**
0412       * Set the application filter
0413       *
0414       * When the application provides a filter, the parser will call out to
0415       * the filter at the completion of the construction of each <code>DOMElement</code>
0416       * node. The filter implementation can choose to remove the element from the
0417       * document being constructed or to terminate the parse early.
0418       * The filter is invoked after the operations requested by the DOMConfiguration
0419       * parameters have been applied. For example, if "validate" is set to true,
0420       * the validation is done before invoking the filter.
0421       *
0422       * <i>Any previously set filter is merely dropped, since the parser
0423       * does not own them.</i>
0424       *
0425       * @param filter  A const pointer to the user supplied application
0426       *                filter.
0427       *
0428       * @see #getFilter
0429       * @since DOM Level 3
0430       */
0431     virtual void setFilter(DOMLSParserFilter* const filter) = 0;
0432 
0433     // -----------------------------------------------------------------------
0434     //  Parsing methods
0435     // -----------------------------------------------------------------------
0436     /**
0437       * Parse an XML document from a resource identified by a <code>DOMLSInput</code>.
0438       *
0439       * The parser owns the returned DOMDocument.  It will be deleted
0440       * when the parser is released.
0441       *
0442       * @param source The <code>DOMLSInput</code> from which the source of the document
0443       *               is to be read.
0444       * @return If the <code>DOMLSParser</code> is a synchronous <code>DOMLSParser</code>
0445       *         the newly created and populated <code>DOMDocument</code> is returned.
0446       *         If the <code>DOMLSParser</code> is asynchronous then <code>NULL</code>
0447       *         is returned since the document object may not yet be constructed when
0448       *         this method returns.
0449       * @exception DOMException INVALID_STATE_ERR: Raised if the <code>DOMLSParser::busy</code>
0450       *                                            attribute is true.
0451       * @exception DOMLSException PARSE_ERR: Starting from Xerces-C++ 4.0.0 this exception is
0452       *                                      raised if the <code>DOMLSParser</code> was unable
0453       *                                      to load the XML document. DOM applications should
0454       *                                      attach a <code>DOMErrorHandler</code> using the
0455       *                                      parameter "error-handler" if they wish to get details
0456       *                                      on the error.
0457       *
0458       * @see DOMLSInput#DOMLSInput
0459       * @see DOMConfiguration
0460       * @see resetDocumentPool
0461       * @since DOM Level 3
0462       */
0463     virtual DOMDocument* parse(const DOMLSInput* source) = 0;
0464 
0465     /**
0466       * Parse an XML document from a location identified by a URI reference [IETF RFC 2396].
0467       * If the URI contains a fragment identifier (see section 4.1 in [IETF RFC 2396]),
0468       * the behavior is not defined by this specification, future versions of this
0469       * specification may define the behavior.
0470       *
0471       * The parser owns the returned DOMDocument.  It will be deleted
0472       * when the parser is released.
0473       *
0474       * @param uri The location of the XML document to be read (in Unicode)
0475       * @return If the <code>DOMLSParser</code> is a synchronous <code>DOMLSParser</code>
0476       *         the newly created and populated <code>DOMDocument</code> is returned.
0477       *         If the <code>DOMLSParser</code> is asynchronous then <code>NULL</code>
0478       *         is returned since the document object is not yet parsed when this method returns.
0479       * @exception DOMException INVALID_STATE_ERR: Raised if the <code>DOMLSParser::busy</code>
0480       *                                            attribute is true.
0481       * @exception DOMLSException PARSE_ERR: Starting from Xerces-C++ 4.0.0 this exception is
0482       *                                      raised if the <code>DOMLSParser</code> was unable
0483       *                                      to load the XML document. DOM applications should
0484       *                                      attach a <code>DOMErrorHandler</code> using the
0485       *                                      parameter "error-handler" if they wish to get details
0486       *                                      on the error.
0487       *
0488       * @see #parse(DOMLSInput,...)
0489       * @see resetDocumentPool
0490       * @since DOM Level 3
0491       */
0492     virtual DOMDocument* parseURI(const XMLCh* const uri) = 0;
0493 
0494     /**
0495       * Parse an XML document from a location identified by a URI reference [IETF RFC 2396].
0496       * If the URI contains a fragment identifier (see section 4.1 in [IETF RFC 2396]),
0497       * the behavior is not defined by this specification, future versions of this
0498       * specification may define the behavior.
0499       *
0500       * The parser owns the returned DOMDocument.  It will be deleted
0501       * when the parser is released.
0502       *
0503       * @param uri The location of the XML document to be read (in the local code page)
0504       * @return If the <code>DOMLSParser</code> is a synchronous <code>DOMLSParser</code>
0505       *         the newly created and populated <code>DOMDocument</code> is returned.
0506       *         If the <code>DOMLSParser</code> is asynchronous then <code>NULL</code>
0507       *         is returned since the document object is not yet parsed when this method returns.
0508       * @exception DOMException INVALID_STATE_ERR: Raised if the <code>DOMLSParser::busy</code>
0509       *                                            attribute is true.
0510       * @exception DOMLSException PARSE_ERR: Starting from Xerces-C++ 4.0.0 this exception is
0511       *                                      raised if the <code>DOMLSParser</code> was unable
0512       *                                      to load the XML document. DOM applications should
0513       *                                      attach a <code>DOMErrorHandler</code> using the
0514       *                                      parameter "error-handler" if they wish to get details
0515       *                                      on the error.
0516       *
0517       * @see #parse(DOMLSInput,...)
0518       * @see resetDocumentPool
0519       * @since DOM Level 3
0520       */
0521     virtual DOMDocument* parseURI(const char* const uri) = 0;
0522 
0523     /**
0524       * Parse an XML fragment from a resource identified by a <code>DOMLSInput</code>
0525       * and insert the content into an existing document at the position specified
0526       * with the context and action arguments. When parsing the input stream, the
0527       * context node (or its parent, depending on where the result will be inserted)
0528       * is used for resolving unbound namespace prefixes. The context node's
0529       * <code>ownerDocument</code> node (or the node itself if the node of type
0530       * <code>DOCUMENT_NODE</code>) is used to resolve default attributes and entity
0531       * references.
0532       * As the new data is inserted into the document, at least one mutation event
0533       * is fired per new immediate child or sibling of the context node.
0534       * If the context node is a <code>DOMDocument</code> node and the action is
0535       * <code>ACTION_REPLACE_CHILDREN</code>, then the document that is passed as
0536       * the context node will be changed such that its <code>xmlEncoding</code>,
0537       * <code>documentURI</code>, <code>xmlVersion</code>, <code>inputEncoding</code>,
0538       * <code>xmlStandalone</code>, and all other such attributes are set to what they
0539       * would be set to if the input source was parsed using <code>DOMLSParser::parse()</code>.
0540       * This method is always synchronous, even if the <code>DOMLSParser</code> is
0541       * asynchronous (<code>DOMLSParser::getAsync()</code> returns true).
0542       * If an error occurs while parsing, the caller is notified through the <code>ErrorHandler</code>
0543       * instance associated with the "error-handler" parameter of the <code>DOMConfiguration</code>.
0544       * When calling <code>parseWithContext</code>, the values of the following configuration
0545       * parameters will be ignored and their default values will always be used instead:
0546       *   "validate",
0547       *   "validate-if-schema"
0548       *   "element-content-whitespace".
0549       * Other parameters will be treated normally, and the parser is expected to call
0550       * the <code>DOMLSParserFilter</code> just as if a whole document was parsed.
0551       *
0552       * @param source The <code>DOMLSInput</code> from which the source document is
0553       *               to be read. The source document must be an XML fragment, i.e.
0554       *               anything except a complete XML document (except in the case where
0555       *               the context node of type <code>DOCUMENT_NODE</code>, and the action is
0556       *               <code>ACTION_REPLACE_CHILDREN</code>), a <code>DOCTYPE</code>
0557       *               (internal subset), entity declaration(s), notation declaration(s),
0558       *               or XML or text declaration(s).
0559       * @param contextNode The node that is used as the context for the data that is being
0560       *                    parsed. This node must be a <code>DOMDocument</code> node, a
0561       *                    <code>DOMDocumentFragment</code> node, or a node of a type that
0562       *                    is allowed as a child of an <code>DOMElement</code> node, e.g.
0563       *                    it cannot be an <code>DOMAttribute</code> node.
0564       * @param action This parameter describes which action should be taken between the new
0565       *               set of nodes being inserted and the existing children of the context node.
0566       *               The set of possible actions is defined in <code>ACTION_TYPES</code> above.
0567       * @return Return the node that is the result of the parse operation. If the result is more
0568       *         than one top-level node, the first one is returned.
0569       *
0570       * @exception DOMException
0571       *     HIERARCHY_REQUEST_ERR: Raised if the content cannot replace, be inserted before, after,
0572       *                            or as a child of the context node (see also <code>DOMNode::insertBefore</code>
0573       *                            or <code>DOMNode::replaceChild</code> in [DOM Level 3 Core]).
0574       *     NOT_SUPPORTED_ERR: Raised if the <code>DOMLSParser</code> doesn't support this method,
0575       *                        or if the context node is of type <code>DOMDocument</code> and the DOM
0576       *                        implementation doesn't support the replacement of the <code>DOMDocumentType</code>
0577       *                        child or <code>DOMElement</code> child.
0578       *     NO_MODIFICATION_ALLOWED_ERR: Raised if the context node is a read only node and the content
0579       *                                  is being appended to its child list, or if the parent node of
0580       *                                  the context node is read only node and the content is being
0581       *                                  inserted in its child list.
0582       *     INVALID_STATE_ERR: Raised if the <code>DOMLSParser::getBusy()</code> returns true.
0583       *
0584       * @exception DOMLSException PARSE_ERR: Raised if the <code>DOMLSParser</code> was unable to load
0585       *                                      the XML fragment. DOM applications should attach a
0586       *                                      <code>DOMErrorHandler</code> using the parameter "error-handler"
0587       *                                      if they wish to get details on the error.
0588       * @since DOM Level 3
0589       */
0590     virtual DOMNode* parseWithContext(const DOMLSInput* source, DOMNode* contextNode, const ActionType action) = 0;
0591 
0592     /**
0593       * Abort the loading of the document that is currently being loaded by the <code>DOMLSParser</code>.
0594       * If the <code>DOMLSParser</code> is currently not busy, a call to this method does nothing.
0595       *
0596       * Note: invoking this method will remove the installed <code>DOMLSParserFilter</code> filter
0597       *
0598       * @since DOM Level 3
0599       */
0600     virtual void abort() = 0;
0601     //@}
0602 
0603     // -----------------------------------------------------------------------
0604     //  Non-standard Extension
0605     // -----------------------------------------------------------------------
0606     /** @name Non-standard Extension */
0607     //@{
0608     /**
0609      * Called to indicate that this DOMLSParser is no longer in use
0610      * and that the implementation may relinquish any resources associated with it.
0611      *
0612      * Access to a released object will lead to unexpected result.
0613      */
0614     virtual void              release() = 0;
0615 
0616     /** Reset the documents vector pool and release all the associated memory
0617       * back to the system.
0618       *
0619       * When parsing a document using a DOM parser, all memory allocated
0620       * for a DOM tree is associated to the DOM document.
0621       *
0622       * If you do multiple parse using the same DOM parser instance, then
0623       * multiple DOM documents will be generated and saved in a vector pool.
0624       * All these documents (and thus all the allocated memory)
0625       * won't be deleted until the parser instance is destroyed.
0626       *
0627       * If you don't need these DOM documents anymore and don't want to
0628       * destroy the DOM parser instance at this moment, then you can call this method
0629       * to reset the document vector pool and release all the allocated memory
0630       * back to the system.
0631       *
0632       * It is an error to call this method if you are in the middle of a
0633       * parse (e.g. in the mid of a progressive parse).
0634       *
0635       * @exception IOException An exception from the parser if this function
0636       *            is called when a parse is in progress.
0637       *
0638       */
0639     virtual void              resetDocumentPool() = 0;
0640 
0641     /**
0642       * Preparse schema grammar (XML Schema, DTD, etc.) via an input source
0643       * object.
0644       *
0645       * This method invokes the preparsing process on a schema grammar XML
0646       * file specified by the DOMLSInput parameter. If the 'toCache' flag
0647       * is enabled, the parser will cache the grammars for re-use. If a grammar
0648       * key is found in the pool, no caching of any grammar will take place.
0649       *
0650       * @param source A const reference to the DOMLSInput object which
0651       *               points to the schema grammar file to be preparsed.
0652       * @param grammarType The grammar type (Schema or DTD).
0653       * @param toCache If <code>true</code>, we cache the preparsed grammar,
0654       *                otherwise, no chaching. Default is <code>false</code>.
0655       * @return The preparsed schema grammar object (SchemaGrammar or
0656       *         DTDGrammar). That grammar object is owned by the parser.
0657       *
0658       * @exception SAXException Any SAX exception, possibly
0659       *            wrapping another exception.
0660       * @exception XMLException An exception from the parser or client
0661       *            handler code.
0662       * @exception DOMException A DOM exception as per DOM spec.
0663       *
0664       * @see DOMLSInput#DOMLSInput
0665       */
0666     virtual Grammar* loadGrammar(const DOMLSInput* source,
0667                                  const Grammar::GrammarType grammarType,
0668                                  const bool toCache = false) = 0;
0669 
0670     /**
0671       * Preparse schema grammar (XML Schema, DTD, etc.) via a file path or URL
0672       *
0673       * This method invokes the preparsing process on a schema grammar XML
0674       * file specified by the file path parameter. If the 'toCache' flag is
0675       * enabled, the parser will cache the grammars for re-use. If a grammar
0676       * key is found in the pool, no caching of any grammar will take place.
0677       *
0678       * @param systemId A const XMLCh pointer to the Unicode string which
0679       *                 contains the path to the XML grammar file to be
0680       *                 preparsed.
0681       * @param grammarType The grammar type (Schema or DTD).
0682       * @param toCache If <code>true</code>, we cache the preparsed grammar,
0683       *                otherwise, no chaching. Default is <code>false</code>.
0684       * @return The preparsed schema grammar object (SchemaGrammar or
0685       *         DTDGrammar). That grammar object is owned by the parser.
0686       *
0687       * @exception SAXException Any SAX exception, possibly
0688       *            wrapping another exception.
0689       * @exception XMLException An exception from the parser or client
0690       *            handler code.
0691       * @exception DOMException A DOM exception as per DOM spec.
0692       */
0693     virtual Grammar* loadGrammar(const XMLCh* const systemId,
0694                                  const Grammar::GrammarType grammarType,
0695                                  const bool toCache = false) = 0;
0696 
0697     /**
0698       * Preparse schema grammar (XML Schema, DTD, etc.) via a file path or URL
0699       *
0700       * This method invokes the preparsing process on a schema grammar XML
0701       * file specified by the file path parameter. If the 'toCache' flag is
0702       * enabled, the parser will cache the grammars for re-use. If a grammar
0703       * key is found in the pool, no caching of any grammar will take place.
0704       *
0705       * @param systemId A const char pointer to a native string which contains
0706       *                 the path to the XML grammar file to be preparsed.
0707       * @param grammarType The grammar type (Schema or DTD).
0708       * @param toCache If <code>true</code>, we cache the preparsed grammar,
0709       *                otherwise, no chaching. Default is <code>false</code>.
0710       * @return The preparsed schema grammar object (SchemaGrammar or
0711       *         DTDGrammar). That grammar object is owned by the parser.
0712       *
0713       *
0714       * @exception SAXException Any SAX exception, possibly
0715       *            wrapping another exception.
0716       * @exception XMLException An exception from the parser or client
0717       *            handler code.
0718       * @exception DOMException A DOM exception as per DOM spec.
0719       */
0720     virtual Grammar* loadGrammar(const char* const systemId,
0721                                  const Grammar::GrammarType grammarType,
0722                                  const bool toCache = false) = 0;
0723 
0724     /**
0725      * Retrieve the grammar that is associated with the specified namespace key
0726      *
0727      * @param  nameSpaceKey Namespace key
0728      * @return Grammar associated with the Namespace key.
0729      */
0730     virtual Grammar* getGrammar(const XMLCh* const nameSpaceKey) const = 0;
0731 
0732     /**
0733      * Retrieve the grammar where the root element is declared.
0734      *
0735      * @return Grammar where root element declared
0736      */
0737     virtual Grammar* getRootGrammar() const = 0;
0738 
0739     /**
0740      * Returns the string corresponding to a URI id from the URI string pool.
0741      *
0742      * @param uriId id of the string in the URI string pool.
0743      * @return URI string corresponding to the URI id.
0744      */
0745     virtual const XMLCh* getURIText(unsigned int uriId) const = 0;
0746 
0747     /**
0748       * Clear the cached grammar pool
0749       */
0750     virtual void resetCachedGrammarPool() = 0;
0751 
0752     /**
0753       * Returns the current src offset within the input source.
0754       *
0755       * @return offset within the input source
0756       */
0757     virtual XMLFilePos getSrcOffset() const = 0;
0758 
0759     //@}
0760 
0761 };
0762 
0763 
0764 XERCES_CPP_NAMESPACE_END
0765 
0766 #endif