예제 #1
0
파일: WXmlParse.cpp 프로젝트: cxwangwc/Rule
BOOL WXmlParse::readObject(std::vector<ExternalObject *> &objTree)
{
	MSXML2::IXMLDOMDocumentPtr doc;
	MSXML2::IXMLDOMElementPtr docRoot;  
	MSXML2::IXMLDOMElementPtr docElement;  
	MSXML2::IXMLDOMNodeListPtr elementNodes;  
	MSXML2::IXMLDOMNamedNodeMapPtr elementAttributes;
	MSXML2::IXMLDOMNodePtr xmlNode;  
	MSXML2::IXMLDOMNodePtr xmlSubNode; 
	MSXML2::IXMLDOMNodePtr xmlAttrNode; 
	doc.CreateInstance(__uuidof(DOMDocument30));  
	doc->load((_variant_t)m_strFileName);

	docRoot = doc->GetdocumentElement();//获得根节点;  
	docRoot->get_childNodes(&elementNodes);  
	LONG length, subLength, attrLength;
	elementNodes->get_length(&length);
	MSXML2::IXMLDOMNodeListPtr subElementNodes; 

	// 3 :  递归获取对象树
	elementNodes->get_item(3, &xmlNode);
	xmlNode->get_childNodes(&subElementNodes);
	subElementNodes->get_length(&subLength);
	for (int j = 0; j < subLength;j++)
	{
		ExternalObject *objTmp = new ExternalObject();
		subElementNodes->get_item(j, &xmlSubNode);//获得某个属性
		xmlSubNode->get_attributes(&elementAttributes);
		readObject(objTmp, xmlSubNode);
		objTree.push_back(objTmp);
	}

	return TRUE;
}
예제 #2
0
bool XmlParser::ReplaceNode(XmlNode nodeNew, XmlNode nodeOld)
{
	MSXML2::IXMLDOMNodePtr pParentNode;
			
	nodeOld.GetIXMLDOMElementPtr()->get_parentNode(&pParentNode);
	return SUCCEEDED(pParentNode->replaceChild(nodeNew.GetIXMLDOMElementPtr(), nodeOld.GetIXMLDOMElementPtr()));	
}
예제 #3
0
파일: WXmlParse.cpp 프로젝트: cxwangwc/Rule
BOOL WXmlParse::readExtendModName(std::vector<std::pair<string, string> > &modNames)
{
	MSXML2::IXMLDOMDocumentPtr doc;
	MSXML2::IXMLDOMElementPtr docRoot;  
	MSXML2::IXMLDOMElementPtr docElement;  
	MSXML2::IXMLDOMNodeListPtr elementNodes;  
	MSXML2::IXMLDOMNamedNodeMapPtr elementAttributes;
	MSXML2::IXMLDOMNodePtr xmlNode;  
	MSXML2::IXMLDOMNodePtr xmlSubNode; 
	MSXML2::IXMLDOMNodePtr xmlAttrNode; 
	doc.CreateInstance(__uuidof(DOMDocument30));  
	doc->load((_variant_t)m_strFileName);

	docRoot = doc->GetdocumentElement();//获得根节点;  
	docRoot->get_childNodes(&elementNodes);  
	LONG length, subLength, attrLength;
	elementNodes->get_length(&length);
	MSXML2::IXMLDOMNodeListPtr subElementNodes; 

	// 3 :  扩展模块列表
	elementNodes->get_item(1, &xmlNode);
	xmlNode->get_childNodes(&subElementNodes);
	subElementNodes->get_length(&subLength);
	for (int j = 0; j < subLength;j++)
	{
		subElementNodes->get_item(j, &xmlSubNode);//获得某个属性
		xmlSubNode->get_attributes(&elementAttributes);
		MSXML2::IXMLDOMNodePtr nameNode = elementAttributes->getNamedItem("name");
		MSXML2::IXMLDOMNodePtr descNode = elementAttributes->getNamedItem("description");
		modNames.push_back(std::make_pair(nameNode->text, descNode->text));
	}

	return TRUE;
}
MTConnectDataModel MTConnectDeviceParser::ReadDeviceDescription(std::string filename)
{
	MTConnectDataModel dataItems;
	dataItems.clear();
	if(GetFileAttributesA(filename.c_str())== INVALID_FILE_ATTRIBUTES)
	{
		filename= ::ExeDirectory() + filename;
	}
	if(GetFileAttributesA(filename.c_str())== INVALID_FILE_ATTRIBUTES)
		throw std::exception("MTConnectDeviceParser::ReadDeviceDescription invalid devices file");

	_devicesfilename = filename;

	try{
		ParseXMLDocument(_devicesfilename.c_str());

		MSXML2::IXMLDOMNodePtr root = m_pXMLDoc->GetdocumentElement();
		MSXML2::IXMLDOMNodeListPtr nodes = root->selectNodes(_bstr_t("//DataItem"));
		for(int i=0; i< nodes->length; i++)
		{
			MSXML2::IXMLDOMNodePtr pNode = NULL;	
			CDataItem dataItem;
			nodes->get_item(i, &pNode);

			dataItem.name = (LPCSTR)  GetAttribute(pNode, "name");
			dataItem.category = (LPCSTR) GetAttribute(pNode, "category");
			dataItem.id = (LPCSTR) GetAttribute(pNode, "id");
			dataItem.type = (LPCSTR) GetAttribute(pNode, "type");
			dataItem.subType = (LPCSTR) GetAttribute(pNode, "subType");
			dataItem.units = (LPCSTR) GetAttribute(pNode, "units");
			dataItem.nativeUnits = (LPCSTR) GetAttribute(pNode, "nativeUnits");
			if(dataItem.type == "ASSET_CHANGED")
			{
				dataItem.category = "ASSET_CHANGED";
			}

			dataItem.category=MakeLower(dataItem.category);
			
			if(!dataItem.name.empty())
			{
				dataItems[dataItem.name]=dataItem;
			}
			// Could get name or id via SHDR
			else if(!dataItem.id.empty())
			{
				dataItems[dataItem.id]=dataItem;
			}
			else
			{
				continue;
			}
		}
	}
	catch(_com_error error)
	{
		std::cout << "MTConnectDeviceParser::ReadDeviceDescription" << error.ErrorMessage();
	}
	return dataItems;

}
void CSimpleFilterDialog::SaveSelection(void)
{
	POSITION pos = m_ResultList.GetFirstSelectedItemPosition(); 

	
	//okopiruje vzorovy element selection
	MSXML2::IXMLDOMElementPtr selection_elem = m_active_element->ownerDocument->createElement("selection");
	MSXML2::IXMLDOMAttributePtr id_attr = m_active_element->ownerDocument->createAttribute("id");
	selection_elem->setAttributeNode(id_attr);
	id_attr.Release();
	
	//vymaze vsechny selection
	MSXML2::IXMLDOMNodeListPtr list = m_cloned_active_element->selectNodes("filter[@type='simple']/selection");
	MSXML2::IXMLDOMSelection * sel;
	list.QueryInterface(__uuidof(MSXML2::IXMLDOMSelection), &sel);
	sel->removeAll();
	sel->Release();

	MSXML2::IXMLDOMNodePtr filter = m_cloned_active_element->selectSingleNode("filter[@type='simple']");
	
	while (pos)
	{
		int nItem = m_ResultList.GetNextSelectedItem(pos);

		selection_elem->setAttribute("id", (LPCTSTR) m_ResultList.GetItemText(nItem, 0));
		filter->appendChild(selection_elem->cloneNode(VARIANT_FALSE));
	}

	selection_elem.Release();

}
예제 #6
0
//-------------------------------------------------------------------------
// Function Name    :GetCount
// Parameter(s)     :void
// Return           :LONG
// Memo             :
//-------------------------------------------------------------------------
LONG CXmlNodes::GetCount(void)
{
	ASSERT( m_pNodeList != NULL );

	LONG lCount = 0l;
	HRESULT hr = S_OK;
	MSXML2::DOMNodeType NodeType;
	MSXML2::IXMLDOMNodePtr pNode = NULL;
	
	for( int i = 0; i < m_pNodeList->length; i++)
	{
		pNode = m_pNodeList->item[i];

		hr = pNode->get_nodeType(&NodeType);
		ASSERT( SUCCEEDED(hr) );

		if( NodeType == MSXML2::NODE_ELEMENT )
		{
			lCount ++;
		}

		SAFE_RELEASE(pNode);
	}

	return lCount;
}
예제 #7
0
// 获取当前节点的最后一个Element子节点
IBpXMLNode* CBpXMLNode::GetLastElementChild() const
{
	if (m_pDOMNode == NULL)
		return NULL;

	if (m_pDOMNode->GetnodeType() == MSXML2::NODE_ELEMENT) 
	{ 
		MSXML2::IXMLDOMNodeListPtr pNodeList = m_pDOMNode->GetchildNodes(); 
		if (pNodeList == NULL)
			return NULL;
		long nListLen = 0;
		pNodeList->get_length(&nListLen);;
		MSXML2::IXMLDOMNodePtr pNode = NULL;
		for (long i = 0; i < nListLen; i++) 
		{ 
			pNodeList->get_item(nListLen - 1 - i, &pNode); 
			if (pNode->GetnodeType() == MSXML2::NODE_ELEMENT) 
			{ 
				CBpXMLNode *pNodeCreated  = new CBpXMLNode();	
				pNodeCreated->m_pDOMNode = pNode;
				return (IBpXMLNode*)pNodeCreated;
			} 
		} 
	}
	return NULL;
}
void Translator::GetFileFormatVersion(std::string &fileFormatVersion, InputStream *readStream, TSError *error, char *errorMsg, long maxErrorMsgLengthInBytes)
{
	readStream->Offset = 0;
	GetParser()->LoadFile(readStream);
	MSXML2::IXMLDOMNodePtr header = GetParser()->GetHeader(readStream);
	fileFormatVersion = header->Getattributes()->getNamedItem("fileformatversion")->text;
}
예제 #9
0
CStdString SmartTagParser::GetTextForSmartTagName(const CStdString & SmartTagName)
{
    if (m_spXMLDom == NULL)
    {
        CStdString msg;
        msg.Format(_T("SmartTagParser::GetTextForSmartTagName - The XML document pointer is null."));
        throw Workshare::NullReferenceException(msg);
    }

    CComBSTR nodeText = _T("//");
    nodeText += GetNamespacePrefix();
    nodeText += _T(":");
    nodeText += SmartTagName;

    MSXML2::IXMLDOMNodePtr pNode = m_spXMLDom->selectSingleNode(nodeText.m_str);

    if (pNode == NULL)
    {
        CStdString msg;
        msg.Format(_T("SmartTagParser::GetTextForSmartTagName - Failed to get node (%s) from the XML"), nodeText);
        throw Workshare::Exception(msg);
    }

    CStdString sValue = pNode->text;

    if (pNode)
    {
        pNode.Release();
    }

    return sValue;
}
예제 #10
0
/******************************************************************************
Function Name  :  GetData
Input(s)       :
Output         :  HRESULT
Functionality  :
Member of      :  CVerifyResponse
Friend of      :  -
Author(s)      :  Venkatanarayana Makam
Date Created   :  06/04/2011
Modifications  :
******************************************************************************/
HRESULT CVerifyResponse::GetData(MSXML2::IXMLDOMNodePtr& pIDomNode)
{
    CVerifyEntity::GetData(pIDomNode);
    _bstr_t bstrNodeName = def_STR_VERIFYMSG_NODE;
    CComVariant NodeValue;
    MSXML2::IXMLDOMNamedNodeMapPtr pDOMVerifyAtrributes;
    MSXML2::IXMLDOMNodePtr pIDOMChildNode;
    pDOMVerifyAtrributes = pIDomNode->Getattributes();
    //bstrNodeName = def_STR_ATTRIB_WAITFOR;
    bstrNodeName.Assign(SysAllocString(CT2W(def_STR_ATTRIB_WAITFOR)));
    pIDOMChildNode = pDOMVerifyAtrributes->getNamedItem(bstrNodeName);
    pIDOMChildNode->get_nodeTypedValue(&NodeValue);
    CString strTemp;
    strTemp = strCopyBSTRToCString(NodeValue);
    //W4 Removal
    m_ushDuration = (USHORT)atoi((LPCSTR)strTemp);
    INT nCount = (INT)m_ouData.m_odVerify_MessageEntityList.GetCount();

    for(int i = 0; i < nCount; i++)
    {
        CVerify_MessageData ouVerifyData;
        POSITION pos = m_ouData.m_odVerify_MessageEntityList.FindIndex(i);
        CVerify_MessageEntity& ouVerifyEntity = m_ouData.m_odVerify_MessageEntityList.GetAt(pos);
        ouVerifyEntity.GetEntityData(VERIFY_MESSAGE, &ouVerifyData);
        m_ouVerifyMsgMap[ouVerifyData.m_dwMessageID] = ouVerifyData;
    }

    return S_OK;
}
예제 #11
0
////////////////////////////////////////////////////////////////////////////
// Helper function: Walk all the Elements at a particular node
////////////////////////////////////////////////////////////////////////////
HRESULT CXMLDocument::WalkTree(int iLevel, MSXML2::IXMLDOMNode* pNode)
{
	HRESULT hr = S_OK;

	CComBSTR bstrNodeName;
	pNode->get_nodeName(&bstrNodeName);

	CComVariant vNodeValue;
	pNode->get_nodeValue(&vNodeValue);
	vNodeValue.ChangeType(VT_BSTR);
	CString strValueString = V_BSTR(&vNodeValue);

	if (m_pCallbackFunction)
		m_pCallbackFunction(iLevel, CString(bstrNodeName), (LPCSTR)NULL, strValueString, m_pCallbackParam);

	MSXML2::IXMLDOMNamedNodeMapPtr pAttributes = NULL;
	if (SUCCEEDED(pNode->get_attributes(&pAttributes)) && (pAttributes != NULL))
	{
		MSXML2::IXMLDOMNodePtr pAttribute = NULL;
		pAttributes->nextNode(&pAttribute);
		bool bRetVal = true;
		while (pAttribute)
		{
			CComBSTR bstrAttribName;
			pAttribute->get_nodeName(&bstrAttribName);

			CComVariant vNodeValue;
			pAttribute->get_nodeValue(&vNodeValue);
			vNodeValue.ChangeType(VT_BSTR);
			CString strValueString = V_BSTR(&vNodeValue);

			if (m_pCallbackFunction)
				bRetVal = m_pCallbackFunction(iLevel+1, CString(bstrNodeName), CString(bstrAttribName), strValueString, m_pCallbackParam);

			if (!bRetVal)
			{
				// set complete error message with node name and all attribute values
				m_strErrorNode = bstrNodeName;
				return S_FALSE;
			}

			pAttributes->nextNode(&pAttribute);
		}
	}

	MSXML2::IXMLDOMNodePtr pChild = NULL;
	pNode->get_firstChild(&pChild);
	while (pChild)
	{
		if (WalkTree(iLevel+1, pChild) != S_OK)
			return S_FALSE;

		MSXML2::IXMLDOMNode* pNext = NULL;
		pChild->get_nextSibling(&pNext);
		pChild = pNext;
	}

	return S_OK;
}
bool PropertyElement::IsPropertyElement(MSXML2::IXMLDOMNodePtr  pNode)
{
	MSXML2::IXMLDOMNodePtr pNameElement = pNode->selectSingleNode(bstr_t(L"Name"));
	MSXML2::IXMLDOMNodePtr pValueElement = pNode->selectSingleNode(bstr_t(L"Value"));
	if(pNameElement!=NULL && pValueElement !=NULL)
		return true;
	return false;
}
예제 #13
0
MSXML2::IXMLDOMNodePtr CXmlBase::InsertEnterAndTabs(MSXML2::IXMLDOMNodePtr pParentNode, MSXML2::IXMLDOMNodePtr pNode, int nLevel)
{
	HRESULT hr = S_OK;
	MSXML2::IXMLDOMDocument2Ptr pDoc = NULL;
	MSXML2::IXMLDOMTextPtr pTabsText = NULL;
	MSXML2::IXMLDOMNodePtr pTabsNode = NULL;
	MSXML2::IXMLDOMElementPtr pElement = NULL;
	CString strText(_T("")), strTabs(_T(""));
	CComBSTR bstrText;

	if (nLevel < 0 
		|| pParentNode == NULL) return NULL;

	if(pNode == NULL)nLevel = 0;

	for (int i=0; i<nLevel; i++)
	{
		strTabs += _T("\t");
	}
	strText.Format(_T("%s%s"), _T("\r\n"), (LPCTSTR)strTabs);
	bstrText = _bstr_t(strText).GetBSTR();

	try
	{
		pDoc = pParentNode->GetownerDocument();
		if (pDoc == NULL) return NULL;

		pTabsText = pDoc->createTextNode((LPCTSTR)strText);
		if (pTabsText == NULL) return NULL;
		CComVariant varNode = pNode.GetInterfacePtr();
		pTabsNode = pParentNode->insertBefore(pTabsText, varNode);


		//hr = pDoc->raw_createTextNode(bstrText.m_str, &pTabsText);
		//if (FAILED(hr) || pTabsText == NULL) return NULL;
		//pElement = pTabsText;
		//pTabsNode = pParentNode->appendChild(pElement);

		//pTabsNode = pDoc->createTextNode((LPCTSTR)strText);  
		//if (pTabsNode == NULL) return NULL;
		//pNode = pNode->appendChild(pTabsNode);
	}
	catch(_com_error &e)
	{
		CString str;
		str.Format(_T("创建xml节点发生异常。\r\nComError:\r\n%s")
			, e.ErrorMessage());
		::MessageBox(NULL,str, g_sAppTitle, MB_OK|MB_ICONERROR);
		return NULL;
	}
	catch(...)
	{
		return NULL;
	}
	return pTabsNode;
}
예제 #14
0
int CXmlBase::GetAttrsOfNode(map<CString, CComBSTR>& mapAttrs, MSXML2::IXMLDOMNodePtr pNode)
{
	MSXML2::IXMLDOMNamedNodeMapPtr pAttrs;
	MSXML2::IXMLDOMNodePtr pAttr;
	HRESULT hr;
	CComBSTR bstrText;
	CString str;
	long lAttrCount = 0;

	mapAttrs.clear();
	
    if (NULL == pNode)
	{
		//WRITELOG("END, pNode为空");
		return 0;
	}

	pAttrs = pNode->Getattributes();
	if (pAttrs == NULL)
	{
		//WRITELOG("END, 取得节点属性集合失败");
		return 0;
	}

	lAttrCount = pAttrs->Getlength();
	for (int i=0; i<lAttrCount; i++)
	{
		pAttr = pAttrs->Getitem(i);
		if (pAttr == NULL)
		{
			//WRITELOG("取得第[%d]个属性为空", i); 
			continue;
		}

		hr = pAttr->get_nodeName(&bstrText);
		if (FAILED(hr))
		{
			//WRITELOG("取得第[%d]个属性名为空", i); 
			continue;
		}
		if (!ConvertBSTR2CString(str, bstrText.m_str))
		{
			//WRITELOG("转换第[%d]个属性名 失败", i); 
			continue;
		}
		hr = pAttr->get_text(&bstrText);
		if (FAILED(hr))
		{
			//WRITELOG("取得第[%d]个属性值 失败,属性[%s]", i, str); 
			continue;
		}
		mapAttrs.insert(make_pair(str, bstrText));
	}
	
	return (int)mapAttrs.size();
}
예제 #15
0
	MSXML2::IXMLDOMNode* CXmlNodeWrapper::InsertAfter(MSXML2::IXMLDOMNode *refNode, MSXML2::IXMLDOMNode *pNode)
	{
		MSXML2::IXMLDOMNodePtr nextNode = refNode->GetnextSibling();
		MSXML2::IXMLDOMNodePtr newNode;
		if (nextNode.GetInterfacePtr() != NULL)
			newNode = m_xmlnode->insertBefore(pNode,(IUnknown*)nextNode);
		else
			newNode = m_xmlnode->appendChild(pNode);
		return newNode.Detach();
	}
예제 #16
0
/******************************************************************************
Function Name  :  nParseTSFile
Input(s)       :  CString omstrTSFile
Output         :  INT
Functionality  :  Load the omStrTSFille
Member of      :  CTestSetupEntity
Friend of      :  -
Author(s)      :  Venkatanarayana Makam
Date Created   :  06/04/2011
Modifications  :
Codetag        : CS002
******************************************************************************/
INT CTestSetupEntity::nParseTSFile(CString omstrTSFile)
{
    MSXML2::IXMLDOMDocumentPtr pIDOMDoc;
    HRESULT hr = pIDOMDoc.CreateInstance(L"Msxml2.DOMDocument");

    if ( FAILED(hr) )
    {
        throw "Unable to create XML parser object";
    }

    if(PathFileExists(omstrTSFile) == FALSE)
    {
        return ERR_PATH_INCORRECT;
    }

    //Create A TestSetup DOM document
    CComVariant varFileName((LPCSTR)omstrTSFile);

    try
    {
        pIDOMDoc->load(varFileName);
        //GetTest Setup Title
        MSXML2::IXMLDOMNodePtr pIDOMTiltleNode;
        _bstr_t bstrNodeName = def_STR_TSNODE_NAME;
        CComVariant NodeValue;
        pIDOMTiltleNode = pIDOMDoc->selectSingleNode(bstrNodeName);
        MSXML2::IXMLDOMNamedNodeMapPtr pDOMTCAtrributes;
        pDOMTCAtrributes = pIDOMTiltleNode->Getattributes();
        MSXML2::IXMLDOMNodePtr pIDOMChildNode;
        //bstrNodeName = def_STR_TSATTRIB_TITLE;
        bstrNodeName.Assign(SysAllocString(CT2W(def_STR_TSATTRIB_TITLE)));
        pIDOMChildNode = pDOMTCAtrributes->getNamedItem(bstrNodeName);
        pIDOMChildNode->get_nodeTypedValue(&NodeValue);
        m_omstrTestSetupTitle = strCopyBSTRToCString(NodeValue);
        pIDOMChildNode.Release();
        //Get Description
        //bstrNodeName = def_STR_TSDESCRIPTION;
        bstrNodeName.Assign(SysAllocString(CT2W(def_STR_TSDESCRIPTION)));
        MSXML2::IXMLDOMNodePtr pIDOMDescriptionNode = pIDOMDoc->selectSingleNode(bstrNodeName);
        pIDOMDescriptionNode->get_nodeTypedValue(&NodeValue);
        m_omstrDescription = strCopyBSTRToCString(NodeValue);
        //Get Header Node
        //bstrNodeName = def_STR_TSHEADER;
        bstrNodeName.Assign(SysAllocString(CT2W(def_STR_TSHEADER)));
        MSXML2::IXMLDOMNodePtr pIDOMHeaderNode = pIDOMDoc->selectSingleNode(bstrNodeName);
        nLoadHeader(pIDOMHeaderNode);
        pIDOMHeaderNode.Release();
        //Get TestCases List
        //bstrNodeName = def_STR_TSTCLIST;
        bstrNodeName.Assign(SysAllocString(CT2W(def_STR_TSTCLIST)));
        MSXML2::IXMLDOMNodePtr pIDOMTSNode = pIDOMDoc->selectSingleNode(bstrNodeName);
        GetData(pIDOMTSNode);
    }
    catch(...)
    {
        return S_FALSE;
    }

    return S_OK;
}
예제 #17
0
	MSXML2::IXMLDOMNode* CXmlNodeWrapper::InsertBefore(MSXML2::IXMLDOMNode *refNode, LPCTSTR nodeName)
	{
		MSXML2::IXMLDOMDocumentPtr xmlDocument = m_xmlnode->GetownerDocument();
		if (xmlDocument)
		{
			MSXML2::IXMLDOMNodePtr newNode = xmlDocument->createNode(_variant_t((short)MSXML2::NODE_ELEMENT),nodeName,"");
			newNode = m_xmlnode->insertBefore(newNode.Detach(),(IUnknown*)refNode);
			return newNode.Detach();
		}
		return NULL;
	}
예제 #18
0
/******************************************************************************
Function Name  :  GetData
Input(s)       :
Output         :  HRESULT
Functionality  :
Member of      :  CVerifyEntity
Friend of      :  -
Author(s)      :  Venkatanarayana Makam
Date Created   :  06/04/2011
Modifications  :
******************************************************************************/
HRESULT CVerifyEntity::GetCommonVerifyData(MSXML2::IXMLDOMNodePtr& pIDomNode, CVerifyData *verifyData)
{
	m_ouData = verifyData;
    _bstr_t bstrNodeName = def_STR_VERIFYMSG_NODE;
    CComVariant NodeValue;
    MSXML2::IXMLDOMNamedNodeMapPtr pDOMVerifyAtrributes;
    MSXML2::IXMLDOMNodePtr pIDOMChildNode;

    pDOMVerifyAtrributes = pIDomNode->Getattributes();
    //bstrNodeName = L"failure";
    bstrNodeName.Assign(SysAllocString(CT2W("failure")));
    pIDOMChildNode = pDOMVerifyAtrributes->getNamedItem(bstrNodeName);
    pIDOMChildNode->get_nodeTypedValue(&NodeValue);
    CString strTemp;
    strTemp = strCopyBSTRToCString(NodeValue);

	//m_ouData = new CVerifyData();
    if(strTemp == "SUCCESS")
    {
        m_ouData->m_eAttributeError = SUCCESS;
    }
    else if(strTemp == "WARNING")
    {
        m_ouData->m_eAttributeError = WARNING;
    }
    else if(strTemp == "ERRORS")
    {
        m_ouData->m_eAttributeError = ERRORS;
    }
    else
    {
        m_ouData->m_eAttributeError = FATAL;
    }
    MSXML2::IXMLDOMNodeListPtr pIDOMSendList;

    LONG lCount;
    //bstrNodeName = def_STR_VERIFYMSG_NODE;
    bstrNodeName.Assign(SysAllocString(CT2W(def_STR_VERIFYMSG_NODE)));
    pIDOMSendList = pIDomNode->selectNodes(bstrNodeName);
    pIDOMSendList->get_length(&lCount);

    for(int i = 0; i < lCount; i++)
    {
        CVerifySubEntity *odVerifySubEntity;
        MSXML2::IXMLDOMNodePtr pIXMLDOMVerifyMsgEntity;
        pIXMLDOMVerifyMsgEntity = pIDOMSendList->Getitem(i);
		//if(CVerifySubEntity::GetData(&odVerifySubEntity, pIXMLDOMVerifyMsgEntity) == S_OK)
		if(this->GetSubEntityData(&odVerifySubEntity, pIXMLDOMVerifyMsgEntity) == S_OK)
        {
            m_ouData->m_odVerifySubEntityList.push_back(odVerifySubEntity);
        }
    }
    return S_OK;
}
예제 #19
0
파일: WXmlParse.cpp 프로젝트: cxwangwc/Rule
BOOL WXmlParse::readCalculateParams(WCalcaulateParam &calParam)
{
	MSXML2::IXMLDOMDocumentPtr doc;
	MSXML2::IXMLDOMElementPtr docRoot;  
	MSXML2::IXMLDOMElementPtr docElement;  
	MSXML2::IXMLDOMNodeListPtr elementNodes;  
	MSXML2::IXMLDOMNamedNodeMapPtr elementAttributes;
	MSXML2::IXMLDOMNodePtr xmlNode;  
	MSXML2::IXMLDOMNodePtr xmlSubNode; 
	MSXML2::IXMLDOMNodePtr xmlAttrNode; 
	doc.CreateInstance(__uuidof(DOMDocument30));  
	if (m_strFileName.IsEmpty())
	{
		return FALSE;
	}
	doc->load((_variant_t)m_strFileName);

	docRoot = doc->GetdocumentElement();//获得根节点;  
	docRoot->get_childNodes(&elementNodes);  
	LONG length, subLength, attrLength;
	elementNodes->get_length(&length);
	MSXML2::IXMLDOMNodeListPtr subElementNodes; 

	// 0 : 
	elementNodes->get_item(2, &xmlNode);
	xmlNode->get_childNodes(&subElementNodes);
	subElementNodes->get_length(&subLength);
	for (int j = 0; j < subLength;j++)
	{
		subElementNodes->get_item(j, &xmlSubNode);//获得某个属性
		xmlSubNode->get_attributes(&elementAttributes); 
		MSXML2::IXMLDOMNodePtr proNode = elementAttributes->getNamedItem("name");
		string proName = proNode->text;
		MSXML2::IXMLDOMNodeListPtr subAttrNodes; 
		xmlSubNode->get_childNodes(&subAttrNodes);
		subAttrNodes->get_length(&attrLength);
//		ASSERT(attrLength == 2);

		MSXML2::IXMLDOMNodePtr descNode;
		MSXML2::IXMLDOMNodePtr stateNode;
		subAttrNodes->get_item(0, &descNode);
		subAttrNodes->get_item(1, &stateNode);
		std::vector<string> vecParam;
		string descText = descNode->text;
		string stateText = stateNode->text;
		vecParam.push_back(proName);
		vecParam.push_back(descText);
		vecParam.push_back(stateText);

		calParam.addParam(vecParam);
	}

	return TRUE;
}
예제 #20
0
	CString CXmlNodeWrapper::GetValue(LPCTSTR valueName)
	{
		if (!IsValid())
			return _T("");

		MSXML2::IXMLDOMNodePtr attribute = m_xmlnode->Getattributes()->getNamedItem(valueName);
		if (attribute)
		{
			return (LPCTSTR)attribute->Gettext();
		}
		return _T("");
	}
예제 #21
0
////////////////////////////////////////////////////////////////////////////
// Helper function:
////////////////////////////////////////////////////////////////////////////
CString CXMLDocument::GetStringValue(LPCSTR szAttrib, MSXML2::IXMLDOMNode* pNode)
{
	CComBSTR bstrValue;
	MSXML2::IXMLDOMNamedNodeMapPtr pAttributes;
	MSXML2::IXMLDOMNodePtr pItemNode;

	if (SUCCEEDED(pNode->get_attributes(&pAttributes)) && (pAttributes != NULL))
		pAttributes->getNamedItem(CComBSTR(szAttrib), &pItemNode);
	if (pItemNode)
		pItemNode->get_text(&bstrValue);

	return CString(bstrValue);
}
void PropertyElement::Save(CMSD::CProperty & prop)
{
	if((name == bstr_t(L"None") && value == bstr_t(L"None")) ||
		(name == bstr_t(L"") && value == bstr_t(L""))
		)
	{
		MSXML2::IXMLDOMNodePtr  pNode = prop.GetNode()->GetparentNode(); 
		pNode->removeChild(prop.GetNode()); 
		return;
	}
	prop.Name.append() = std::string((LPCSTR) this->name);
	prop.Value2.append() = std::string((LPCSTR) value);
	CREATEIF(prop.Description.append(), description);
}
//Check if the header info matches any of the supported file format headers.
bool Translator::CanTranslate(const char *fileExtension, InputStream* readStream, TSError *error, char* errorMsg, long maxErrorMsgLengthInBytes, bool checkfileExtension/*=true*/)
{
	bool ret = false;
	readStream->Offset = 0;
	GetParser()->LoadFile(readStream);
	MSXML2::IXMLDOMNodePtr header = GetParser()->GetHeader(readStream);
	std::string description = header->Getattributes()->getNamedItem("description")->text;
	if (  !m_TranslatorInfo.headerInfo.compare( description))
	{
		readStream->Offset = 0;
		ret = true;
	}
	return ret;
}
예제 #24
0
파일: WXmlParse.cpp 프로젝트: cxwangwc/Rule
BOOL WXmlParse::readParam(std::vector<WParamDefine *> &outParams)
{
	MSXML2::IXMLDOMDocumentPtr doc;
	MSXML2::IXMLDOMElementPtr docRoot;  
	MSXML2::IXMLDOMElementPtr docElement;  
	MSXML2::IXMLDOMNodeListPtr elementNodes;  
	MSXML2::IXMLDOMNamedNodeMapPtr elementAttributes;
	MSXML2::IXMLDOMNodePtr xmlNode;  
	MSXML2::IXMLDOMNodePtr xmlSubNode; 
	MSXML2::IXMLDOMNodePtr xmlAttrNode; 
	doc.CreateInstance(__uuidof(DOMDocument30));  
	if (m_strFileName.IsEmpty())
	{
		return FALSE;
	}
	doc->load((_variant_t)m_strFileName);

	docRoot = doc->GetdocumentElement();//获得根节点;  
	docRoot->get_childNodes(&elementNodes);  
	LONG length, subLength, attrLength;
	elementNodes->get_length(&length);
	MSXML2::IXMLDOMNodeListPtr subElementNodes; 

	// 0 : 
	elementNodes->get_item(0, &xmlNode);
	xmlNode->get_childNodes(&subElementNodes);
	subElementNodes->get_length(&subLength);
	for (int j = 0; j < subLength;j++)
	{
		subElementNodes->get_item(j, &xmlSubNode);//获得某个属性
		xmlSubNode->get_attributes(&elementAttributes); 
		MSXML2::IXMLDOMNodePtr proNode = elementAttributes->getNamedItem("name");
		string proName = proNode->text;
		WParamDefine *paramTest = new WParamDefine(proName);
		MSXML2::IXMLDOMNodeListPtr subAttrNodes;  
		xmlSubNode->get_childNodes(&subAttrNodes);
		subAttrNodes->get_length(&attrLength);
		for (int k = 0;k < attrLength;k++)
		{
			subAttrNodes->get_item(k, &xmlAttrNode);
			string attrName = xmlAttrNode->nodeName;
			string attrText = xmlAttrNode->text;
			paramTest->addValue(attrName, attrText);
		}
		outParams.push_back(paramTest);
	}

	return TRUE;
}
예제 #25
0
BOOL CXmlFile::Export(const CXmlItem* pItem, CXmlNodeWrapper* pNode) const
{
	// own value
	if (pItem->GetValueLen())
		pNode->SetText(pItem->GetValue());
	
	// attributes and items
	POSITION pos = pItem->GetFirstItemPos();
	int nNode = 0;
	
	while (pos)
	{
		const CXmlItem* pXIChild = pItem->GetNextItem(pos);
		ASSERT (pXIChild);
		
		CString sItem = pXIChild->GetName();
		
		if (pXIChild->IsAttribute())
		{
			ASSERT (!pXIChild->GetSibling());
			pNode->SetValue(sItem, pXIChild->GetValue());
		}
		else if (pXIChild->IsCDATA())
		{
			// create a named node to wrap the CDATA
			MSXML2::IXMLDOMNodePtr pChildNode = pNode->InsertNode(nNode++, (LPCTSTR)sItem);
			MSXML2::IXMLDOMCDATASectionPtr pCData = 
				pNode->ParentDocument()->createCDATASection((LPCTSTR)pXIChild->GetValue());
			pChildNode->appendChild(pCData);
		}
		else // node
		{
			while (pXIChild)
			{
				// Valik - Change IXMLDOMNode* to IXMLDOMNodePtr to prevent an ambiguous symbol error (C2872) in VC 7.1
				MSXML2::IXMLDOMNodePtr pChildNode = pNode->InsertNode(nNode++, (LPCTSTR)sItem);
				CXmlNodeWrapper nodeChild(pChildNode);
				ASSERT (nodeChild.IsValid());
				
				Export(pXIChild, &nodeChild);
				
				// siblings
				pXIChild = pXIChild->GetSibling();
			}
		}
	}
	
	return TRUE;
}
예제 #26
0
bool XmlIOStreamImp::ReadNodeAttribute(const CString& attrName, CString& attrValue)
{
	DATA_ASSERT(mpCurrentNode != NULL);
	if(NULL == mpCurrentNode)
		return false;

	MSXML2::IXMLDOMNamedNodeMapPtr attribs = mpCurrentNode->Getattributes();
	
	MSXML2::IXMLDOMNodePtr pAttr = attribs->getNamedItem((LPCTSTR)attrName);
	if(NULL == pAttr)
		return false;

	attrValue = pAttr->GetnodeValue();
	return true;
}
예제 #27
0
	MSXML2::IXMLDOMNode* CXmlNodeWrapper::InsertNode(int index,LPCTSTR nodeName)
	{
		MSXML2::IXMLDOMDocumentPtr xmlDocument = m_xmlnode->GetownerDocument();
		if (xmlDocument)
		{
			MSXML2::IXMLDOMNodePtr newNode = xmlDocument->createNode(_variant_t((short)MSXML2::NODE_ELEMENT),nodeName,"");
			MSXML2::IXMLDOMNode* refNode = GetNode(index);
			if (refNode)
				newNode = m_xmlnode->insertBefore(newNode.Detach(),refNode);
			else
				newNode = m_xmlnode->appendChild(newNode.Detach());
			return newNode.Detach();
		}
		return NULL;
	}
예제 #28
0
	MSXML2::IXMLDOMNode* CXmlNodeWrapper::InsertNode(int index,MSXML2::IXMLDOMNodePtr pNode)
	{
		MSXML2::IXMLDOMNodePtr newNode = pNode->cloneNode(VARIANT_TRUE);
		if (newNode)
		{
			MSXML2::IXMLDOMNode* refNode = GetNode(index);
			if (refNode)
				newNode = m_xmlnode->insertBefore(newNode.Detach(),refNode);
			else
				newNode = m_xmlnode->appendChild(newNode.Detach());
			return newNode.Detach();
		}
		else
			return NULL;
	}
예제 #29
0
//add by lh for close a sub node on 2010-08-19
CyNode CyNode::CloneSubNode(const std::wstring&  nodeName) const
{
	MSXML2::IXMLDOMNodePtr spChild;
	MSXML2::IXMLDOMNodePtr spCloneChild;
	if(m_spNode){	
		int nCount = 0;
		for (spChild = m_spNode->firstChild; spChild; spChild = spChild->nextSibling){
			wstring csNodeName = (const wchar_t*)(spChild->nodeName);
			if (csNodeName == csNodeName){
				spCloneChild = spChild->cloneNode(-1);
				break;
			}
		}	
	}
	return CyNode(spCloneChild);
}
bool PropertyElement::IsDistributionReferenceProperty(MSXML2::IXMLDOMNodePtr  pNode)
{
	MSXML2::IXMLDOMNodePtr pDistRefElement = pNode->selectSingleNode(bstr_t(L"./DistributionDefinitionReference/DistributionDefinitionIdentifier"));
	if(pDistRefElement !=NULL)
		return true;
	return false;
}