Esempio n. 1
0
CStdString SmartTagParser::GetNamespacePrefix()
{
    if (m_spXMLDom == NULL)
    {
        CStdString msg;
        msg.Format(_T("SmartTagParser::GetNamespacePrefix - The XML document pointer is null."));
        throw Workshare::NullReferenceException(msg);
    }

    MSXML2::IXMLDOMElementPtr spElement = m_spXMLDom->firstChild;
    if (spElement == NULL)
    {
        CStdString msg;
        msg.Format(_T("SmartTagParser::GetNamespacePrefix - Failed to get the first node of the document."));
        throw Workshare::Exception(msg);
    }

    MSXML2::IXMLDOMNamedNodeMapPtr spAttributes = spElement->attributes;
    if (spAttributes == NULL)
    {
        spElement.Release();

        CStdString msg;
        msg.Format(_T("SmartTagParser::GetNamespacePrefix - Failed to get attributes of the first child of the document."));
        throw Workshare::Exception(msg);
    }

    MSXML2::IXMLDOMAttributePtr spAttribute = spAttributes->item[0];
    if (spAttribute == NULL)
    {
        spElement.Release();
        spAttributes.Release();

        CStdString msg;
        msg.Format(_T("SmartTagParser::GetNamespacePrefix - Failed to get attributes of the first child of the document."));
        throw Workshare::Exception(msg);
    }

    CStdString sFullNamespace = spAttribute->xml;
	HRESULT hr = m_spXMLDom->raw_setProperty(_T("SelectionNamespaces"), _variant_t(sFullNamespace.c_str()));
	if (FAILED(hr))
	{
		CStdString message;
		message.Format(_T("SmartTagParser::SmartTagParser - Failed to set namespace : %s."), sFullNamespace.c_str());
		throw Workshare::Com::ComException(message.c_str(), hr, m_spXMLDom);
	}

    int iPosStart = sFullNamespace.Find(_T(":"));
    int iPosEnd = sFullNamespace.Find(_T("="));

    CStdString sPrefix = sFullNamespace.Mid(iPosStart+1, iPosEnd - (iPosStart+1));

    spElement.Release();
    spAttributes.Release();
    spAttribute.Release();

    return sPrefix;
}
/******************************************************************************
Function Name  :  GetData
Input(s)       :  MSXML2::IXMLDOMNodePtr& pIDomNode
Output         :  HRESULT
Functionality  :   
Member of      :  CWaitEntity
Friend of      :  -
Author(s)      :  Venkatanarayana Makam
Date Created   :  06/04/2011
Modifications  :  
******************************************************************************/
HRESULT CWaitEntity::GetData(MSXML2::IXMLDOMNodePtr& pIDomNode)
{
    _bstr_t bstrNodeName;
    CComVariant NodeValue;	
    MSXML2::IXMLDOMNamedNodeMapPtr pDOMWaitAtrributes;
    pDOMWaitAtrributes = pIDomNode->Getattributes();
    MSXML2::IXMLDOMNodePtr pIDOMChildNode;

    //bstrNodeName = L"purpose";
	bstrNodeName.Assign(SysAllocString(CT2W("purpose")));
    pIDOMChildNode = pDOMWaitAtrributes->getNamedItem(bstrNodeName);
    pIDOMChildNode->get_nodeTypedValue(&NodeValue);		
	m_ouData.m_omPurpose = strCopyBSTRToCString(NodeValue);
    
    pIDomNode->get_nodeTypedValue(&NodeValue);
	CString strTemp;	
	strTemp = strCopyBSTRToCString(NodeValue);
    //W4 Removal - Type Conversion No problem.
    m_ouData.m_ushDuration = (USHORT)atoi((LPCSTR)strTemp);
    pIDOMChildNode.Release();
    pDOMWaitAtrributes.Release();
    return S_OK;
}