From d351b153604a93f616aa667d3c37c6acaf68e23d Mon Sep 17 00:00:00 2001
From: Khaled Noaman <knoaman@apache.org>
Date: Wed, 29 May 2002 21:31:50 +0000
Subject: [PATCH] DOM L3 LS: DOMInputSource, DOMEntityResolver,
 DOMImplementationLS and DOMBuilder

git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@173765 13f79535-47bb-0310-9956-ffa450edef68
---
 src/xercesc/dom/DOMBuilder.hpp                | 421 ++++++++++++
 src/xercesc/dom/DOMEntityResolver.hpp         | 168 +++++
 src/xercesc/dom/DOMImplementationLS.hpp       | 189 ++++++
 src/xercesc/dom/DOMInputSource.hpp            | 283 ++++++++
 src/xercesc/dom/Makefile.in                   |   8 +-
 .../dom/impl/DOMImplementationImpl.cpp        |  25 +
 .../dom/impl/DOMImplementationImpl.hpp        |  11 +-
 src/xercesc/dom/impl/DOMWriterImpl.cpp        |   9 +-
 src/xercesc/parsers/DOMBuilderImpl.cpp        | 306 +++++++++
 src/xercesc/parsers/DOMBuilderImpl.hpp        | 621 ++++++++++++++++++
 10 files changed, 2036 insertions(+), 5 deletions(-)
 create mode 100644 src/xercesc/dom/DOMBuilder.hpp
 create mode 100644 src/xercesc/dom/DOMEntityResolver.hpp
 create mode 100644 src/xercesc/dom/DOMImplementationLS.hpp
 create mode 100644 src/xercesc/dom/DOMInputSource.hpp
 create mode 100644 src/xercesc/parsers/DOMBuilderImpl.cpp
 create mode 100644 src/xercesc/parsers/DOMBuilderImpl.hpp

diff --git a/src/xercesc/dom/DOMBuilder.hpp b/src/xercesc/dom/DOMBuilder.hpp
new file mode 100644
index 000000000..4574e49d5
--- /dev/null
+++ b/src/xercesc/dom/DOMBuilder.hpp
@@ -0,0 +1,421 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2002 The Apache Software Foundation.  All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ *    if any, must include the following acknowledgment:
+ *       "This product includes software developed by the
+ *        Apache Software Foundation (http://www.apache.org/)."
+ *    Alternately, this acknowledgment may appear in the software itself,
+ *    if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xerces" and "Apache Software Foundation" must
+ *    not be used to endorse or promote products derived from this
+ *    software without prior written permission. For written
+ *    permission, please contact apache\@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ *    nor may "Apache" appear in their name, without prior written
+ *    permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation, and was
+ * originally based on software copyright (c) 2001, International
+ * Business Machines, Inc., http://www.ibm.com .  For more information
+ * on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/*
+ * $Id$
+ *
+ */
+
+#ifndef DOMBUILDER_HPP
+#define DOMBUILDER_HPP
+
+
+#include <xercesc/util/XercesDefs.hpp>
+
+class DOMErrorHandler;
+class DOMEntityResolver;
+class DOMInputSource;
+class DOMBuilderFilter;
+class DOMNode;
+class DOMDocument;
+
+ /**
+  * DOMBuilder provides an API for parsing XML documents and building the
+  * corresponding DOM document tree. A DOMBuilder instance is obtained from
+  * the DOMImplementationLS interface by invoking its createDOMBuilder method.
+  * This implementation also allows the applications to install an error and
+  * an entity handler (useful extensions to the DOM specification).
+  *
+  */
+class CDOM_EXPORT DOMBuilder
+{
+protected :
+    // -----------------------------------------------------------------------
+    //  Hidden constructors
+    // -----------------------------------------------------------------------
+    /** @name Constructors */
+    //@{
+
+    /** Default constructor */
+    DOMBuilder() {};
+
+    //@}
+
+public :
+    // -----------------------------------------------------------------------
+    //  Class types
+    // -----------------------------------------------------------------------
+    enum ActionType
+    {
+        ACTION_REPLACE            = 1,
+        ACTION_APPEND_AS_CHILDREN = 2,
+        ACTION_INSERT_AFTER       = 3,
+        ACTION_INSERT_BEFORE      = 4
+    };
+
+    // -----------------------------------------------------------------------
+    //  All constructors are hidden, just the destructor is available
+    // -----------------------------------------------------------------------
+    /** @name Destructor */
+    //@{
+  /**
+    * Destructor
+    *
+    */
+    virtual ~DOMBuilder() {};
+    //@}
+
+
+    // -----------------------------------------------------------------------
+    //  Getter methods
+    // -----------------------------------------------------------------------
+
+    /** @name Getter methods */
+    //@{
+
+    /** Get a pointer to the error handler
+      *
+      * This method returns the installed error handler. If no handler
+      * has been installed, then it will be a zero pointer.
+      *
+      * @return The pointer to the installed error handler object.
+      */
+    virtual DOMErrorHandler* getErrorHandler() = 0;
+
+    /** Get a const pointer to the error handler
+      *
+      * This method returns the installed error handler.  If no handler
+      * has been installed, then it will be a zero pointer.
+      *
+      * @return A const pointer to the installed error handler object.
+      */
+    virtual const DOMErrorHandler* getErrorHandler() const = 0;
+
+    /** Get a pointer to the entity resolver
+      *
+      * This method returns the installed entity resolver.  If no resolver
+      * has been installed, then it will be a zero pointer.
+      *
+      * @return The pointer to the installed entity resolver object.
+      */
+    virtual DOMEntityResolver* getEntityResolver() = 0;
+
+    /** Get a const pointer to the entity resolver
+      *
+      * This method returns the installed entity resolver. If no resolver
+      * has been installed, then it will be a zero pointer.
+      *
+      * @return A const pointer to the installed entity resolver object.
+      */
+    virtual const DOMEntityResolver* getEntityResolver() const = 0;
+
+    /** Get a pointer to the application filter
+      *
+      * This method returns the installed application filter. If no filter
+      * has been installed, then it will be a zero pointer.
+      *
+      * @return The pointer to the installed application filter.
+      */
+    virtual DOMBuilderFilter* getFilter() = 0;
+
+    /** Get a const pointer to the application filter
+      *
+      * This method returns the installed application filter. If no filter
+      * has been installed, then it will be a zero pointer.
+      *
+      * @return A const pointer to the installed application filter
+      */
+    virtual const DOMBuilderFilter* getFilter() const = 0;
+
+    //@}
+
+
+    // -----------------------------------------------------------------------
+    //  Setter methods
+    // -----------------------------------------------------------------------
+
+    /** @name Setter methods */
+    //@{
+
+    /** Set the error handler
+      *
+      * This method allows applications to install their own error handler
+      * to trap error and warning messages.
+      *
+      * <i>Any previously set handler is merely dropped, since the parser
+      * does not own them.</i>
+      *
+      * @param handler  A const pointer to the user supplied error
+      *                 handler.
+      *
+      * @see #getErrorHandler
+      */
+    virtual void setErrorHandler(DOMErrorHandler* const handler) = 0;
+
+    /** Set the entity resolver
+      *
+      * This method allows applications to install their own entity
+      * resolver. By installing an entity resolver, the applications
+      * can trap and potentially redirect references to external
+      * entities.
+      *
+      * <i>Any previously set resolver is merely dropped, since the parser
+      * does not own them.</i>
+      *
+      * @param handler  A const pointer to the user supplied entity
+      *                 resolver.
+      *
+      * @see #getEntityResolver
+      */
+    virtual void setEntityResolver(DOMEntityResolver* const handler) = 0;
+
+    /** Set the application filter
+      *
+      * When the application provides a filter, the parser will call out to
+      * the filter at the completion of the construction of each Element node.
+      * The filter implementation can choose to remove the element from the
+      * document being constructed (unless the element is the document element)
+      * or to terminate the parse early. If the document is being validated
+      * when it's loaded the validation happens before the filter is called.
+      *
+      * <i>Any previously set filter is merely dropped, since the parser
+      * does not own them.</i>
+      *
+      * @param filter  A const pointer to the user supplied application
+      *                filter.
+      *
+      * @see #getFilter
+      */
+    virtual void setFilter(DOMBuilderFilter* const filter) = 0;
+
+    //@}
+
+
+    // -----------------------------------------------------------------------
+    //  Feature methods
+    // -----------------------------------------------------------------------
+    /** @name Feature methods */
+    //@{
+
+    /** Set the state of a feature
+      *
+      * It is possible for a DOMBuilder to recognize a feature name but to be
+      * unable to set its value.
+      *
+      * @param name  The feature name.
+      * @param state The requested state of the feature (true or false).
+      * @exception DOMException
+      *     NOT_SUPPORTED_ERR: Raised when the DOMBuilder recognizes the
+      *     feature name but cannot set the requested value.
+      *     <br>NOT_FOUND_ERR: Raised when the DOMBuilder does not recognize
+      *     the feature name.
+      *
+      * @see #setFeature
+      * @see #canSetFeature
+      */
+    virtual void setFeature(const XMLCh* const name, const bool state) = 0;
+
+    /** Look up the value of a feature.
+      *
+      * @param name The feature name.
+      * @return The current state of the feature (true or false)
+      * @exception DOMException
+      *     NOT_FOUND_ERR: Raised when the DOMBuilder does not recognize
+      *     the feature name. 
+      *
+      * @see #getFeature
+      * @see #canSetFeature
+      */
+    virtual bool getFeature(const XMLCh* const name) = 0;
+
+    /** Query whether setting a feature to a specific value is supported.
+      *
+      * @param name  The feature name.
+      * @param state The requested state of the feature (true or false).
+      * @return <code>true</code> if the feature could be successfully set
+      *     to the specified value, or <code>false</code> if the feature
+      *     is not recognized or the requested value is not supported. The
+      *     value of the feature itself is not changed.
+      *
+      * @see #getFeature
+      * @see #setFeature
+      */
+    virtual bool canSetFeature(const XMLCh* const name, const bool state) = 0;
+
+    //@}
+
+    // -----------------------------------------------------------------------
+    //  Parsing methods
+    // -----------------------------------------------------------------------
+    /** @name Parsing methods */
+    //@{
+
+    /** Parse via an input source object
+      *
+      * This method invokes the parsing process on the XML file specified
+      * by the DOMInputSource parameter. This API is borrowed from the
+      * SAX Parser interface.
+      *
+      * @param source A const reference to the DOMInputSource object which
+      *               points to the XML file to be parsed.
+      * @param reuseGrammar The flag indicating whether the existing Grammar
+      *                     should be reused or not for this parsing run.
+      *                     If true, there cannot be any internal subset.
+      * @return If the DOMBuilder is a synchronous DOMBuilder the newly created
+      *         and populated Document is returned. If the DOMBuilder is
+      *         asynchronous then <code>null</code> is returned since the
+      *         document object is not yet parsed when this method returns.
+      * @exception SAXException Any SAX exception, possibly
+      *            wrapping another exception.
+      * @exception XMLException An exception from the parser or client
+      *            handler code.
+      * @exception DOMException A DOM exception as per DOM spec.
+      *
+      * @see DOMInputSource#DOMInputSource
+      * @see #setEntityResolver
+      * @see #setErrorHandler
+      */
+    virtual DOMDocument* parse(const DOMInputSource& source, const bool reuseGrammar = false) = 0;
+
+    /** Parse via a file path or URL
+      *
+      * This method invokes the parsing process on the XML file specified by
+      * the Unicode string parameter 'systemId'.
+      *
+      * @param systemId A const XMLCh pointer to the Unicode string which
+      *                 contains the path to the XML file to be parsed.
+      * @param reuseGrammar The flag indicating whether the existing Grammar
+      *                     should be reused or not for this parsing run.
+      *                     If true, there cannot be any internal subset.
+      * @return If the DOMBuilder is a synchronous DOMBuilder the newly created
+      *         and populated Document is returned. If the DOMBuilder is
+      *         asynchronous then <code>null</code> is returned since the
+      *         document object is not yet parsed when this method returns.
+      * @exception SAXException Any SAX exception, possibly
+      *            wrapping another exception.
+      * @exception XMLException An exception from the parser or client
+      *            handler code.
+      * @exception DOMException A DOM exception as per DOM spec.
+      *
+      * @see #parse(DOMInputSource,...)
+      */
+    virtual DOMDocument* parseURI(const XMLCh* const systemId, const bool reuseGrammar = false) = 0;
+
+    /** Parse via a file path or URL (in the local code page)
+      *
+      * This method invokes the parsing process on the XML file specified by
+      * the native char* string parameter 'systemId'.
+      *
+      * @param systemId A const char pointer to a native string which
+      *                 contains the path to the XML file to be parsed.
+      * @param reuseGrammar The flag indicating whether the existing Grammar
+      *                     should be reused or not for this parsing run.
+      *                     If true, there cannot be any internal subset.
+      * @return If the DOMBuilder is a synchronous DOMBuilder the newly created
+      *         and populated Document is returned. If the DOMBuilder is
+      *         asynchronous then <code>null</code> is returned since the
+      *         document object is not yet parsed when this method returns.
+      * @exception SAXException Any SAX exception, possibly
+      *            wrapping another exception.
+      * @exception XMLException An exception from the parser or client
+      *            handler code.
+      * @exception DOMException A DOM exception as per DOM spec.
+      *
+      * @see #parse(DOMInputSource,...)
+      */
+    virtual DOMDocument* parseURI(const char* const systemId, const bool reuseGrammar = false) = 0;
+
+    /** Parse via an input source object
+      *
+      * This method invokes the parsing process on the XML file specified
+      * by the DOMInputSource parameter, and inserts the content into an
+      * existing document at the position specified with the contextNode
+      * and action arguments. When parsing the input stream the context node
+      * is used for resolving unbound namespace prefixes.
+      *
+      * @param source A const reference to the DOMInputSource object which
+      *               points to the XML file to be parsed.
+      * @param contextNode The node that is used as the context for the data
+      *                    that is being parsed. This node must be a Document
+      *                    node, a DocumentFragment node, or a node of a type
+      *                    that is allowed as a child of an element, e.g. it
+      *                    can not be an attribute node.
+      * @param action This parameter describes which action should be taken
+      *               between the new set of node being inserted and the
+      *               existing children of the context node.
+      * @exception DOMException
+      *     NOT_SUPPORTED_ERR: Raised when the DOMBuilder doesn't support
+      *     this method.
+      *     <br>NO_MODIFICATION_ALLOWED_ERR: Raised if the context node is
+      *     readonly.
+      */
+    virtual void parseWithContext
+    (
+        const   DOMInputSource& source
+        ,       DOMNode* const contextNode
+        , const short action
+    ) = 0;
+
+private :
+    // -----------------------------------------------------------------------
+    //  Unimplemented constructors and operators
+    // -----------------------------------------------------------------------
+    DOMBuilder(const DOMBuilder&);
+    void operator=(const DOMBuilder&);
+};
+
+
+#endif
diff --git a/src/xercesc/dom/DOMEntityResolver.hpp b/src/xercesc/dom/DOMEntityResolver.hpp
new file mode 100644
index 000000000..e071ef0f2
--- /dev/null
+++ b/src/xercesc/dom/DOMEntityResolver.hpp
@@ -0,0 +1,168 @@
+/*
+ * The Apache Software License, Version 1.1
+ * 
+ * Copyright (c) 2002 The Apache Software Foundation.  All rights
+ * reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer. 
+ * 
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ * 
+ * 3. The end-user documentation included with the redistribution,
+ *    if any, must include the following acknowledgment:  
+ *       "This product includes software developed by the
+ *        Apache Software Foundation (http://www.apache.org/)."
+ *    Alternately, this acknowledgment may appear in the software itself,
+ *    if and wherever such third-party acknowledgments normally appear.
+ * 
+ * 4. The names "Xerces" and "Apache Software Foundation" must
+ *    not be used to endorse or promote products derived from this
+ *    software without prior written permission. For written 
+ *    permission, please contact apache\@apache.org.
+ * 
+ * 5. Products derived from this software may not be called "Apache",
+ *    nor may "Apache" appear in their name, without prior written
+ *    permission of the Apache Software Foundation.
+ * 
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ * 
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation, and was
+ * originally based on software copyright (c) 1999, International
+ * Business Machines, Inc., http://www.ibm.com .  For more information
+ * on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/*
+ * $Log$
+ * Revision 1.1  2002/05/29 21:28:02  knoaman
+ * DOM L3 LS: DOMInputSource, DOMEntityResolver, DOMImplementationLS and DOMBuilder
+ *
+ */
+
+
+#ifndef DOMENTITYRESOLVER_HPP
+#define DOMENTITYRESOLVER_HPP
+
+#include <xercesc/util/XercesDefs.hpp>
+
+class DOMInputSource;
+
+/**
+  * DOMEntityResolver provides a way for applications to redirect references
+  * to external entities.
+  *
+  * <p>Applications needing to implement customized handling for external
+  * entities must implement this interface and register their implementation
+  * by setting the entityResolver attribute of the DOMBuilder.</p>
+  *
+  * <p>The DOMBuilder will then allow the application to intercept any
+  * external entities (including the external DTD subset and external parameter
+  * entities) before including them.</p>
+  *
+  * <p>Many DOM applications will not need to implement this interface, but it
+  * will be especially useful for applications that build XML documents from
+  * databases or other specialized input sources, or for applications that use
+  * URNs.</p>
+  *
+  * @see DOMBuilder#setEntityResolver
+  * @see DOMInputSource#DOMInputSource
+  */
+class CDOM_EXPORT DOMEntityResolver
+{
+protected:
+    /** @name Constructors */
+    //@{
+
+    /** Default Constructor */
+    DOMEntityResolver() {};
+
+    //@}
+
+public:
+    /** @name Destructor */
+    //@{
+
+    /** Destructor */
+    virtual ~DOMEntityResolver() {};
+
+    //@}
+
+    /** @name The DOMEntityResolver interface */
+    //@{
+
+  /**
+    * Allow the application to resolve external entities.
+    *
+    * <p>The DOMBuilder will call this method before opening any external
+    * entity except the top-level document entity (including the
+    * external DTD subset, external entities referenced within the
+    * DTD, and external entities referenced within the document
+    * element): the application may request that the DOMBuilder resolve
+    * the entity itself, that it use an alternative URI, or that it
+    * use an entirely different input source.</p>
+    *
+    * <p>Application writers can use this method to redirect external
+    * system identifiers to secure and/or local URIs, to look up
+    * public identifiers in a catalogue, or to read an entity from a
+    * database or other input source (including, for example, a dialog
+    * box).</p>
+    *
+    * <p>If the system identifier is a URL, the DOMBuilder parser must
+    * resolve it fully before reporting it to the application.</p>
+    *
+    * @param publicId The public identifier of the external entity
+    *        being referenced, or null if none was supplied.
+    * @param systemId The system identifier of the external entity
+    *        being referenced.
+    * @param baseURI The absolute base URI of the resource being parsed, or
+    *        <code>null</code> if there is no base URI.
+    * @return A DOMInputSource object describing the new input source,
+    *         or <code>null</code> to request that the parser open a regular
+    *         URI connection to the system identifier.
+    * @exception DOMSystemException Any DOMSystemException exception, possibly
+    *            wrapping another exception.
+    * @see DOMInputSource#DOMInputSource
+    */
+    virtual DOMInputSource* resolveEntity
+    (
+        const   XMLCh* const    publicId
+        , const XMLCh* const    systemId
+        , const XMLCh* const    baseURI
+    ) = 0;
+
+    //@}
+
+private :
+    /* Unimplemented constructors and operators */
+    
+    /* Copy constructor */
+    DOMEntityResolver(const DOMEntityResolver&);
+
+    /* Assignment operator */
+    void operator=(const DOMEntityResolver&);
+
+};
+
+#endif
diff --git a/src/xercesc/dom/DOMImplementationLS.hpp b/src/xercesc/dom/DOMImplementationLS.hpp
new file mode 100644
index 000000000..b3b85867d
--- /dev/null
+++ b/src/xercesc/dom/DOMImplementationLS.hpp
@@ -0,0 +1,189 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2002 The Apache Software Foundation.  All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ *    if any, must include the following acknowledgment:
+ *       "This product includes software developed by the
+ *        Apache Software Foundation (http://www.apache.org/)."
+ *    Alternately, this acknowledgment may appear in the software itself,
+ *    if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xerces" and "Apache Software Foundation" must
+ *    not be used to endorse or promote products derived from this
+ *    software without prior written permission. For written
+ *    permission, please contact apache\@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ *    nor may "Apache" appear in their name, without prior written
+ *    permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation, and was
+ * originally based on software copyright (c) 1999, International
+ * Business Machines, Inc., http://www.ibm.com .  For more information
+ * on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/*
+ * $Log$
+ * Revision 1.1  2002/05/29 21:28:02  knoaman
+ * DOM L3 LS: DOMInputSource, DOMEntityResolver, DOMImplementationLS and DOMBuilder
+ *
+ */
+
+
+#ifndef DOMIMPLEMENTATIONLS_HPP
+#define DOMIMPLEMENTATIONLS_HPP
+
+#include <xercesc/util/XercesDefs.hpp>
+
+class DOMBuilder;
+class DOMWriter;
+class DOMInputSource;
+
+
+/**
+  *
+  * <p><code>DOMImplementationLS</code> contains the factory methods for
+  * creating objects that implement the <code>DOMBuilder</code> (parser) and
+  * <code>DOMWriter</code> (serializer) interfaces.</p>
+  *
+  * <p>An object that implements DOMImplementationLS is obtained by doing a
+  * binding specific cast from DOMImplementation to DOMImplementationLS.
+  * Implementations supporting the Load and Save feature must implement the
+  * DOMImplementationLS interface on whatever object implements the
+  * DOMImplementation interface.</p>
+  */
+class CDOM_EXPORT DOMImplementationLS
+{
+protected :
+    // -----------------------------------------------------------------------
+    //  Hidden constructors
+    // -----------------------------------------------------------------------
+    /** @name Constructors */
+    //@{
+
+    /** Default constructor */
+    DOMImplementationLS() {};
+
+    //@}
+
+
+public:
+    // -----------------------------------------------------------------------
+    //  All constructors are hidden, just the destructor is available
+    // -----------------------------------------------------------------------
+    /** @name Destructor */
+    //@{
+  /**
+    * Destructor
+    *
+    */
+    virtual ~DOMImplementationLS() {};
+    //@}
+
+    
+    // -----------------------------------------------------------------------
+    //  Public constants
+    // -----------------------------------------------------------------------
+    enum
+    {
+        MODE_SYNCHRONOUS = 1,
+        MODE_ASYNCHRONOUS = 2
+    };
+
+    // -----------------------------------------------------------------------
+    /** @name Virtual DOMImplementation LS interface */
+    //@{
+  /**
+    * <p>Create a new DOMBuilder. The newly constructed parser may then be
+    * configured by means of its setFeature method, and used to parse
+    * documents by means of its parse method.</p>
+    *
+    * @param mode The mode argument is either <code>MODE_SYNCHRONOUS</code> or
+    * <code>MODE_ASYNCHRONOUS</code>, if mode is <code>MODE_SYNCHRONOUS</code>
+    * then the <code>DOMBuilder</code> that is created will operate in
+    * synchronous mode, if it's <code>MODE_ASYNCHRONOUS</code> then the
+    * <code>DOMBuilder</code> that is created will operate in asynchronous
+    * mode.
+    * @param schemaType An absolute URI representing the type of the schema
+    * language used during the load of a Document using the newly created
+    * <code>DOMBuilder</code>. Note that no lexical checking is done on the
+    * absolute URI. In order to create a DOMBuilder for any kind of schema
+    * types (i.e. the DOMBuilder will be free to use any schema found), use
+    * the value <code>null</code>.
+    * @return The newly created <code>DOMBuilder<code> object. This
+    * <code>DOMBuilder</code> is either synchronous or asynchronous depending
+    * on the value of the <code>mode<code> argument.
+    * @exception DOMException NOT_SUPPORTED_ERR: Raised if the requested mode
+    * or schema type is not supported.
+    *
+    * @see DOMBuilder
+    */
+    virtual DOMBuilder* createDOMBuilder(const short mode,
+                                         const XMLCh* const schemaType) = 0;
+
+
+  /**
+    * <p>Create a new DOMWriter. DOMWriters are used to serialize a DOM tree
+    * back into an XML document.</p>
+    *
+    * @return The newly created <code>DOMWriter<code> object.
+    *
+    * @see DOMWriter
+    */
+    virtual DOMWriter* createDOMWriter() = 0;
+
+  /**
+    * <p>Create a new "empty" DOMInputSource.</p>
+    *
+    * @return The newly created <code>DOMInputSource<code> object.
+    *
+    * @see DOMInputSource
+    */
+    virtual DOMInputSource* createDOMInputSource() = 0;
+
+    //@}
+
+
+private:
+    // -----------------------------------------------------------------------
+    //  Unimplemented constructors and operators
+    // -----------------------------------------------------------------------
+    DOMImplementationLS(const DOMImplementationLS&);
+    void operator=(const DOMImplementationLS&);
+
+};
+
+
+#endif
diff --git a/src/xercesc/dom/DOMInputSource.hpp b/src/xercesc/dom/DOMInputSource.hpp
new file mode 100644
index 000000000..1dd1c1164
--- /dev/null
+++ b/src/xercesc/dom/DOMInputSource.hpp
@@ -0,0 +1,283 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2002 The Apache Software Foundation.  All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ *    if any, must include the following acknowledgment:
+ *       "This product includes software developed by the
+ *        Apache Software Foundation (http://www.apache.org/)."
+ *    Alternately, this acknowledgment may appear in the software itself,
+ *    if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xerces" and "Apache Software Foundation" must
+ *    not be used to endorse or promote products derived from this
+ *    software without prior written permission. For written
+ *    permission, please contact apache\@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ *    nor may "Apache" appear in their name, without prior written
+ *    permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation, and was
+ * originally based on software copyright (c) 1999, International
+ * Business Machines, Inc., http://www.ibm.com .  For more information
+ * on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/*
+ * $Log$
+ * Revision 1.1  2002/05/29 21:28:02  knoaman
+ * DOM L3 LS: DOMInputSource, DOMEntityResolver, DOMImplementationLS and DOMBuilder
+ *
+ */
+
+
+#ifndef DOMINPUTSOURCE_HPP
+#define DOMINPUTSOURCE_HPP
+
+#include <xercesc/util/XercesDefs.hpp>
+
+class BinInputStream;
+
+
+/**
+  * This interface represents a single input source for an XML entity.
+  *
+  * <p>This interface allows an application to encapsulate information about
+  * an input source in a single object, which may include a public identifier,
+  * a system identifier, a byte stream (possibly with a specified encoding),
+  * and/or a character stream.</p>
+  *
+  * <p>There are two places that the application will deliver this input source
+  * to the parser: as the argument to the parse method, or as the return value
+  * of the DOMEntityResolver.resolveEntity method.</p>
+  *
+  * <p>The DOMBuilder will use the DOMInputSource object to determine how to
+  * read XML input. If there is a character stream available, the parser will
+  * read that stream directly; if not, the parser will use a byte stream, if
+  * available; if neither a character stream nor a byte stream is available,
+  * the parser will attempt to open a URI connection to the resource identified
+  * by the system identifier.</p>
+  *
+  * <p>A DOMInputSource object belongs to the application: the parser shall
+  * never modify it in any way (it may modify a copy if necessary).</p>
+  *
+  * @see DOMBuilder#parse
+  * @see DOMEntityResolver#resolveEntity
+  */
+class CDOM_EXPORT DOMInputSource
+{
+protected :
+    // -----------------------------------------------------------------------
+    //  Hidden constructors
+    // -----------------------------------------------------------------------
+    /** @name Constructors */
+    //@{
+
+    /** Default constructor */
+    DOMInputSource() {};
+
+    //@}
+
+
+public:
+    // -----------------------------------------------------------------------
+    //  All constructors are hidden, just the destructor is available
+    // -----------------------------------------------------------------------
+    /** @name Destructor */
+    //@{
+  /**
+    * Destructor
+    *
+    */
+    virtual ~DOMInputSource() {};
+    //@}
+
+
+    // -----------------------------------------------------------------------
+    /** @name Virtual input source interface */
+    //@{
+  /**
+    * Makes the byte stream for this input source.
+    *
+    * <p>The derived class must create and return a binary input stream of an
+    * appropriate type for its kind of data source. The returned stream must
+    * be dynamically allocated and becomes the parser's property.
+    * </p>
+    *
+    * @see BinInputStream
+    */
+    virtual BinInputStream* makeStream() const = 0;
+
+    //@}
+
+
+    // -----------------------------------------------------------------------
+    /** @name Getter methods */
+    //@{
+  /**
+    * An input source can be set to force the parser to assume a particular
+    * encoding for the data that input source reprsents, via the setEncoding()
+    * method. This method returns name of the encoding that is to be forced.
+    * If the encoding has never been forced, it returns a null pointer.
+    *
+    * @return The forced encoding, or null if none was supplied.
+    * @see #setEncoding
+    */
+    virtual const XMLCh* getEncoding() const = 0;
+
+
+  /**
+    * Get the public identifier for this input source.
+    *
+    * @return The public identifier, or null if none was supplied.
+    * @see #setPublicId
+    */
+    virtual const XMLCh* getPublicId() const = 0;
+
+
+  /**
+    * Get the system identifier for this input source.
+    *
+    * <p>If the system ID is a URL, it will be fully resolved.</p>
+    *
+    * @return The system identifier.
+    * @see #setSystemId
+    */
+    virtual const XMLCh* getSystemId() const = 0;
+
+
+  /**
+    * Get the base URI to be used for resolving relative URIs to absolute
+    * URIs. If the baseURI is itself a relative URI, the behavior is
+    * implementation dependent.
+    *
+    * @return The base URI.
+    * @see #setBaseURI
+    */
+    virtual const XMLCh* getBaseURI() const = 0;
+
+
+  /**
+    * Get the flag that indicates if the parser should issue fatal error if this input source
+    * is not found.
+    *
+    * @return True if the parser should issue fatal error if this input source is not found.
+    *         False if the parser issue warning message instead.
+    * @see #setIssueFatalErrorIfNotFound
+    */
+    virtual const bool getIssueFatalErrorIfNotFound() const = 0;
+
+    //@}
+
+
+    // -----------------------------------------------------------------------
+    /** @name Setter methods */
+    //@{
+
+  /**
+    * Set the encoding which will be required for use with the XML text read
+    * via a stream opened by this input source.
+    *
+    * <p>This is usually not set, allowing the encoding to be sensed in the
+    * usual XML way. However, in some cases, the encoding in the file is known
+    * to be incorrect because of intermediate transcoding, for instance
+    * encapsulation within a MIME document.
+    *
+    * @param encodingStr The name of the encoding to force.
+    */
+    virtual void setEncoding(const XMLCh* const encodingStr) = 0;
+
+
+  /**
+    * Set the public identifier for this input source.
+    *
+    * <p>The public identifier is always optional: if the application writer
+    * includes one, it will be provided as part of the location information.</p>
+    *
+    * @param publicId The public identifier as a string.
+    * @see #getPublicId
+    */
+    virtual void setPublicId(const XMLCh* const publicId) = 0;
+
+  /**
+    * Set the system identifier for this input source.
+    *
+    * <p>Set the system identifier for this input source.
+    *
+    * </p>The system id is always required. The public id may be used to map
+    * to another system id, but the system id must always be present as a fall
+    * back.
+    *
+    * <p>If the system ID is a URL, it must be fully resolved.</p>
+    *
+    * @param systemId The system identifier as a string.
+    * @see #getSystemId
+    */
+    virtual void setSystemId(const XMLCh* const systemId) = 0;
+
+  /**
+    * Set the base URI to be used for resolving relative URIs to absolute
+    * URIs. If the baseURI is itself a relative URI, the behavior is
+    * implementation dependent.
+    *
+    * @param baseURI The base URI.
+    * @see #getBaseURI
+    */
+    virtual void setBaseURI(const XMLCh* const baseURI) = 0;
+
+  /**
+    * Indicates if the parser should issue fatal error if this input source
+    * is not found.  If set to false, the parser issue warning message instead.
+    *
+    * @param  flag True if the parser should issue fatal error if this input source is not found.
+    *               If set to false, the parser issue warning message instead.  (Default: true)
+    *
+    * @see #getIssueFatalErrorIfNotFound
+    */
+    virtual void setIssueFatalErrorIfNotFound(const bool flag) = 0;
+
+    //@}
+
+
+private:
+    // -----------------------------------------------------------------------
+    //  Unimplemented constructors and operators
+    // -----------------------------------------------------------------------
+    DOMInputSource(const DOMInputSource&);
+    void operator=(const DOMInputSource&);
+
+};
+
+
+#endif
diff --git a/src/xercesc/dom/Makefile.in b/src/xercesc/dom/Makefile.in
index 094aeaca5..a1f4475a2 100644
--- a/src/xercesc/dom/Makefile.in
+++ b/src/xercesc/dom/Makefile.in
@@ -79,6 +79,7 @@ include ../Makefile.incl
 DOM_CPP_PUBHEADERS = \
 	DOM.hpp \
 	DOMAttr.hpp \
+	DOMBuilder.hpp \
 	DOMCDATASection.hpp \
 	DOMCharacterData.hpp \
 	DOMComment.hpp \
@@ -90,10 +91,13 @@ DOM_CPP_PUBHEADERS = \
 	DOMElement.hpp \
 	DOMEntity.hpp \
 	DOMEntityReference.hpp \
+	DOMEntityResolver.hpp \
 	DOMError.hpp \
 	DOMErrorHandler.hpp \
 	DOMException.hpp \
 	DOMImplementation.hpp \
+	DOMImplementationLS.hpp \
+	DOMInputSource.hpp \
 	DOMLocator.hpp \
 	DOMNamedNodeMap.hpp \
 	DOMNode.hpp \
@@ -115,7 +119,9 @@ DOM_C_FILES =
 
 DOM_CPP_OBJECTS = \
 	DOMException.$(TO) \
-	DOMRangeException.$(TO)
+	DOMRangeException.$(TO) \
+	DOMWriter.$(TO) \
+	DOMWriterFilter.$(TO)
 
 all::	includes $(DOM_CPP_OBJECTS) impl deprecated
 
diff --git a/src/xercesc/dom/impl/DOMImplementationImpl.cpp b/src/xercesc/dom/impl/DOMImplementationImpl.cpp
index 880c6ada2..25105d3a9 100644
--- a/src/xercesc/dom/impl/DOMImplementationImpl.cpp
+++ b/src/xercesc/dom/impl/DOMImplementationImpl.cpp
@@ -61,6 +61,7 @@
 #include "DOMImplementationImpl.hpp"
 #include "DOMDocumentImpl.hpp"
 #include "DOMDocumentTypeImpl.hpp"
+#include "DOMWriterImpl.hpp"
 
 #include <xercesc/dom/DOMDocument.hpp>
 #include <xercesc/dom/DOMDocumentType.hpp>
@@ -68,6 +69,7 @@
 #include <xercesc/util/PlatformUtils.hpp>
 #include <xercesc/util/XMLUniDefs.hpp>
 #include <xercesc/util/XMLRegisterCleanup.hpp>
+#include <xercesc/parsers/DOMBuilderImpl.hpp>
 
 //
 //  Static constants.  These are lazily initialized on first usage.
@@ -213,3 +215,26 @@ DOMDocument *DOMImplementationImpl::createDocument()
         return new DOMDocumentImpl();
 }
 
+
+// DOM LS
+
+DOMBuilder* DOMImplementationImpl::createDOMBuilder(const short mode,
+                                                    const XMLCh* const schemaType)
+{
+    if (mode == DOMImplementationLS::MODE_ASYNCHRONOUS)
+        throw DOMException(DOMException::NOT_SUPPORTED_ERR, 0);
+
+    return new DOMBuilderImpl();
+}
+
+
+DOMWriter* DOMImplementationImpl::createDOMWriter()
+{
+    return new DOMWriterImpl();
+}
+
+DOMInputSource* DOMImplementationImpl::createDOMInputSource()
+{
+    throw DOMException(DOMException::NOT_SUPPORTED_ERR, 0);
+}
+
diff --git a/src/xercesc/dom/impl/DOMImplementationImpl.hpp b/src/xercesc/dom/impl/DOMImplementationImpl.hpp
index 9fbc77161..e33c6fb60 100644
--- a/src/xercesc/dom/impl/DOMImplementationImpl.hpp
+++ b/src/xercesc/dom/impl/DOMImplementationImpl.hpp
@@ -71,8 +71,11 @@
 
 #include <xercesc/util/XercesDefs.hpp>
 #include <xercesc/dom/DOMImplementation.hpp>
+#include <xercesc/dom/DOMImplementationLS.hpp>
 
-class DOMImplementationImpl: public DOMImplementation {
+class DOMImplementationImpl: public DOMImplementation,
+                             public DOMImplementationLS
+{
 private:
     DOMImplementationImpl();
     DOMImplementationImpl(const DOMImplementationImpl & other);
@@ -86,6 +89,12 @@ public:
     virtual DOMDocument               *createDocument(const XMLCh *namespaceURI,
                                             const XMLCh *qualifiedName, DOMDocumentType *doctype);
     virtual DOMDocument               *createDocument();
+
+    // DOMImplementationLS
+    virtual DOMBuilder* createDOMBuilder(const short mode,
+                                         const XMLCh* const schemaType);
+    virtual DOMWriter* createDOMWriter();
+    virtual DOMInputSource* createDOMInputSource();
 };
 
 
diff --git a/src/xercesc/dom/impl/DOMWriterImpl.cpp b/src/xercesc/dom/impl/DOMWriterImpl.cpp
index ffe3ac5da..835e8952b 100644
--- a/src/xercesc/dom/impl/DOMWriterImpl.cpp
+++ b/src/xercesc/dom/impl/DOMWriterImpl.cpp
@@ -57,16 +57,19 @@
 /*
  * $Id$
  * $Log$
+ * Revision 1.2  2002/05/29 21:31:50  knoaman
+ * DOM L3 LS: DOMInputSource, DOMEntityResolver, DOMImplementationLS and DOMBuilder
+ *
  * Revision 1.1  2002/05/28 22:39:39  peiyongz
  * DOM3 Save Interface: DOMWriter/DOMWriterFilter
  *
  */
 
-#include <xercesc/dom/impl/DOMWriterImpl.hpp>
+#include "DOMWriterImpl.hpp"
 
 #include <xercesc/dom/DOM.hpp>
-#include <xercesc/dom/impl/DOMErrorImpl.hpp>
-#include <xercesc/dom/impl/DOMLocatorImpl.hpp>
+#include "DOMErrorImpl.hpp"
+#include "DOMLocatorImpl.hpp"
 
 #include <xercesc/framework/MemBufFormatTarget.hpp>
 #include <xercesc/util/XMLUniDefs.hpp>
diff --git a/src/xercesc/parsers/DOMBuilderImpl.cpp b/src/xercesc/parsers/DOMBuilderImpl.cpp
new file mode 100644
index 000000000..c61116e43
--- /dev/null
+++ b/src/xercesc/parsers/DOMBuilderImpl.cpp
@@ -0,0 +1,306 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2002 The Apache Software Foundation.  All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ *    if any, must include the following acknowledgment:
+ *       "This product includes software developed by the
+ *        Apache Software Foundation (http://www.apache.org/)."
+ *    Alternately, this acknowledgment may appear in the software itself,
+ *    if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xerces" and "Apache Software Foundation" must
+ *    not be used to endorse or promote products derived from this
+ *    software without prior written permission. For written
+ *    permission, please contact apache\@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ *    nor may "Apache" appear in their name, without prior written
+ *    permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation, and was
+ * originally based on software copyright (c) 2001, International
+ * Business Machines, Inc., http://www.ibm.com .  For more information
+ * on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/**
+*  This file contains code to build the DOM tree. It registers a document
+*  handler with the scanner. In these handler methods, appropriate DOM nodes
+*  are created and added to the DOM tree.
+*
+* $Id$
+*
+*/
+
+
+
+// ---------------------------------------------------------------------------
+//  Includes
+// ---------------------------------------------------------------------------
+#include <xercesc/parsers/DOMBuilderImpl.hpp>
+#include <xercesc/util/IOException.hpp>
+#include <xercesc/dom/DOMEntityResolver.hpp>
+#include <xercesc/dom/DOMErrorHandler.hpp>
+#include <xercesc/dom/impl/DOMErrorImpl.hpp>
+#include <xercesc/dom/impl/DOMLocatorImpl.hpp>
+#include <xercesc/dom/DOMException.hpp>
+#include <xercesc/sax/SAXParseException.hpp>
+#include <xercesc/internal/XMLScanner.hpp>
+#include <xercesc/util/DOMInputSourceWrapper.hpp>
+
+
+// ---------------------------------------------------------------------------
+//  DOMBuilderImpl: Constructors and Destructor
+// ---------------------------------------------------------------------------
+DOMBuilderImpl::DOMBuilderImpl(XMLValidator* const valToAdopt) :
+
+AbstractDOMParser(valToAdopt)
+, fAutoValidation(false)
+, fValidation(false)
+, fErrorHandler(0)
+, fEntityResolver(0)
+, fFilter(0)
+{
+}
+
+
+DOMBuilderImpl::~DOMBuilderImpl()
+{
+}
+
+
+// ---------------------------------------------------------------------------
+//  DOMBuilderImpl: Setter methods
+// ---------------------------------------------------------------------------
+void DOMBuilderImpl::setErrorHandler(DOMErrorHandler* const handler)
+{
+    fErrorHandler = handler;
+    if (fErrorHandler) {
+        getScanner()->setErrorReporter(this);
+    }
+    else {
+        getScanner()->setErrorReporter(0);
+    }
+}
+
+void DOMBuilderImpl::setEntityResolver(DOMEntityResolver* const handler)
+{
+    fEntityResolver = handler;
+    if (fEntityResolver) {
+        getScanner()->setEntityHandler(this);
+    }
+    else {
+        getScanner()->setEntityHandler(0);
+    }
+}
+
+void DOMBuilderImpl::setFilter(DOMBuilderFilter* const filter)
+{
+    throw DOMException(DOMException::NOT_SUPPORTED_ERR, 0);
+}
+
+
+// ---------------------------------------------------------------------------
+//  DOMBuilderImpl: Feature methods
+// ---------------------------------------------------------------------------
+void DOMBuilderImpl::setFeature(const XMLCh* const name, const bool state)
+{
+	if (getParseInProgress())
+		throw SAXNotSupportedException("Feature modification is not supported during parse.");
+
+    if (XMLString::compareString(name, XMLUni::fgDOMEntities) == 0) {
+        setCreateEntityReferenceNodes(state);
+    }
+    else if (XMLString::compareString(name, XMLUni::fgDOMNamespaces) == 0) {
+        setDoNamespaces(state);
+    }
+    else if (XMLString::compareString(name, XMLUni::fgDOMWhitespaceInElementContent) == 0) {
+        setIncludeIgnorableWhitespace(state);
+    }
+    else if (XMLString::compareString(name, XMLUni::fgDOMValidation) == 0) {
+
+        fValidation = state;
+
+        if (state) {
+            if (getValidationScheme() == AbstractDOMParser::Val_Never)
+                setValidationScheme(AbstractDOMParser::Val_Always);
+        }
+        else {
+            setValidationScheme(AbstractDOMParser::Val_Never);
+        }
+    }
+    else if (XMLString::compareString(name, XMLUni::fgDOMValidateIfSchema) == 0) {
+
+        fAutoValidation = state;
+
+        if (state) {
+            setValidationScheme(AbstractDOMParser::Val_Auto);
+        }
+        else {
+            setValidationScheme(AbstractDOMParser::Val_Never);
+        }
+    }
+    else {
+        throw DOMException(DOMException::NOT_SUPPORTED_ERR, 0);
+    }
+}
+
+bool DOMBuilderImpl::getFeature(const XMLCh* const name)
+{
+    if (XMLString::compareString(name, XMLUni::fgDOMEntities) == 0) {
+        return getCreateEntityReferenceNodes();
+    }
+    else if (XMLString::compareString(name, XMLUni::fgDOMNamespaces) == 0) {
+        return getDoNamespaces();
+    }
+    else if (XMLString::compareString(name, XMLUni::fgDOMWhitespaceInElementContent) == 0) {
+        return getIncludeIgnorableWhitespace();
+    }
+    else if (XMLString::compareString(name, XMLUni::fgDOMValidation) == 0) {
+        return fValidation;
+    }
+    else if (XMLString::compareString(name, XMLUni::fgDOMValidateIfSchema) == 0) {
+        return fAutoValidation;
+    }
+    else {
+        throw DOMException(DOMException::NOT_SUPPORTED_ERR, 0);
+    }
+
+    return false;
+}
+
+bool DOMBuilderImpl::canSetFeature(const XMLCh* const name, const bool state)
+{
+    if ((XMLString::compareString(name, XMLUni::fgDOMEntities) == 0) ||
+        (XMLString::compareString(name, XMLUni::fgDOMNamespaces) == 0) ||
+        (XMLString::compareString(name, XMLUni::fgDOMValidation) == 0) ||
+        (XMLString::compareString(name, XMLUni::fgDOMValidateIfSchema) == 0) ||
+        (XMLString::compareString(name, XMLUni::fgDOMWhitespaceInElementContent) == 0)) {
+        return true;
+    }
+
+    return false;
+}
+
+// ---------------------------------------------------------------------------
+//  DOMBuilderImpl: Parsing methods
+// ---------------------------------------------------------------------------
+DOMDocument* DOMBuilderImpl::parse(const DOMInputSource& source,
+                                   const bool reuseGrammar)
+{
+    DOMInputSourceWrapper isWrapper((DOMInputSource*) &source);
+
+    isWrapper.setAdoptInputSource(false);
+    AbstractDOMParser::parse(isWrapper, reuseGrammar);
+    return getDocument();
+}
+
+DOMDocument* DOMBuilderImpl::parseURI(const XMLCh* const systemId,
+                                      const bool reuseGrammar)
+{
+    AbstractDOMParser::parse(systemId, reuseGrammar);
+    return getDocument();
+}
+
+DOMDocument* DOMBuilderImpl::parseURI(const char* const systemId,
+                                      const bool reuseGrammar)
+{
+    AbstractDOMParser::parse(systemId, reuseGrammar);
+    return getDocument();
+}
+
+void DOMBuilderImpl::parseWithContext(const DOMInputSource& source,
+                                      DOMNode* const contextNode,
+                                      const short action)
+{
+    throw DOMException(DOMException::NOT_SUPPORTED_ERR, 0);
+}
+
+
+// ---------------------------------------------------------------------------
+//  DOMBuilderImpl: Implementation of the XMLErrorReporter interface
+// ---------------------------------------------------------------------------
+void DOMBuilderImpl::error( const   unsigned int                code
+                            , const XMLCh* const                msgDomain
+                            , const XMLErrorReporter::ErrTypes  errType
+                            , const XMLCh* const                errorText
+                            , const XMLCh* const                systemId
+                            , const XMLCh* const                publicId
+                            , const XMLSSize_t                  lineNum
+                            , const XMLSSize_t                  colNum)
+{
+    if (fErrorHandler) {
+
+        short severity = DOMError::SEVERITY_ERROR;
+
+        if (errType == XMLErrorReporter::ErrType_Warning)
+            severity = DOMError::SEVERITY_WARNING;
+        else if (errType == XMLErrorReporter::ErrType_Fatal)
+            severity = DOMError::SEVERITY_FATAL_ERROR;
+
+        DOMLocatorImpl location((int)lineNum, (int) colNum, getCurrentNode(), systemId);
+        DOMErrorImpl domError(severity, errorText, &location);
+
+        fErrorHandler->handleError(domError);
+    }
+}
+
+void DOMBuilderImpl::resetErrors()
+{
+}
+
+
+// ---------------------------------------------------------------------------
+//  DOMBuilderImpl: Implementation of XMLEntityHandler interface
+// ---------------------------------------------------------------------------
+InputSource*
+DOMBuilderImpl::resolveEntity(const XMLCh* const publicId,
+                              const XMLCh* const systemId,
+                              const XMLCh* const baseURI)
+{
+    //
+    //  Just map it to the SAX entity resolver. If there is not one installed,
+    //  return a null pointer to cause the default resolution.
+    //
+    if (fEntityResolver) {
+
+        DOMInputSource* is = fEntityResolver->resolveEntity(publicId, systemId, baseURI);
+
+        if (is)
+            return new DOMInputSourceWrapper(is);
+    }
+
+    return 0;
+}
+
diff --git a/src/xercesc/parsers/DOMBuilderImpl.hpp b/src/xercesc/parsers/DOMBuilderImpl.hpp
new file mode 100644
index 000000000..947736977
--- /dev/null
+++ b/src/xercesc/parsers/DOMBuilderImpl.hpp
@@ -0,0 +1,621 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2002 The Apache Software Foundation.  All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ *    if any, must include the following acknowledgment:
+ *       "This product includes software developed by the
+ *        Apache Software Foundation (http://www.apache.org/)."
+ *    Alternately, this acknowledgment may appear in the software itself,
+ *    if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xerces" and "Apache Software Foundation" must
+ *    not be used to endorse or promote products derived from this
+ *    software without prior written permission. For written
+ *    permission, please contact apache\@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ *    nor may "Apache" appear in their name, without prior written
+ *    permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation, and was
+ * originally based on software copyright (c) 2001, International
+ * Business Machines, Inc., http://www.ibm.com .  For more information
+ * on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/*
+ * $Id$
+ *
+ */
+
+#if !defined(DOMBUILDERIMPL_HPP)
+#define DOMBUILDERIMPL_HPP
+
+
+#include <xercesc/parsers/AbstractDOMParser.hpp>
+#include <xercesc/dom/DOMBuilder.hpp>
+
+ /**
+  * DOMBuilderImpl provides an implementation of a DOMBuilder interface.
+  * A DOMBuilder instance is obtained from the DOMImplementationLS interface
+  * by invoking its createDOMBuilder method.
+  */
+class PARSERS_EXPORT DOMBuilderImpl : public AbstractDOMParser,
+                                      public DOMBuilder
+{
+public :
+    // -----------------------------------------------------------------------
+    //  Constructors and Detructor
+    // -----------------------------------------------------------------------
+
+    /** @name Constructors and Destructor */
+    //@{
+    /** Construct a DOMBuilderImpl, with an optional validator
+      *
+      * Constructor with an instance of validator class to use for
+      * validation. If you don't provide a validator, a default one will
+      * be created for you in the scanner.
+      *
+      * @param valToAdopt Pointer to the validator instance to use. The
+      *                   parser is responsible for freeing the memory.
+      */
+    DOMBuilderImpl(XMLValidator* const valToAdopt = 0);
+
+    /**
+      * Destructor
+      */
+    virtual ~DOMBuilderImpl();
+
+    //@}
+
+
+    // -----------------------------------------------------------------------
+    //  Getter methods
+    // -----------------------------------------------------------------------
+
+    /** @name Getter methods */
+    //@{
+
+    /** Get a pointer to the error handler
+      *
+      * This method returns the installed error handler. If no handler
+      * has been installed, then it will be a zero pointer.
+      *
+      * @return The pointer to the installed error handler object.
+      */
+    DOMErrorHandler* getErrorHandler();
+
+    /** Get a const pointer to the error handler
+      *
+      * This method returns the installed error handler.  If no handler
+      * has been installed, then it will be a zero pointer.
+      *
+      * @return A const pointer to the installed error handler object.
+      */
+    const DOMErrorHandler* getErrorHandler() const;
+
+    /** Get a pointer to the entity resolver
+      *
+      * This method returns the installed entity resolver.  If no resolver
+      * has been installed, then it will be a zero pointer.
+      *
+      * @return The pointer to the installed entity resolver object.
+      */
+    DOMEntityResolver* getEntityResolver();
+
+    /** Get a const pointer to the entity resolver
+      *
+      * This method returns the installed entity resolver. If no resolver
+      * has been installed, then it will be a zero pointer.
+      *
+      * @return A const pointer to the installed entity resolver object.
+      */
+    const DOMEntityResolver* getEntityResolver() const;
+
+    /** Get a pointer to the application filter
+      *
+      * This method returns the installed application filter. If no filter
+      * has been installed, then it will be a zero pointer.
+      *
+      * @return The pointer to the installed application filter.
+      */
+    DOMBuilderFilter* getFilter();
+
+    /** Get a const pointer to the application filter
+      *
+      * This method returns the installed application filter. If no filter
+      * has been installed, then it will be a zero pointer.
+      *
+      * @return A const pointer to the installed application filter
+      */
+    const DOMBuilderFilter* getFilter() const;
+
+    //@}
+
+
+    // -----------------------------------------------------------------------
+    //  Setter methods
+    // -----------------------------------------------------------------------
+
+    /** @name Setter methods */
+    //@{
+
+    /** Set the error handler
+      *
+      * This method allows applications to install their own error handler
+      * to trap error and warning messages.
+      *
+      * <i>Any previously set handler is merely dropped, since the parser
+      * does not own them.</i>
+      *
+      * @param handler  A const pointer to the user supplied error
+      *                 handler.
+      *
+      * @see #getErrorHandler
+      */
+    void setErrorHandler(DOMErrorHandler* const handler);
+
+    /** Set the entity resolver
+      *
+      * This method allows applications to install their own entity
+      * resolver. By installing an entity resolver, the applications
+      * can trap and potentially redirect references to external
+      * entities.
+      *
+      * <i>Any previously set resolver is merely dropped, since the parser
+      * does not own them.</i>
+      *
+      * @param handler  A const pointer to the user supplied entity
+      *                 resolver.
+      *
+      * @see #getEntityResolver
+      */
+    void setEntityResolver(DOMEntityResolver* const handler);
+
+    /** Set the application filter
+      *
+      * When the application provides a filter, the parser will call out to
+      * the filter at the completion of the construction of each Element node.
+      * The filter implementation can choose to remove the element from the
+      * document being constructed (unless the element is the document element)
+      * or to terminate the parse early. If the document is being validated
+      * when it's loaded the validation happens before the filter is called.
+      *
+      * <i>Any previously set filter is merely dropped, since the parser
+      * does not own them.</i>
+      *
+      * @param filter  A const pointer to the user supplied application
+      *                filter.
+      *
+      * @see #getFilter
+      */
+    void setFilter(DOMBuilderFilter* const filter);
+
+    //@}
+
+
+    // -----------------------------------------------------------------------
+    //  Feature methods
+    // -----------------------------------------------------------------------
+    /** @name Feature methods */
+    //@{
+
+    /** Set the state of a feature
+      *
+      * It is possible for a DOMBuilder to recognize a feature name but to be
+      * unable to set its value.
+      *
+      * @param name  The feature name.
+      * @param state The requested state of the feature (true or false).
+      * @exception DOMException
+      *     NOT_SUPPORTED_ERR: Raised when the DOMBuilder recognizes the
+      *     feature name but cannot set the requested value.
+      *     <br>NOT_FOUND_ERR: Raised when the DOMBuilder does not recognize
+      *     the feature name.
+      *
+      * @see #setFeature
+      * @see #canSetFeature
+      */
+    void setFeature(const XMLCh* const name, const bool state);
+
+    /** Look up the value of a feature.
+      *
+      * @param name The feature name.
+      * @return The current state of the feature (true or false)
+      * @exception DOMException
+      *     NOT_FOUND_ERR: Raised when the DOMBuilder does not recognize
+      *     the feature name. 
+      *
+      * @see #getFeature
+      * @see #canSetFeature
+      */
+    bool getFeature(const XMLCh* const name);
+
+    /** Query whether setting a feature to a specific value is supported.
+      *
+      * @param name  The feature name.
+      * @param state The requested state of the feature (true or false).
+      * @return <code>true</code> if the feature could be successfully set
+      *     to the specified value, or <code>false</code> if the feature
+      *     is not recognized or the requested value is not supported. The
+      *     value of the feature itself is not changed.
+      *
+      * @see #getFeature
+      * @see #setFeature
+      */
+    bool canSetFeature(const XMLCh* const name, const bool state);
+
+    //@}
+
+    // -----------------------------------------------------------------------
+    //  Parsing methods
+    // -----------------------------------------------------------------------
+    /** @name Parsing methods */
+    //@{
+
+    /** Parse via an input source object
+      *
+      * This method invokes the parsing process on the XML file specified
+      * by the DOMInputSource parameter. This API is borrowed from the
+      * SAX Parser interface.
+      *
+      * @param source A const reference to the DOMInputSource object which
+      *               points to the XML file to be parsed.
+      * @param reuseGrammar The flag indicating whether the existing Grammar
+      *                     should be reused or not for this parsing run.
+      *                     If true, there cannot be any internal subset.
+      * @return If the DOMBuilder is a synchronous DOMBuilder the newly created
+      *         and populated Document is returned. If the DOMBuilder is
+      *         asynchronous then <code>null</code> is returned since the
+      *         document object is not yet parsed when this method returns.
+      * @exception SAXException Any SAX exception, possibly
+      *            wrapping another exception.
+      * @exception XMLException An exception from the parser or client
+      *            handler code.
+      * @exception DOMException A DOM exception as per DOM spec.
+      *
+      * @see DOMInputSource#DOMInputSource
+      * @see #setEntityResolver
+      * @see #setErrorHandler
+      */
+    DOMDocument* parse(const DOMInputSource& source, const bool reuseGrammar = false);
+
+    /** Parse via a file path or URL
+      *
+      * This method invokes the parsing process on the XML file specified by
+      * the Unicode string parameter 'systemId'.
+      *
+      * @param systemId A const XMLCh pointer to the Unicode string which
+      *                 contains the path to the XML file to be parsed.
+      * @param reuseGrammar The flag indicating whether the existing Grammar
+      *                     should be reused or not for this parsing run.
+      *                     If true, there cannot be any internal subset.
+      * @return If the DOMBuilder is a synchronous DOMBuilder the newly created
+      *         and populated Document is returned. If the DOMBuilder is
+      *         asynchronous then <code>null</code> is returned since the
+      *         document object is not yet parsed when this method returns.
+      * @exception SAXException Any SAX exception, possibly
+      *            wrapping another exception.
+      * @exception XMLException An exception from the parser or client
+      *            handler code.
+      * @exception DOM_DOMException A DOM exception as per DOM spec.
+      *
+      * @see #parse(DOMInputSource,...)
+      */
+    DOMDocument* parseURI(const XMLCh* const systemId, const bool reuseGrammar = false);
+
+    /** Parse via a file path or URL (in the local code page)
+      *
+      * This method invokes the parsing process on the XML file specified by
+      * the native char* string parameter 'systemId'.
+      *
+      * @param systemId A const char pointer to a native string which
+      *                 contains the path to the XML file to be parsed.
+      * @param reuseGrammar The flag indicating whether the existing Grammar
+      *                     should be reused or not for this parsing run.
+      *                     If true, there cannot be any internal subset.
+      * @return If the DOMBuilder is a synchronous DOMBuilder the newly created
+      *         and populated Document is returned. If the DOMBuilder is
+      *         asynchronous then <code>null</code> is returned since the
+      *         document object is not yet parsed when this method returns.
+      * @exception SAXException Any SAX exception, possibly
+      *            wrapping another exception.
+      * @exception XMLException An exception from the parser or client
+      *            handler code.
+      * @exception DOM_DOMException A DOM exception as per DOM spec.
+      *
+      * @see #parse(DOMInputSource,...)
+      */
+    DOMDocument* parseURI(const char* const systemId, const bool reuseGrammar = false);
+
+    /** Parse via an input source object
+      *
+      * This method invokes the parsing process on the XML file specified
+      * by the DOMInputSource parameter, and inserts the content into an
+      * existing document at the position specified with the contextNode
+      * and action arguments. When parsing the input stream the context node
+      * is used for resolving unbound namespace prefixes.
+      *
+      * @param source A const reference to the DOMInputSource object which
+      *               points to the XML file to be parsed.
+      * @param contextNode The node that is used as the context for the data
+      *                    that is being parsed. This node must be a Document
+      *                    node, a DocumentFragment node, or a node of a type
+      *                    that is allowed as a child of an element, e.g. it
+      *                    can not be an attribute node.
+      * @param action This parameter describes which action should be taken
+      *               between the new set of node being inserted and the
+      *               existing children of the context node.
+      * @exception DOMException
+      *     NOT_SUPPORTED_ERR: Raised when the DOMBuilder doesn't support
+      *     this method.
+      *     <br>NO_MODIFICATION_ALLOWED_ERR: Raised if the context node is
+      *     readonly.
+      */
+    virtual void parseWithContext
+    (
+        const   DOMInputSource& source
+        ,       DOMNode* const contextNode
+        , const short action
+    );
+
+
+    // -----------------------------------------------------------------------
+    //  Implementation of the XMLErrorReporter interface.
+    // -----------------------------------------------------------------------
+
+    /** @name Implementation of the XMLErrorReporter interface. */
+    //@{
+
+    /** Handle errors reported from the parser
+      *
+      * This method is used to report back errors found while parsing the
+      * XML file. This method is also borrowed from the SAX specification.
+      * It calls the corresponding user installed Error Handler method:
+      * 'fatal', 'error', 'warning' depending on the severity of the error.
+      * This classification is defined by the XML specification.
+      *
+      * @param errCode An integer code for the error.
+      * @param msgDomain A const pointer to an Unicode string representing
+      *                  the message domain to use.
+      * @param errType An enumeration classifying the severity of the error.
+      * @param errorText A const pointer to an Unicode string representing
+      *                  the text of the error message.
+      * @param systemId  A const pointer to an Unicode string representing
+      *                  the system id of the XML file where this error
+      *                  was discovered.
+      * @param publicId  A const pointer to an Unicode string representing
+      *                  the public id of the XML file where this error
+      *                  was discovered.
+      * @param lineNum   The line number where the error occurred.
+      * @param colNum    The column number where the error occurred.
+      * @see DOMErrorHandler
+      */
+    virtual void error
+    (
+        const   unsigned int                errCode
+        , const XMLCh* const                msgDomain
+        , const XMLErrorReporter::ErrTypes  errType
+        , const XMLCh* const                errorText
+        , const XMLCh* const                systemId
+        , const XMLCh* const                publicId
+        , const XMLSSize_t                  lineNum
+        , const XMLSSize_t                  colNum
+    );
+
+    /** Reset any error data before a new parse
+     *
+      * This method allows the user installed Error Handler callback to
+      * 'reset' itself.
+      *
+      * <b><font color="#FF0000">This method is a no-op for this DOM
+      * implementation.</font></b>
+      */
+    virtual void resetErrors();
+    //@}
+
+
+    // -----------------------------------------------------------------------
+    //  Implementation of the XMLEntityHandler interface.
+    // -----------------------------------------------------------------------
+
+    /** @name Implementation of the XMLEntityHandler interface. */
+    //@{
+
+    /** Handle an end of input source event
+      *
+      * This method is used to indicate the end of parsing of an external
+      * entity file.
+      *
+      * <b><font color="#FF0000">This method is a no-op for this DOM
+      * implementation.</font></b>
+      *
+      * @param inputSource A const reference to the InputSource object
+      *                    which points to the XML file being parsed.
+      * @see InputSource
+      */
+    virtual void endInputSource(const InputSource& inputSource);
+
+    /** Expand a system id
+      *
+      * This method allows an installed XMLEntityHandler to further
+      * process any system id's of enternal entities encountered in
+      * the XML file being parsed, such as redirection etc.
+      *
+      * <b><font color="#FF0000">This method always returns 'false'
+      * for this DOM implementation.</font></b>
+      *
+      * @param systemId  A const pointer to an Unicode string representing
+      *                  the system id scanned by the parser.
+      * @param toFill    A pointer to a buffer in which the application
+      *                  processed system id is stored.
+      * @return 'true', if any processing is done, 'false' otherwise.
+      */
+    virtual bool expandSystemId
+    (
+        const   XMLCh* const    systemId
+        ,       XMLBuffer&      toFill
+    );
+
+    /** Reset any entity handler information
+      *
+      * This method allows the installed XMLEntityHandler to reset
+      * itself.
+      *
+      * <b><font color="#FF0000">This method is a no-op for this DOM
+      * implementation.</font></b>
+      */
+    virtual void resetEntities();
+
+    /** Resolve a public/system id
+      *
+      * This method allows a user installed entity handler to further
+      * process any pointers to external entities. The applications can
+      * implement 'redirection' via this callback. This method is also
+      * borrowed from the SAX specification.
+      *
+      * @param publicId A const pointer to a Unicode string representing the
+      *                 public id of the entity just parsed.
+      * @param systemId A const pointer to a Unicode string representing the
+      *                 system id of the entity just parsed.
+      * @return The value returned by the user installed resolveEntity
+      *         method or NULL otherwise to indicate no processing was done.
+      * @see DOMEntityResolver
+      */
+    virtual InputSource* resolveEntity
+    (
+        const   XMLCh* const    publicId
+        , const XMLCh* const    systemId
+        , const XMLCh* const    baseURI
+    );
+
+    /** Handle a 'start input source' event
+      *
+      * This method is used to indicate the start of parsing an external
+      * entity file.
+      *
+      * <b><font color="#FF0000">This method is a no-op for this DOM parse
+      * implementation.</font></b>
+      *
+      * @param inputSource A const reference to the InputSource object
+      *                    which points to the external entity
+      *                    being parsed.
+      */
+    virtual void startInputSource(const InputSource& inputSource);
+
+    //@}
+
+
+private :
+    // -----------------------------------------------------------------------
+    //  Private data members
+    //
+    //  fEntityResolver
+    //      The installed DOM entity resolver, if any. Null if none.
+    //
+    //  fErrorHandler
+    //      The installed DOM error handler, if any. Null if none.
+    //
+    //  fFilter
+    //      The installed application filter, if any. Null if none.
+    //-----------------------------------------------------------------------
+    bool                        fAutoValidation;
+    bool                        fValidation;
+    DOMEntityResolver*          fEntityResolver;
+    DOMErrorHandler*            fErrorHandler;
+    DOMBuilderFilter*           fFilter;
+};
+
+
+
+// ---------------------------------------------------------------------------
+//  DOMBuilderImpl: Handlers for the XMLEntityHandler interface
+// ---------------------------------------------------------------------------
+inline void DOMBuilderImpl::endInputSource(const InputSource&)
+{
+    // The DOM entity resolver doesn't handle this
+}
+
+inline bool DOMBuilderImpl::expandSystemId(const XMLCh* const, XMLBuffer&)
+{
+    // The DOM entity resolver doesn't handle this
+    return false;
+}
+
+inline void DOMBuilderImpl::resetEntities()
+{
+    // Nothing to do on this one
+}
+
+inline void DOMBuilderImpl::startInputSource(const InputSource&)
+{
+    // The DOM entity resolver doesn't handle this
+}
+
+
+// ---------------------------------------------------------------------------
+//  DOMBuilderImpl: Getter methods
+// ---------------------------------------------------------------------------
+inline DOMErrorHandler* DOMBuilderImpl::getErrorHandler()
+{
+    return fErrorHandler;
+}
+
+inline const DOMErrorHandler* DOMBuilderImpl::getErrorHandler() const
+{
+    return fErrorHandler;
+}
+
+inline DOMEntityResolver* DOMBuilderImpl::getEntityResolver()
+{
+    return fEntityResolver;
+}
+
+inline const DOMEntityResolver* DOMBuilderImpl::getEntityResolver() const
+{
+    return fEntityResolver;
+}
+
+inline DOMBuilderFilter* DOMBuilderImpl::getFilter()
+{
+    return fFilter;
+}
+
+inline const DOMBuilderFilter* DOMBuilderImpl::getFilter() const
+{
+    return fFilter;
+}
+
+
+#endif
-- 
GitLab