コード例 #1
0
ファイル: XMLDOMDocument.cpp プロジェクト: gitrider/wxsj2
STDMETHODIMP CXMLDOMDocument::putref_documentElement(IXMLDOMElement  *newVal)
{
	ATLTRACE(_T("CXMLDOMDocument::putref_documentElement\n"));

	DOMElement* elem;

	try
	{
		elem = m_Document->getDocumentElement();
		if (NULL == newVal && elem!=NULL) {
			m_Document->removeChild(elem);
			return S_OK;
		}
	}
	catch(DOMException& ex)
	{
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}
		
	CComQIPtr<IIBMXMLDOMNodeIdentity,&IID_IIBMXMLDOMNodeIdentity> pNewVal(newVal);
	if (!pNewVal)
		return E_NOINTERFACE;

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

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

	try
	{
		if(elem==NULL)
			m_Document->appendChild(pNewValNode);
		else
			m_Document->replaceChild(pNewValNode, elem);
	}
	catch(DOMException& ex)
	{
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}
	
	return S_OK;
}
コード例 #2
0
ファイル: XMLDOMEntity.cpp プロジェクト: ksmyth/xerces-c
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;
}
コード例 #3
0
ファイル: XMLDOMXMLDecl.cpp プロジェクト: gitrider/wxsj2
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;

}
コード例 #4
0
ファイル: XMLDOMNodeList.cpp プロジェクト: js422/PERL
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;
}
コード例 #5
0
ファイル: XMLDOMAttribute.cpp プロジェクト: gitrider/wxsj2
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;
}
コード例 #6
0
ファイル: XMLDOMAttribute.cpp プロジェクト: gitrider/wxsj2
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;
}
コード例 #7
0
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;
}
コード例 #8
0
ファイル: XMLDOMNodeList.cpp プロジェクト: js422/PERL
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;
}
コード例 #9
0
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;

}
コード例 #10
0
ファイル: XMLDOMElement.cpp プロジェクト: ksmyth/xerces-c
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;
}
コード例 #11
0
// 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;
}
コード例 #12
0
ファイル: XMLDOMDocument.cpp プロジェクト: gitrider/wxsj2
STDMETHODIMP CXMLDOMDocument::nodeFromID(BSTR idString, IXMLDOMNode  **pVal)
{
	ATLTRACE(_T("CXMLDOMDocument::nodeFromID\n"));

	if (NULL == pVal)
		return E_POINTER;

	*pVal = NULL;
	HRESULT hr = S_OK;

	try
	{
		hr = wrapNode(m_pIXMLDOMDocument, m_Document->getElementById(idString),IID_IXMLDOMNode,reinterpret_cast<LPVOID *> (pVal));
	}
	catch(DOMException& ex)
	{
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}
	
	return hr;
}
コード例 #13
0
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;
}
コード例 #14
0
ファイル: XMLDOMDocument.cpp プロジェクト: gitrider/wxsj2
STDMETHODIMP CXMLDOMDocument::save(VARIANT location)
{
	ATLTRACE(_T("CXMLDOMDocument::save\n"));

	if (V_VT(&location) != VT_BSTR)
		return E_INVALIDARG;

	_bstr_t file(V_BSTR(&location));
	if (0 == file.length())
		return E_INVALIDARG;

	_bstr_t text;
	
	try {
		DOMNodeList* childs = m_Document->getChildNodes();
		int length = childs->getLength();
		for (int i=0; i < length; ++i) {
			DOMNode* child = childs->item(i);
			_bstr_t nodeText;
			GetXML(child,nodeText);
			text += nodeText;
		}
	}
	catch(DOMException& ex)
	{
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		return E_FAIL;
	}

	FILE* fp = _tfopen(file, "wt");
	if (fp == NULL)
		return E_FAIL;

	if(text.length()>0 && _fputts(text, fp)<0)
    {
        fclose(fp);
        return E_FAIL;
    }
	
	if(fclose(fp)!=0)
        return E_FAIL;

	return S_OK;
}
コード例 #15
0
ファイル: XMLDOMElement.cpp プロジェクト: ksmyth/xerces-c
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;
}
コード例 #16
0
ファイル: XMLDOMAttribute.cpp プロジェクト: gitrider/wxsj2
	//  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;
}
コード例 #17
0
ファイル: XMLDOMElement.cpp プロジェクト: ksmyth/xerces-c
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;
}
コード例 #18
0
ファイル: XMLDOMElement.cpp プロジェクト: ksmyth/xerces-c
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;
}
コード例 #19
0
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;
}
コード例 #20
0
ファイル: XMLDOMElement.cpp プロジェクト: ksmyth/xerces-c
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;
}
コード例 #21
0
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;

}
コード例 #22
0
ファイル: XMLDOMDocument.cpp プロジェクト: gitrider/wxsj2
STDMETHODIMP CXMLDOMDocument::get_documentElement(IXMLDOMElement  * *pVal)
{
	ATLTRACE(_T("CXMLDOMDocument::get_documentElement\n"));

	if (NULL == pVal)
		return E_POINTER;

	*pVal = NULL;

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

	try
	{
		pObj->element = m_Document->getDocumentElement();
	}
	catch(DOMException& ex)
	{
		pObj->Release();
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		pObj->Release();
		return S_OK;
	}
	
	hr = pObj->QueryInterface(IID_IXMLDOMElement, reinterpret_cast<LPVOID*> (pVal));
	if (S_OK != hr)
		*pVal = NULL;

	pObj->Release();
	return S_OK;
}
コード例 #23
0
ファイル: XMLDOMDocument.cpp プロジェクト: gitrider/wxsj2
STDMETHODIMP CXMLDOMDocument::createDocumentFragment(IXMLDOMDocumentFragment  **docFrag)
{
	ATLTRACE(_T("CXMLDOMDocument::createDocumentFragment\n"));

	if (NULL == docFrag)
		return E_POINTER;

	*docFrag = NULL;

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

	try
	{
		pObj->documentFragment = m_Document->createDocumentFragment();
	}
	catch(DOMException& ex)
	{
		pObj->Release();
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		pObj->Release();
		return E_FAIL;
	}
	
	hr = pObj->QueryInterface(IID_IXMLDOMDocumentFragment, reinterpret_cast<LPVOID*> (docFrag));
	if (S_OK != hr)
		*docFrag = NULL;

	pObj->Release();
	return hr;
}
コード例 #24
0
ファイル: XMLDOMNodeList.cpp プロジェクト: js422/PERL
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;
}
コード例 #25
0
ファイル: XMLDOMDocument.cpp プロジェクト: gitrider/wxsj2
STDMETHODIMP CXMLDOMDocument::createCDATASection(BSTR data, IXMLDOMCDATASection  **cdata)
{
	ATLTRACE(_T("CXMLDOMDocument::createCDATASection\n"));

	if (NULL == cdata)
		return E_POINTER;

	*cdata = NULL;

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

	try
	{
		pObj->cdataSection = m_Document->createCDATASection(data);
	}
	catch(DOMException& ex)
	{
		pObj->Release();
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		pObj->Release();
		return E_FAIL;
	}
	
	hr = pObj->QueryInterface(IID_IXMLDOMCDATASection, reinterpret_cast<LPVOID*> (cdata));
	if (S_OK != hr)
		*cdata = NULL;

	pObj->Release();
	return hr;
}
コード例 #26
0
ファイル: XMLDOMDocument.cpp プロジェクト: gitrider/wxsj2
STDMETHODIMP CXMLDOMDocument::createProcessingInstruction(BSTR target, BSTR data, IXMLDOMProcessingInstruction  **pVal)
{
	ATLTRACE(_T("CXMLDOMDocument::createProcessingInstruction\n"));

	if (NULL == pVal)
		return E_POINTER;

	*pVal = NULL;

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

	try
	{
		pObj->processingInstruction = m_Document->createProcessingInstruction(target, data);
	}
	catch(DOMException& ex)
	{
		pObj->Release();
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		pObj->Release();
		return E_FAIL;
	}
	
	hr = pObj->QueryInterface(IID_IXMLDOMProcessingInstruction, reinterpret_cast<LPVOID*> (pVal));
	if (S_OK != hr)
		*pVal = NULL;

	pObj->Release();
	return hr;
}
コード例 #27
0
ファイル: XMLDOMDocument.cpp プロジェクト: gitrider/wxsj2
STDMETHODIMP CXMLDOMDocument::getElementsByTagName(BSTR tagName, IXMLDOMNodeList  **pVal)
{
	ATLTRACE(_T("CXMLDOMDocument::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 = m_Document->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;
}
コード例 #28
0
ファイル: XMLDOMDocument.cpp プロジェクト: gitrider/wxsj2
STDMETHODIMP CXMLDOMDocument::createEntityReference(BSTR name, IXMLDOMEntityReference  **entityRef)
{
	ATLTRACE(_T("CXMLDOMDocument::createEntityReference\n"));

	if (NULL == entityRef)
		return E_POINTER;

	*entityRef = NULL;

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

	try
	{
		pObj->entityReference = m_Document->createEntityReference(name);
	}
	catch(DOMException& ex)
	{
		pObj->Release();
		return MakeHRESULT(ex);
	}
	catch(...)
	{
		pObj->Release();
		return E_FAIL;
	}
	
	hr = pObj->QueryInterface(IID_IXMLDOMEntityReference, reinterpret_cast<LPVOID*> (entityRef));
	if (S_OK != hr)
		*entityRef = NULL;

	pObj->Release();
	return hr;
}
コード例 #29
0
ファイル: XMLDOMElement.cpp プロジェクト: ksmyth/xerces-c
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;
}
コード例 #30
0
ファイル: XMLDOMDocument.cpp プロジェクト: gitrider/wxsj2
STDMETHODIMP CXMLDOMDocument::createNode(VARIANT TYPE, BSTR name, BSTR namespaceURI, IXMLDOMNode  **pVal)
{
	ATLTRACE(_T("CXMLDOMDocument::createNode\n"));

	HRESULT hr = S_OK;
	if (NULL == pVal)
		return E_POINTER;

	*pVal = NULL;

	VARIANT type;
	::VariantInit(&type);
	if (V_VT(&TYPE) != VT_I4 && V_VT(&TYPE) != VT_BSTR)
		hr = ::VariantChangeType(&type,&TYPE,0,VT_I4); 	
	else
		hr = ::VariantCopy(&type,&TYPE);
	
	if (S_OK != hr)
		return hr;

	DOMNodeType nodeType = NODE_INVALID;
	if (VT_I4 == V_VT(&type))
		nodeType = static_cast<DOMNodeType> (V_I4(&type));
	else {
		OLECHAR* str = V_BSTR(&type);
		for (int i = 0; i < g_DomNodeNameSize; ++i) {
			if (0 == _wcsicmp(str,g_DomNodeName[i])) {
				nodeType = static_cast<DOMNodeType> (i);
				break;
			}
		}
	}

	::VariantClear(&type);
	
	if (NODE_INVALID		== nodeType ||
		NODE_DOCUMENT		== nodeType	||
		NODE_DOCUMENT_TYPE	== nodeType	||
		NODE_ENTITY			== nodeType ||
		NODE_NOTATION		== nodeType)
		return E_FAIL;

	try
	{
	switch(nodeType) {
		case NODE_ELEMENT:
		{
			DOMElement* node;
			if (SysStringLen(namespaceURI) > 0)
				node = m_Document->createElementNS(namespaceURI,name);
			else
				node = m_Document->createElement(name);
			
			hr = wrapNode(m_pIXMLDOMDocument,node,IID_IXMLDOMNode,reinterpret_cast<LPVOID *> (pVal));
			break;
		}
		case NODE_ATTRIBUTE:
		{
			DOMAttr* node;
			if (SysStringLen(namespaceURI) > 0)
				node = m_Document->createAttributeNS(namespaceURI,name);
			else
				node = m_Document->createAttribute(name);

			hr = wrapNode(m_pIXMLDOMDocument,node,IID_IXMLDOMNode,reinterpret_cast<LPVOID *> (pVal));
			break;
		}
		case NODE_TEXT:
		{
			DOMText* node = m_Document->createTextNode(OLESTR(""));
			hr = wrapNode(m_pIXMLDOMDocument,node,IID_IXMLDOMNode,reinterpret_cast<LPVOID *> (pVal));
			break;
		}
		case NODE_CDATA_SECTION:
		{
			DOMCDATASection* node = m_Document->createCDATASection(OLESTR(""));
			hr = wrapNode(m_pIXMLDOMDocument,node,IID_IXMLDOMNode,reinterpret_cast<LPVOID *> (pVal));
			break;
		}
		case NODE_ENTITY_REFERENCE:
		{
			DOMEntityReference* node = m_Document->createEntityReference(name);
			hr = wrapNode(m_pIXMLDOMDocument,node,IID_IXMLDOMNode,reinterpret_cast<LPVOID *> (pVal));
			break;
		}
		case NODE_PROCESSING_INSTRUCTION:
		{
			DOMProcessingInstruction* node = m_Document->createProcessingInstruction(name,OLESTR(""));
			hr = wrapNode(m_pIXMLDOMDocument,node,IID_IXMLDOMNode,reinterpret_cast<LPVOID *> (pVal));
			break;
		}
		case NODE_COMMENT:
		{
			DOMComment* node = m_Document->createComment(OLESTR(""));
			hr = wrapNode(m_pIXMLDOMDocument,node,IID_IXMLDOMNode,reinterpret_cast<LPVOID *> (pVal));
			break;
		}
		case NODE_DOCUMENT_FRAGMENT:
		{
			DOMDocumentFragment* node = m_Document->createDocumentFragment();
			hr = wrapNode(m_pIXMLDOMDocument,node,IID_IXMLDOMNode,reinterpret_cast<LPVOID *> (pVal));
			break;
		}
		default:
			hr = E_FAIL;
			break;
	}
	}
	catch(DOMException& ex)
	{
		hr = MakeHRESULT(ex);
	}
	catch (...)
	{
		hr = E_FAIL;
	}
	
	return hr;
}