[GME-commit] GMESRC/GME/Include/xercesc/com BindStatusCallback.cpp, NONE, 1.1 BindStatusCallback.h, NONE, 1.1 IXMLDOMCharacterDataImpl.h, NONE, 1.1 IXMLDOMNodeImpl.h, NONE, 1.1 IXMLDOMNodeImpl.inl, NONE, 1.1 IXMLDOMTextImpl.h, NONE, 1.1 NodeContainerImpl.h, NONE, 1.1 README.txt, NONE, 1.1 StdAfx.cpp, NONE, 1.1 StdAfx.h, NONE, 1.1 XMLDOMAttribute.cpp, NONE, 1.1 XMLDOMAttribute.h, NONE, 1.1 XMLDOMCDATASection.h, NONE, 1.1 XMLDOMComment.h, NONE, 1.1 XMLDOMDocument.cpp, NONE, 1.1 XMLDOMDocument.h, NONE, 1.1 XMLDOMDocumentFragment.h, NONE, 1.1 XMLDOMDocumentType.cpp, NONE, 1.1 XMLDOMDocumentType.h, NONE, 1.1 XMLDOMElement.cpp, NONE, 1.1 XMLDOMElement.h, NONE, 1.1 XMLDOMEntity.cpp, NONE, 1.1 XMLDOMEntity.h, NONE, 1.1 XMLDOMEntityReference.h, NONE, 1.1 XMLDOMImplementation.cpp, NONE, 1.1 XMLDOMImplementation.h, NONE, 1.1 XMLDOMNamedNodeMap.cpp, NONE, 1.1 XMLDOMNamedNodeMap.h, NONE, 1.1 XMLDOMNodeList.cpp, NONE, 1.1 XMLDOMNodeList.h, NONE, 1.1 XMLDOMNotation.cpp, NONE, 1.1 XMLDOMNotation.h, NONE, 1.1 XMLDOMParseError.cpp, NONE, 1.1 XMLDOMParseError.h, N ONE, 1.1 XMLDOMProcessingInstruction.cpp, NONE, 1.1 XMLDOMProcessingInstruction.h, NONE, 1.1 XMLDOMText.h, NONE, 1.1 XMLDOMUtil.cpp, NONE, 1.1 XMLDOMUtil.h, NONE, 1.1 XMLDOMXMLDecl.cpp, NONE, 1.1 XMLDOMXMLDecl.h, NONE, 1.1 XMLHTTPRequest.cpp, NONE, 1.1 XMLHttpRequest.h, NONE, 1.1 registry.bin, NONE, 1.1 resource.h, NONE, 1.1 xml4com.cpp, NONE, 1.1 xml4com.def, NONE, 1.1 xml4com.idl, NONE, 1.1 xml4com.rc, NONE, 1.1 xml4comCP.h, NONE, 1.1 xml4comps.def, NONE, 1.1 xml4comps.mk, NONE, 1.1 xmldocument.rgs, NONE, 1.1 xmlhttprequest.rgs, NONE, 1.1

Log messages of CVS commits gme-commit at list.isis.vanderbilt.edu
Tue Feb 19 14:16:29 CST 2008


Update of /project/gme-repository/GMESRC/GME/Include/xercesc/com
In directory escher:/tmp/cvs-serv26529/com

Added Files:
	BindStatusCallback.cpp BindStatusCallback.h 
	IXMLDOMCharacterDataImpl.h IXMLDOMNodeImpl.h 
	IXMLDOMNodeImpl.inl IXMLDOMTextImpl.h NodeContainerImpl.h 
	README.txt StdAfx.cpp StdAfx.h XMLDOMAttribute.cpp 
	XMLDOMAttribute.h XMLDOMCDATASection.h XMLDOMComment.h 
	XMLDOMDocument.cpp XMLDOMDocument.h XMLDOMDocumentFragment.h 
	XMLDOMDocumentType.cpp XMLDOMDocumentType.h XMLDOMElement.cpp 
	XMLDOMElement.h XMLDOMEntity.cpp XMLDOMEntity.h 
	XMLDOMEntityReference.h XMLDOMImplementation.cpp 
	XMLDOMImplementation.h XMLDOMNamedNodeMap.cpp 
	XMLDOMNamedNodeMap.h XMLDOMNodeList.cpp XMLDOMNodeList.h 
	XMLDOMNotation.cpp XMLDOMNotation.h XMLDOMParseError.cpp 
	XMLDOMParseError.h XMLDOMProcessingInstruction.cpp 
	XMLDOMProcessingInstruction.h XMLDOMText.h XMLDOMUtil.cpp 
	XMLDOMUtil.h XMLDOMXMLDecl.cpp XMLDOMXMLDecl.h 
	XMLHTTPRequest.cpp XMLHttpRequest.h registry.bin resource.h 
	xml4com.cpp xml4com.def xml4com.idl xml4com.rc xml4comCP.h 
	xml4comps.def xml4comps.mk xmldocument.rgs xmlhttprequest.rgs 
Log Message:
Xerces2.7 includes checkin.


CVS User: Zoltan Molnar, ISIS (zolmol)

--- NEW FILE: XMLDOMAttribute.cpp ---
/*
 * Copyright 1999-2001,2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * $Id: XMLDOMAttribute.cpp,v 1.1 2008/02/19 20:16:27 zolmol Exp $
 */

#include "stdafx.h"
#include "xml4com.h"
#include "XMLDOMAttribute.h"

// IXMLDOMAttribute methods
STDMETHODIMP CXMLDOMAttribute::get_name(BSTR  *pVal)
{
	ATLTRACE(_T("CXMLDOMAttribute::get_name\n"));

	if (NULL == pVal)
		return E_POINTER;

	try
	{
		*pVal = SysAllocString(attr->getName());
	}
	catch(DOMException& ex) {
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}
	

	return S_OK;
}

STDMETHODIMP CXMLDOMAttribute::get_value(VARIANT  *pVal)
{
	ATLTRACE(_T("CXMLDOMAttribute::get_value\n"));

	if (NULL == pVal)
		return E_POINTER;

	::VariantInit(pVal);

	try
	{
		V_VT(pVal)   = VT_BSTR;
		V_BSTR(pVal) = SysAllocString(attr->getValue());
	}
	catch(DOMException& ex) {
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}


	return S_OK;
}

STDMETHODIMP CXMLDOMAttribute::put_value(VARIANT newVal)
{
	ATLTRACE(_T("CXMLDOMAttribute::put_value\n"));

	try
	{
		if(V_VT(&newVal) == VT_BSTR) {
			attr->setValue(V_BSTR(&newVal));
		}
		else {
			attr->setValue((BSTR) (_bstr_t) newVal);
		}

		attr->setValue(V_BSTR(&newVal));
	}
	catch(DOMException& ex) {
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}
	
	return S_OK;
}

	//  IXMLDOMNode method
STDMETHODIMP CXMLDOMAttribute::get_specified(VARIANT_BOOL  *pVal)
{
	ATLTRACE(_T("CXMLDOMAttribute::get_specified\n"));

	try
	{
		*pVal = attr->getSpecified() ? VARIANT_TRUE : VARIANT_FALSE;
	}
	catch(DOMException& ex) {
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}
	
	return S_OK;
}


STDMETHODIMP CXMLDOMAttribute::get_nodeValue(VARIANT  *pVal)
{
	ATLTRACE(_T("CXMLDOMAttribute::get_nodeValue\n"));

	if (NULL == pVal)
		return E_POINTER;

	::VariantInit(pVal);

	try
	{
		V_VT(pVal)   = VT_BSTR;
		V_BSTR(pVal) = SysAllocString(attr->getValue());
	}
	catch(DOMException& ex) {
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}


	return S_OK;
}



--- NEW FILE: xmlhttprequest.rgs ---
HKCR
{
	IBMXML.XMLHttpRequest.2.6.0 = s 'Apache Xerces XML Http Request'
	{
		CLSID = s '{3A725053-15FB-4065-9171-BC02BCF3876C}'
	}
	IBMXML.XMLHttpRequest = s 'Apache Xerces XML Http Request'
	{
		CLSID = s '{3A725053-15FB-4065-9171-BC02BCF3876C}'
		CurVer = s 'Xerces.XMLHttpRequest.2.6.0'
	}
	NoRemove CLSID
	{
		ForceRemove {3A725053-15FB-4065-9171-BC02BCF3876C} = s 'Apache Xerces XML Http Request'
		{
			ProgID = s 'Xerces.XMLHttpRequest.2.6.0'
			VersionIndependentProgID = s 'Xerces.XMLHttpRequest'
			ForceRemove 'Programmable'
			InprocServer32 = s '%XMLMODULE%'
			{
				val ThreadingModel = s 'Apartment'
			}
			'TypeLib' = s '{C4775B62-ECD6-11d4-94B4-00A0CC57CBCB}'
		}
	}
}
--- NEW FILE: xml4comps.mk ---

xml4comps.dll: dlldata.obj xml4com_p.obj xml4com_i.obj
	link /dll /out:xml4comps.dll /def:xml4comps.def /entry:DllMain dlldata.obj xml4com_p.obj xml4com_i.obj \
		kernel32.lib rpcndr.lib rpcns4.lib rpcrt4.lib oleaut32.lib uuid.lib \

.c.obj:
	cl /c /Ox /DWIN32 /D_WIN32_WINNT=0x0400 /DREGISTER_PROXY_DLL \
		$<

clean:
	@del xml4comps.dll
	@del xml4comps.lib
	@del xml4comps.exp
	@del dlldata.obj
	@del xml4com_p.obj
	@del xml4com_i.obj

--- NEW FILE: XMLDOMNotation.cpp ---
/*
 * Copyright 1999-2001,2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * $Id: XMLDOMNotation.cpp,v 1.1 2008/02/19 20:16:27 zolmol Exp $
 */

#include "stdafx.h"
#include "xml4com.h"
#include "XMLDOMNotation.h"

STDMETHODIMP CXMLDOMNotation::get_publicId(VARIANT  *pVal)
{
	ATLTRACE(_T("CXMLDOMNotation::get_publicId\n"));

	if (NULL == pVal)
		return E_POINTER;

	::VariantInit(pVal);

	try
	{
        const XMLCh* val=notation->getPublicId();
		if(val == NULL)
		{
			V_VT(pVal) = VT_NULL;
		}
		else
		{
			V_VT(pVal) = VT_BSTR;
			V_BSTR(pVal) = SysAllocString(val);
		}
	}
	catch(DOMException& ex)
	{
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}
	

	return S_OK;
}

STDMETHODIMP CXMLDOMNotation::get_systemId(VARIANT  *pVal)
{
	ATLTRACE(_T("CXMLDOMNotation::get_systemId\n"));

	if (NULL == pVal)
		return E_POINTER;

	::VariantInit(pVal);

	try
	{
        const XMLCh* val=notation->getSystemId();
		if(val == NULL)
		{
			V_VT(pVal) = VT_NULL;
		}
		else
		{
			V_VT(pVal) = VT_BSTR;
			V_BSTR(pVal) = SysAllocString(val);
		}
	}
	catch(DOMException& ex)
	{
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}
	

	return S_OK;
}

--- NEW FILE: XMLDOMDocumentFragment.h ---
/*
 * Copyright 1999-2001,2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * $Id: XMLDOMDocumentFragment.h,v 1.1 2008/02/19 20:16:27 zolmol Exp $
 */

#ifndef ___xmldomdocumentfragment_h___
#define ___xmldomdocumentfragment_h___

#include <xercesc/dom/DOMDocumentFragment.hpp>
#include "IXMLDOMNodeImpl.h"

XERCES_CPP_NAMESPACE_USE

class ATL_NO_VTABLE CXMLDOMDocumentFragment :
	public CComObjectRootEx<CComSingleThreadModel>,
	public IXMLDOMNodeImpl<IXMLDOMDocumentFragment, &IID_IXMLDOMDocumentFragment>
{
public:
	CXMLDOMDocumentFragment()
	{}

	void	FinalRelease()
	{
		ReleaseOwnerDoc();
	}
	
	virtual DOMNode* get_DOMNode()			 { return documentFragment;}
	virtual DOMNodeType get_DOMNodeType() const  { return NODE_DOCUMENT_FRAGMENT; }

DECLARE_NOT_AGGREGATABLE(CXMLDOMDocumentFragment)

DECLARE_PROTECT_FINAL_CONSTRUCT()

BEGIN_COM_MAP(CXMLDOMDocumentFragment)
	COM_INTERFACE_ENTRY(IXMLDOMDocumentFragment)
	COM_INTERFACE_ENTRY(IXMLDOMNode)
	COM_INTERFACE_ENTRY(IIBMXMLDOMNodeIdentity)
	COM_INTERFACE_ENTRY(IDispatch)
	COM_INTERFACE_ENTRY(ISupportErrorInfo)
END_COM_MAP()

	DOMDocumentFragment* documentFragment;
};

typedef CComObject<CXMLDOMDocumentFragment> CXMLDOMDocumentFragmentObj;

#endif // ___xmldomdocumentfragment_h___
--- NEW FILE: XMLDOMEntityReference.h ---
/*
 * Copyright 1999-2001,2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * $Id: XMLDOMEntityReference.h,v 1.1 2008/02/19 20:16:27 zolmol Exp $
 */

#ifndef ___xmldomentityreference_h___
#define ___xmldomentityreference_h___

#include <xercesc/dom/DOMEntityReference.hpp>
#include "IXMLDOMNodeImpl.h"

XERCES_CPP_NAMESPACE_USE

class ATL_NO_VTABLE CXMLDOMEntityReference :
	public CComObjectRootEx<CComSingleThreadModel>,
	public IXMLDOMNodeImpl<IXMLDOMEntityReference, &IID_IXMLDOMEntityReference>
{
public:
	CXMLDOMEntityReference()
	{}

	void	FinalRelease()
	{
		ReleaseOwnerDoc();
	}

	virtual DOMNode* get_DOMNode()			 { return entityReference;}
	virtual DOMNodeType get_DOMNodeType() const  { return NODE_ENTITY_REFERENCE; }

DECLARE_NOT_AGGREGATABLE(CXMLDOMEntityReference)
DECLARE_PROTECT_FINAL_CONSTRUCT()

BEGIN_COM_MAP(CXMLDOMEntityReference)
	COM_INTERFACE_ENTRY(IXMLDOMEntityReference)
	COM_INTERFACE_ENTRY(IXMLDOMNode)
	COM_INTERFACE_ENTRY(IIBMXMLDOMNodeIdentity)
	COM_INTERFACE_ENTRY(IDispatch)
	COM_INTERFACE_ENTRY(ISupportErrorInfo)
END_COM_MAP()

	DOMEntityReference* entityReference;
};

typedef CComObject<CXMLDOMEntityReference> CXMLDOMEntityReferenceObj;

#endif // ___xmldomentityreference_h___
--- NEW FILE: XMLDOMElement.cpp ---
/*
 * Copyright 1999-2001,2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * $Id: XMLDOMElement.cpp,v 1.1 2008/02/19 20:16:27 zolmol Exp $
 */

#include "stdafx.h"
#include "xml4com.h"
#include "XMLDOMElement.h"
#include "XMLDOMAttribute.h"
#include "XMLDOMNodeList.h"

// IXMLDOMElement methods
STDMETHODIMP CXMLDOMElement::get_tagName(BSTR  *pVal)
{
	ATLTRACE(_T("CXMLDOMElement::get_tagName\n"));

	if (NULL == pVal)
		return E_POINTER;

	*pVal = NULL;

	try
	{
		*pVal = SysAllocString(element->getTagName());
	}
	catch(DOMException& ex)
	{
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}
	
	return S_OK;
}

STDMETHODIMP CXMLDOMElement::getAttribute(BSTR name, VARIANT  *pVal)
{
	ATLTRACE(_T("CXMLDOMElement::getAttribute\n"));

	if (NULL == pVal)
		return E_POINTER;

	::VariantInit(pVal);
	V_VT(pVal) = VT_EMPTY;

	try {
		V_VT(pVal)   = VT_BSTR;
		V_BSTR(pVal) = SysAllocString(element->getAttribute(name));
	}
	catch(DOMException& ex)
	{
		return MakeHRESULT(ex);
	}
	catch(...) {
		return E_FAIL;
	}
	
	return S_OK;
}

STDMETHODIMP CXMLDOMElement::setAttribute(BSTR name, VARIANT value)
{
	ATLTRACE(_T("CXMLDOMElement::setAttribute\n"));

	try
	{
		if (V_VT(&value) == VT_BSTR)
		{
			element->setAttribute(name, value.bstrVal);
		}
		else {
			element->setAttribute(name,(BSTR) (_bstr_t) value);
		}
	}
	catch(DOMException& ex)
	{
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}
	

	return S_OK;
}

STDMETHODIMP CXMLDOMElement::removeAttribute(BSTR name)
{
	ATLTRACE(_T("CXMLDOMElement::removeAttribute\n"));

	try
	{
		element->removeAttribute(name);
	}
	catch(DOMException& ex)
	{
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}
	
	return S_OK;
}

STDMETHODIMP CXMLDOMElement::getAttributeNode(BSTR name, IXMLDOMAttribute  **attr)
{
	ATLTRACE(_T("CXMLDOMElement::getAttributeNode\n"));

	if (NULL == attr)
		return E_POINTER;

	*attr = NULL;
	DOMAttr* attrNode=element->getAttributeNode(name);
	if(attrNode==NULL)
		return S_OK;
	

	CXMLDOMAttributeObj *pObj = NULL;
	HRESULT hr = CXMLDOMAttributeObj::CreateInstance(&pObj);
	if (S_OK != hr)
		return hr;

	pObj->AddRef();
	pObj->SetOwnerDoc(m_pIXMLDOMDocument);

	try
	{
		pObj->attr = attrNode;
	}
	catch(DOMException& ex)
	{
		pObj->Release();
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		pObj->Release();
		return E_FAIL;
	}
	
	hr = pObj->QueryInterface(IID_IXMLDOMAttribute, reinterpret_cast<LPVOID*> (attr));
	if (S_OK != hr)
		*attr = NULL;

	pObj->Release();
	return hr;
}

STDMETHODIMP CXMLDOMElement::setAttributeNode(IXMLDOMAttribute  *attr, IXMLDOMAttribute  **attributeNode)
{
	ATLTRACE(_T("CXMLDOMElement::setAttributeNode\n"));

	if (NULL == attr || NULL == attributeNode)
		return E_POINTER;

	*attributeNode = NULL;

	DOMAttr* newAttr = NULL;
	IIBMXMLDOMNodeIdentity* nodeID = NULL;
	HRESULT sc = attr->QueryInterface(IID_IIBMXMLDOMNodeIdentity,(void**) &nodeID);
	if(SUCCEEDED(sc)) {
		long id = 0;
		sc = nodeID->get_NodeId(&id);
		nodeID->Release();
		if(SUCCEEDED(sc)) {
			//
			//   any subsequent failure will be reported as an invalid arg
			//
			sc = E_INVALIDARG;
			try {
				DOMNode* newNode = (DOMNode*) id;
				if(newNode->getNodeType() == DOMNode::ATTRIBUTE_NODE) {
					newAttr = (DOMAttr*) newNode;
				}
			}
			catch(...) {
			}
		}
	}

	//
	//   if we couldn't extract an attribute out of the
	//       argument, then return with a failure code
	if(newAttr == NULL) return sc;

	sc = S_OK;
	try
	{
		DOMAttr* oldAttr = element->setAttributeNode(newAttr);
		if(oldAttr!=NULL) {
			CXMLDOMAttributeObj *pObj = NULL;
			sc = CXMLDOMAttributeObj::CreateInstance(&pObj);
			if (SUCCEEDED(sc)) {
				pObj->attr = oldAttr;
				pObj->AddRef();
				pObj->SetOwnerDoc(m_pIXMLDOMDocument);

				sc = pObj->QueryInterface(IID_IXMLDOMAttribute, reinterpret_cast<LPVOID*> (attributeNode));
				pObj->Release();
			}
		}
	}
	catch(DOMException& ex)
	{
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}


	return sc;
}

STDMETHODIMP CXMLDOMElement::removeAttributeNode(IXMLDOMAttribute  *attr, IXMLDOMAttribute  * *attributeNode)
{
	ATLTRACE(_T("CXMLDOMElement::removeAttributeNode\n"));

	if (NULL == attr || NULL == attributeNode)
		return E_POINTER;

	*attributeNode = NULL;

	CXMLDOMAttributeObj *pObj = NULL;
	HRESULT hr = CXMLDOMAttributeObj::CreateInstance(&pObj);
	if (S_OK != hr)
		return hr;
	
	pObj->AddRef();
	pObj->SetOwnerDoc(m_pIXMLDOMDocument);

	try
	{
		long id = 0;
		IIBMXMLDOMNodeIdentity* nodeID = NULL;
		if(SUCCEEDED(attr->QueryInterface(IID_IIBMXMLDOMNodeIdentity,(void**) &nodeID))) {
			nodeID->get_NodeId(&id);
			nodeID->Release();
		}
		pObj->attr = element->removeAttributeNode((DOMAttr*) id);
	}
	catch(DOMException& ex)
	{
		pObj->Release();
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		pObj->Release();
		return E_FAIL;
	}
	
	hr = pObj->QueryInterface(IID_IXMLDOMAttribute, reinterpret_cast<LPVOID*> (attributeNode));
	if (S_OK != hr)
		*attributeNode = NULL;

	pObj->Release();
	return hr;
}

STDMETHODIMP CXMLDOMElement::getElementsByTagName(BSTR tagName, IXMLDOMNodeList  **pVal)
{
	ATLTRACE(_T("CXMLDOMElement::getElementsByTagName\n"));

	if (NULL == pVal)
		return E_POINTER;

	*pVal = NULL;

	CXMLDOMNodeListObj *pObj = NULL;
	HRESULT hr = CXMLDOMNodeListObj::CreateInstance(&pObj);
	if (S_OK != hr)
		return hr;
	
	pObj->AddRef();
	pObj->SetOwnerDoc(m_pIXMLDOMDocument);

	try
	{
		pObj->m_container = element->getElementsByTagName(tagName);
	}
	catch(DOMException& ex)
	{
		pObj->Release();
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		pObj->Release();
		return E_FAIL;
	}
	
	hr = pObj->QueryInterface(IID_IXMLDOMNodeList, reinterpret_cast<LPVOID*> (pVal));
	if (S_OK != hr)
		*pVal = NULL;

	pObj->Release();
	return hr;
}

STDMETHODIMP CXMLDOMElement::normalize(void)
{
	ATLTRACE(_T("CXMLDOMElement::normalize\n"));

	try
	{
		element->normalize();
	}
	catch(DOMException& ex)
	{
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}	

	return S_OK;
}

--- NEW FILE: XMLDOMNamedNodeMap.h ---
/*
 * Copyright 1999-2001,2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * $Id: XMLDOMNamedNodeMap.h,v 1.1 2008/02/19 20:16:27 zolmol Exp $
 */

#ifndef ___xmldomnamednodemap_h___
#define ___xmldomnamednodemap_h___

#include <xercesc/dom/DOMNamedNodeMap.hpp>
#include "NodeContainerImpl.h"

XERCES_CPP_NAMESPACE_USE

class ATL_NO_VTABLE CXMLDOMNamedNodeMap :
	public CComObjectRootEx<CComSingleThreadModel>,
	public IDispatchImpl<IXMLDOMNamedNodeMap, &IID_IXMLDOMNamedNodeMap, &LIBID_Xerces, XERCES_VERSION_MAJOR, INVK_CAT2_RAW_NUMERIC(XERCES_VERSION_MINOR,XERCES_VERSION_REVISION)>,
	public NodeContainerImpl<DOMNamedNodeMap>,
	public ISupportErrorInfo
{
public:
	CXMLDOMNamedNodeMap()
	{}

	void FinalRelease()
	{
		ReleaseOwnerDoc();
	}

DECLARE_NOT_AGGREGATABLE(CXMLDOMNamedNodeMap)
DECLARE_PROTECT_FINAL_CONSTRUCT()

BEGIN_COM_MAP(CXMLDOMNamedNodeMap)
	COM_INTERFACE_ENTRY(IXMLDOMNamedNodeMap)
	COM_INTERFACE_ENTRY(IDispatch)
	COM_INTERFACE_ENTRY(ISupportErrorInfo)
END_COM_MAP()


	//   ISupportErrorInfo
	HRESULT STDMETHODCALLTYPE InterfaceSupportsErrorInfo(REFIID iid);

	// IXMLDOMNamedNodeMap methods
	STDMETHOD(getNamedItem)(BSTR name, IXMLDOMNode  * *namedItem);
	STDMETHOD(setNamedItem)(IXMLDOMNode  *newItem, IXMLDOMNode  * *nameItem);
	STDMETHOD(removeNamedItem)(BSTR name, IXMLDOMNode  * *namedItem);
	STDMETHOD(get_item)(long index, IXMLDOMNode  * *pVal);
	STDMETHOD(get_length)(long  *pVal);
	STDMETHOD(getQualifiedItem)(BSTR baseName, BSTR namespaceURI, IXMLDOMNode  * *node);
	STDMETHOD(removeQualifiedItem)(BSTR baseName, BSTR namespaceURI, IXMLDOMNode  * *node);
	STDMETHOD(nextNode)(IXMLDOMNode  * *nextItem);
	STDMETHOD(reset)();
	STDMETHOD(get__newEnum)(IUnknown  * *pVal);
};

typedef CComObject<CXMLDOMNamedNodeMap> CXMLDOMNamedNodeMapObj;

#endif // ___xmldomnamednodemap_h___
--- NEW FILE: xmldocument.rgs ---
HKCR
{
	Xerces.DOMDocument.2.6.0 = s 'Apache Xerces Parser for COM'
	{
		CLSID = s '{C4775B61-ECD6-11d4-94B4-00A0CC57CBCB}'
	}
	Xerces.DOMDocument = s 'Apache Xerces Parser For COM'
	{
		CLSID = s '{C4775B61-ECD6-11d4-94B4-00A0CC57CBCB}'
		CurVer = s 'Xerces.DOMDocument.2.6.0'
	}
	NoRemove CLSID
	{
		ForceRemove {C4775B61-ECD6-11d4-94B4-00A0CC57CBCB} = s 'Apache Xerces Parser for COM'
		{
			ProgID = s 'Xerces.DOMDocument.2.6.0'
			VersionIndependentProgID = s 'Xerces.DOMDocument'
			ForceRemove 'Programmable'
			InprocServer32 = s '%XMLMODULE%'
			{
				val ThreadingModel = s 'Apartment'
			}
			'TypeLib' = s '{C4775B62-ECD6-11d4-94B4-00A0CC57CBCB}'
		}
	}
}
--- NEW FILE: XMLDOMImplementation.cpp ---
/*
 * Copyright 1999-2000,2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * $Id: XMLDOMImplementation.cpp,v 1.1 2008/02/19 20:16:27 zolmol Exp $
 */

#include "stdafx.h"
#include "xml4com.h"
#include "XMLDOMImplementation.h"

STDMETHODIMP CXMLDOMImplementation::hasFeature(BSTR feature, BSTR ver, VARIANT_BOOL  *pVal)
{
	ATLTRACE(_T("CXMLDOMImplementation::hasFeature\n"));

	if (NULL == pVal)
		return E_POINTER;

	*pVal = VARIANT_FALSE;

	try
	{
		*pVal = (implementation->hasFeature(feature, ver) ? VARIANT_TRUE : VARIANT_FALSE);
	}
	catch(...)
	{
		return E_FAIL;
	}
	

	return S_OK;
}
--- NEW FILE: XMLDOMAttribute.h ---
/*
 * Copyright 1999-2001,2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * $Id: XMLDOMAttribute.h,v 1.1 2008/02/19 20:16:27 zolmol Exp $
 */

#ifndef ___xmldomattribute_h___
#define ___xmldomattribute_h___

#include <xercesc/dom/DOMAttr.hpp>
#include "IXMLDOMNodeImpl.h"
XERCES_CPP_NAMESPACE_USE

class ATL_NO_VTABLE CXMLDOMAttribute :
	public CComObjectRootEx<CComSingleThreadModel>,
	public IXMLDOMNodeImpl<IXMLDOMAttribute, &IID_IXMLDOMAttribute>
{
public:
	CXMLDOMAttribute()
	{}

	void	FinalRelease()
	{
		ReleaseOwnerDoc();
	}

	virtual DOMNode* get_DOMNode()			 { return attr;}
	virtual DOMNodeType get_DOMNodeType() const  { return NODE_ATTRIBUTE; }

DECLARE_NOT_AGGREGATABLE(CXMLDOMAttribute)
DECLARE_PROTECT_FINAL_CONSTRUCT()

BEGIN_COM_MAP(CXMLDOMAttribute)
	COM_INTERFACE_ENTRY(IXMLDOMAttribute)
	COM_INTERFACE_ENTRY(IXMLDOMNode)
	COM_INTERFACE_ENTRY(IIBMXMLDOMNodeIdentity)
	COM_INTERFACE_ENTRY(ISupportErrorInfo)
	COM_INTERFACE_ENTRY(IDispatch)
END_COM_MAP()
	
	//  IXMLDOMNode method
	STDMETHOD(get_specified)(VARIANT_BOOL  *pVal);


	// IXMLDOMAttribute methods
	STDMETHOD(get_name)(BSTR  *pVal);
	STDMETHOD(get_value)(VARIANT  *pVal);
	STDMETHOD(put_value)(VARIANT newVal);

	//
	//   override IXMLDOMNodeImpl to always return a string
	//      even when empty
	//
	STDMETHOD(get_nodeValue)(VARIANT* pVal);

	DOMAttr* attr;
};

typedef CComObject<CXMLDOMAttribute> CXMLDOMAttributeObj;

#endif // ___xmldomattribute_h___
--- NEW FILE: README.txt ---

COM Wrapper
-----------

xerces-com.dll needs to be registered before its first use.  This can be done using either through the References Dialog in Microsoft(r) Visual Basic (tm) or Microsoft(r) Excel or using REGSVR32.EXE,
provided with many Windows development environments.

To register using Microsoft(r) Visual Basic 6.0, select Project/References from the menu to show the References dialog, press the Browse dialog and then select xerces-com.dll.  In Microsoft(r) Excel,
select Tools/Macro/Visual Basic Editor to show the VBA editor and then select Tools/References for the references dialog.

To register using REGSVR32 from the command line, type REGSVR32 followed by the path name of xerces-com.dll.

After registration, the xerces-com will appear on the References dialog as "Xerces XML Parser".

xerces-com was designed to support the same interfaces as Microsoft XML 2.0.  For many Visual Basic applications, the only changes necessary are to add the reference to Xerces XML Parser, remove the
reference to Microsoft XML 2.0, and to change the line that creates the parser object.

Each of the following lines would create an instance of a Microsoft XML 2.0 parser:

Dim xmlparser as new MSXML.DOMDocument
Dim xmlparser as new DOMDocument
Set object = CreateObject("MSXML.DOMDocument")
Set object = CreateObject("MSXML2.DOMDocument")

The following lines would create an instance of a Xerces parser:

Dim xmlparser as new Xerces.DOMDocument
Dim xmlparser as new DOMDocument
Set object = CreateObject("Xerces.DOMDocument")
set object = CreateObject("Xerces.DOMDocument.2.3.0")

If you leave both MSXML and Xerces in the same project, you may need to disambiguate interfaces by prepending MSXML or Xerces.

For many applications, MSXML and Xerces will be interchangable.  However, there may be documents that MSXML rejects and Xerces accepts and vice versa and the DOM presented to the application may be
slightly different.  Specific examples include:

MSXML represents entity references as entity reference elements,
Xerces expands the entity references.

MSXML represents the XML declaration as a processing instruction node,
Xerces does not represent the XML declaration.

MSXML will suppress whitespace nodes regardless of validation setting when preserveWhitespace = false,
Xerces will only suppress whitespace when validation = true.

--- NEW FILE: XMLDOMDocument.cpp ---
/*
 * Copyright 1999-2001,2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * $Id: XMLDOMDocument.cpp,v 1.1 2008/02/19 20:16:27 zolmol Exp $
 */
[...1559 lines suppressed...]

	if (VT_DISPATCH != V_VT(&newVal) &&
		VT_NULL		!= V_VT(&newVal))
		return E_INVALIDARG;

	LPDISPATCH pDisp = NULL;
	if (VT_DISPATCH == V_VT(&newVal))
		pDisp = V_DISPATCH(&newVal);

	if (m_pOnTransformNode != NULL) {
		m_pOnTransformNode->Release();
		m_pOnTransformNode = NULL;
	}
	m_pOnTransformNode = pDisp;
	if (m_pOnTransformNode != NULL)
		m_pOnTransformNode->AddRef();

	return S_OK;
}


--- NEW FILE: XMLDOMDocumentType.cpp ---
/*
 * Copyright 1999-2001,2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * $Id: XMLDOMDocumentType.cpp,v 1.1 2008/02/19 20:16:27 zolmol Exp $
 */

#include "stdafx.h"
#include "xml4com.h"
#include "XMLDOMDocumentType.h"
#include "XMLDOMNamedNodeMap.h"

// IXMLDOMDocumentType methods
STDMETHODIMP CXMLDOMDocumentType::get_name(BSTR  *pVal)
{
	ATLTRACE(_T("CXMLDOMDocumentType::get_name\n"));

	if (NULL == pVal)
		return E_POINTER;

	*pVal = NULL;

	try
	{
		*pVal = SysAllocString(documentType->getName());
	}
	catch(DOMException& ex)
	{
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}
	

	return S_OK;
}

STDMETHODIMP CXMLDOMDocumentType::get_entities(IXMLDOMNamedNodeMap  **pVal)
{
	ATLTRACE(_T("CXMLDOMDocumentType::get_entities\n"));

	if (NULL == pVal)
		return E_POINTER;

	*pVal = NULL;

	CXMLDOMNamedNodeMapObj *pObj = NULL;
	HRESULT hr = CXMLDOMNamedNodeMapObj::CreateInstance(&pObj);
	if (S_OK != hr)
		return hr;
	
	pObj->AddRef();
	pObj->SetOwnerDoc(m_pIXMLDOMDocument);

	try
	{
		pObj->m_container = documentType->getEntities();
	}
	catch(DOMException& ex)
	{
		pObj->Release();
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		pObj->Release();
		return E_FAIL;
	}
	
	hr = pObj->QueryInterface(IID_IXMLDOMNamedNodeMap, reinterpret_cast<LPVOID*> (pVal));
	if (S_OK != hr)
		*pVal = NULL;

	pObj->Release();
	return hr;
}

STDMETHODIMP CXMLDOMDocumentType::get_notations(IXMLDOMNamedNodeMap  **pVal)
{
	ATLTRACE(_T("CXMLDOMDocumentType::get_notations\n"));

	if (NULL == pVal)
		return E_POINTER;

	*pVal = NULL;

	CXMLDOMNamedNodeMapObj *pObj = NULL;
	HRESULT hr = CXMLDOMNamedNodeMapObj::CreateInstance(&pObj);
	if (S_OK != hr)
		return hr;
	
	pObj->AddRef();
	pObj->SetOwnerDoc(m_pIXMLDOMDocument);

	try
	{
		pObj->m_container = documentType->getNotations();
	}
	catch(DOMException& ex)
	{
		pObj->Release();
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		pObj->Release();
		return E_FAIL;
	}
	
	hr = pObj->QueryInterface(IID_IXMLDOMNamedNodeMap, reinterpret_cast<LPVOID*> (pVal));
	if (S_OK != hr)
		*pVal = NULL;

	pObj->Release();
	return hr;

}
--- NEW FILE: XMLDOMText.h ---
/*
 * Copyright 1999-2001,2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * $Id: XMLDOMText.h,v 1.1 2008/02/19 20:16:27 zolmol Exp $
 */

#ifndef ___xmldomtext_h___
#define ___xmldomtext_h___

#include <xercesc/dom/DOMText.hpp>
#include "IXMLDOMTextImpl.h"

XERCES_CPP_NAMESPACE_USE

class ATL_NO_VTABLE CXMLDOMText :
	public CComObjectRootEx<CComSingleThreadModel>,
	public IXMLDOMTextImpl<IXMLDOMText, &IID_IXMLDOMText>
{
public:
	CXMLDOMText()
	{}
	
	void	FinalRelease()
	{
		ReleaseOwnerDoc();
	}

	virtual DOMText* get_DOMText()		 	 { return text;}
	virtual DOMNodeType get_DOMNodeType() const  { return NODE_TEXT; }

DECLARE_NOT_AGGREGATABLE(CXMLDOMText)
DECLARE_PROTECT_FINAL_CONSTRUCT()

BEGIN_COM_MAP(CXMLDOMText)
	COM_INTERFACE_ENTRY(IXMLDOMText)
	COM_INTERFACE_ENTRY(IXMLDOMCharacterData)
	COM_INTERFACE_ENTRY(IXMLDOMNode)
	COM_INTERFACE_ENTRY(IIBMXMLDOMNodeIdentity)
	COM_INTERFACE_ENTRY(IDispatch)
	COM_INTERFACE_ENTRY(ISupportErrorInfo)
END_COM_MAP()
	
	DOMText* text;
};

typedef CComObject<CXMLDOMText> CXMLDOMTextObj;

#endif // ___xmldomtext_h___
--- NEW FILE: XMLDOMNotation.h ---
/*
 * Copyright 1999-2001,2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * $Id: XMLDOMNotation.h,v 1.1 2008/02/19 20:16:27 zolmol Exp $
 */

#ifndef ___xmldomnotation_h___
#define ___xmldomnotation_h___

#include <xercesc/dom/DOMNotation.hpp>
#include "IXMLDOMNodeImpl.h"

XERCES_CPP_NAMESPACE_USE

class ATL_NO_VTABLE CXMLDOMNotation :
	public CComObjectRootEx<CComSingleThreadModel>,
	public IXMLDOMNodeImpl<IXMLDOMNotation, &IID_IXMLDOMNotation>
{
public:
	CXMLDOMNotation()
	{}
	
	void	FinalRelease()
	{
		ReleaseOwnerDoc();
	}

	virtual DOMNode* get_DOMNode()			 { return notation;}
	virtual DOMNodeType get_DOMNodeType() const  { return NODE_NOTATION; }

DECLARE_NOT_AGGREGATABLE(CXMLDOMNotation)
DECLARE_PROTECT_FINAL_CONSTRUCT()

BEGIN_COM_MAP(CXMLDOMNotation)
	COM_INTERFACE_ENTRY(IXMLDOMNotation)
	COM_INTERFACE_ENTRY(IXMLDOMNode)
	COM_INTERFACE_ENTRY(IIBMXMLDOMNodeIdentity)
	COM_INTERFACE_ENTRY(IDispatch)
	COM_INTERFACE_ENTRY(ISupportErrorInfo)
END_COM_MAP()

	// IXMLDOMNotation methods
	STDMETHOD(get_publicId)(VARIANT  *pVal);
	STDMETHOD(get_systemId)(VARIANT  *pVal);

	DOMNotation* notation;
};

typedef CComObject<CXMLDOMNotation> CXMLDOMNotationObj;

#endif // ___xmldomnotation_h___
--- NEW FILE: XMLDOMElement.h ---
/*
 * Copyright 1999-2001,2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * $Id: XMLDOMElement.h,v 1.1 2008/02/19 20:16:27 zolmol Exp $
 */

#ifndef ___xmldomelement_h___
#define ___xmldomelement_h___

#include <xercesc/dom/DOMElement.hpp>
#include "IXMLDOMNodeImpl.h"

XERCES_CPP_NAMESPACE_USE

class ATL_NO_VTABLE CXMLDOMElement :
	public CComObjectRootEx<CComSingleThreadModel>,
	public IXMLDOMNodeImpl<IXMLDOMElement, &IID_IXMLDOMElement>
{
public:
	CXMLDOMElement()
	{}

	void	FinalRelease()
	{
		ReleaseOwnerDoc();
	}

	virtual DOMNode* get_DOMNode()	  { return element;}
	virtual DOMNodeType get_DOMNodeType() const  { return NODE_ELEMENT; }

DECLARE_NOT_AGGREGATABLE(CXMLDOMElement)

DECLARE_PROTECT_FINAL_CONSTRUCT()

BEGIN_COM_MAP(CXMLDOMElement)
	COM_INTERFACE_ENTRY(IXMLDOMElement)
	COM_INTERFACE_ENTRY(IXMLDOMNode)
	COM_INTERFACE_ENTRY(IIBMXMLDOMNodeIdentity)
	COM_INTERFACE_ENTRY(IDispatch)
	COM_INTERFACE_ENTRY(ISupportErrorInfo)
END_COM_MAP()

	// IXMLDOMElement methods
	STDMETHOD(get_tagName)(BSTR  *pVal);
	STDMETHOD(getAttribute)(BSTR name, VARIANT  *value);
	STDMETHOD(setAttribute)(BSTR name, VARIANT value);
	STDMETHOD(removeAttribute)(BSTR name);
	STDMETHOD(getAttributeNode)(BSTR name, IXMLDOMAttribute  * *attr);
	STDMETHOD(setAttributeNode)(IXMLDOMAttribute  *attr, IXMLDOMAttribute  * *attributeNode);
	STDMETHOD(removeAttributeNode)(IXMLDOMAttribute  *attr, IXMLDOMAttribute  * *attributeNode);
	STDMETHOD(getElementsByTagName)(BSTR tagName, IXMLDOMNodeList  * *resultList);
	STDMETHOD(normalize)(void);

	DOMElement* element;
};

typedef CComObject<CXMLDOMElement> CXMLDOMElementObj;

#endif // ___xmldomelement_h___
--- NEW FILE: XMLDOMProcessingInstruction.h ---
/*
 * Copyright 1999-2001,2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * $Id: XMLDOMProcessingInstruction.h,v 1.1 2008/02/19 20:16:27 zolmol Exp $
 */

#ifndef ___xmldomprocessinginstruction_h___
#define ___xmldomprocessinginstruction_h___

#include <xercesc/dom/DOMProcessingInstruction.hpp>
#include "IXMLDOMNodeImpl.h"

XERCES_CPP_NAMESPACE_USE

class ATL_NO_VTABLE CXMLDOMProcessingInstruction :
	public CComObjectRootEx<CComSingleThreadModel>,
	public IXMLDOMNodeImpl<IXMLDOMProcessingInstruction, &IID_IXMLDOMProcessingInstruction>
{
public:
	CXMLDOMProcessingInstruction()
	{}
	
	void	FinalRelease()
	{
		ReleaseOwnerDoc();
	}

	virtual DOMNode* get_DOMNode()			 { return processingInstruction;}
	virtual DOMNodeType get_DOMNodeType() const  { return NODE_PROCESSING_INSTRUCTION; }

DECLARE_NOT_AGGREGATABLE(CXMLDOMProcessingInstruction)
DECLARE_PROTECT_FINAL_CONSTRUCT()

BEGIN_COM_MAP(CXMLDOMProcessingInstruction)
	COM_INTERFACE_ENTRY(IXMLDOMProcessingInstruction)
	COM_INTERFACE_ENTRY(IXMLDOMNode)
	COM_INTERFACE_ENTRY(IIBMXMLDOMNodeIdentity)
	COM_INTERFACE_ENTRY(IDispatch)
	COM_INTERFACE_ENTRY(ISupportErrorInfo)
END_COM_MAP()

	// IXMLDOMProcessingInstruction methods
	STDMETHOD(get_target)(BSTR  *pVal);
	STDMETHOD(get_data)(BSTR  *pVal);
	STDMETHOD(put_data)(BSTR newVal);

	DOMProcessingInstruction* processingInstruction;
};

typedef CComObject<CXMLDOMProcessingInstruction> CXMLDOMProcessingInstructionObj;

#endif // ___xmldomprocessinginstruction_h___
--- NEW FILE: xml4com.idl ---
/*
 * Copyright 1999-2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * $Id: xml4com.idl,v 1.1 2008/02/19 20:16:27 zolmol Exp $
 */

// This file will be processed by the MIDL tool to
// produce the type library (xml4com.tlb) and marshalling code.

import "oaidl.idl";

[
	uuid(C4775B62-ECD6-11d4-94B4-00A0CC57CBCB),
	//
	//  Format for version is major.minor
	//  no support for additional parts (like 1.5.2)
	//  Use 1.60 for subsequent release
	version(2.70),
	helpstring("Xerces XML Parser 2.7.0")
]
library Xerces
{
	importlib("stdole32.tlb");
	importlib("stdole2.tlb");

	//
	//   it appears to be necessary to forward declare
	//      this interface to lure it into the type library
	interface IXMLDOMNotation;

	//
	//   might as well insure the rest we use are here
	//
	interface IXMLDOMAttribute;
	interface IXMLDOMCDATASection;
	interface IXMLDOMComment;
	interface IXMLDOMDocument;
	interface IXMLDOMDocumentType;
	interface IXMLDOMElement;
	interface IXMLDOMEntity;
	interface IXMLDOMEntityReference;
	interface IXMLDOMImplementation;
	interface IXMLDOMNamedNodeMap;
	interface IXMLDOMNodeList;
	interface IXMLDOMParseError;
	interface IXMLDOMProcessingInstruction;
	interface IXMLDOMText;
	interface IXMLHttpRequest;


	//
	//
	//    if you get an "Cannot open input file" error here
	//       then you most probably do not have a recent
	//        Microsoft Platform SDK in your include path
	//
	//    See http://xml.apache.org/xerces-c/build.html#BuildCOM
	import "xmldom.idl";
	
	[
		object,
		uuid(35ADBB42-47B2-4b22-9D2E-1DA260EE5007),
		hidden,
		oleautomation,
		helpstring("IIBMXMLDOMNodeIdentity Interface"),
		pointer_default(unique)
	]
	interface IIBMXMLDOMNodeIdentity : IUnknown
	{
		[propget, helpstring("property NodeId")] HRESULT NodeId([out, retval] long *pVal);
	};

	[
		uuid(C4775B61-ECD6-11d4-94B4-00A0CC57CBCB),
		helpstring("DOMDocument Class")
	]
	coclass DOMDocument
	{
		[default] interface IXMLDOMDocument;
		[default, source] dispinterface XMLDOMDocumentEvents;
	};

	[
	  uuid(3A725053-15FB-4065-9171-BC02BCF3876C),
	  helpstring("XMLHTTPRequest class.")
	]
	coclass XMLHTTPRequest
	{
		[default] interface IXMLHttpRequest;
	};
};

--- NEW FILE: BindStatusCallback.h ---
/*
 * Copyright 1999-2000,2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * $Id: BindStatusCallback.h,v 1.1 2008/02/19 20:16:27 zolmol Exp $
 */

// BindStatusCallback.h : Declaration of the BindStatCallback

#ifndef ___bindstatuscallback_h___
#define ___bindstatuscallback_h___

class CXMLDOMDocument;

/////////////////////////////////////////////////////////////////////////////
// BindStatCallback
class ATL_NO_VTABLE CBindStatCallback : 
	public CComObjectRootEx<CComSingleThreadModel>,
	public IBindStatusCallback
{
public:
	CBindStatCallback()
		:m_pDoc(NULL)
	{
	}

DECLARE_NOT_AGGREGATABLE(CBindStatCallback)

DECLARE_PROTECT_FINAL_CONSTRUCT()

BEGIN_COM_MAP(CBindStatCallback)
	COM_INTERFACE_ENTRY(IBindStatusCallback)
END_COM_MAP()

// IBindStatusCallback
public:
	STDMETHOD(OnStartBinding)(DWORD dwReserved, IBinding *pBinding);
	STDMETHOD(GetPriority)(LONG *pnPriority);
	STDMETHOD(OnLowResource)(DWORD reserved);
	STDMETHOD(OnProgress)(ULONG ulProgress, ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText);
	STDMETHOD(OnStopBinding)(HRESULT hresult, LPCWSTR szError);
	STDMETHOD(GetBindInfo)(DWORD *pgrfBINDF, BINDINFO *pbindInfo);
	STDMETHOD(OnDataAvailable)(DWORD grfBSCF, DWORD dwSize, FORMATETC *pformatetc, STGMEDIUM *pstgmed);
	STDMETHOD(OnObjectAvailable)(REFIID riid, IUnknown *punk);

	CXMLDOMDocument *m_pDoc;
};

typedef CComObject<CBindStatCallback> CBindStatCallbackObj;

#endif //___bindstatuscallback_h___

--- NEW FILE: xml4com.def ---
; xml4com.def : Declares the module parameters.

LIBRARY      "xerces-com.dll"

EXPORTS
	DllCanUnloadNow     @1 PRIVATE
	DllGetClassObject   @2 PRIVATE
	DllRegisterServer   @3 PRIVATE
	DllUnregisterServer	@4 PRIVATE

--- NEW FILE: XMLDOMComment.h ---
/*
 * Copyright 1999-2001,2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * $Id: XMLDOMComment.h,v 1.1 2008/02/19 20:16:27 zolmol Exp $
 */

#ifndef ___xmldomcomment_h___
#define ___xmldomcomment_h___

#include <xercesc/dom/DOMComment.hpp>
#include "IXMLDOMCharacterDataImpl.h"

XERCES_CPP_NAMESPACE_USE

class ATL_NO_VTABLE CXMLDOMComment :
	public CComObjectRootEx<CComSingleThreadModel>,
	public IXMLDOMCharacterDataImpl<IXMLDOMComment, &IID_IXMLDOMComment>
{
public:
	CXMLDOMComment()
	{}

	void	FinalRelease()
	{
		ReleaseOwnerDoc();
	}

	virtual DOMCharacterData* get_DOMCharacterData()  { return comment;}
	virtual DOMNodeType get_DOMNodeType() const			{ return NODE_COMMENT; }
	
DECLARE_NOT_AGGREGATABLE(CXMLDOMComment)
DECLARE_PROTECT_FINAL_CONSTRUCT()

BEGIN_COM_MAP(CXMLDOMComment)
	COM_INTERFACE_ENTRY(IXMLDOMComment)
	COM_INTERFACE_ENTRY(IXMLDOMCharacterData)
	COM_INTERFACE_ENTRY(IXMLDOMNode)
	COM_INTERFACE_ENTRY(IIBMXMLDOMNodeIdentity)
	COM_INTERFACE_ENTRY(ISupportErrorInfo)
	COM_INTERFACE_ENTRY(IDispatch)
END_COM_MAP()

	DOMComment* comment;
};

typedef CComObject<CXMLDOMComment> CXMLDOMCommentObj;

#endif // ___xmldomcomment_h___
--- NEW FILE: XMLHTTPRequest.cpp ---
/*
 * Copyright 1999-2000,2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * $Id: XMLHTTPRequest.cpp,v 1.1 2008/02/19 20:16:27 zolmol Exp $
 */
[...1056 lines suppressed...]
			VARIANT var;
			::VariantInit(&var);
			V_VT(&var)   = VT_UI1;
			V_UI1(&var)	 = pByte[i];
	
			hr = ::SafeArrayPutElement(psa, ix, &var);
			if (S_OK != hr) {
				::SafeArrayDestroy(psa);
				break;		
			}
		}
	}

	if (S_OK == hr) {
		V_VT(&varOut)	 = VT_ARRAY | VT_VARIANT;
		V_ARRAY(&varOut) = psa;
	}
	
	return hr;
}
--- NEW FILE: XMLDOMNodeList.cpp ---
/*
 * Copyright 1999-2001,2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * $Id: XMLDOMNodeList.cpp,v 1.1 2008/02/19 20:16:27 zolmol Exp $
 */

#include "stdafx.h"
#include "xml4com.h"
#include "XMLDOMNodeList.h"
#include "XMLDOMUtil.h"
#include "IXMLDOMNodeImpl.h"

typedef CComEnumOnSTL<IEnumVARIANT, &IID_IEnumVARIANT, VARIANT, _Copy<VARIANT>,NodeContainerImpl<DOMNodeList> >
		CComEnumUnknownOnNodeContainer;

STDMETHODIMP CXMLDOMNodeList::get_item(long index, IXMLDOMNode  **pVal)
{
	ATLTRACE(_T("CXMLDOMNodeList::get_item\n"));

	if (NULL == pVal)
		return E_POINTER;

	*pVal = NULL;
	HRESULT hr = S_OK;

	try
	{
		if (m_container == 0 || index < 0)
			return E_INVALIDARG;

		long length = m_container->getLength();
		//
		//    if index is beyond end
		//       return a null object not an exception
		//
		if (index < length)
			hr = wrapNode(m_pIXMLDOMDocument,m_container->item(index),IID_IXMLDOMNode, reinterpret_cast<LPVOID *> (pVal));
	}
	catch(DOMException& ex)
	{
		return MakeHRESULT(ex);
	}

	catch(...)
	{
		return E_FAIL;
	}
	
	return hr;
}

STDMETHODIMP CXMLDOMNodeList::get_length(long  *pVal)
{
	ATLTRACE(_T("CXMLDOMNodeList::get_length\n"));

	if (NULL == pVal)
		return E_POINTER;

	*pVal = 0;

	if (m_container == 0)
		return S_OK;

	try
	{
		*pVal = m_container->getLength();
	}
	catch(DOMException& ex)
	{
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}
	
	return S_OK;
}

STDMETHODIMP CXMLDOMNodeList::nextNode(IXMLDOMNode  **pVal)
{
	ATLTRACE(_T("CXMLDOMNodeList::nextNode\n"));

	if (NULL == pVal)
		return E_POINTER;

	*pVal = NULL;

	if (m_container == 0)
		return S_OK;
	
	int length = m_container->getLength();
	if (0 == length)
		return S_OK;

	if (m_NextNodeIndex >= length)
		return S_OK;

	
	HRESULT hr = S_OK;

	try
	{
		hr = wrapNode(m_pIXMLDOMDocument,m_container->item(m_NextNodeIndex),IID_IXMLDOMNode, reinterpret_cast<LPVOID *> (pVal));
	}
	catch(DOMException& ex)
	{
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}

	++m_NextNodeIndex;
	
	return hr;
}

STDMETHODIMP CXMLDOMNodeList::reset()
{
	ATLTRACE(_T("CXMLDOMNodeList::reset\n"));
	
	m_NextNodeIndex = 0;
	
	return S_OK;
}

STDMETHODIMP CXMLDOMNodeList::get__newEnum(IUnknown  **pVal)
{
	ATLTRACE(_T("CXMLDOMNodeList::get__newEnum\n"));

	if (NULL == pVal)
		return E_POINTER;

	*pVal = NULL;

	CComObject<CComEnumUnknownOnNodeContainer> *pe = NULL;
	HRESULT hr = CComObject<CComEnumUnknownOnNodeContainer>::CreateInstance(&pe);
	if (S_OK != hr)
		return hr;

	pe->AddRef();

	hr = pe->Init(GetUnknown(),*this);
	if (S_OK == hr)
		hr = pe->QueryInterface(pVal);

	pe->Release();

	return hr;
}


HRESULT CXMLDOMNodeList::InterfaceSupportsErrorInfo(REFIID riid)
{
	if(riid == IID_IXMLDOMNodeList) return S_OK;
	return S_FALSE;
}
--- NEW FILE: XMLDOMXMLDecl.h ---
/*
 * Copyright 1999-2000,2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


#ifndef ___xmldomxmldecl_h___
#define ___xmldomxmldecl_h___

#include <xercesc/dom/DOMProcessingInstruction.hpp>
#include "IXMLDOMNodeImpl.h"

XERCES_CPP_NAMESPACE_USE

class ATL_NO_VTABLE CXMLDOMXMLDecl : 
	public CComObjectRootEx<CComSingleThreadModel>,
	public IXMLDOMNodeImpl<IXMLDOMProcessingInstruction, &IID_IXMLDOMProcessingInstruction>
{
public:
	CXMLDOMXMLDecl()
	{}
	
	void	FinalRelease()
	{
		ReleaseOwnerDoc();
	}

	virtual DOMNode* get_DOMNode()			 { return xmlDecl;} 
	virtual DOMNodeType get_DOMNodeType() const  { return NODE_PROCESSING_INSTRUCTION; }

DECLARE_NOT_AGGREGATABLE(CXMLDOMXMLDecl)
DECLARE_PROTECT_FINAL_CONSTRUCT()

BEGIN_COM_MAP(CXMLDOMXMLDecl)
	COM_INTERFACE_ENTRY(IXMLDOMProcessingInstruction)
	COM_INTERFACE_ENTRY(IXMLDOMNode)
	COM_INTERFACE_ENTRY(IIBMXMLDOMNodeIdentity)
	COM_INTERFACE_ENTRY(IDispatch)
END_COM_MAP()

	// IXMLDOMProcessingInstruction methods
	STDMETHOD(get_target)(BSTR  *pVal);
	STDMETHOD(get_data)(BSTR  *pVal);
	STDMETHOD(put_data)(BSTR newVal);

	DOMProcessingInstruction* xmlDecl;
};

typedef CComObject<CXMLDOMXMLDecl> CXMLDOMXMLDeclObj;

#endif // ___xmldomprocessinginstruction_h___
--- NEW FILE: XMLDOMDocumentType.h ---
/*
 * Copyright 1999-2001,2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * $Id: XMLDOMDocumentType.h,v 1.1 2008/02/19 20:16:27 zolmol Exp $
 */

#ifndef ___xmldomdocumenttype_h___
#define ___xmldomdocumenttype_h___

#include <xercesc/dom/DOMDocumentType.hpp>
#include "IXMLDOMNodeImpl.h"

XERCES_CPP_NAMESPACE_USE

class ATL_NO_VTABLE CXMLDOMDocumentType :
	public CComObjectRootEx<CComSingleThreadModel>,
	public IXMLDOMNodeImpl<IXMLDOMDocumentType, &IID_IXMLDOMDocumentType>
{
public:
	CXMLDOMDocumentType()
	{}

	void	FinalRelease()
	{
		ReleaseOwnerDoc();
	}

	virtual DOMNode* get_DOMNode()	  { return documentType;}
	virtual DOMNodeType get_DOMNodeType() const  { return NODE_DOCUMENT_TYPE; }

DECLARE_NOT_AGGREGATABLE(CXMLDOMDocumentType)
DECLARE_PROTECT_FINAL_CONSTRUCT()

BEGIN_COM_MAP(CXMLDOMDocumentType)
	COM_INTERFACE_ENTRY(IXMLDOMDocumentType)
	COM_INTERFACE_ENTRY(IXMLDOMNode)
	COM_INTERFACE_ENTRY(IIBMXMLDOMNodeIdentity)
	COM_INTERFACE_ENTRY(IDispatch)
	COM_INTERFACE_ENTRY(ISupportErrorInfo)
END_COM_MAP()

	// IXMLDOMDocumentType methods
	STDMETHOD(get_name)(BSTR  *pVal);
	STDMETHOD(get_entities)(IXMLDOMNamedNodeMap  * *pVal);
	STDMETHOD(get_notations)(IXMLDOMNamedNodeMap  * *pVal);

	DOMDocumentType* documentType;
};

typedef CComObject<CXMLDOMDocumentType> CXMLDOMDocumentTypeObj;

#endif // ___xmldomdocumenttype_h___
--- NEW FILE: XMLDOMParseError.cpp ---
/*
 * Copyright 1999-2000,2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * $Id: XMLDOMParseError.cpp,v 1.1 2008/02/19 20:16:27 zolmol Exp $
 */

#include "stdafx.h"
#include "xml4com.h"
#include "XMLDOMParseError.h"

HRESULT CXMLDOMParseError::FinalConstruct()
{
	m_CS.Init();
	return S_OK;
}

void CXMLDOMParseError::FinalRelease()	
{
	m_CS.Term(); 
}

void CXMLDOMParseError::SetData( long code,
								 const _bstr_t &url,
								 const _bstr_t &reason,
								 const _bstr_t &source,
								 long  lineNumber,
								 long  linePos,
								 long  filePos)
{
	m_CS.Lock(); 
	m_Code			= code;
	m_url			= url;
	m_Reason		= reason;
	m_Source		= source;
	m_LineNumber	= lineNumber;
	m_LinePos		= linePos;
	m_FilePos		= filePos;
	m_CS.Unlock(); 
}

void CXMLDOMParseError::Reset()
{
	m_CS.Lock(); 
	m_Code			= 0;
	m_url			= _T("");
	m_Reason		= _T("");
	m_Source		= _T("");
	m_LineNumber	= 0;
	m_LinePos		= 0;
	m_FilePos		= 0;
	m_CS.Unlock(); 
}

// IXMLDOMParseError methods
STDMETHODIMP CXMLDOMParseError::get_errorCode(long  *pVal)
{
	ATLTRACE(_T("CXMLDOMParseError::get_errorCode\n"));

	if (NULL == pVal)
		return E_POINTER;

	m_CS.Lock(); 
	*pVal = m_Code;
	m_CS.Unlock(); 

	return S_OK;
}

STDMETHODIMP CXMLDOMParseError::get_url(BSTR  *pVal)
{
	ATLTRACE(_T("CXMLDOMParseError::get_url\n"));

	if (NULL == pVal)
		return E_POINTER;

	m_CS.Lock(); 
	*pVal = m_url.copy();
	m_CS.Unlock(); 

	return S_OK;
}

STDMETHODIMP CXMLDOMParseError::get_reason(BSTR  *pVal)
{
	ATLTRACE(_T("CXMLDOMParseError::get_reason\n"));

	if (NULL == pVal)
		return E_POINTER;

	m_CS.Lock(); 
	*pVal = m_Reason.copy();
	m_CS.Unlock(); 

	return S_OK;
}

STDMETHODIMP CXMLDOMParseError::get_srcText(BSTR  *pVal)
{
	ATLTRACE(_T("CXMLDOMParseError::get_srcText\n"));

	if (NULL == pVal)
		return E_POINTER;

	m_CS.Lock(); 
	*pVal = m_Source.copy();
	m_CS.Unlock(); 
	
	return S_OK;
}

STDMETHODIMP CXMLDOMParseError::get_line(long  *pVal)
{
	ATLTRACE(_T("CXMLDOMParseError::get_line\n"));

	if (NULL == pVal)
		return E_POINTER;

	m_CS.Lock(); 
	*pVal = m_LineNumber;
	m_CS.Unlock(); 

	return S_OK;
}

STDMETHODIMP CXMLDOMParseError::get_linepos(long  *pVal)
{
	ATLTRACE(_T("CXMLDOMParseError::get_linepos\n"));

	if (NULL == pVal)
		return E_POINTER;

	m_CS.Lock(); 
	*pVal = m_LinePos;
	m_CS.Unlock(); 
	
	return S_OK;
}

STDMETHODIMP CXMLDOMParseError::get_filepos(long  *pVal)
{
	ATLTRACE(_T("CXMLDOMParseError::get_filepos\n"));

	if (NULL == pVal)
		return E_POINTER;

	m_CS.Lock(); 
	*pVal = m_FilePos;
	m_CS.Unlock(); 

	return S_OK;
}


--- NEW FILE: xml4com.rc ---
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"

#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "winres.h"

/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS

/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32

#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//

1 TEXTINCLUDE DISCARDABLE 
BEGIN
    "resource.h\0"
END

2 TEXTINCLUDE DISCARDABLE 
BEGIN
    "#include ""winres.h""\r\n"
    "\0"
END

3 TEXTINCLUDE DISCARDABLE 
BEGIN
    "1 TYPELIB ""..\\\\..\\\\..\\\\Build\\\\Win32\\\\xml4com\\\\xml4com.tlb""\r\n"
    "\0"
END

#endif    // APSTUDIO_INVOKED


#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//
// Version
//

VS_VERSION_INFO VERSIONINFO
 FILEVERSION 2,5,0,0
 PRODUCTVERSION 2,5,0,0
 FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
 FILEFLAGS 0x1L
#else
 FILEFLAGS 0x0L
#endif
 FILEOS 0x4L
 FILETYPE 0x2L
 FILESUBTYPE 0x0L
BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "040904b0"
        BEGIN
            VALUE "Comments", "\0"
            VALUE "CompanyName", "Apache Software Foundation\0"
            VALUE "FileDescription", "Xerces XML Parser for COM\0"
            VALUE "FileVersion", "2, 5, 0, 0\0"
            VALUE "InternalName", "Xerces XML Parser for COM \0"
            VALUE "LegalCopyright", "Copyright © Apache Software Foundation 2000 subject to licensing terms\0"
            VALUE "LegalTrademarks", "\0"
            VALUE "OLESelfRegister", "\0"
            VALUE "OriginalFilename", "xerces-com.dll\0"
            VALUE "PrivateBuild", "\0"
            VALUE "ProductName", "Xerces XML Parser for COM\0"
            VALUE "ProductVersion", "2, 5, 0, 0\0"
            VALUE "SpecialBuild", "\0"
        END
    END
    BLOCK "VarFileInfo"
    BEGIN
        VALUE "Translation", 0x409, 1200
    END
END

#endif    // !_MAC


/////////////////////////////////////////////////////////////////////////////
//
// REGISTRY
//

IDR_XMLDOCUMENT         REGISTRY DISCARDABLE    "xmldocument.rgs"
IDR_XMLHTTPREQUEST      REGISTRY DISCARDABLE    "xmlhttprequest.rgs"

/////////////////////////////////////////////////////////////////////////////
//
// String Table
//

STRINGTABLE DISCARDABLE 
BEGIN
    IDS_PROJNAME            "xml4com"
END

#endif    // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////



#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
1 TYPELIB "..\\..\\..\\Build\\Win32\\xml4com\\xml4com.tlb"

/////////////////////////////////////////////////////////////////////////////
#endif    // not APSTUDIO_INVOKED


--- NEW FILE: XMLDOMImplementation.h ---
/*
 * Copyright 1999-2000,2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * $Id: XMLDOMImplementation.h,v 1.1 2008/02/19 20:16:27 zolmol Exp $
 */

#ifndef ___xmldomimplementation_h___
#define ___xmldomimplementation_h___

#include <xercesc/dom/DOMImplementation.hpp>

XERCES_CPP_NAMESPACE_USE

class ATL_NO_VTABLE CXMLDOMImplementation : 
	public CComObjectRootEx<CComSingleThreadModel>,
	public IDispatchImpl<IXMLDOMImplementation, &IID_IXMLDOMImplementation, &LIBID_Xerces, XERCES_VERSION_MAJOR, INVK_CAT2_RAW_NUMERIC(XERCES_VERSION_MINOR,XERCES_VERSION_REVISION)>
{
public:
	CXMLDOMImplementation()
	{}

DECLARE_NOT_AGGREGATABLE(CXMLDOMImplementation)
DECLARE_PROTECT_FINAL_CONSTRUCT()

BEGIN_COM_MAP(CXMLDOMImplementation)
	COM_INTERFACE_ENTRY(IXMLDOMImplementation)
	COM_INTERFACE_ENTRY(IDispatch)
END_COM_MAP()

	// IXMLDOMImplementation methods
	STDMETHOD(hasFeature)(BSTR feature, BSTR ver, VARIANT_BOOL  *pVal);

	DOMImplementation* implementation;
};

typedef CComObject<CXMLDOMImplementation> CXMLDOMImplementationObj;

#endif // ___xmldomimplemenation_h___

--- NEW FILE: IXMLDOMNodeImpl.inl ---
/*
 * Copyright 1999-2000,2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * $Id: IXMLDOMNodeImpl.inl,v 1.1 2008/02/19 20:16:27 zolmol Exp $
 */


#include <xercesc/dom/DOMNode.hpp>
#include <xercesc/dom/DOMDocument.hpp>
#include <xercesc/dom/DOMText.hpp>
#include "XMLDOMNodeList.h"
#include "XMLDOMNamedNodeMap.h"
#include "XMLDOMUtil.h"
#include <xercesc/dom/DOMException.hpp>

XERCES_CPP_NAMESPACE_USE

template <class T, const IID* piid, class tihclass>
HRESULT STDMETHODCALLTYPE IXMLDOMNodeImpl<T,piid,tihclass>::InterfaceSupportsErrorInfo(REFIID riid)
{
	if(riid == *piid) return S_OK;
	return S_FALSE;
}

template <class T, const IID* piid, class tihclass>
STDMETHODIMP
IXMLDOMNodeImpl<T,piid,tihclass>::get_nodeName(BSTR *pVal)
{
	ATLTRACE(_T("IXMLDOMNodeImpl::get_nodeName\n"));

	if (NULL == pVal)
		return E_POINTER;

	*pVal = NULL;

	try
	{
		*pVal = SysAllocString(get_DOMNode()->getNodeName());
	}
	catch(DOMException& ex)
	{
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}
	
	return S_OK;
}

template <class T, const IID* piid, class tihclass>
STDMETHODIMP
IXMLDOMNodeImpl<T,piid,tihclass>::get_nodeValue(VARIANT *pVal)
{
	ATLTRACE(_T("IXMLDOMNodeImpl::get_nodeValue\n"));

	if (NULL == pVal)
		return E_POINTER;

	::VariantInit(pVal);


	try
	{
        const XMLCh* val=get_DOMNode()->getNodeValue();
		if (val != 0)
		{
			V_VT(pVal)   = VT_BSTR;
			V_BSTR(pVal) = SysAllocString(val);
		}
		else
			V_VT(pVal) = VT_NULL;
	}
	catch(DOMException& ex)
	{
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}
	
	return S_OK;
}

template <class T, const IID* piid, class tihclass>
STDMETHODIMP
IXMLDOMNodeImpl<T,piid,tihclass>::put_nodeValue(VARIANT newVal)
{
	ATLTRACE(_T("IXMLDOMNodeImpl::put_nodeValue\n"));

	try
	{
		if(V_VT(&newVal) == VT_BSTR)
		{
			get_DOMNode()->setNodeValue(V_BSTR(&newVal));
		}
		//
		//   coerce to BSTR or throw error
		//
		else
		{
			get_DOMNode()->setNodeValue((BSTR) (_bstr_t) newVal);
		}
	}
	catch(DOMException& ex)
	{
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}
	

	return S_OK;
}

template <class T, const IID* piid, class tihclass>
STDMETHODIMP
IXMLDOMNodeImpl<T,piid,tihclass>::get_nodeType(DOMNodeType *pVal)
{
	ATLTRACE(_T("IXMLDOMNodeImpl::get_nodeType\n"));

	if (NULL == pVal)
		return E_POINTER;

	*pVal = get_DOMNodeType();

	return S_OK;
}

template <class T, const IID* piid, class tihclass>
STDMETHODIMP
IXMLDOMNodeImpl<T,piid,tihclass>::get_parentNode(IXMLDOMNode **pVal)
{	
	ATLTRACE(_T("IXMLDOMNodeImpl::get_parentNode\n"));
	
	if (NULL == pVal)
		return E_POINTER;

	*pVal = NULL;
	HRESULT hr = S_OK;

	try
	{
		DOMNode* n = get_DOMNode()->getParentNode();
		if(n!=NULL) {
			hr = wrapNode(m_pIXMLDOMDocument, n,IID_IXMLDOMNode,reinterpret_cast<LPVOID *> (pVal));
		}
	}
	catch(DOMException& ex)
	{
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}
	

	return hr;
}

template <class T, const IID* piid, class tihclass>
STDMETHODIMP
IXMLDOMNodeImpl<T,piid,tihclass>::get_childNodes(IXMLDOMNodeList * *pVal)
{
	ATLTRACE(_T("IXMLDOMNodeImpl::get_childNodes\n"));
	
	if (NULL == pVal)
		return E_POINTER;

	*pVal = NULL;

	CXMLDOMNodeListObj *pObj = NULL;
	HRESULT hr = CXMLDOMNodeListObj::CreateInstance(&pObj);
	if (S_OK != hr)
		return hr;
	
	pObj->AddRef();
	pObj->SetOwnerDoc(m_pIXMLDOMDocument);

	try
	{
		pObj->m_container = get_DOMNode()->getChildNodes();
	}
	catch(DOMException& ex)
	{
		pObj->Release();
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		pObj->Release();
		return E_FAIL;
	}
	
	hr = pObj->QueryInterface(IID_IXMLDOMNodeList, reinterpret_cast<LPVOID*> (pVal));
	if (S_OK != hr)
		*pVal = NULL;

	pObj->Release();
	return hr;
}

template <class T, const IID* piid, class tihclass>
STDMETHODIMP
IXMLDOMNodeImpl<T,piid,tihclass>::get_firstChild(IXMLDOMNode **pVal)
{
	ATLTRACE(_T("IXMLDOMNodeImpl::get_firstChild\n"));

	if (NULL == pVal)
		return E_POINTER;

	*pVal = NULL;

	HRESULT hr = S_OK;

	try
	{
		DOMNode* n = get_DOMNode()->getFirstChild();
		//
		//   returns Nothing if no children
		//
		if(n!=NULL)
			hr = wrapNode(m_pIXMLDOMDocument,n,IID_IXMLDOMNode, reinterpret_cast<LPVOID *> (pVal));
	}
	catch(DOMException& ex)
	{
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}
	

	return hr;
}

template <class T, const IID* piid, class tihclass>
STDMETHODIMP
IXMLDOMNodeImpl<T,piid,tihclass>::get_lastChild(IXMLDOMNode **pVal)
{
	ATLTRACE(_T("IXMLDOMNodeImpl::get_lastChild\n"));

	if (NULL == pVal)
		return E_POINTER;

	*pVal = NULL;

	HRESULT hr = S_OK;

	try
	{
		DOMNode* n = get_DOMNode()->getLastChild();
		if(n!=NULL)
			hr = wrapNode(m_pIXMLDOMDocument,n,IID_IXMLDOMNode, reinterpret_cast<LPVOID *> (pVal));
	}
	catch(DOMException& ex)
	{
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}
	

	return hr;
}

template <class T, const IID* piid, class tihclass>
STDMETHODIMP
IXMLDOMNodeImpl<T,piid,tihclass>::get_previousSibling(IXMLDOMNode * *pVal)
{
	ATLTRACE(_T("IXMLDOMNodeImpl::get_previousSibling\n"));

	if (NULL == pVal)
		return E_POINTER;

	*pVal = NULL;
	HRESULT hr = S_OK;

	try
	{
		DOMNode* n = get_DOMNode()->getPreviousSibling();
		if(n!=NULL)
			hr = wrapNode(m_pIXMLDOMDocument,n,IID_IXMLDOMNode, reinterpret_cast<LPVOID *> (pVal));
	}
	catch(DOMException& ex)
	{
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}
	

	return hr;
}

template <class T, const IID* piid, class tihclass>
STDMETHODIMP
IXMLDOMNodeImpl<T,piid,tihclass>::get_nextSibling(IXMLDOMNode * *pVal)
{
	ATLTRACE(_T("IXMLDOMNodeImpl::get_nextSibling\n"));

	if (NULL == pVal)
		return E_POINTER;

	*pVal = NULL;

	HRESULT hr = S_OK;

	try
	{
		DOMNode* n = get_DOMNode()->getNextSibling();
		if(n!=NULL)
			hr = wrapNode(m_pIXMLDOMDocument,n,IID_IXMLDOMNode, reinterpret_cast<LPVOID *> (pVal));
	}
	catch(DOMException& ex)
	{
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}
	
	return hr;
}

template <class T, const IID* piid, class tihclass>
STDMETHODIMP
IXMLDOMNodeImpl<T,piid,tihclass>::get_attributes(IXMLDOMNamedNodeMap * *pVal)
{
	ATLTRACE(_T("IXMLDOMNodeImpl::get_attributes\n"));

	if (NULL == pVal)
		return E_POINTER;

	*pVal = NULL;

	DOMNamedNodeMap* map=NULL;
	try
	{
		map = get_DOMNode()->getAttributes();
	}
	catch(DOMException& ex)
	{
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}
	
	if ((map == 0) || (NODE_ELEMENT  != get_DOMNodeType()))
		//&&
		//NODE_ENTITY   != get_DOMNodeType() &&
		//NODE_NOTATION != get_DOMNodeType())
		return S_OK;
	
	CXMLDOMNamedNodeMapObj *pObj = NULL;
	HRESULT hr = CXMLDOMNamedNodeMapObj::CreateInstance(&pObj);
	if (S_OK != hr)
		return hr;
	
	pObj->AddRef();
	pObj->SetOwnerDoc(m_pIXMLDOMDocument);
	pObj->m_container = map;
	
	hr = pObj->QueryInterface(IID_IXMLDOMNamedNodeMap, reinterpret_cast<LPVOID*> (pVal));
	if (S_OK != hr)
		*pVal = NULL;

	pObj->Release();
	return hr;
}

template <class T, const IID* piid, class tihclass>
STDMETHODIMP
IXMLDOMNodeImpl<T,piid,tihclass>::insertBefore(IXMLDOMNode *newChild, VARIANT refChild, IXMLDOMNode **outNewChild)
{
	ATLTRACE(_T("IXMLDOMNodeImpl::insertBefore\n"));

	if (NULL == outNewChild)
		return E_POINTER;

	*outNewChild = NULL;

	if (NULL == newChild)
		return E_INVALIDARG;

	if (V_VT(&refChild) != VT_DISPATCH && V_VT(&refChild) != VT_NULL)
		return E_INVALIDARG;

	if (V_VT(&refChild) == VT_NULL)
		return appendChild(newChild,outNewChild);
	
	CComQIPtr<IIBMXMLDOMNodeIdentity,&IID_IIBMXMLDOMNodeIdentity> pNewChild(newChild);
	if (!pNewChild)
		return E_NOINTERFACE;

	long id = 0;
	HRESULT hr = pNewChild->get_NodeId(&id);
	if (S_OK != hr)
		return hr;

	DOMNode *pNewChildNode = reinterpret_cast<DOMNode*> (id);
	if (NULL == pNewChildNode)
		return E_INVALIDARG;

	CComQIPtr<IIBMXMLDOMNodeIdentity,&IID_IIBMXMLDOMNodeIdentity> pRefChild(V_DISPATCH(&refChild));
	if (!pRefChild)
		return E_NOINTERFACE;

	id = 0;
	hr = pRefChild->get_NodeId(&id);
	if (S_OK != hr)
		return hr;

	DOMNode *pRefChildNode = reinterpret_cast<DOMNode*> (id);
	if (NULL == pRefChildNode)
		return E_INVALIDARG;

	try
	{
		DOMNode* n = get_DOMNode()->insertBefore(pNewChildNode, pRefChildNode);
		hr = wrapNode(m_pIXMLDOMDocument,n,IID_IXMLDOMNode, reinterpret_cast<LPVOID *> (outNewChild));
	}
	catch(DOMException& ex)
	{
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}
	
	return hr;
}

template <class T, const IID* piid, class tihclass>
STDMETHODIMP
IXMLDOMNodeImpl<T,piid,tihclass>::replaceChild(IXMLDOMNode *newChild, IXMLDOMNode *oldChild, IXMLDOMNode * *outNewChild)
{
	ATLTRACE(_T("IXMLDOMNodeImpl::replaceChild\n"));

	if (NULL == outNewChild)
		return E_POINTER;

	*outNewChild = NULL;

	if (NULL == oldChild)
		return E_INVALIDARG;

	if (NULL == newChild)
		return removeChild(oldChild,outNewChild);

		
	CComQIPtr<IIBMXMLDOMNodeIdentity,&IID_IIBMXMLDOMNodeIdentity> pNewChild(newChild);
	if (!pNewChild)
		return E_NOINTERFACE;

	long id = 0;
	HRESULT hr = pNewChild->get_NodeId(&id);
	if (S_OK != hr)
		return hr;

	DOMNode *pNewChildNode = reinterpret_cast<DOMNode*> (id);
	if (NULL == pNewChildNode)
		return E_INVALIDARG;

	CComQIPtr<IIBMXMLDOMNodeIdentity,&IID_IIBMXMLDOMNodeIdentity> pOldChild(oldChild);
	if (!pOldChild)
		return E_NOINTERFACE;

	id = 0;
	hr = pOldChild->get_NodeId(&id);
	if (S_OK != hr)
		return hr;

	DOMNode *pOldChildNode = reinterpret_cast<DOMNode*> (id);
	if (NULL == pOldChildNode)
		return E_INVALIDARG;

	try
	{
		DOMNode* n = get_DOMNode()->replaceChild(pNewChildNode, pOldChildNode);
		hr = wrapNode(m_pIXMLDOMDocument,n,IID_IXMLDOMNode, reinterpret_cast<LPVOID *> (outNewChild));
	}
	catch(DOMException& ex)
	{
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}
	
	return S_OK;
}

template <class T, const IID* piid, class tihclass>
STDMETHODIMP
IXMLDOMNodeImpl<T,piid,tihclass>::removeChild(IXMLDOMNode *child, IXMLDOMNode * *oldChild)
{
	ATLTRACE(_T("IXMLDOMNodeImpl::removeChild\n"));

	if (NULL == oldChild)
		return E_POINTER;

	*oldChild = NULL;

	if (NULL == child)
		return E_INVALIDARG;
		
	CComQIPtr<IIBMXMLDOMNodeIdentity,&IID_IIBMXMLDOMNodeIdentity> pChild(child);
	if (!pChild)
		return E_NOINTERFACE;

	long id = 0;
	HRESULT hr = pChild->get_NodeId(&id);
	if (S_OK != hr)
		return hr;

	DOMNode *pChildNode = reinterpret_cast<DOMNode*> (id);
	if (NULL == pChildNode)
		return E_INVALIDARG;

	try
	{
		DOMNode* n = get_DOMNode()->removeChild(pChildNode);
		if(n!=NULL)
			hr = wrapNode(m_pIXMLDOMDocument,n,IID_IXMLDOMNode, reinterpret_cast<LPVOID *> (oldChild));
	}
	catch(DOMException& ex)
	{
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}
	
	return S_OK;
}

template <class T, const IID* piid, class tihclass>
STDMETHODIMP
IXMLDOMNodeImpl<T,piid,tihclass>::appendChild(IXMLDOMNode *newChild, IXMLDOMNode * *outNewChild)
{
	ATLTRACE(_T("IXMLDOMNodeImpl::appendChild\n"));
	
	if (NULL == outNewChild)
		return E_POINTER;

	*outNewChild = NULL;

	if (NULL == newChild)
		return E_INVALIDARG;
		
	CComQIPtr<IIBMXMLDOMNodeIdentity,&IID_IIBMXMLDOMNodeIdentity> pNewChild(newChild);
	if (!pNewChild)
		return E_NOINTERFACE;

	long id = 0;
	HRESULT hr = pNewChild->get_NodeId(&id);
	if (S_OK != hr)
		return hr;

	DOMNode *pNewChildNode = reinterpret_cast<DOMNode*> (id);
	if (NULL == pNewChildNode)
		return E_INVALIDARG;

	try
	{
		DOMNode* n = get_DOMNode()->appendChild(pNewChildNode);
		hr = wrapNode(m_pIXMLDOMDocument,n,IID_IXMLDOMNode, reinterpret_cast<LPVOID *> (outNewChild));
	}
	catch(DOMException& ex)
	{
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}
	
	return S_OK;
}

template <class T, const IID* piid, class tihclass>
STDMETHODIMP
IXMLDOMNodeImpl<T,piid,tihclass>::hasChildNodes(VARIANT_BOOL *hasChild)
{
	ATLTRACE(_T("IXMLDOMNodeImpl::hasChildNodes\n"));

	if (NULL == hasChild)
		return E_POINTER;

	*hasChild = VARIANT_FALSE;

	try
	{
		*hasChild = (get_DOMNode()->hasChildNodes()) ? VARIANT_TRUE : VARIANT_FALSE;
	}
	catch(DOMException& ex)
	{
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}
	
	return S_OK;
}

template <class T, const IID* piid, class tihclass>
STDMETHODIMP
IXMLDOMNodeImpl<T,piid,tihclass>::get_ownerDocument(IXMLDOMDocument **pVal)
{
	ATLTRACE(_T("IXMLDOMNodeImpl::get_ownerDocument\n"));

	if (NULL == pVal)
		return E_POINTER;
	*pVal = NULL;

	if (get_DOMNodeType() != NODE_DOCUMENT)
	{
		*pVal = m_pIXMLDOMDocument;
		if (*pVal != NULL)
			(*pVal)->AddRef();
	}
	return S_OK;
}

template <class T, const IID* piid, class tihclass>
STDMETHODIMP
IXMLDOMNodeImpl<T,piid,tihclass>::cloneNode(VARIANT_BOOL deep, IXMLDOMNode **pVal)
{
	ATLTRACE(_T("IXMLDOMNodeImpl::cloneNode\n"));

	if (NULL == pVal)
		return E_POINTER;

	*pVal = NULL;
	HRESULT hr = S_OK;

	try
	{
		hr = wrapNode(m_pIXMLDOMDocument,get_DOMNode()->cloneNode((VARIANT_TRUE == deep) ? true : false),IID_IXMLDOMNode, reinterpret_cast<LPVOID *> (pVal));
	}
	catch(DOMException& ex)
	{
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}
	

	return hr;
}

template <class T, const IID* piid, class tihclass>
STDMETHODIMP
IXMLDOMNodeImpl<T,piid,tihclass>::get_nodeTypeString(BSTR *pVal)
{
	ATLTRACE(_T("IXMLDOMNodeImpl::get_nodeTypeString\n"));

	USES_CONVERSION;

	if (NULL == pVal)
		return E_POINTER;

	*pVal = ::SysAllocString(g_DomNodeName[get_DOMNodeType()]);
	
	return S_OK;
}

template <class T, const IID* piid, class tihclass>
STDMETHODIMP
IXMLDOMNodeImpl<T,piid,tihclass>::get_text(BSTR *pVal)
{
	ATLTRACE(_T("IXMLDOMNodeImpl::get_text\n"));

	if (NULL == pVal)
		return E_POINTER;

	*pVal = SysAllocString(get_DOMNode()->getTextContent());

	return S_OK;
}

template <class T, const IID* piid, class tihclass>
STDMETHODIMP
IXMLDOMNodeImpl<T,piid,tihclass>::put_text(BSTR newVal)
{
	ATLTRACE(_T("IXMLDOMNodeImpl::put_text\n"));

	DOMNodeType type = get_DOMNodeType();
	if (NODE_DOCUMENT_FRAGMENT == type ||
		NODE_DOCUMENT_TYPE	   == type ||
		NODE_ENTITY			   == type ||
		NODE_ENTITY_REFERENCE  == type ||
		NODE_NOTATION		   == type)
		return E_ACCESSDENIED;

	try
	{
		if(NODE_ELEMENT == type)
		{
			//
			//   remove all child elements
			//
			DOMNode* elem = get_DOMNode();
			DOMNode* child = elem->getLastChild();
			while(child!=NULL)
			{
				elem->removeChild(child);
				child = elem->getLastChild();
			}
			
			XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument* doc = elem->getOwnerDocument();
			elem->appendChild(doc->createTextNode(newVal));
		}
		else
			get_DOMNode()->setNodeValue(newVal);
	}
	catch(DOMException& ex)
	{
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}

	return S_OK;
}


template <class T, const IID* piid, class tihclass>
STDMETHODIMP
IXMLDOMNodeImpl<T,piid,tihclass>::get_specified(VARIANT_BOOL *pVal)
{
	ATLTRACE(_T("IXMLDOMNodeImpl::get_specified\n"));

	*pVal = VARIANT_TRUE;
	return S_OK;
}

template <class T, const IID* piid, class tihclass>
STDMETHODIMP
IXMLDOMNodeImpl<T,piid,tihclass>::get_definition(IXMLDOMNode * *pVal)
{	
	ATLTRACE(_T("IXMLDOMNodeImpl::get_definition\n"));

	return E_NOTIMPL;
}

template <class T, const IID* piid, class tihclass>
STDMETHODIMP
IXMLDOMNodeImpl<T,piid,tihclass>::get_nodeTypedValue(VARIANT *pVal)
{
	ATLTRACE(_T("IXMLDOMNodeImpl::get_nodeTypedValue\n"));

	return get_nodeValue(pVal);
}

template <class T, const IID* piid, class tihclass>
STDMETHODIMP
IXMLDOMNodeImpl<T,piid,tihclass>::put_nodeTypedValue(VARIANT newVal)
{	
	ATLTRACE(_T("IXMLDOMNodeImpl::put_nodeTypedValue\n"));

	return put_nodeValue(newVal);
}

template <class T, const IID* piid, class tihclass>
STDMETHODIMP
IXMLDOMNodeImpl<T,piid,tihclass>::get_dataType(VARIANT *pVal)
{
	ATLTRACE(_T("IXMLDOMNodeImpl::get_dataType\n"));

	return E_NOTIMPL;
}

template <class T, const IID* piid, class tihclass>
STDMETHODIMP
IXMLDOMNodeImpl<T,piid,tihclass>::put_dataType(BSTR dataTypeName)
{
	ATLTRACE(_T("IXMLDOMNodeImpl::put_dataType\n"));

	return E_NOTIMPL;
}

template <class T, const IID* piid, class tihclass>
STDMETHODIMP
IXMLDOMNodeImpl<T,piid,tihclass>::get_xml(BSTR *pVal)
{
	ATLTRACE(_T("IXMLDOMNodeImpl::get_xml\n"));

	if (NULL == pVal)
		return E_POINTER;

	*pVal = NULL;

	_bstr_t text;
	
	try {
		GetXML(get_DOMNode(),text);
	}
	catch(DOMException& ex)
	{
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}

	*pVal = text.copy();
	
	return S_OK;
}

template <class T, const IID* piid, class tihclass>
STDMETHODIMP
IXMLDOMNodeImpl<T,piid,tihclass>::transformNode(IXMLDOMNode *stylesheet, BSTR *xmlString)
{
	ATLTRACE(_T("IXMLDOMNodeImpl::transformNode\n"));

	return E_NOTIMPL;
}

template <class T, const IID* piid, class tihclass>
STDMETHODIMP
IXMLDOMNodeImpl<T,piid,tihclass>::selectNodes(BSTR queryString, IXMLDOMNodeList * *resultList)
{
	ATLTRACE(_T("IXMLDOMNodeImpl::selectNodes\n"));

	return E_NOTIMPL;
}

template <class T, const IID* piid, class tihclass>
STDMETHODIMP
IXMLDOMNodeImpl<T,piid,tihclass>::selectSingleNode(BSTR queryString, IXMLDOMNode * *resultNode)
{
	ATLTRACE(_T("IXMLDOMNodeImpl::selectSingleNode\n"));

	return E_NOTIMPL;
}

template <class T, const IID* piid, class tihclass>
STDMETHODIMP
IXMLDOMNodeImpl<T,piid,tihclass>::get_parsed(VARIANT_BOOL *pVal)
{
	ATLTRACE(_T("IXMLDOMNodeImpl::get_parsed\n"));

	if (NULL == pVal)
		return E_POINTER;

	*pVal = VARIANT_TRUE;
	return S_OK;
}

template <class T, const IID* piid, class tihclass>
STDMETHODIMP
IXMLDOMNodeImpl<T,piid,tihclass>::get_namespaceURI(BSTR *pVal)
{
	ATLTRACE(_T("IXMLDOMNodeImpl::get_namespaceURI\n"));

	if (NULL == pVal)
		return E_POINTER;

	*pVal = NULL;

	try {
		*pVal = SysAllocString(get_DOMNode()->getNamespaceURI());
	}
	catch(DOMException& ex)
	{
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}

	return S_OK;
}

template <class T, const IID* piid, class tihclass>
STDMETHODIMP
IXMLDOMNodeImpl<T,piid,tihclass>::get_prefix(BSTR *pVal)
{
	ATLTRACE(_T("IXMLDOMNodeImpl::get_prefix\n"));
	
	if (NULL == pVal)
		return E_POINTER;

	*pVal = NULL;

	try {
		*pVal = SysAllocString(get_DOMNode()->getPrefix());
	}
	catch(DOMException& ex)
	{
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}

	return S_OK;
}

template <class T, const IID* piid, class tihclass>
STDMETHODIMP
IXMLDOMNodeImpl<T,piid,tihclass>::get_baseName(BSTR *pVal)
{
	ATLTRACE(_T("IXMLDOMNodeImpl::get_baseName\n"));

	if (NULL == pVal)
		return E_POINTER;

	*pVal = NULL;

	try {
		*pVal = SysAllocString(get_DOMNode()->getLocalName());
	}
	catch(DOMException& ex)
	{
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}

	return S_OK;
}

template <class T, const IID* piid, class tihclass>
STDMETHODIMP
IXMLDOMNodeImpl<T,piid,tihclass>::transformNodeToObject(IXMLDOMNode *stylesheet, VARIANT outputObject)
{
	ATLTRACE(_T("IXMLDOMNodeImpl::transformNodeToObject\n"));

	return E_NOTIMPL;
}


--- NEW FILE: XMLDOMUtil.cpp ---
/*
 * Copyright 1999-2001,2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * $Id: XMLDOMUtil.cpp,v 1.1 2008/02/19 20:16:27 zolmol Exp $
 */

#include "stdafx.h"
#include "xml4com.h"
#include "XMLDOMElement.h"
#include "XMLDOMAttribute.h"
#include "XMLDOMText.h"
#include "XMLDOMCDATASection.h"
#include "XMLDOMEntityReference.h"
#include "XMLDOMEntity.h"
#include "XMLDOMProcessingInstruction.h"
#include "XMLDOMComment.h"
#include "XMLDOMDocument.h"
#include "XMLDOMDocumentType.h"
#include "XMLDOMDocumentFragment.h"
#include "XMLDOMNotation.h"
#include "XMLDOMUtil.h"
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/util/XMLUniDefs.hpp>
#include <xercesc/util/XMLString.hpp>


const OLECHAR* g_DomNodeName[] =
{	
	OLESTR("invalid"),
	OLESTR("element"),
	OLESTR("attribute"),
	OLESTR("text"),
	OLESTR("cdatasection"),
	OLESTR("entityreference"),
	OLESTR("entity"),
	OLESTR("processinginstruction"),
	OLESTR("comment"),
	OLESTR("document"),
	OLESTR("documenttype"),
	OLESTR("documentfragment"),
	OLESTR("notation")
};

const int g_DomNodeNameSize = sizeof(g_DomNodeName) / sizeof(OLECHAR*);

template <class Base>
class CComObjectPool
{
public:
	CComObjectPool(unsigned long poolSize);

	virtual ~CComObjectPool();

	HRESULT WINAPI CreateInstance(Base** pp);

	HRESULT Deactivate(Base* obj);

private:
	Base** m_pool;
	unsigned long m_size;
	unsigned long m_hit;
	unsigned long m_attempt;
	HRESULT Activate(Base* obj);
};




template <class Base>
class CPooledComObject : public Base
{
public:
	typedef Base _BaseClass;
	CPooledComObject(void* = NULL)
	{
		_Module.Lock();
	}
	// Set refcount to 1 to protect destruction
	~CPooledComObject()
	{
		m_dwRef = 1L;
		FinalRelease();
#ifdef _ATL_DEBUG_INTERFACES
		_Module.DeleteNonAddRefThunk(_GetRawUnknown());
#endif
		_Module.Unlock();
	}
	//If InternalAddRef or InternalRelease is undefined then your class
	//doesn't derive from CComObjectRoot
	STDMETHOD_(ULONG, AddRef)() {return InternalAddRef();}
	STDMETHOD_(ULONG, Release)()
	{
		ULONG l = InternalRelease();
		if (l == 0) {
			if(SUCCEEDED(m_pool.Deactivate(this))) {
				FinalRelease();
			}
			else
				delete this;
		}
		return l;
	}
	//if _InternalQueryInterface is undefined then you forgot BEGIN_COM_MAP
	STDMETHOD(QueryInterface)(REFIID iid, void ** ppvObject)
	{return _InternalQueryInterface(iid, ppvObject);}
	template <class Q>
	HRESULT STDMETHODCALLTYPE QueryInterface(Q** pp)
	{
		return QueryInterface(__uuidof(Q), (void**)pp);
	}

	static HRESULT WINAPI CreateInstance(Base** pp) {
		return m_pool.CreateInstance(pp);
	}

private:
	static CComObjectPool<Base> m_pool;
};




template <class Base>
CComObjectPool<Base>::CComObjectPool(unsigned long poolSize) {
	m_pool = NULL;
	m_size = poolSize;
	m_pool = new Base*[m_size];
	for(unsigned long i = 0; i < m_size; i++)
		m_pool[i] = NULL;
	m_hit= 0;
	m_attempt = 0;
}

template <class Base>
CComObjectPool<Base>::~CComObjectPool() {
	for(unsigned long i = 0; i < m_size; i++) {
		if(m_pool[i]) delete m_pool[i];
	}
	delete [] m_pool;
}

template <class Base>
HRESULT CComObjectPool<Base>::Deactivate(Base* obj) {
	for(unsigned long i = 0; i < m_size; i++) {
		if(m_pool[i] == NULL) {
			m_pool[i] = obj;
			return S_OK;
		}
	}
	return E_FAIL;
}

template <class Base>
HRESULT CComObjectPool<Base>::Activate(Base* p)
{
	p->SetVoid(NULL);
	p->InternalFinalConstructAddRef();
	HRESULT hRes = p->FinalConstruct();
	p->InternalFinalConstructRelease();
	return hRes;
}


template <class Base>
HRESULT WINAPI CComObjectPool<Base>::CreateInstance(Base** pp) {
	ATLASSERT(pp != NULL);
	HRESULT hRes = E_OUTOFMEMORY;
	Base* p = NULL;

	m_attempt++;

	for(unsigned long i = 0; i < m_size; i++) {
		if(m_pool[i]) {
			p = m_pool[i];
			m_pool[i] = NULL;
			hRes = Activate(p);
			if (SUCCEEDED(hRes)) {
				m_hit++;
				break;
			}
			else {
				delete p;
				p = NULL;
			}
		}
	}

	if(FAILED(hRes)) {
		ATLTRY(p = new CPooledComObject<Base>())
		if (p != NULL) {
			hRes = Activate(p);
			if (hRes != S_OK) {
				delete p;
				p = NULL;
			}
		}
	}
	*pp = p;
	return hRes;
}


CComObjectPool<CXMLDOMElement> CPooledComObject<CXMLDOMElement>::m_pool(6);
typedef CPooledComObject<CXMLDOMElement> CPooledXMLDOMElementObj;

CComObjectPool<CXMLDOMAttribute> CPooledComObject<CXMLDOMAttribute>::m_pool(6);
typedef CPooledComObject<CXMLDOMAttribute> CPooledXMLDOMAttributeObj;

CComObjectPool<CXMLDOMText> CPooledComObject<CXMLDOMText>::m_pool(6);
typedef CPooledComObject<CXMLDOMText> CPooledXMLDOMTextObj;

CComObjectPool<CXMLDOMCDATASection> CPooledComObject<CXMLDOMCDATASection>::m_pool(6);
typedef CPooledComObject<CXMLDOMCDATASection> CPooledXMLDOMCDATASectionObj;

CComObjectPool<CXMLDOMEntityReference> CPooledComObject<CXMLDOMEntityReference>::m_pool(6);
typedef CPooledComObject<CXMLDOMEntityReference> CPooledXMLDOMEntityReferenceObj;

CComObjectPool<CXMLDOMEntity> CPooledComObject<CXMLDOMEntity>::m_pool(6);
typedef CPooledComObject<CXMLDOMEntity> CPooledXMLDOMEntityObj;

CComObjectPool<CXMLDOMProcessingInstruction> CPooledComObject<CXMLDOMProcessingInstruction>::m_pool(6);
typedef CPooledComObject<CXMLDOMProcessingInstruction> CPooledXMLDOMProcessingInstructionObj;

CComObjectPool<CXMLDOMComment> CPooledComObject<CXMLDOMComment>::m_pool(6);
typedef CPooledComObject<CXMLDOMComment> CPooledXMLDOMCommentObj;


HRESULT wrapNode(IXMLDOMDocument *pDoc, DOMNode* node, REFIID iid, LPVOID *pVal)
{
	HRESULT hr = S_OK;
	if (NULL == pVal)
		return E_POINTER;

	*pVal = NULL;
	short type = node->getNodeType();

	// the way we are constructing the wrappers is kind of fishy but oh well...
	// the various IBM DOM wrapper classes don't ever add any members or have
	// any v-tables so what we are doing should be safe.  There isn't any other
	// way as far as I can tell to do this....

	switch(type)
	{
	case DOMNode::ELEMENT_NODE:
	{
		CXMLDOMElement *pObj = NULL;
		hr = CPooledXMLDOMElementObj::CreateInstance(&pObj);
		if (S_OK != hr)
			return hr;
	
		pObj->AddRef();
		pObj->SetOwnerDoc(pDoc);

		try
		{
			pObj->element = static_cast<DOMElement*> (node);
		}
		catch(DOMException& ex)
		{
			pObj->Release();
			return MakeHRESULT(ex);
		}
		catch(...)
		{
			pObj->Release();
			return E_FAIL;
		}
	
		hr = pObj->QueryInterface(iid, pVal);
		if (S_OK != hr)
			*pVal = NULL;

		pObj->Release();
		break;
	}
	case DOMNode::ATTRIBUTE_NODE:
	{
		CXMLDOMAttribute *pObj = NULL;
		hr = CPooledXMLDOMAttributeObj::CreateInstance(&pObj);
		if (S_OK != hr)
			return hr;
	
		pObj->AddRef();
		pObj->SetOwnerDoc(pDoc);

		try
		{
			pObj->attr = static_cast<DOMAttr*> (node);
		}
		catch(DOMException& ex)
		{
			pObj->Release();
			return MakeHRESULT(ex);
		}
		catch(...)
		{
			pObj->Release();
			return E_FAIL;
		}
	
		hr = pObj->QueryInterface(iid, pVal);
		if (S_OK != hr)
			*pVal = NULL;

		pObj->Release();
		break;
	}
	case DOMNode::TEXT_NODE:
	{
		CXMLDOMText *pObj = NULL;
		hr = CPooledXMLDOMTextObj::CreateInstance(&pObj);
		if (S_OK != hr)
			return hr;
	
		pObj->AddRef();
		pObj->SetOwnerDoc(pDoc);

		try
		{
			pObj->text = static_cast<DOMText*> (node);
		}
		catch(DOMException& ex)
		{
			pObj->Release();
			return MakeHRESULT(ex);
		}
		catch(...)
		{
			pObj->Release();
			return E_FAIL;
		}
	
		hr = pObj->QueryInterface(iid, pVal);
		if (S_OK != hr)
			*pVal = NULL;

		pObj->Release();
		break;
	}
	case DOMNode::CDATA_SECTION_NODE:
	{
		CXMLDOMCDATASection *pObj = NULL;
		hr = CPooledXMLDOMCDATASectionObj::CreateInstance(&pObj);
		if (S_OK != hr)
			return hr;
	
		pObj->AddRef();
		pObj->SetOwnerDoc(pDoc);

		try
		{
			pObj->cdataSection = static_cast<DOMCDATASection*> (node);
		}
		catch(DOMException& ex)
		{
			pObj->Release();
			return MakeHRESULT(ex);
		}
		catch(...)
		{
			pObj->Release();
			return E_FAIL;
		}
	
		hr = pObj->QueryInterface(iid, pVal);
		if (S_OK != hr)
			*pVal = NULL;

		pObj->Release();
		break;
	}
	case DOMNode::ENTITY_REFERENCE_NODE:
	{
		CXMLDOMEntityReference *pObj = NULL;
		hr = CPooledXMLDOMEntityReferenceObj::CreateInstance(&pObj);
		if (S_OK != hr)
			return hr;
	
		pObj->AddRef();
		pObj->SetOwnerDoc(pDoc);

		try
		{
			pObj->entityReference = static_cast<DOMEntityReference*> (node);
		}
		catch(DOMException& ex)
		{
			pObj->Release();
			return MakeHRESULT(ex);
		}
		catch(...)
		{
			pObj->Release();
			return E_FAIL;
		}
	
		hr = pObj->QueryInterface(iid, pVal);
		if (S_OK != hr)
			*pVal = NULL;

		pObj->Release();
		break;
	}
	case DOMNode::ENTITY_NODE:
	{
		CXMLDOMEntity *pObj = NULL;
		hr = CPooledXMLDOMEntityObj::CreateInstance(&pObj);
		if (S_OK != hr)
			return hr;
	
		pObj->AddRef();
		pObj->SetOwnerDoc(pDoc);
		
		try
		{
			pObj->entity = static_cast<DOMEntity*> (node);
		}
		catch(DOMException& ex)
		{
			pObj->Release();
			return MakeHRESULT(ex);
		}
		catch(...)
		{
			pObj->Release();
			return E_FAIL;
		}
	
		hr = pObj->QueryInterface(iid, pVal);
		if (S_OK != hr)
			*pVal = NULL;

		pObj->Release();
		break;
	}
	case DOMNode::PROCESSING_INSTRUCTION_NODE:
	{
		CXMLDOMProcessingInstruction *pObj = NULL;
		hr = CPooledXMLDOMProcessingInstructionObj::CreateInstance(&pObj);
		if (S_OK != hr)
			return hr;
	
		pObj->AddRef();
		pObj->SetOwnerDoc(pDoc);

		try
		{
			pObj->processingInstruction = static_cast<DOMProcessingInstruction*> (node);
		}
		catch(DOMException& ex)
		{
			pObj->Release();
			return MakeHRESULT(ex);
		}
		catch(...)
		{
			pObj->Release();
			return E_FAIL;
		}
	
		hr = pObj->QueryInterface(iid, pVal);
		if (S_OK != hr)
			*pVal = NULL;

		pObj->Release();
		break;
	}
	case DOMNode::COMMENT_NODE:
	{
		CXMLDOMComment *pObj = NULL;
		hr = CPooledXMLDOMCommentObj::CreateInstance(&pObj);
		if (S_OK != hr)
			return hr;
	
		pObj->AddRef();
		pObj->SetOwnerDoc(pDoc);

		try
		{
			pObj->comment = static_cast<DOMComment*> (node);
		}
		catch(DOMException& ex)
		{
			pObj->Release();
			return MakeHRESULT(ex);
		}
		catch(...)
		{
			pObj->Release();
			return E_FAIL;
		}
	
		hr = pObj->QueryInterface(iid, pVal);
		if (S_OK != hr)
			*pVal = NULL;

		pObj->Release();
		break;
	}
	case DOMNode::DOCUMENT_NODE:
	{
		CXMLDOMDocumentObj *pObj = NULL;
		hr = CXMLDOMDocumentObj::CreateInstance(&pObj);
		if (S_OK != hr)
			return hr;
	
		pObj->AddRef();
		pObj->SetOwnerDoc(pDoc);

		try
		{
			pObj->m_Document = static_cast<XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument*> (node);
		}
		catch(DOMException& ex)
		{
			pObj->Release();
			return MakeHRESULT(ex);
		}
		catch(...)
		{
			pObj->Release();
			return E_FAIL;
		}
	
		hr = pObj->QueryInterface(iid, pVal);
		if (S_OK != hr)
			*pVal = NULL;

		pObj->Release();
		break;
	}
	case DOMNode::DOCUMENT_TYPE_NODE:
	{
		CXMLDOMDocumentTypeObj *pObj = NULL;
		hr = CXMLDOMDocumentTypeObj::CreateInstance(&pObj);
		if (S_OK != hr)
			return hr;
	
		pObj->AddRef();
		pObj->SetOwnerDoc(pDoc);

		try
		{
			pObj->documentType = static_cast<DOMDocumentType*> (node);
		}
		catch(DOMException& ex)
		{
			pObj->Release();
			return MakeHRESULT(ex);
		}
		catch(...)
		{
			pObj->Release();
			return E_FAIL;
		}
	
		hr = pObj->QueryInterface(iid, pVal);
		if (S_OK != hr)
			*pVal = NULL;

		pObj->Release();
		break;
	}
	case DOMNode::DOCUMENT_FRAGMENT_NODE:
	{
		CXMLDOMDocumentFragmentObj *pObj = NULL;
		hr = CXMLDOMDocumentFragmentObj::CreateInstance(&pObj);
		if (S_OK != hr)
			return hr;
	
		pObj->AddRef();
		pObj->SetOwnerDoc(pDoc);

		try
		{
			pObj->documentFragment = static_cast<DOMDocumentFragment*> (node);
		}
		catch(DOMException& ex)
		{
			pObj->Release();
			return MakeHRESULT(ex);
		}
		catch(...)
		{
			pObj->Release();
			return E_FAIL;
		}
	
		hr = pObj->QueryInterface(iid, pVal);
		if (S_OK != hr)
			*pVal = NULL;

		pObj->Release();
		break;
	}
	case DOMNode::NOTATION_NODE:
	{
		CXMLDOMNotationObj *pObj = NULL;
		hr = CXMLDOMNotationObj::CreateInstance(&pObj);
		if (S_OK != hr)
			return hr;
	
		pObj->AddRef();
		pObj->SetOwnerDoc(pDoc);

		try
		{
			pObj->notation = static_cast<DOMNotation*> (node);
		}
		catch(DOMException& ex)
		{
			pObj->Release();
			return MakeHRESULT(ex);
		}
		catch(...)
		{
			pObj->Release();
			return E_FAIL;
		}
	
		hr = pObj->QueryInterface(iid, pVal);
		if (S_OK != hr)
			*pVal = NULL;

		pObj->Release();
		break;
	}

	default:
		hr = E_NOTIMPL;
		break;
	}

	return hr;
}


class xmlstream {
public:
	xmlstream() {
		m_length = 0;
		m_alloc = 0;
		m_buffer = 0;
		m_next = 0;
	}

	~xmlstream() {
		delete [] m_buffer;
	}

	xmlstream& operator<<(const XMLCh* other) {
		//
		//   get length of string
		//
		unsigned long len = 0;
		for(const XMLCh* source = other; *source; source++,len++);

		//
		//    append to stream
		//
		append(other,len);
		return *this;
	}

	xmlstream& operator<<(const XMLCh other) {
		append(&other,1);
		return *this;
	}

	BSTR SysAllocString() {
		if(m_length > 0)
			return SysAllocStringLen(m_buffer,m_length);
		return 0;
	}

private:
	void append(const XMLCh* other,unsigned long length) {
		const XMLCh* source = NULL;

		if(m_length + length > m_alloc) {
			unsigned long chunk = 4096;
			if(length > chunk) chunk += length;
			XMLCh* newbuf = new XMLCh[m_alloc+ chunk];
			m_alloc += chunk;
			m_next = newbuf + m_length;

			//
			//    copy old content into new buffer
			//
			XMLCh* dest = newbuf;
			source = m_buffer;
			for(unsigned long i = 0; i < m_length; i++,dest++,source++) {
				*dest = *source;
			}
			delete [] m_buffer;
			m_buffer = newbuf;
		}

		source = other;
		for(unsigned long i = 0; i < length; i++,source++,m_next++) {
			*m_next = *source;
		}
		m_length += length;
	}

	unsigned long m_length;
	unsigned long m_alloc;
	XMLCh* m_buffer;
	XMLCh* m_next;
};




// ---------------------------------------------------------------------------
//  outputContent
//
//  Write document content from a string to a C++ ostream. Escape the
//  XML special characters (<, &, etc.) unless this is suppressed by the
//  command line option.
// ---------------------------------------------------------------------------
void outputContent(xmlstream& target, const XMLCh* toWrite)
{

    int            length = XMLString::stringLen(toWrite);

    int index;
    for (index = 0; index < length; index++)
    {
        switch (toWrite[index])
        {
        case chAmpersand :
            target << XMLStrL("&amp;");
            break;

        case chOpenAngle :
            target << XMLStrL("&lt;");
            break;

        case chCloseAngle:
            target << XMLStrL("&gt;");
            break;

        case chDoubleQuote :
            target << XMLStrL("&quot;");
            break;

        default:
            // If it is none of the special characters, print it as such
            target << toWrite[index];
            break;
        }
    }

    return;
}

xmlstream& operator<<(xmlstream& target, const DOMNode* toWrite)
{
    // Get the name and value out for convenience
    const XMLCh* nodeName = toWrite->getNodeName();
    const XMLCh* nodeValue = toWrite->getNodeValue();


	switch (toWrite->getNodeType())
    {
		case DOMNode::TEXT_NODE:
        {
            outputContent(target, nodeValue);
            break;
        }

        case DOMNode::PROCESSING_INSTRUCTION_NODE :
        {
            target  << XMLStrL("<?")
                    << nodeName
                    << XMLStrL(' ')
                    << nodeValue
                    << XMLStrL("?>");
            break;
        }

        case DOMNode::DOCUMENT_NODE :
        {
            //
            //  Bug here:  we need to find a way to get the encoding name
            //  for the default code page on the system where the program
            //  is running, and plug that in for the encoding name.
            //
            XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument* document=(XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument*)toWrite;
            target << XMLStrL("<?xml version=\"") << document->getVersion() << XMLStrL("\"");
            const XMLCh* str = document->getEncoding();
            if (str != 0)
                target << XMLStrL(" encoding=\"") << str << XMLStrL("\"");
            if(document->getStandalone())
                target << XMLStrL(" standalone=\"yes\"");
            target << XMLStrL("?>");

            DOMNode* child = toWrite->getFirstChild();
            while( child != 0)
            {
                target << child;
                child = child->getNextSibling();
            }
            break;
        }

        case DOMNode::ELEMENT_NODE :
        {
            // Output the element start tag.
            target << XMLStrL('<') << nodeName;

            // Output any attributes on this element
            DOMNamedNodeMap* attributes = toWrite->getAttributes();
            int attrCount = attributes->getLength();
            for (int i = 0; i < attrCount; i++)
            {
                DOMNode*  attribute = attributes->item(i);

                target  << XMLStrL(' ') << attribute->getNodeName()
                        << XMLStrL(" = \"");
                        //  Note that "<" must be escaped in attribute values.
                        outputContent(target, attribute->getNodeValue());
                        target << XMLStrL('"');
            }

            //
            //  Test for the presence of children, which includes both
            //  text content and nested elements.
            //
            DOMNode* child = toWrite->getFirstChild();
            if (child != 0)
            {
                // There are children. Close start-tag, and output children.
                target << XMLStrL(">");
                while( child != 0)
                {
                    target << child;
                    child = child->getNextSibling();
                }

                // Done with children.  Output the end tag.
                target << XMLStrL("</") << nodeName << XMLStrL(">");
            }
            else
            {
                //
                //  There were no children. Output the short form close of
                //  the element start tag, making it an empty-element tag.
                //
                target << XMLStrL("/>");
            }
            break;
        }

        case DOMNode::ENTITY_REFERENCE_NODE:
        {
            DOMNode* child;
            for (child = toWrite->getFirstChild(); child != 0; child = child->getNextSibling())
                target << child;
            break;
        }

        case DOMNode::CDATA_SECTION_NODE:
        {
            target << XMLStrL("<![CDATA[") << nodeValue << XMLStrL("]]>");
            break;
        }

        case DOMNode::COMMENT_NODE:
        {
            target << XMLStrL("<!--") << nodeValue << XMLStrL("-->");
            break;
        }

        case DOMNode::DOCUMENT_TYPE_NODE:
        {
			DOMDocumentType* doctype = (DOMDocumentType*)toWrite;;

			target << XMLStrL("<!DOCTYPE ") << nodeName ;
			const XMLCh* id = doctype->getPublicId();
			if (id != 0)
				target << XMLStrL(" PUBLIC \"") << id << XMLStrL("\"");
			id = doctype->getSystemId();
			if (id != 0)
				target << XMLStrL(" SYSTEM \"") << id << XMLStrL("\"");
			id = doctype->getInternalSubset();
			if (id !=0)
				target << XMLStrL(" [ ") << id  << XMLStrL("]");
			target  << XMLStrL(">");
            break;
        }
		case DOMNode::ENTITY_NODE:
        {
			DOMEntity* entity = (DOMEntity*)toWrite;;

			target << XMLStrL("<!ENTITY ") << nodeName;
			const XMLCh* id = entity->getPublicId();
			if (id != 0)
				target << XMLStrL("PUBLIC \"") << id << XMLStrL("\"");
			id = entity->getSystemId();
			if (id != 0)
				target << XMLStrL("SYSTEM \"") << id << XMLStrL("\"");
			id = entity->getNotationName();
			if (id != 0)
				target << XMLStrL("NDATA \"") << id << XMLStrL("\"");

            break;
        }
        default:
            target << XMLStrL("<!-- Unrecognized node type -->");
    }
	return target;
}

void GetXML(const DOMNode* node, _bstr_t &text)
{
	xmlstream stream;
	stream << node;
	text = _bstr_t(stream.SysAllocString(),false);
}


--- NEW FILE: XMLDOMCDATASection.h ---
/*
 * Copyright 1999-2001,2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * $Id: XMLDOMCDATASection.h,v 1.1 2008/02/19 20:16:27 zolmol Exp $
 */

#ifndef ___xmldomcdatasection_h___
#define ___xmldomcdatasection_h___

#include <xercesc/dom/DOMCDATASection.hpp>
#include "IXMLDOMTextImpl.h"
XERCES_CPP_NAMESPACE_USE

class ATL_NO_VTABLE CXMLDOMCDATASection :
	public CComObjectRootEx<CComSingleThreadModel>,
	public IXMLDOMTextImpl<IXMLDOMCDATASection, &IID_IXMLDOMCDATASection>
{
public:
	CXMLDOMCDATASection()
	{}

	void	FinalRelease()
	{
		ReleaseOwnerDoc();
	}

	virtual DOMText* get_DOMText()			 { return cdataSection;}
	virtual DOMNodeType get_DOMNodeType() const  { return NODE_CDATA_SECTION; }

DECLARE_NOT_AGGREGATABLE(CXMLDOMCDATASection)

DECLARE_PROTECT_FINAL_CONSTRUCT()

BEGIN_COM_MAP(CXMLDOMCDATASection)
	COM_INTERFACE_ENTRY(IXMLDOMCDATASection)
	COM_INTERFACE_ENTRY(IXMLDOMText)
	COM_INTERFACE_ENTRY(IXMLDOMCharacterData)
	COM_INTERFACE_ENTRY(IXMLDOMNode)
	COM_INTERFACE_ENTRY(IIBMXMLDOMNodeIdentity)
	COM_INTERFACE_ENTRY(ISupportErrorInfo)
	COM_INTERFACE_ENTRY(IDispatch)
END_COM_MAP()

	DOMCDATASection* cdataSection;
};

typedef CComObject<CXMLDOMCDATASection> CXMLDOMCDATASectionObj;

#endif // ___xmldomcdatasection_h___
--- NEW FILE: XMLDOMEntity.h ---
/*
 * Copyright 1999-2000,2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * $Id: XMLDOMEntity.h,v 1.1 2008/02/19 20:16:27 zolmol Exp $
 */

#ifndef ___xmldomentity_h___
#define ___xmldomentity_h___

#include <xercesc/dom/DOMEntity.hpp>
#include "IXMLDOMNodeImpl.h"

XERCES_CPP_NAMESPACE_USE

class ATL_NO_VTABLE CXMLDOMEntity : 
	public CComObjectRootEx<CComSingleThreadModel>,
	public IXMLDOMNodeImpl<IXMLDOMEntity, &IID_IXMLDOMEntity>
{
public:
	CXMLDOMEntity()
	{}

	void	FinalRelease()
	{
		ReleaseOwnerDoc();
	}

	virtual DOMNode* get_DOMNode()			 { return entity;} 
	virtual DOMNodeType get_DOMNodeType() const  { return NODE_ENTITY; }

DECLARE_NOT_AGGREGATABLE(CXMLDOMEntity)
DECLARE_PROTECT_FINAL_CONSTRUCT()

BEGIN_COM_MAP(CXMLDOMEntity)
	COM_INTERFACE_ENTRY(IXMLDOMEntity)
	COM_INTERFACE_ENTRY(IXMLDOMNode)
	COM_INTERFACE_ENTRY(IIBMXMLDOMNodeIdentity)
	COM_INTERFACE_ENTRY(IDispatch)
END_COM_MAP()

	// IXMLDOMEntity methods
	STDMETHOD(get_publicId)(VARIANT  *pVal);
	STDMETHOD(get_systemId)(VARIANT  *pVal);
	STDMETHOD(get_notationName)(BSTR  *pVal);

	DOMEntity* entity;
};

typedef CComObject<CXMLDOMEntity> CXMLDOMEntityObj;

#endif // ___xmldomentity_h___
--- NEW FILE: xml4comps.def ---

LIBRARY      "xml4comPS"

DESCRIPTION  'Proxy/Stub DLL'

EXPORTS
	DllGetClassObject       @1	PRIVATE
	DllCanUnloadNow         @2	PRIVATE
	GetProxyDllInfo         @3	PRIVATE
	DllRegisterServer		@4	PRIVATE
	DllUnregisterServer		@5	PRIVATE

--- NEW FILE: StdAfx.h ---
/*
 * Copyright 1999-2000,2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * $Id: StdAfx.h,v 1.1 2008/02/19 20:16:27 zolmol Exp $
 */

// stdafx.h : include file for standard system include files,
//      or project specific include files that are used frequently,
//      but are changed infrequently

#if !defined(AFX_STDAFX_H__975CB5CC_234E_4CA0_940E_DA102634BF51__INCLUDED_)
#define AFX_STDAFX_H__975CB5CC_234E_4CA0_940E_DA102634BF51__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#define STRICT
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0400
#endif
#define _ATL_APARTMENT_THREADED

#define DOMDocument _MSXMLDOMDocument
#define XMLHTTPRequest _MSXMLHTTPRequest
#define CLSID_DOMDocument CLSID_MSDOMDocument
#define CLSID_XMLHTTPRequest CLSID_MSXMLHTTPRequest

//
//   suppress MSXML.H since we duplicate some of the information
//      in xml4com.h
//

#include <atlbase.h>
//You may derive a class from CComModule and use it if you want to override
//something, but do not change the name of _Module
extern CComModule _Module;
#include <atlcom.h>
#include <atlctl.h>
#include <comdef.h>
#include <ExDisp.h>
#include <ShlGuid.h>
#include <stdio.h>
#include <process.h>
#include <Wininet.h>

#undef DOMDocument
#undef XMLHTTPRequest
#undef CLSID_DOMDocument
#undef CLSID_XMLHTTPRequest

//
//   These are defined in xml4dom_i.c which is included in xml4dom.cpp
//
//
extern const IID CLSID_DOMDocument;
extern const IID CLSID_XMLHTTPRequest;
extern const IID LIBID_Xerces;

const long	MSG_READY_STATE_CHANGE = WM_APP + 0x0001;


//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_STDAFX_H__975CB5CC_234E_4CA0_940E_DA102634BF51__INCLUDED)

--- NEW FILE: StdAfx.cpp ---
// stdafx.cpp : source file that includes just the standard includes
//  stdafx.pch will be the pre-compiled header
//  stdafx.obj will contain the pre-compiled type information

#include "stdafx.h"

#if defined(_ATL_STATIC_REGISTRY)
#include <statreg.h>
#if defined(_MSC_VER) && _MSC_VER < 1300
#include <statreg.cpp>
#endif
#endif

#if defined(_MSC_VER) && _MSC_VER < 1300
#include <atlimpl.cpp>
#endif

//
//   This macro is defined in MSXML.H's compatible with IE5
//      and not defined in those from IE4.
//
//   To correct, install a IE5 or later version of the Microsoft Platform SDK
//      and add \Program Files\Microsoft Platform SDK\Include as the first entry
//      on the Directories tab on the dialog displayed after selecting Tools Options
//      from the Visual Studio IDE.
//
#ifndef __IXMLDOMNode_INTERFACE_DEFINED__
#error "xerces-dom requires an MSXML.H compatible with IE5 or later.  See http://xml.apache.org/xerces-c/build.html#BuildCOM for directions to correct this problem."
#endif


--- NEW FILE: XMLDOMUtil.h ---
/*
 * Copyright 1999-2000,2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * $Id: XMLDOMUtil.h,v 1.1 2008/02/19 20:16:27 zolmol Exp $
 */

#ifndef ___wrapnode_h___
#define ___wrapnode_h___

#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/dom/DOMNode.hpp>
XERCES_CPP_NAMESPACE_USE

extern const OLECHAR* g_DomNodeName[];
extern const int	g_DomNodeNameSize;

void GetXML (const DOMNode* node, _bstr_t &text);
HRESULT wrapNode(IXMLDOMDocument *pDoc, DOMNode* node, REFIID iid, LPVOID *pVal);



#endif // ___wrapnode_h___
--- NEW FILE: resource.h ---
/*
 * Copyright 1999-2000,2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * $Id: resource.h,v 1.1 2008/02/19 20:16:27 zolmol Exp $
 */

//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by xml4com.rc
//
#define IDS_PROJNAME                    100
#define IDR_XMLDOCUMENT                 203
#define IDR_XMLHTTPREQUEST              204

// Next default values for new objects
// 
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE        205
#define _APS_NEXT_COMMAND_VALUE         32768
#define _APS_NEXT_CONTROL_VALUE         201
#define _APS_NEXT_SYMED_VALUE           101
#endif
#endif

--- NEW FILE: XMLDOMProcessingInstruction.cpp ---
/*
 * Copyright 1999-2001,2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * $Id: XMLDOMProcessingInstruction.cpp,v 1.1 2008/02/19 20:16:27 zolmol Exp $
 */

#include "stdafx.h"
#include "xml4com.h"
#include "XMLDOMProcessingInstruction.h"

// IXMLDOMProcessingInstruction methods
STDMETHODIMP CXMLDOMProcessingInstruction::get_target(BSTR  *pVal)
{
	ATLTRACE(_T("CXMLDOMProcessingInstruction::get_target\n"));

	if (NULL == pVal)
		return E_POINTER;

	*pVal = NULL;

	try
	{
		*pVal = SysAllocString(processingInstruction->getTarget());
	}
	catch(DOMException& ex)
	{
		return MakeHRESULT(ex);
	}

	catch(...)
	{
		return E_FAIL;
	}

	return S_OK;
}

STDMETHODIMP CXMLDOMProcessingInstruction::get_data(BSTR  *pVal)
{
	ATLTRACE(_T("CXMLDOMProcessingInstruction::get_data\n"));

	if (NULL == pVal)
		return E_POINTER;

	*pVal = NULL;

	try
	{
		*pVal = SysAllocString(processingInstruction->getData());
	}
	catch(DOMException& ex)
	{
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}

	return S_OK;

}

STDMETHODIMP CXMLDOMProcessingInstruction::put_data(BSTR newVal)
{
	ATLTRACE(_T("CXMLDOMProcessingInstruction::put_data\n"));

	try
	{
		processingInstruction->setData(newVal);
	}
	catch(DOMException& ex)
	{
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}
	
	return S_OK;
}

--- NEW FILE: IXMLDOMNodeImpl.h ---
/*
 * Copyright 1999-2001,2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * $Id: IXMLDOMNodeImpl.h,v 1.1 2008/02/19 20:16:27 zolmol Exp $
 */

#ifndef ___ixmldomnodeimpl_h___
#define ___ixmldomnodeimpl_h___

#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/dom/DOMException.hpp>
XERCES_CPP_NAMESPACE_USE


//
//   This macro is defined in MSXML.H's compatible with IE5
//      and not defined in those from IE4.
//
//   To correct, install a IE5 or later version of the Microsoft Platform SDK
//      and add \Program Files\Microsoft Platform SDK\Include as the first entry
//      on the Directories tab on the dialog displayed after selecting Tools Options
//      from the Visual Studio IDE.
//
//   See http://xml.apache.org/xerces-c/build.html#BuildCOM
#ifndef __IXMLDOMNode_INTERFACE_DEFINED__
#error "xerces-dom requires an MSXML.H compatible with IE5 or later.  See http://xml.apache.org/xerces-c/build.html#BuildCOM for directions to correct this problem."
#endif


template <class T, const IID* piid, class tihclass = CComTypeInfoHolder>
class ATL_NO_VTABLE IXMLDOMNodeImpl:
	public IDispatchImpl<T,piid,&LIBID_Xerces, XERCES_VERSION_MAJOR, INVK_CAT2_RAW_NUMERIC(XERCES_VERSION_MINOR,XERCES_VERSION_REVISION),tihclass>,
	public IIBMXMLDOMNodeIdentity,
	public ISupportErrorInfo
{
public:

	IXMLDOMNodeImpl()
		:m_pIXMLDOMDocument(NULL)
	{}

	virtual DOMNode* get_DOMNode()		    = 0;
	virtual DOMNodeType get_DOMNodeType() const = 0;

	void	SetOwnerDoc(IXMLDOMDocument	*p)
	{
		m_pIXMLDOMDocument = p;
		if (m_pIXMLDOMDocument != NULL)
			m_pIXMLDOMDocument->AddRef();
	}

	// IIBMXMLDOMNodeIdentity
	STDMETHOD(get_NodeId)(long *pVal)
	{
		ATLTRACE(_T("IXMLDOMNodeImpl::get_NodeId\n"));

		if (NULL == pVal)
			return E_POINTER;

		*pVal = reinterpret_cast<long> (get_DOMNode());
		return S_OK;
	}

	//   ISupportErrorInfo
	HRESULT STDMETHODCALLTYPE InterfaceSupportsErrorInfo(REFIID iid);
	

	// IXMLDOMNode
    STDMETHOD(get_nodeName)(BSTR  *pVal);
	STDMETHOD(get_nodeValue)(VARIANT  *pVal);
	STDMETHOD(put_nodeValue)(VARIANT newVal);
	STDMETHOD(get_nodeType)(DOMNodeType  *pVal);
	STDMETHOD(get_parentNode)(IXMLDOMNode  * *pVal);
	STDMETHOD(get_childNodes)(IXMLDOMNodeList  * *pVal);
	STDMETHOD(get_firstChild)(IXMLDOMNode  * *pVal);
	STDMETHOD(get_lastChild)(IXMLDOMNode  * *pVal);
	STDMETHOD(get_previousSibling)(IXMLDOMNode  * *pVal);
	STDMETHOD(get_nextSibling)(IXMLDOMNode  * *pVal);
	STDMETHOD(get_attributes)(IXMLDOMNamedNodeMap  * *pVal);
	STDMETHOD(insertBefore)(IXMLDOMNode  *newChild, VARIANT refChild, IXMLDOMNode  * *outNewChild);
	STDMETHOD(replaceChild)(IXMLDOMNode  *newChild, IXMLDOMNode  *oldChild, IXMLDOMNode  * *outNewChild);
	STDMETHOD(removeChild)(IXMLDOMNode  *childNode, IXMLDOMNode  * *oldChild);
	STDMETHOD(appendChild)(IXMLDOMNode  *newChild, IXMLDOMNode  * *outNewChild);
	STDMETHOD(hasChildNodes)(VARIANT_BOOL  *hasChild);
	STDMETHOD(get_ownerDocument)(IXMLDOMDocument  * *pVal);
	STDMETHOD(cloneNode)(VARIANT_BOOL deep, IXMLDOMNode  * *cloneRoot);
	STDMETHOD(get_nodeTypeString)(BSTR  *pVal);
	STDMETHOD(get_text)(BSTR  *pVal);
	STDMETHOD(put_text)(BSTR newVal);
	STDMETHOD(get_specified)(VARIANT_BOOL  *pVal);
	STDMETHOD(get_definition)(IXMLDOMNode  * *pVal);
	STDMETHOD(get_nodeTypedValue)(VARIANT  *pVal);
	STDMETHOD(put_nodeTypedValue)(VARIANT newVal);
	STDMETHOD(get_dataType)(VARIANT  *pVal);
	STDMETHOD(put_dataType)(BSTR dataTypeName);
	STDMETHOD(get_xml)(BSTR  *pVal);
	STDMETHOD(transformNode)(IXMLDOMNode  *stylesheet, BSTR  *xmlString);
	STDMETHOD(selectNodes)(BSTR queryString, IXMLDOMNodeList  * *resultList);
	STDMETHOD(selectSingleNode)(BSTR queryString, IXMLDOMNode  * *resultNode);
	STDMETHOD(get_parsed)(VARIANT_BOOL  *pVal);
	STDMETHOD(get_namespaceURI)(BSTR  *pVal);
	STDMETHOD(get_prefix)(BSTR  *pVal);
	STDMETHOD(get_baseName)(BSTR  *pVal);
	STDMETHOD(transformNodeToObject)(IXMLDOMNode  *stylesheet, VARIANT outputObject);

protected:

	IXMLDOMDocument	*m_pIXMLDOMDocument;
	
	void	ReleaseOwnerDoc()
	{
		if (m_pIXMLDOMDocument != NULL) {
			m_pIXMLDOMDocument->Release();
			m_pIXMLDOMDocument = NULL;
		}
	}

};

HRESULT MakeHRESULT(DOMException& ex);

#include "IXMLDOMNodeImpl.inl"

#endif // ___ixmldomnodeimpl_h___

--- NEW FILE: XMLDOMDocument.h ---
/*
 * Copyright 1999-2001,2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * $Id: XMLDOMDocument.h,v 1.1 2008/02/19 20:16:27 zolmol Exp $
 */

#ifndef ___xmldomdocument_h___
#define ___xmldomdocument_h___

#include <xercesc/dom/DOMDocument.hpp>
#include "IXMLDOMNodeImpl.h"

#include "resource.h"       // main symbols
#include "XMLDOMParseError.h"

#include <xercesc/sax/ErrorHandler.hpp>
#include "xml4comCP.h"

XERCES_CPP_NAMESPACE_USE

class XERCES_CPP_NAMESPACE_QUALIFIER SAXParseException;

class ATL_NO_VTABLE CXMLDOMDocument :
	public CComObjectRootEx<CComSingleThreadModel>,
	public CComCoClass<CXMLDOMDocument, &CLSID_DOMDocument>,
	public IObjectSafetyImpl<CXMLDOMDocument, INTERFACESAFE_FOR_UNTRUSTED_CALLER>,
	public IXMLDOMNodeImpl<IXMLDOMDocument, &IID_IXMLDOMDocument>,
	public IObjectWithSiteImpl<CXMLDOMDocument>,
	public CProxyXMLDOMDocumentEvents< CXMLDOMDocument >,
	public IConnectionPointContainerImpl<CXMLDOMDocument>,
	public IProvideClassInfo2Impl<&CLSID_DOMDocument, &DIID_XMLDOMDocumentEvents, &LIBID_Xerces, XERCES_VERSION_MAJOR, INVK_CAT2_RAW_NUMERIC(XERCES_VERSION_MINOR,XERCES_VERSION_REVISION)>,
	public CWindowImpl<CXMLDOMDocument, CWindow, CWinTraits<0,0> >,
	ErrorHandler
{
public:
	CXMLDOMDocument();

	HRESULT FinalConstruct();
	void	FinalRelease();

	virtual DOMNode*        get_DOMNode()		    { return m_Document;}
    virtual DOMNodeType     get_DOMNodeType() const { return NODE_DOCUMENT; }

	virtual void resetErrors() {};

	//DECLARE_REGISTRY_RESOURCEID(IDR_XMLDOCUMENT)
	static HRESULT WINAPI UpdateRegistry(BOOL bRegister);

DECLARE_NOT_AGGREGATABLE(CXMLDOMDocument)

DECLARE_PROTECT_FINAL_CONSTRUCT()

BEGIN_COM_MAP(CXMLDOMDocument)
	COM_INTERFACE_ENTRY(IXMLDOMDocument)
	COM_INTERFACE_ENTRY(IXMLDOMNode)
	COM_INTERFACE_ENTRY(IDispatch)
	COM_INTERFACE_ENTRY(IIBMXMLDOMNodeIdentity)
	COM_INTERFACE_ENTRY(IObjectSafety)
	COM_INTERFACE_ENTRY(IObjectWithSite)
	COM_INTERFACE_ENTRY(ISupportErrorInfo)
	COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer)
	COM_INTERFACE_ENTRY(IProvideClassInfo)
	COM_INTERFACE_ENTRY(IProvideClassInfo2)
	COM_INTERFACE_ENTRY(ISupportErrorInfo)
END_COM_MAP()

BEGIN_CONNECTION_POINT_MAP(CXMLDOMDocument)
	CONNECTION_POINT_ENTRY(DIID_XMLDOMDocumentEvents)
END_CONNECTION_POINT_MAP()

	DECLARE_WND_CLASS(_T("XMLParseMonitor"))

BEGIN_MSG_MAP(CMonitorWnd)
	MESSAGE_HANDLER(MSG_READY_STATE_CHANGE,	OnReadyStateChange)
END_MSG_MAP()

	LRESULT OnReadyStateChange(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);

	// ISupportsErrorInfo
	STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);

	// IXMLDOMDocument methods
	STDMETHOD(get_doctype)(IXMLDOMDocumentType  * *pVal);
	STDMETHOD(get_implementation)(IXMLDOMImplementation  * *pVal);
	STDMETHOD(get_documentElement)(IXMLDOMElement  * *pVal);
	STDMETHOD(putref_documentElement)(IXMLDOMElement  *newVal);
	STDMETHOD(createElement)(BSTR tagName, IXMLDOMElement  * *element);
	STDMETHOD(createDocumentFragment)(IXMLDOMDocumentFragment  * *docFrag);
	STDMETHOD(createTextNode)(BSTR data, IXMLDOMText  * *text);
	STDMETHOD(createComment)(BSTR data, IXMLDOMComment  * *comment);
	STDMETHOD(createCDATASection)(BSTR data, IXMLDOMCDATASection  * *cdata);
	STDMETHOD(createProcessingInstruction)(BSTR target, BSTR data, IXMLDOMProcessingInstruction  * *pVal);
	STDMETHOD(createAttribute)(BSTR name, IXMLDOMAttribute  * *attr);
	STDMETHOD(createEntityReference)(BSTR name, IXMLDOMEntityReference  * *entityRef);
	STDMETHOD(getElementsByTagName)(BSTR tagName, IXMLDOMNodeList  * *resultList);
	STDMETHOD(createNode)(VARIANT type, BSTR name, BSTR namespaceURI, IXMLDOMNode  * *node);
	STDMETHOD(nodeFromID)(BSTR idString, IXMLDOMNode  * *node);
	STDMETHOD(load)(VARIANT xmlSource, VARIANT_BOOL  *isSuccessful);
	STDMETHOD(get_readyState)(long  *pVal);
	STDMETHOD(get_parseError)(IXMLDOMParseError  * *pVal);
	STDMETHOD(get_url)(BSTR  *pVal);
	STDMETHOD(get_async)(VARIANT_BOOL  *pVal);
	STDMETHOD(put_async)(VARIANT_BOOL newVal);
	STDMETHOD(abort)(void);
	STDMETHOD(loadXML)(BSTR bstrXML, VARIANT_BOOL  *success);
	STDMETHOD(save)(VARIANT location);
	STDMETHOD(get_validateOnParse)(VARIANT_BOOL  *pVal);
	STDMETHOD(put_validateOnParse)(VARIANT_BOOL newVal);
	STDMETHOD(get_resolveExternals)(VARIANT_BOOL  *pVal);
	STDMETHOD(put_resolveExternals)(VARIANT_BOOL newVal);
	STDMETHOD(get_preserveWhiteSpace)(VARIANT_BOOL  *pVal);
	STDMETHOD(put_preserveWhiteSpace)(VARIANT_BOOL newVal);
	STDMETHOD(put_onreadystatechange)(VARIANT newVal);
	STDMETHOD(put_ondataavailable)(VARIANT newVal);
	STDMETHOD(put_ontransformnode)(VARIANT newVal);

	// Error handling
	virtual void warning(const SAXParseException& exc);
	virtual void error(const SAXParseException& exc);
    virtual void fatalError(const SAXParseException& exc);

	bool IsAbort() const { return m_bAbort; }

	XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument*		  m_Document;

private:

	bool				  m_bValidate;
	long				  m_lReadyState;
	_bstr_t			      m_url;
	CXMLDOMParseErrorObj *m_pParseError;
	bool			      m_bAsync;	
	bool				  m_bAbort;
	HANDLE				  m_hParseThread;
	LPDISPATCH			  m_pOnReadyStateChange;
	LPDISPATCH			  m_pOnDataAvailable;
	LPDISPATCH			  m_pOnTransformNode;

	// thread data
	_bstr_t				  m_FileName;
	_bstr_t				  m_xml;
	XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument*		  m_TmpDocument;
	bool			      m_bParseError;
	bool				  m_bThreadValidate;
	bool                  m_bPreserveWhiteSpace;
	
	HRESULT GetBaseURL(_bstr_t &baseURL);
	
	static UINT APIENTRY ParseThread(void *pParm);
};

typedef CComObject<CXMLDOMDocument> CXMLDOMDocumentObj;

#endif // ___xmldomdocument_h___
--- NEW FILE: IXMLDOMTextImpl.h ---
/*
 * Copyright 1999-2000,2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * $Id: IXMLDOMTextImpl.h,v 1.1 2008/02/19 20:16:27 zolmol Exp $
 */

#ifndef ___ixmldomtextimpl_h___
#define ___ixmldomtextimpl_h___

#include "XMLDOMUtil.h"
#include "IXMLDOMCharacterDataImpl.h"

template <class T, const IID* piid, class tihclass = CComTypeInfoHolder>
class ATL_NO_VTABLE IXMLDOMTextImpl: public IXMLDOMCharacterDataImpl<T,piid,tihclass>
{
public:

	virtual DOMText* get_DOMText() = 0; 
	virtual DOMCharacterData* get_DOMCharacterData() { return get_DOMText(); } 

	// IXMLDOMText

STDMETHOD(splitText)(long offset, IXMLDOMText  **rightHandTextNode)
{
	ATLTRACE(_T("IXMLDOMTextImpl::splitText\n"));

	if (NULL == rightHandTextNode)
		return E_POINTER;

	*rightHandTextNode = NULL;

	HRESULT hr = S_OK;

	try
	{
		hr = wrapNode(m_pIXMLDOMDocument,get_DOMText()->splitText(offset),IID_IXMLDOMText, reinterpret_cast<LPVOID *> (rightHandTextNode));
	}
	catch(...)
	{
		return E_FAIL;
	}
	
	return hr;
}

};

#endif // ___ixmldomtextimpl_h___
--- NEW FILE: XMLHttpRequest.h ---
/*
 * Copyright 1999-2000,2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * $Id: XMLHttpRequest.h,v 1.1 2008/02/19 20:16:27 zolmol Exp $
 */

#ifndef ___xmlhttprequest_h___
#define ___xmlhttprequest_h___

#include <xercesc/dom/DOMDocument.hpp>
#include "IXMLDOMNodeImpl.h"

#include "resource.h"       // main symbols

class ATL_NO_VTABLE CXMLHttpRequest : 
	public CComObjectRootEx<CComSingleThreadModel>,
	public CComCoClass<CXMLHttpRequest, &CLSID_XMLHTTPRequest>,
	public IObjectSafetyImpl<CXMLHttpRequest, INTERFACESAFE_FOR_UNTRUSTED_CALLER>,
	public IDispatchImpl<IXMLHttpRequest, &IID_IXMLHttpRequest, &LIBID_Xerces, XERCES_VERSION_MAJOR, INVK_CAT2_RAW_NUMERIC(XERCES_VERSION_MINOR,XERCES_VERSION_REVISION)>,
	public IObjectWithSiteImpl<CXMLHttpRequest>,
	public ISupportErrorInfo,
	public CWindowImpl<CXMLHttpRequest, CWindow, CWinTraits<0,0> >
{
public:
	CXMLHttpRequest();

	HRESULT FinalConstruct();
	void	FinalRelease();

	//DECLARE_REGISTRY_RESOURCEID(IDR_XMLHTTPREQUEST)
	static HRESULT WINAPI UpdateRegistry(BOOL bRegister);

DECLARE_NOT_AGGREGATABLE(CXMLHttpRequest)

DECLARE_PROTECT_FINAL_CONSTRUCT()

BEGIN_COM_MAP(CXMLHttpRequest)
	COM_INTERFACE_ENTRY(IXMLHttpRequest)
	COM_INTERFACE_ENTRY(IDispatch)
	COM_INTERFACE_ENTRY(IObjectSafety)
	COM_INTERFACE_ENTRY(IObjectWithSite)
	COM_INTERFACE_ENTRY(ISupportErrorInfo)
END_COM_MAP()

	DECLARE_WND_CLASS(_T("XMLHttpRequestMonitor")) 

BEGIN_MSG_MAP(CMonitorWnd)
	MESSAGE_HANDLER(MSG_READY_STATE_CHANGE,	OnReadyStateChange)
END_MSG_MAP()

	LRESULT OnReadyStateChange(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);


	// ISupportsErrorInfo
	STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);

	// IXMLHttpRequest methods
	STDMETHOD(open)(/*[in]*/ BSTR bstrMethod, /*[in]*/ BSTR bstrUrl, /*[in,optional]*/ VARIANT varAsync, /*[in,optional]*/ VARIANT bstrUser, /*[in,optional]*/ VARIANT bstrPassword);
	STDMETHOD(setRequestHeader)(/*[in]*/ BSTR bstrHeader, /*[in]*/ BSTR bstrValue);
	STDMETHOD(getResponseHeader)(/*[in]*/ BSTR bstrHeader, /*[out, retval]*/ BSTR * pbstrValue);
	STDMETHOD(getAllResponseHeaders)(/*[out, retval]*/ BSTR * pbstrHeaders);
	STDMETHOD(send)(/*[in, optional]*/ VARIANT varBody);
	STDMETHOD(abort)();
	STDMETHOD(get_status)(/*[out, retval]*/ long * plStatus);
	STDMETHOD(get_statusText)(/*[out, retval]*/ BSTR * pbstrStatus);
	STDMETHOD(get_responseXML)(/*[out, retval]*/ IDispatch ** ppBody);
	STDMETHOD(get_responseText)(/*[out, retval]*/ BSTR * pbstrBody);
	STDMETHOD(get_responseBody)(/*[out, retval]*/ VARIANT * pvarBody);
	STDMETHOD(get_responseStream)(/*[out, retval]*/ VARIANT * pvarBody);
	STDMETHOD(get_readyState)(/*[out, retval]*/ long * plState);
	STDMETHOD(put_onreadystatechange)(/*[in]*/ IDispatch * pReadyStateSink);

private:

	LPDISPATCH	  m_pOnReadyStateChange;
	bool		  m_bAbort; 	
	HANDLE		  m_hThread;		
	long		  m_lReadyState;
	bool		  m_bAsync;	
	_bstr_t		  m_Method;
	_bstr_t		  m_HostName;	
	INTERNET_PORT m_Port;
	_bstr_t		  m_URLPath;
	_bstr_t		  m_User;
	_bstr_t		  m_Password;
	DWORD		  m_dwStatus;
	_bstr_t		  m_StatusText;	
	_bstr_t		  m_ResponseHeaders;
	CSimpleMap<_bstr_t, _bstr_t>  m_RequestHeaderMap;
	HWND		  m_HwndParent;		
 
	PBYTE		  m_pBody;
	long		  m_lBodyLength;
	PBYTE		  m_pResponseBody;
	long		  m_lResponseBodyLength;
	_bstr_t	      m_Error;	
	bool	      m_bSuccess;

	HWND GetParentWindow();

	static _bstr_t GetErrorMsg(DWORD rc);
	static void CALLBACK InternetStatusCallback(HINTERNET hInternet,
												DWORD dwContext,
												DWORD dwInternetStatus,
												LPVOID lpvStatusInformation,
												DWORD dwStatusInformationLength);
	static UINT APIENTRY SendThread(void *pParm);
	static HRESULT InitializeVarFromByte(VARIANT &varOut, const PBYTE pByte, long lSize);
};

typedef CComObject<CXMLHttpRequest> CXMLHttpRequestObj;

#endif // ___xmlhttprequest_h___
--- NEW FILE: XMLDOMEntity.cpp ---
/*
 * Copyright 1999-2001,2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * $Id: XMLDOMEntity.cpp,v 1.1 2008/02/19 20:16:27 zolmol Exp $
 */

#include "stdafx.h"
#include "xml4com.h"
#include "XMLDOMEntity.h"

// IXMLDOMEntity methods
STDMETHODIMP CXMLDOMEntity::get_publicId(VARIANT  *pVal)
{
	ATLTRACE(_T("CXMLDOMEntity::get_publicId\n"));

	if (NULL == pVal)
		return E_POINTER;

	::VariantInit(pVal);

	try
	{
        const XMLCh* val=entity->getPublicId();
		if(val == NULL)
		{
			V_VT(pVal) = VT_NULL;
		}
		else
		{
			V_VT(pVal)   = VT_BSTR;
			V_BSTR(pVal) = SysAllocString(val);
		}
	}
	catch(DOMException& ex) {
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}
	
	return S_OK;
}

STDMETHODIMP CXMLDOMEntity::get_systemId(VARIANT  *pVal)
{
	ATLTRACE(_T("CXMLDOMEntity::get_systemId\n"));

	if (NULL == pVal)
		return E_POINTER;

	::VariantInit(pVal);

	try
	{
        const XMLCh* val=entity->getSystemId();
		if(val == NULL)
		{
			V_VT(pVal) = VT_NULL;
		}
		else
		{
			V_VT(pVal)   = VT_BSTR;
			V_BSTR(pVal) = SysAllocString(val);
		}
	}
	catch(DOMException& ex) {
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}
	
	return S_OK;
}

STDMETHODIMP CXMLDOMEntity::get_notationName(BSTR  *pVal)
{
	ATLTRACE(_T("CXMLDOMEntity::get_notationName\n"));

	if (NULL == pVal)
		return E_POINTER;

	*pVal = NULL;

	try
	{
		*pVal = SysAllocString(entity->getNotationName());
	}
	catch(DOMException& ex) {
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}

	return S_OK;
}

--- NEW FILE: XMLDOMXMLDecl.cpp ---
/*
 * Copyright 1999-2001,2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/*
 * $Id: XMLDOMXMLDecl.cpp,v 1.1 2008/02/19 20:16:27 zolmol Exp $
 */

#include "stdafx.h"
#include "xml4com.h"
#include "XMLDOMXMLDecl.h"

// IXMLDOMProcessingInstruction methods
STDMETHODIMP CXMLDOMXMLDecl::get_target(BSTR  *pVal)
{
	ATLTRACE(_T("CXMLDOMXMLDecl::get_target\n"));

	if (NULL == pVal)
		return E_POINTER;

	*pVal = NULL;

	try
	{
		*pVal = SysAllocString(OLESTR("xml"));
	}
	catch(...)
	{
		return E_FAIL;
	}

	return S_OK;
}

STDMETHODIMP CXMLDOMXMLDecl::get_data(BSTR  *pVal)
{
	ATLTRACE(_T("CXMLDOMXMLDecl::get_data\n"));

	if (NULL == pVal)
		return E_POINTER;

	*pVal = NULL;

	try
	{
        *pVal = SysAllocString(xmlDecl->getTarget());
	}
	catch(DOMException& ex)
	{
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}

	return S_OK;

}

STDMETHODIMP CXMLDOMXMLDecl::put_data(BSTR newVal)
{
	ATLTRACE(_T("CXMLDOMXMLDecl::put_data\n"));

	return E_NOTIMPL;
}

--- NEW FILE: XMLDOMNamedNodeMap.cpp ---
/*
 * Copyright 1999-2001,2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * $Id: XMLDOMNamedNodeMap.cpp,v 1.1 2008/02/19 20:16:27 zolmol Exp $
 */

#include "stdafx.h"
#include "xml4com.h"
#include "XMLDOMNamedNodeMap.h"
#include "XMLDOMUtil.h"
#include "IXMLDOMNodeImpl.h"

typedef CComEnumOnSTL<IEnumVARIANT, &IID_IEnumVARIANT, VARIANT, _Copy<VARIANT>, NodeContainerImpl<DOMNamedNodeMap> >
		CComEnumUnknownOnNamedNodeContainer;

STDMETHODIMP CXMLDOMNamedNodeMap::getNamedItem(BSTR name, IXMLDOMNode  **pVal)
{
	ATLTRACE(_T("CXMLDOMNamedNodeMap::getNamedItem\n"));

	if (NULL == pVal)
		return E_POINTER;

	*pVal = NULL;
	HRESULT hr = S_OK;

	if (m_container == 0)
		return S_OK;

	try
	{
		DOMNode* n = m_container->getNamedItem(name);
		if(n!=NULL)
			hr = wrapNode(m_pIXMLDOMDocument,n,IID_IXMLDOMNode, reinterpret_cast<LPVOID *> (pVal));
	}
	catch(DOMException& ex)
	{
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}
	
	return hr;
}

STDMETHODIMP CXMLDOMNamedNodeMap::setNamedItem(IXMLDOMNode  *newItem, IXMLDOMNode  **pVal)
{
	ATLTRACE(_T("CXMLDOMNamedNodeMap::setNamedItem\n"));

	if (NULL == pVal)
		return E_POINTER;

	*pVal = NULL;

	if (m_container == 0)
		return S_OK;

	if (NULL == newItem)
		return E_INVALIDARG;

	CComQIPtr<IIBMXMLDOMNodeIdentity,&IID_IIBMXMLDOMNodeIdentity> pNewItem(newItem);
	if (!pNewItem)
		return E_NOINTERFACE;

	long id = 0;
	HRESULT hr = pNewItem->get_NodeId(&id);
	if (S_OK != hr)
		return hr;

	DOMNode *pNewItemNode = reinterpret_cast<DOMNode*> (id);
	if (NULL == pNewItemNode)
		return E_INVALIDARG;

	try
	{
		const XMLCh* name = pNewItemNode->getNodeName();
		//
		//  returns old node
		//
		DOMNode* n = m_container->setNamedItem(pNewItemNode);
		if(n!=NULL)
			hr = wrapNode(m_pIXMLDOMDocument,n,IID_IXMLDOMNode, reinterpret_cast<LPVOID *> (pVal));
	}
	catch(DOMException& ex)
	{
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}

	return hr;
}

STDMETHODIMP CXMLDOMNamedNodeMap::removeNamedItem(BSTR name, IXMLDOMNode  **pVal)
{
	ATLTRACE(_T("CXMLDOMNamedNodeMap::removeNamedItem\n"));
	
	if (NULL == pVal)
		return E_POINTER;

	*pVal = NULL;
	HRESULT hr = S_OK;

	if (m_container == 0)
		return S_OK;

	try
	{
		DOMNode* n = m_container->removeNamedItem(name);
		if(n!=NULL)
			hr = wrapNode(m_pIXMLDOMDocument,n,IID_IXMLDOMNode, reinterpret_cast<LPVOID *> (pVal));
	}
	//
	//   if we had a failure, return success anyway
	//
	catch(...)
	{
	}
	
	return hr;
}

STDMETHODIMP CXMLDOMNamedNodeMap::get_item(long index, IXMLDOMNode  **pVal)
{
	ATLTRACE(_T("CXMLDOMNamedNodeMap::get_item\n"));

	if (NULL == pVal)
		return E_POINTER;

	*pVal = NULL;
	HRESULT hr = S_OK;
	
	try
	{
		if (m_container == 0 || index < 0)
			return E_INVALIDARG;

		long length =  m_container->getLength();
		if (index < length)
			hr = wrapNode(m_pIXMLDOMDocument,m_container->item(index),IID_IXMLDOMNode, reinterpret_cast<LPVOID *> (pVal));
	}
	catch(DOMException& ex)
	{
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}
	
	return hr;
}

STDMETHODIMP CXMLDOMNamedNodeMap::get_length(long  *pVal)
{
	ATLTRACE(_T("CXMLDOMNamedNodeMap::get_length\n"));

	if (NULL == pVal)
		return E_POINTER;

	*pVal = 0;

	if (m_container == 0)
		return S_OK;

	try
	{
		*pVal = m_container->getLength();
	}
	catch(DOMException& ex)
	{
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}
	
	return S_OK;
}

STDMETHODIMP CXMLDOMNamedNodeMap::getQualifiedItem(BSTR baseName, BSTR namespaceURI, IXMLDOMNode  **pVal)
{
	ATLTRACE(_T("CXMLDOMNamedNodeMap::getQualifiedItem\n"));

	if (NULL == pVal)
		return E_POINTER;

	*pVal = NULL;
	
	if (m_container == 0)
		return S_OK;
	
	HRESULT hr = S_OK;

	try
	{
		DOMNode* n = m_container->getNamedItemNS(namespaceURI,baseName);
		if(n!=NULL)
			hr = wrapNode(m_pIXMLDOMDocument,n,IID_IXMLDOMNode, reinterpret_cast<LPVOID *> (pVal));
	}
	catch(DOMException& ex)
	{
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}

	return S_OK;
}

STDMETHODIMP CXMLDOMNamedNodeMap::removeQualifiedItem(BSTR baseName, BSTR namespaceURI, IXMLDOMNode  **pVal)
{
	ATLTRACE(_T("CXMLDOMNamedNodeMap::removeQualifiedItem\n"));

	if (NULL == pVal)
		return E_POINTER;

	*pVal = NULL;
	
	if (m_container == 0)
		return S_OK;
	
	HRESULT hr = S_OK;

	try
	{
		DOMNode* n = m_container->removeNamedItemNS(namespaceURI,baseName);
		if(n!=NULL)
			hr = wrapNode(m_pIXMLDOMDocument,n,IID_IXMLDOMNode, reinterpret_cast<LPVOID *> (pVal));
	}
	catch(DOMException& ex)
	{
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}

	return S_OK;
}

STDMETHODIMP CXMLDOMNamedNodeMap::nextNode(IXMLDOMNode  **pVal)
{
	ATLTRACE(_T("CXMLDOMNamedNodeMap::nextNode\n"));
	if (NULL == pVal)
		return E_POINTER;

	*pVal = NULL;

	if (m_container == 0)
		return S_OK;
	
	int length = m_container->getLength();
	if (0 == length)
		return S_OK;

	if (m_NextNodeIndex >= length)
		return S_OK;
	
	HRESULT hr = S_OK;

	try
	{
		DOMNode* n = m_container->item(m_NextNodeIndex);
		if(n!=NULL)
			hr = wrapNode(m_pIXMLDOMDocument,n,IID_IXMLDOMNode, reinterpret_cast<LPVOID *> (pVal));
	}
	catch(DOMException& ex)
	{
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}

	++m_NextNodeIndex;
	
	return hr;
}

STDMETHODIMP CXMLDOMNamedNodeMap::reset()
{
	ATLTRACE(_T("CXMLDOMNamedNodeMap::reset\n"));

	m_NextNodeIndex = 0;
	
	return S_OK;
}

STDMETHODIMP CXMLDOMNamedNodeMap::get__newEnum(IUnknown  **pVal)
{
	ATLTRACE(_T("CXMLDOMNamedNodeMap::get__newEnum\n"));

	if (NULL == pVal)
		return E_POINTER;

	*pVal = NULL;

	CComObject<CComEnumUnknownOnNamedNodeContainer> *pe = NULL;
	HRESULT hr = CComObject<CComEnumUnknownOnNamedNodeContainer>::CreateInstance(&pe);
	if (S_OK != hr)
		return hr;

	pe->AddRef();

	hr = pe->Init(GetUnknown(),*this);
	if (S_OK == hr)
		hr = pe->QueryInterface(pVal);

	pe->Release();

	return hr;
}

HRESULT CXMLDOMNamedNodeMap::InterfaceSupportsErrorInfo(REFIID riid)
{
	if(riid == IID_IXMLDOMNamedNodeMap) return S_OK;
	return S_FALSE;
}
--- NEW FILE: XMLDOMNodeList.h ---
/*
 * Copyright 1999-2001,2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * $Id: XMLDOMNodeList.h,v 1.1 2008/02/19 20:16:27 zolmol Exp $
 */

#ifndef ___xmldomnodelist_h___
#define ___xmldomnodelist_h___

#include <xercesc/dom/DOMNodeList.hpp>
#include "NodeContainerImpl.h"

XERCES_CPP_NAMESPACE_USE

class ATL_NO_VTABLE CXMLDOMNodeList :
	public CComObjectRootEx<CComSingleThreadModel>,
	public IDispatchImpl<IXMLDOMNodeList, &IID_IXMLDOMNodeList, &LIBID_Xerces, XERCES_VERSION_MAJOR, INVK_CAT2_RAW_NUMERIC(XERCES_VERSION_MINOR,XERCES_VERSION_REVISION)>,
	public NodeContainerImpl<DOMNodeList>,
	public ISupportErrorInfo
{
public:
	CXMLDOMNodeList()
	{}

	void FinalRelease()
	{
		ReleaseOwnerDoc();
	}

DECLARE_NOT_AGGREGATABLE(CXMLDOMNodeList)
DECLARE_PROTECT_FINAL_CONSTRUCT()

BEGIN_COM_MAP(CXMLDOMNodeList)
	COM_INTERFACE_ENTRY(IXMLDOMNodeList)
	COM_INTERFACE_ENTRY(IDispatch)
	COM_INTERFACE_ENTRY(ISupportErrorInfo)
END_COM_MAP()

	//   ISupportErrorInfo
	HRESULT STDMETHODCALLTYPE InterfaceSupportsErrorInfo(REFIID iid);
	

	// IXMLDOMNodeList
	STDMETHOD(get_item)(long index, IXMLDOMNode  **pVal);
	STDMETHOD(get_length)(long  *pVal);
	STDMETHOD(nextNode)(IXMLDOMNode  **nextItem);
	STDMETHOD(reset)();
	STDMETHOD(get__newEnum)(IUnknown  **pVal);
};
typedef CComObject<CXMLDOMNodeList> CXMLDOMNodeListObj;

#endif // ___xmldomnodelist_h___
--- NEW FILE: XMLDOMParseError.h ---
/*
 * Copyright 1999-2000,2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * $Id: XMLDOMParseError.h,v 1.1 2008/02/19 20:16:27 zolmol Exp $
 */

#ifndef ___xmldomparseerror_h___
#define ___xmldomparseerror_h___

#include <xercesc/util/XercesDefs.hpp>
XERCES_CPP_NAMESPACE_USE

class ATL_NO_VTABLE CXMLDOMParseError : 
	public CComObjectRootEx<CComSingleThreadModel>,
	public IDispatchImpl<IXMLDOMParseError, &IID_IXMLDOMParseError, &LIBID_Xerces, XERCES_VERSION_MAJOR, INVK_CAT2_RAW_NUMERIC(XERCES_VERSION_MINOR,XERCES_VERSION_REVISION)>
{
public:
	CXMLDOMParseError()
		:m_Code		 (0)
		,m_url		 (_T(""))
		,m_Reason	 (_T(""))
		,m_Source	 (_T(""))
		,m_LineNumber(0)
		,m_LinePos	 (0)
		,m_FilePos	 (0)
	{}

	HRESULT FinalConstruct();
	void	FinalRelease();	

DECLARE_NOT_AGGREGATABLE(CXMLDOMParseError)

DECLARE_PROTECT_FINAL_CONSTRUCT()

BEGIN_COM_MAP(CXMLDOMParseError)
	COM_INTERFACE_ENTRY(IXMLDOMParseError)
	COM_INTERFACE_ENTRY(IDispatch)
END_COM_MAP()

	// IXMLDOMParseError methods
	STDMETHOD(get_errorCode)(/* [out][retval] */ long  *errorCode);
    STDMETHOD(get_url)(/* [out][retval] */ BSTR  *urlString);
    STDMETHOD(get_reason)(/* [out][retval] */ BSTR  *reasonString);
    STDMETHOD(get_srcText)(/* [out][retval] */ BSTR  *sourceString);
    STDMETHOD(get_line)(/* [out][retval] */ long  *lineNumber);
    STDMETHOD(get_linepos)(/* [out][retval] */ long  *linePosition);
    STDMETHOD(get_filepos)(/* [out][retval] */ long  *filePosition);

	void SetData(long code,
				 const _bstr_t &url,
				 const _bstr_t &reason,
				 const _bstr_t &source,
				 long  lineNumber,
				 long  linePos,
				 long  filePos);
	void Reset();

private:

	long	m_Code;
	_bstr_t m_url;
	_bstr_t m_Reason;
	_bstr_t m_Source;
	long	m_LineNumber;
	long	m_LinePos;
	long	m_FilePos;

	CComCriticalSection	m_CS;
};

typedef CComObject<CXMLDOMParseError> CXMLDOMParseErrorObj;

#endif // ___xmldomparseerror_h___
--- NEW FILE: xml4com.cpp ---
/*
 * Copyright 1999-2001,2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * $Id: xml4com.cpp,v 1.1 2008/02/19 20:16:27 zolmol Exp $
 */

// xml4com.cpp : Implementation of DLL Exports.
// Note: Proxy/Stub Information
//      To merge the proxy/stub code into the object DLL, add the file
//      dlldatax.c to the project.  Make sure precompiled headers
//      are turned off for this file, and add _MERGE_PROXYSTUB to the
//      defines for the project.
//
//      If you are not running WinNT4.0 or Win95 with DCOM, then you
//      need to remove the following define from dlldatax.c
//      #define _WIN32_WINNT 0x0400
//
//      Further, if you are running MIDL without /Oicf switch, you also
//      need to remove the following define from dlldatax.c.
//      #define USE_STUBLESS_PROXY
//
//      Modify the custom build rule for xml4com.idl by adding the following
//      files to the Outputs.
//          xml4com_p.c
//          dlldata.c
//      To build a separate proxy/stub DLL,
//      run nmake -f xml4comps.mk in the project directory.

#include "stdafx.h"
#include "resource.h"
#include <initguid.h>

#include <xercesc/util/PlatformUtils.hpp>
#include "xml4com.h"
#include <xercesc/dom/DOMException.hpp>

//
//
//    These were extracted from an identifier definition file
//       generated by compiling MSXML.IDL using the MIDL compiler
//        (and removing CLSID_DOMDocument, CLSID_XMLHttpRequest, et al)
//
const IID IID_IXMLDOMImplementation = {0x2933BF8F,0x7B36,0x11d2,{0xB2,0x0E,0x00,0xC0,0x4F,0x98,0x3E,0x60}};


const IID IID_IXMLDOMNode = {0x2933BF80,0x7B36,0x11d2,{0xB2,0x0E,0x00,0xC0,0x4F,0x98,0x3E,0x60}};


const IID IID_IXMLDOMDocumentFragment = {0x3efaa413,0x272f,0x11d2,{0x83,0x6f,0x00,0x00,0xf8,0x7a,0x77,0x82}};


const IID IID_IXMLDOMDocument = {0x2933BF81,0x7B36,0x11d2,{0xB2,0x0E,0x00,0xC0,0x4F,0x98,0x3E,0x60}};


const IID IID_IXMLDOMNodeList = {0x2933BF82,0x7B36,0x11d2,{0xB2,0x0E,0x00,0xC0,0x4F,0x98,0x3E,0x60}};


const IID IID_IXMLDOMNamedNodeMap = {0x2933BF83,0x7B36,0x11d2,{0xB2,0x0E,0x00,0xC0,0x4F,0x98,0x3E,0x60}};


const IID IID_IXMLDOMCharacterData = {0x2933BF84,0x7B36,0x11d2,{0xB2,0x0E,0x00,0xC0,0x4F,0x98,0x3E,0x60}};


const IID IID_IXMLDOMAttribute = {0x2933BF85,0x7B36,0x11d2,{0xB2,0x0E,0x00,0xC0,0x4F,0x98,0x3E,0x60}};


const IID IID_IXMLDOMElement = {0x2933BF86,0x7B36,0x11d2,{0xB2,0x0E,0x00,0xC0,0x4F,0x98,0x3E,0x60}};


const IID IID_IXMLDOMText = {0x2933BF87,0x7B36,0x11d2,{0xB2,0x0E,0x00,0xC0,0x4F,0x98,0x3E,0x60}};


const IID IID_IXMLDOMComment = {0x2933BF88,0x7B36,0x11d2,{0xB2,0x0E,0x00,0xC0,0x4F,0x98,0x3E,0x60}};


const IID IID_IXMLDOMProcessingInstruction = {0x2933BF89,0x7B36,0x11d2,{0xB2,0x0E,0x00,0xC0,0x4F,0x98,0x3E,0x60}};


const IID IID_IXMLDOMCDATASection = {0x2933BF8A,0x7B36,0x11d2,{0xB2,0x0E,0x00,0xC0,0x4F,0x98,0x3E,0x60}};


const IID IID_IXMLDOMDocumentType = {0x2933BF8B,0x7B36,0x11d2,{0xB2,0x0E,0x00,0xC0,0x4F,0x98,0x3E,0x60}};


const IID IID_IXMLDOMNotation = {0x2933BF8C,0x7B36,0x11d2,{0xB2,0x0E,0x00,0xC0,0x4F,0x98,0x3E,0x60}};


const IID IID_IXMLDOMEntity = {0x2933BF8D,0x7B36,0x11d2,{0xB2,0x0E,0x00,0xC0,0x4F,0x98,0x3E,0x60}};


const IID IID_IXMLDOMEntityReference = {0x2933BF8E,0x7B36,0x11d2,{0xB2,0x0E,0x00,0xC0,0x4F,0x98,0x3E,0x60}};


const IID IID_IXMLDOMParseError = {0x3efaa426,0x272f,0x11d2,{0x83,0x6f,0x00,0x00,0xf8,0x7a,0x77,0x82}};


const IID IID_IXTLRuntime = {0x3efaa425,0x272f,0x11d2,{0x83,0x6f,0x00,0x00,0xf8,0x7a,0x77,0x82}};


const IID DIID_XMLDOMDocumentEvents = {0x3efaa427,0x272f,0x11d2,{0x83,0x6f,0x00,0x00,0xf8,0x7a,0x77,0x82}};



const IID IID_IXMLHttpRequest = {0xED8C108D,0x4349,0x11D2,{0x91,0xA4,0x00,0xC0,0x4F,0x79,0x69,0xE8}};


const IID IID_IXMLDSOControl = {0x310afa62,0x0575,0x11d2,{0x9c,0xa9,0x00,0x60,0xb0,0xec,0x3d,0x39}};


const IID IID_IXMLElementCollection = {0x65725580,0x9B5D,0x11d0,{0x9B,0xFE,0x00,0xC0,0x4F,0xC9,0x9C,0x8E}};


const IID IID_IXMLDocument = {0xF52E2B61,0x18A1,0x11d1,{0xB1,0x05,0x00,0x80,0x5F,0x49,0x91,0x6B}};


const IID IID_IXMLDocument2 = {0x2B8DE2FE,0x8D2D,0x11d1,{0xB2,0xFC,0x00,0xC0,0x4F,0xD9,0x15,0xA9}};


const IID IID_IXMLElement = {0x3F7F31AC,0xE15F,0x11d0,{0x9C,0x25,0x00,0xC0,0x4F,0xC9,0x9C,0x8E}};


const IID IID_IXMLElement2 = {0x2B8DE2FF,0x8D2D,0x11d1,{0xB2,0xFC,0x00,0xC0,0x4F,0xD9,0x15,0xA9}};


const IID IID_IXMLAttribute = {0xD4D4A0FC,0x3B73,0x11d1,{0xB2,0xB4,0x00,0xC0,0x4F,0xB9,0x25,0x96}};


const IID IID_IXMLError = {0x948C5AD3,0xC58D,0x11d0,{0x9C,0x0B,0x00,0xC0,0x4F,0xC9,0x9C,0x8E}};



//
//   This file is generated from the type library compilation
//       of xml4com.idl
//
#include "xml4com_i.c"
#include "XMLDOMDocument.h"
#include "XMLHTTPRequest.h"

#ifdef _MERGE_PROXYSTUB
extern "C" HINSTANCE hProxyDll;
#endif

CComModule _Module;

BEGIN_OBJECT_MAP(ObjectMap)
OBJECT_ENTRY(CLSID_DOMDocument, CXMLDOMDocument)
OBJECT_ENTRY(CLSID_XMLHTTPRequest, CXMLHttpRequest)
END_OBJECT_MAP()

/////////////////////////////////////////////////////////////////////////////
// DLL Entry Point

extern "C"
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
    lpReserved;
#ifdef _MERGE_PROXYSTUB
    if (!PrxDllMain(hInstance, dwReason, lpReserved))
        return FALSE;
#endif
    if (dwReason == DLL_PROCESS_ATTACH)
    {
        _Module.Init(ObjectMap, hInstance, &LIBID_Xerces);
        DisableThreadLibraryCalls(hInstance);
		XMLPlatformUtils::Initialize();
    }
    else if (dwReason == DLL_PROCESS_DETACH)
    {
        XMLPlatformUtils::Terminate();
        _Module.Term();
    }
    return TRUE;    // ok
}

/////////////////////////////////////////////////////////////////////////////
// Used to determine whether the DLL can be unloaded by OLE

STDAPI DllCanUnloadNow(void)
{
#ifdef _MERGE_PROXYSTUB
    if (PrxDllCanUnloadNow() != S_OK)
        return S_FALSE;
#endif
    return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
}

/////////////////////////////////////////////////////////////////////////////
// Returns a class factory to create an object of the requested type

STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
{
#ifdef _MERGE_PROXYSTUB
    if (PrxDllGetClassObject(rclsid, riid, ppv) == S_OK)
        return S_OK;
#endif
    return _Module.GetClassObject(rclsid, riid, ppv);
}

/////////////////////////////////////////////////////////////////////////////
// DllRegisterServer - Adds entries to the system registry

STDAPI DllRegisterServer(void)
{
#ifdef _MERGE_PROXYSTUB
    HRESULT hRes = PrxDllRegisterServer();
    if (FAILED(hRes))
        return hRes;
#endif
    // registers object, typelib and all interfaces in typelib
    return _Module.RegisterServer(TRUE);
}

/////////////////////////////////////////////////////////////////////////////
// DllUnregisterServer - Removes entries from the system registry

STDAPI DllUnregisterServer(void)
{
#ifdef _MERGE_PROXYSTUB
    PrxDllUnregisterServer();
#endif
    return _Module.UnregisterServer(TRUE);
}


static LPOLESTR Msgs[] =
{
	OLESTR("UNDEFINED DOM ERROR"),
	OLESTR("INDEX_SIZE_ERR"),   // INDEX_SIZE_ERR =  1
	OLESTR("DOMSTRING_SIZE_ERR"),  // DOMSTRING_SIZE_ERR =  2
	OLESTR("HIERARCHY_REQUEST_ERR"),   // HIERARCHY_REQUEST_ERR =  3
	OLESTR("WRONG_DOCUMENT_ERR"),   // WRONG_DOCUMENT_ERR =  4
	OLESTR("INVALID_CHARACTER_ERR"),   // INVALID_CHARACTER_ERR =  5
	OLESTR("NO_DATA_ALLOWED_ERR"),   // NO_DATA_ALLOWED_ERR =  6
	OLESTR("NO_MODIFICATION_ALLOWED_ERR"),   // NO_MODIFICATION_ALLOWED_ERR =  7
	OLESTR("NOT_FOUND_ERR"),   // NOT_FOUND_ERR =  8
	OLESTR("NOT_SUPPORTED_ERR"),   // NOT_SUPPORTED_ERR =  9
	OLESTR("INUSE_ATTRIBUTE_ERR"),   // INUSE_ATTRIBUTE_ERR =  10
	OLESTR("INVALID_STATE_ERR"),   // INVALID_STATE_ERR =  11
	OLESTR("SYNTAX_ERR	"),   // 	SYNTAX_ERR	 =  12
	OLESTR("INVALID_MODIFICATION_ERR"),   // 	INVALID_MODIFICATION_ERR =  13
	OLESTR("NAMESPACE_ERR"),   // 	NAMESPACE_ERR	 =  14
	OLESTR("INVALID_ACCESS_ERR") // INVALID_ACCESS_ERR   = 15
    OLESTR("VALIDATION_ERR") // VALIDATION_ERR = 16
};

//
//
//   makes an HRESULT with a code based on the DOM error code
//
HRESULT MakeHRESULT(DOMException& ex)
{
	ICreateErrorInfo* pCErr = NULL;
	HRESULT sc = CreateErrorInfo(&pCErr);
	if(SUCCEEDED(sc)) {
		const XMLCh* msg = ex.msg;
		if(msg == NULL)
		{
			if(ex.code >= DOMException::INDEX_SIZE_ERR &&
				ex.code <= DOMException::VALIDATION_ERR)
			{
				sc = pCErr->SetDescription(Msgs[ex.code]);
			}
			else
			{
				sc = pCErr->SetDescription(Msgs[0]);
			}
		}
		else
		{
			sc = pCErr->SetDescription(SysAllocString(ex.msg));
		}

		IErrorInfo* pErr = NULL;
		sc = pCErr->QueryInterface(IID_IErrorInfo,(void**) &pErr);
		if(SUCCEEDED(sc))
		{
			sc = SetErrorInfo(0,pErr);
			pErr->Release();
		}
		pCErr->Release();
	}
	return 0x80040600 + ex.code;
}




--- NEW FILE: IXMLDOMCharacterDataImpl.h ---
/*
 * Copyright 1999-2000,2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * $Id: IXMLDOMCharacterDataImpl.h,v 1.1 2008/02/19 20:16:27 zolmol Exp $
 */

#ifndef ___ixmldomcharacterdataimpl_h___
#define ___ixmldomcharacterdataimpl_h___

#include "IXMLDOMNodeImpl.h"
XERCES_CPP_NAMESPACE_USE

template <class T, const IID* piid, class tihclass = CComTypeInfoHolder>
class ATL_NO_VTABLE IXMLDOMCharacterDataImpl: public IXMLDOMNodeImpl<T,piid,tihclass>
{
public:

	virtual DOMCharacterData* get_DOMCharacterData() = 0; 
	virtual DOMNode* get_DOMNode() { return get_DOMCharacterData(); } 

	// IXMLDOMCharacterData 

STDMETHOD(get_data)(BSTR  *pVal)
{
	ATLTRACE(_T("IXMLDOMCharacterDataImpl::get_data\n"));

	if (NULL == pVal)
		return E_POINTER;

	*pVal = NULL;
	
	try
	{
		*pVal = SysAllocString(get_DOMCharacterData()->getData());
	}
	catch(...)
	{
		return E_FAIL;
	}
	

	return S_OK;
}

STDMETHOD(put_data)(BSTR newVal)
{
	ATLTRACE(_T("IXMLDOMCharacterDataImpl::put_data\n"));

	try
	{
		get_DOMCharacterData()->setData(newVal);
	}
	catch(...)
	{
		return E_FAIL;
	}
	

	return S_OK;
}

STDMETHOD(get_length)(long  *pVal)
{
	ATLTRACE(_T("IXMLDOMCharacterDataImpl::get_length\n"));

	if (NULL == pVal)
		return E_POINTER;

	*pVal = 0;

	try
	{
		*pVal = get_DOMCharacterData()->getLength();
	}
	catch(...)
	{
		return E_FAIL;
	}

	return S_OK;
}

STDMETHOD(substringData)(long offset, long count, BSTR  *data)
{
	ATLTRACE(_T("IXMLDOMCharacterDataImpl::substringData\n"));

	if (NULL == data)
		return E_POINTER;

	*data = NULL;

	try
	{
        *data = SysAllocString(get_DOMCharacterData()->substringData(offset, count));
	}
	catch(...)
	{
		return E_FAIL;
	}
	
	return S_OK;
}

STDMETHOD(appendData)(BSTR data)
{
	ATLTRACE(_T("IXMLDOMCharacterDataImpl::appendData\n"));

	try
	{
		get_DOMCharacterData()->appendData(data);
	}
	catch(...)
	{
		return E_FAIL;
	}
	

	return S_OK;
}

STDMETHOD(insertData)(long offset, BSTR data)
{
	ATLTRACE(_T("IXMLDOMCharacterDataImpl::insertData\n"));

	try
	{
		get_DOMCharacterData()->insertData(offset, data);
	}
	catch(...)
	{
		return E_FAIL;
	}
	

	return S_OK;
}

STDMETHOD(deleteData)(long offset, long count)
{
	ATLTRACE(_T("IXMLDOMCharacterDataImpl::deleteData\n"));

	try
	{
		get_DOMCharacterData()->deleteData(offset, count);
	}
	catch(...)
	{
		return E_FAIL;
	}
	

	return S_OK;
}

STDMETHOD(replaceData)(long offset, long count, BSTR data)
{
	ATLTRACE(_T("IXMLDOMCharacterDataImpl::replaceData\n"));

	try
	{
		get_DOMCharacterData()->replaceData(offset, count, data);
	}
	catch(...)
	{
		return E_FAIL;
	}
	
	return S_OK;
}

};

#endif // ___ixmldomcharacterdataimpl_h___
--- NEW FILE: xml4comCP.h ---
/*
 * Copyright 1999-2000,2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * $Id: xml4comCP.h,v 1.1 2008/02/19 20:16:27 zolmol Exp $
 */

#ifndef _XML4COMCP_H_
#define _XML4COMCP_H_

template <class T>
class CProxyXMLDOMDocumentEvents : public IConnectionPointImpl<T, &DIID_XMLDOMDocumentEvents, CComDynamicUnkArray>
{
	//Warning this class may be recreated by the wizard.
public:
	HRESULT Fire_ondataavailable()
	{
		CComVariant varResult;
		T* pT = static_cast<T*>(this);
		int nConnectionIndex;
		int nConnections = m_vec.GetSize();
		
		for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
		{
			pT->Lock();
			CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
			pT->Unlock();
			IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
			if (pDispatch != NULL)
			{
				VariantClear(&varResult);
				DISPPARAMS disp = { NULL, NULL, 0, 0 };
				pDispatch->Invoke(0xc6, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL);
			}
		}
		return varResult.scode;
	
	}
	HRESULT Fire_onreadystatechange()
	{
		CComVariant varResult;
		T* pT = static_cast<T*>(this);
		int nConnectionIndex;
		int nConnections = m_vec.GetSize();
		
		for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
		{
			pT->Lock();
			CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
			pT->Unlock();
			IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
			if (pDispatch != NULL)
			{
				VariantClear(&varResult);
				DISPPARAMS disp = { NULL, NULL, 0, 0 };
				pDispatch->Invoke(DISPID_READYSTATECHANGE, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL);
			}
		}
		return varResult.scode;
	
	}
};
#endif
--- NEW FILE: BindStatusCallback.cpp ---
/*
 * Copyright 1999-2000,2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * $Id: BindStatusCallback.cpp,v 1.1 2008/02/19 20:16:27 zolmol Exp $
 */

// CBindStatCallback.cpp : Implementation of BindStatusCallback
#include "stdafx.h"
#include "resource.h"
#include "BindStatusCallback.h"
#include "xml4com.h"
#include "XMLDOMDocument.h"

/////////////////////////////////////////////////////////////////////////////
// CBindStatCallback

STDMETHODIMP CBindStatCallback::OnStartBinding(DWORD dwReserved, IBinding *pBinding)
{
	ATLTRACE(_T("CBindStatCallback::OnStartBinding\n"));
	return S_OK;
}

STDMETHODIMP CBindStatCallback::GetPriority(LONG *pnPriority)
{
	ATLTRACE(_T("CBindStatCallback::GetPriority\n"));
	return E_NOTIMPL;
}

STDMETHODIMP CBindStatCallback::OnLowResource(DWORD reserved)
{
	ATLTRACE(_T("CBindStatCallback::OnLowResource\n"));
	return E_NOTIMPL;
}

STDMETHODIMP CBindStatCallback::OnProgress(ULONG ulProgress, ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText)
{
	ATLTRACE(_T("CBindStatCallback::OnProgress %d %d\n"),ulProgress,ulProgressMax);
	if (m_pDoc->IsAbort())
		return E_ABORT; 

	_bstr_t text(szStatusText);
	switch (ulStatusCode) {
		case BINDSTATUS_FINDINGRESOURCE:
			text = _T("Finding resource ") + text;
			break;
		case BINDSTATUS_CONNECTING:
			text = _T("Connecting ") + text;
			break;
		case BINDSTATUS_REDIRECTING:
			text = _T("Redirecting ") + text;
			break;
		case BINDSTATUS_BEGINDOWNLOADDATA:
			text = _T("Begin to download data ") + text;
			break;
		case BINDSTATUS_DOWNLOADINGDATA:
			text = _T("Downloading data ") + text;
			break;
		case BINDSTATUS_ENDDOWNLOADDATA:
			text = _T("End of downloading data ") + text;
			break;
		case BINDSTATUS_BEGINDOWNLOADCOMPONENTS:
			text = _T("Downloading components ") + text;
			break;
	    case BINDSTATUS_INSTALLINGCOMPONENTS:
			text = _T("Installing components ") + text;
			break;
	    case BINDSTATUS_ENDDOWNLOADCOMPONENTS:
			text = _T("End of downloading components ") + text;
			break;
	    case BINDSTATUS_USINGCACHEDCOPY:
			text = _T("Using cached copy ") + text;
			break;
	    case BINDSTATUS_SENDINGREQUEST:
			text = _T("Sending request ") + text;
			break;
	    case BINDSTATUS_CLASSIDAVAILABLE:
			text = _T("Classid available ") + text;
			break;
	    case BINDSTATUS_MIMETYPEAVAILABLE:
			text = _T("Mime type available ") + text;
			break;
	    case BINDSTATUS_CACHEFILENAMEAVAILABLE:
			text = _T("Cache file name available ") + text;
			break;
	    case BINDSTATUS_BEGINSYNCOPERATION:
			text = _T("Begin sync operation ") + text;
			break;
	    case BINDSTATUS_ENDSYNCOPERATION:
			text = _T("End of sync operation ") + text;
			break;
	    case BINDSTATUS_BEGINUPLOADDATA:
			text = _T("Begin uploading data ") + text;
			break;
	    case BINDSTATUS_UPLOADINGDATA:
			text = _T("Uploading data ") + text;
			break;
	    case BINDSTATUS_PROTOCOLCLASSID:
			text = _T("Protocol classid ") + text;
			break;
		case BINDSTATUS_ENCODING:
			text = _T("Encoding ") + text;
			break;
	    case BINDSTATUS_CLASSINSTALLLOCATION:
			text = _T("Class intall location ") + text;
			break;
	    case BINDSTATUS_DECODING:
			text = _T("Decoding ") + text;
			break;
		default:
			break;
	}

	ATLTRACE(_T("CBindStatCallback::OnProgress %s\n"),text);
	
	return S_OK;
}

STDMETHODIMP CBindStatCallback::OnStopBinding(HRESULT hresult, LPCWSTR szError)
{
	ATLTRACE(_T("CBindStatCallback::OnStopBinding\n"));
	return S_OK;
}

STDMETHODIMP CBindStatCallback::GetBindInfo(DWORD *pgrfBINDF, BINDINFO *pbindInfo)
{
	ATLTRACE(_T("CBindStatCallback::GetBindInfo\n"));
	return E_NOTIMPL;
}

STDMETHODIMP CBindStatCallback::OnDataAvailable(DWORD grfBSCF, DWORD dwSize, FORMATETC *pformatetc, STGMEDIUM *pstgmed)
{
	ATLTRACE(_T("CBindStatCallback::OnDataAvailable\n"));
	return E_NOTIMPL;
}

STDMETHODIMP CBindStatCallback::OnObjectAvailable(REFIID riid, IUnknown *punk)
{
	ATLTRACE(_T("CBindStatCallback::OnObjectAvailable\n"));
	return E_NOTIMPL;
}

--- NEW FILE: NodeContainerImpl.h ---
/*
 * Copyright 1999-2000,2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * $Id: NodeContainerImpl.h,v 1.1 2008/02/19 20:16:27 zolmol Exp $
 */

#ifndef ___nodecontainerimpl_h___
#define ___nodecontainerimpl_h___

template <class T>
class NodeContainerImpl
{
public:

	class iterator 
	{
	public:
		iterator()
			:m_container(NULL)
			,m_NextNodeIndex(0)
			,m_pIXMLDOMDocument(NULL)
		{
			VariantInit(&m_NextVar);
			V_VT(&m_NextVar) = VT_NULL;
		}	

		iterator(const T* container,int idx,IXMLDOMDocument *p)
			:m_container(container)
			,m_NextNodeIndex(idx)
			,m_pIXMLDOMDocument(p)
		{
			VariantInit(&m_NextVar);
			V_VT(&m_NextVar) = VT_NULL;
			if (m_pIXMLDOMDocument != NULL)
				m_pIXMLDOMDocument->AddRef();
		}

		~iterator()
		{
			VariantClear(&m_NextVar);
			if (m_pIXMLDOMDocument != NULL)
				m_pIXMLDOMDocument->Release();
		}
		
		bool operator !=(const iterator& rhs)
		{
			return (m_NextNodeIndex != rhs.m_NextNodeIndex);
		}
		
		iterator& operator=(const iterator& rhs)
		{
			if (this != &rhs) {
				if (m_pIXMLDOMDocument != NULL) {
					m_pIXMLDOMDocument->Release() ;
					m_pIXMLDOMDocument = NULL ;
				}
				m_container = rhs.m_container ;
				m_NextNodeIndex = rhs.m_NextNodeIndex ;
				m_NextVar = rhs.m_NextVar ;
				m_pIXMLDOMDocument = rhs.m_pIXMLDOMDocument ;
				if (m_pIXMLDOMDocument != NULL) {
					m_pIXMLDOMDocument->AddRef() ;
				}
			}
			return *this ;
		}


		VARIANT& operator*()
		{
			if (m_container == 0)
				return m_NextVar;

			int length = m_container->getLength(); 
			if (m_NextNodeIndex >= length)
				return m_NextVar;
			
			CComPtr<IXMLDOMNode> pNode;
			HRESULT hr = wrapNode(m_pIXMLDOMDocument,m_container->item(m_NextNodeIndex),IID_IXMLDOMNode, reinterpret_cast<LPVOID *> (&pNode));
			if (S_OK == hr) {
				CComQIPtr<IDispatch,&IID_IDispatch> pDisp(pNode);
				if (pNode) {
					VariantClear(&m_NextVar);
					V_VT(&m_NextVar)	   = VT_DISPATCH;
					V_DISPATCH(&m_NextVar) = pDisp.Detach();
				}
			}

			return m_NextVar;
		}
		
		iterator operator++(int)
		{
			return iterator(m_container,m_NextNodeIndex++,m_pIXMLDOMDocument);		
		}
		
	private:

		const T*		 m_container;	
		int			     m_NextNodeIndex;
		IXMLDOMDocument	*m_pIXMLDOMDocument;
		VARIANT			 m_NextVar;
	};

	typedef iterator const_iterator;

	NodeContainerImpl()
		:m_NextNodeIndex(0)
		,m_pIXMLDOMDocument(NULL)
	{}

	iterator begin()
	{
		return iterator(m_container,0,m_pIXMLDOMDocument);
	}
	
	iterator end()
	{
		if (m_container == 0)
			return iterator(m_container,0,m_pIXMLDOMDocument);
		else	
			return iterator(m_container,m_container->getLength(),m_pIXMLDOMDocument);
	}
	
	void	SetOwnerDoc(IXMLDOMDocument	*p)
	{
		m_pIXMLDOMDocument = p;
		if (m_pIXMLDOMDocument != NULL)
			m_pIXMLDOMDocument->AddRef();
	}

	T*				 m_container;

protected:

	int				 m_NextNodeIndex;
	IXMLDOMDocument	*m_pIXMLDOMDocument;

	void	ReleaseOwnerDoc()
	{
		if (m_pIXMLDOMDocument != NULL) {
			m_pIXMLDOMDocument->Release();
			m_pIXMLDOMDocument = NULL;
		}
	}
};

#endif // ___nodecontainerimpl_h___

--- NEW FILE: registry.bin ---



More information about the GME-commit mailing list