Exemple #1
0
	std::wstring CXmlNode::ReadValueString(const std::wstring& sName, const std::wstring& nDef)
	{
		CXmlNode oTemp;
		if (GetNode(sName, oTemp))
			return oTemp.GetText();
		return L"";
	}
Exemple #2
0
HRESULT CXmlDocument::SetXmlDocument(VARIANT* pXmlDocument, bool& bLoginPage,bool bCheckLogin, bool& bErrXml)
{
	bCheckLogin;
	bErrXml = false;
	bLoginPage = false;

	CString xpath(_T("//AwsTimeout/Url"));
	CString errpath(_T("//Error"));
	CXmlNode node;

	if (SetXmlDocument(pXmlDocument)==S_OK)
	{
		
		if (m_pNode!=NULL)
		{
			node = Find(xpath);
			if (!node.IsNull())
				bLoginPage = true;

			node = Find(errpath);
			if(!node.IsNull()) 
				bErrXml = true;
		}
	}
	return S_OK;
}
Exemple #3
0
//----------------------------------------
CDefaultRecord* CAliasesDictionary::CreateDefaultRecord(CXmlNode* defaultRecordNode)
{
  if (defaultRecordNode == NULL)
  {
    return NULL;
  }

  CDefaultRecord* defaultRecord = new CDefaultRecord();

  std::string value;

  bool bOk = defaultRecordNode->GetPropVal(CAliasesDictionary::m_NAME_ATTR, &value);
  if (!bOk)
  {
    std::string msg = CTools::Format("Unable to create default record - Default record name is empty - "
      "Please check all '%s' attributes of the '%s' elements in the aliases dictionary '%s'.",
      CAliasesDictionary::m_NAME_ATTR.c_str(),
      CAliasesDictionary::m_DEFAULT_RECORD_ELT.c_str(),
      m_fullFileName.c_str());

    delete defaultRecord;
    defaultRecord = NULL;

    throw CXMLException(msg, BRATHL_ERROR);
  }

  defaultRecord->SetName(value);

  CObArray arrayNodes(false);
  
  FindAllNodesByName(CAliasesDictionary::m_PRODUCT_TYPE_ELT, defaultRecordNode, arrayNodes, false);

  CObArray::const_iterator it;

  for(it = arrayNodes.begin() ; it != arrayNodes.end() ; it++)
  {
    CXmlNode* node = dynamic_cast<CXmlNode*>(*it);

    if (node == NULL)
    {
      continue;
    }

    CXmlNode* textNode = node->GetChildren();

    if (textNode == NULL)
    {
      continue;
    }

    std::string productType = textNode->GetContent().c_str();
    if (productType.empty())
    {
      continue;
    }
    defaultRecord->AddProductType(productType);
  }

  return defaultRecord;
}
Exemple #4
0
bool CXmlDocument::SetNodeAttribute(const CXmlNode& node, const CString& attributeName, const CString& value)
{
	if(node.GetNode() == NULL)
		return FALSE;

	XmlAttribute pAttr;
	HRESULT hr = m_pDoc->createAttribute((_bstr_t)attributeName, &pAttr);
	if ( FAILED(hr) )
		return FALSE;

	hr = pAttr->put_text((_bstr_t)value);
	if( FAILED(hr) )
		return FALSE;

	XmlMap pNodeMap;
	hr = node.GetNode()->get_attributes(&pNodeMap);
	if ( FAILED(hr) )
		return FALSE;

	XmlNode pNamedItem;
	hr = pNodeMap->setNamedItem(pAttr, &pNamedItem);
	if ( FAILED(hr) )
		return FALSE;

	return TRUE;
}
Exemple #5
0
BOOL CXmlNode::GetFirstChildNode(LPCTSTR pNodeName, CXmlNode& objXmlNode)
{
	IXMLDOMNode * pXMLNode, * pTmpXMLNode;
	BSTR bstrNodeName;
	HRESULT hr;

	if (!pNodeName || !m_pXMLNode)
		return FALSE;

	pXMLNode = NULL;
	hr = m_pXMLNode->get_firstChild(&pXMLNode);
	while (hr == S_OK)
	{
		bstrNodeName = NULL;
		hr = pXMLNode->get_nodeName(&bstrNodeName);
		if (hr == S_OK)
		{
			int nRet = wcscmp(bstrNodeName, pNodeName);
			::SysFreeString(bstrNodeName);
			if (nRet == 0)
			{
				objXmlNode.Attach(pXMLNode);
				return TRUE;
			}
		}

		pTmpXMLNode = NULL;
		hr = pXMLNode->get_nextSibling(&pTmpXMLNode);
		pXMLNode->Release();
		pXMLNode = pTmpXMLNode;
	}

	objXmlNode.Attach(NULL);
	return FALSE;
}
Exemple #6
0
BOOL CXmlDocument::SelectSingleNode(LPCTSTR pNodeName, CXmlNode& objXmlNode)
{
	IXMLDOMNode * pXMLNode;
	BSTR bstrNodeName;
	HRESULT hr;

	if (NULL == pNodeName || NULL == m_pXMLDoc)
		return FALSE;

	bstrNodeName = ::SysAllocString(pNodeName);

	pXMLNode = NULL;
	hr = m_pXMLDoc->selectSingleNode(bstrNodeName, &pXMLNode);
	::SysFreeString(bstrNodeName);
	if (hr == S_OK)
	{
		objXmlNode.Attach(pXMLNode);
		return TRUE;
	}
	else
	{
		objXmlNode.Attach(NULL);
		return FALSE;
	}
}
Exemple #7
0
BOOL CXMLVecLS::LoadNonFillVecElem(COutlined *pElem,CXmlNode &node)
{
	pElem->SetDasHStyle(node.GetIntAttrib(_T("DashStyle")));
	pElem->SetOutlineWidth(node.GetIntAttrib(_T("OutlineWidth")));
	pElem->SetOutlineColor(node.GetUIntAttrib(_T("OutlineColor")));
	return TRUE;
}
Exemple #8
0
CString CXmlDocument::GetNameSpaces()
{
	CString cstr,xpath,name,ns;
	int at;
	long count;
	count = m_pDoc->namespaces->length;
	CXmlNode node;
	for(long i =0;i<count;++i)
	{
		ns = (LPCTSTR)m_pDoc->namespaces->namespaceURI[i];
		xpath.Format(_T("//*[namespace-uri()='%s']"),ns);
		node = this->Find(xpath);
		if(node.IsValid())
		{
			name = node.GetName();
			if((at=name.Find(_T(":"),0))>=0)
			{
				if(!cstr.IsEmpty()) cstr += _T(" ");
				cstr.AppendFormat(_T("xmlns:%s='%s'"),name.Left(at),ns);
			}
		}

	}
	return cstr;
}
Exemple #9
0
void  CXmlNode::SetNodeAttribute(const CString& xpath, const CString& attributeName, const CString& value)
{
	CXmlNode child = this->Find(xpath);
	if(child.IsValid())
	{
		child.SetAttribute(attributeName, value);
	}
}
Exemple #10
0
	CString CXmlNode::ReadValueString(const CString& sName, const CString& nDef)
	{
		CString sRes;
		CXmlNode oTemp;
		if(GetNode(sName, oTemp))
			sRes = oTemp.GetText();
		return sRes;
	}
Exemple #11
0
void CXmlNode::SetNodeValue(const CString& xpath, const CString& value)
{
	CXmlNode node = this->Find(xpath);
	if(node.IsNull())
		return;
	else
		node.SetValue(value);
}
Exemple #12
0
void  CXMLVecLS::SaveFilledVecElem(const CFilled *pElem,CXmlNode &node)
{
	node.SetAttrib(_T("Outline"),pElem->IsOutline());
	node.SetAttrib(_T("DashStyle"),pElem->GetDashStyle());
	node.SetAttrib(_T("OutlineWidth"),pElem->GetOutlineWidth());
	node.SetAttrib(_T("OutlineColor"),pElem->GetOutlineColor());

	node.SetAttrib(_T("Fill"),pElem->IsFill());
	node.SetAttrib(_T("FillColor"),pElem->GetFillColor());
}
Exemple #13
0
// 加载杂项配置
BOOL LoadMiscConfig(LPCTSTR lpszFileName)
{
	CXmlDocument xmlDoc;
	CXmlNode xmlNode;

	BOOL bRet = xmlDoc.Load(lpszFileName);
	if (!bRet)
		return FALSE;

	bRet = xmlDoc.SelectSingleNode(_T("/Misc/FontInfo"), xmlNode);
	if (bRet)
	{
		g_fontInfo.m_strName = xmlNode.GetAttribute(_T("Name"));
		g_fontInfo.m_nSize = xmlNode.GetAttributeInt(_T("Size"));
		tstring strColor = xmlNode.GetAttribute(_T("Color"));
		g_fontInfo.m_clrText = HexStrToRGB(strColor.c_str());
		g_fontInfo.m_bBold = xmlNode.GetAttributeInt(_T("Bold"));
		g_fontInfo.m_bItalic = xmlNode.GetAttributeInt(_T("Italic"));
		g_fontInfo.m_bUnderLine = xmlNode.GetAttributeInt(_T("UnderLine"));
	}

	bRet = xmlDoc.SelectSingleNode(_T("/Misc/HotKey"), xmlNode);
	if (bRet)
	{
		tstring strHotKey = xmlNode.GetText();
		g_cHotKey = toupper(strHotKey.at(0));
	}

	xmlNode.Release();
	xmlDoc.Release();

	return TRUE;
}
Exemple #14
0
void CComplexTest::Do(const _tstring & sFileName)
{
	CXmlNode xmlData;
	boost::property_tree::xml_parser::read_xml(sFileName, xmlData);

	const CXmlNode& xmlCase = xmlData.get_child(_T("complex_test.cases.case"));

	CTestCase Case;
	Case.Execute(xmlCase);

}
Exemple #15
0
_variant_t CXmlNode::GetNodeAttributeData(LPCTSTR xpath,LPCTSTR attrname,const _variant_t defVar)
{
	CXmlNode node = this->Find(xpath);
	if(node.IsNull())
	{
		return defVar;
	}
	else
	{
		return node.GetAttributeData(attrname, defVar); //Using the default value specified by a client
	}
}
Exemple #16
0
CString CXmlNode::GetNodeAttribute(LPCTSTR xpath,LPCTSTR attrname)
{
	CXmlNode node = this->Find(xpath);
	if(node.IsNull())
	{
		return _T("");
	}
	else
	{
		return node.GetAttribute(attrname);
	}
}
Exemple #17
0
CString CXmlNode::GetNodeXml(LPCTSTR xpath)
{
	CXmlNode node = this->Find(xpath);
	if(node.IsNull())
	{
		return _T("");
	}
	else
	{
		return node.GetXml();
	}
}
Exemple #18
0
	int CXmlNode::ReadValueInt(const CString& str, const int& nDef)
	{
		int nRes = nDef;
		CXmlNode oTemp;
		if(GetNode(str, oTemp))
		{
			CString sText;
			if(oTemp.GetTextIfExist(sText))
				nRes = XmlUtils::GetInteger(sText);
		}
		return nRes;
	}
Exemple #19
0
_variant_t CXmlNode::GetAttributeData(const CString& attributeName,const _variant_t defVar)
{
	CXmlNode node;
	node=m_pNode->attributes->_getNamedItem(_bstr_t(attributeName));
	if(node.IsValid())
	{
		return node.GetData();
	}
	else
	{
		return defVar;
	}
}
Exemple #20
0
////////////////////////////////////////////////////////////////////////////////////
//CXmlNodeList
CString CXmlNodeList::GetDelimitedString(const CString &delimiter)
{
	ATLASSERT(m_pNodeList!=NULL);
	CString cstr;
	CXmlNode node;
	long nLength = m_pNodeList->Getlength();
	for(long i=0;i<nLength;i++)
	{	
		if(i>0) cstr+=delimiter;
		node=m_pNodeList->Getitem(i);
		cstr+=node.GetValue();
	}
	return cstr;
}
Exemple #21
0
_variant_t CXmlNode::GetNodeData(LPCTSTR xpath)
{
	CXmlNode node = this->Find(xpath);
	if(node.IsNull())
	{
		_variant_t var;
		var.Clear();
		return var;
	}
	else
	{
		return node.GetData();
	}
}
Exemple #22
0
	CNodeList CXmlNode::GetChildNode(const std::string& iTagName) const
	{
		CNodeList ret_List;
        CNodeList::const_iterator itr = mChildNodeList.begin();
        CNodeList::const_iterator lst = mChildNodeList.end();
        for(;itr != lst; ++itr)
		{
            CXmlNode* node = *itr;
			if (node->GetNodeInfo().mTagName == iTagName)
			{
				ret_List.push_back((*itr));
			}
		}
		return ret_List;
	}
Exemple #23
0
CString CXmlNode::GetAttribute(const CString& attributeName, bool bNoTrim)
{
	CXmlNode node;
	node=m_pNode->attributes->_getNamedItem(_bstr_t(attributeName));
	if(node.IsValid())
	{
		/// Modified by Anor qiu on Aug 21, 2006.
		//return node.GetValue();
		return bNoTrim? node.GetNodeValue() : node.GetValue();
		///}}
	}
	else
	{
		return _T("");
	}
}
Exemple #24
0
static void StartElementHnd(void *userData, const char *name, const char **atts) {

    XmlParsingContext *ctx = (XmlParsingContext*)userData;
    CXmlNode *node = new CXmlNode(XML_ELEMENT_NODE, CharToString(name));
    const char **a = atts;
    while (*a) {
        node->AddProperty(CharToString(a[0]), CharToString(a[1]));
        a += 2;
    }
    if (ctx->root == NULL)
        ctx->root = node;
    else
        ctx->node->AddChild(node);
    ctx->node = node;
    ctx->lastAsText = NULL;
}
void SectionDescriptor::Parse()
{
    if ( !GetNode()->HasProp(TYPE_ATTR) ) {
        throw wxString::Format(DESCRIPTOR_WRONG_XML + wxString("  %s"), wxString(GetNode()->GetName()));
    }
    m_type = new wxString(GetNode()->GetPropVal(TYPE_ATTR, ""));

    CXmlNode* current = GetNode()->GetChildren();
    while ( NULL != current ) {
        if ( wxString(current->GetName()).Cmp(COMPOSER_FIELD_ATTR) == 0 ) {
            SectionFieldDescriptor* elem = new SectionFieldDescriptor(*current);
            m_fields.push_back(elem);
        }
        current = current->GetNext();
    }
}
Exemple #26
0
bool CXmlNode::operator<(const CXmlNode &_rEl)
{
	if(this->nodeData.parent)
	{
		return this->GetProperty(this->nodeData.parent->propertyNameSorting).ToInt()<_rEl.GetProperty(this->nodeData.parent->propertyNameSorting).ToInt();
	}
	return false;
}
void ComposerDescriptor::Parse()
{
    if ( !GetNode()->HasProp(DEFAULT_JUSTIFY_ATTR) 
         || !GetNode()->HasProp(DEFAULT_FILLER_ATTR) ) {
        throw wxString::Format(DESCRIPTOR_WRONG_XML + wxString(" %s"), wxString(GetNode()->GetName()));
    }
    SectionFieldDescriptor::SetDefaultAlignment(SectionFieldDescriptor::ParseAlignment(wxString(GetNode()->GetPropVal(DEFAULT_JUSTIFY_ATTR, "L"))));
    SectionFieldDescriptor::SetDefaultFiller(wxString(GetNode()->GetPropVal(DEFAULT_FILLER_ATTR, " "))[0]);

    CXmlNode* current = GetNode()->GetChildren();
    while ( NULL != current ) {
        if ( wxString(current->GetName()).Cmp(SECTION_ATTR) == 0 ) {
            SectionDescriptor* elem = new SectionDescriptor(*current);
            m_sections.push_back(elem);
        }
        current = current->GetNext();
    }
}
Exemple #28
0
	CXmlNode CXmlNode::ReadNodeNoNS(const CString& strNodeName)
	{
		CXmlNode node;
		if (IsValid())
		{
			int nCount = (int)m_pBase->m_nodes.size();
			for (int i = 0; i < nCount; ++i)
			{
				if (strNodeName == GetNameNoNS(m_pBase->m_nodes[i]->m_sName))
				{
					CXmlNodeBase* pBase = m_pBase->m_nodes[i];
					node.SetBase(pBase);
					break;
				}
			}
		}
		return node;
	}
Exemple #29
0
BOOL CXmlNode::GetAttribute(const CString& attName,CString &attValue)
{
	try
	{
		BOOL ret = FALSE;
		CXmlNode node = m_pNode->attributes->_getNamedItem(_bstr_t(attName));
		if(node.IsValid())
		{
			attValue = node.GetValue();
			ret = TRUE;
		}
		return ret;
	}
	catch(_com_error &)
	{
		return FALSE;
	}
}
Exemple #30
0
    bool CXmlNode::GetChilds(CXmlNodes& oXmlNodes)
	{
        bool bRes = false;
		if (IsValid())
		{
			int nCount = (int)m_pBase->m_nodes.size();
			if(nCount > 0)
			{
                bRes = true;
				for (int i = 0; i < nCount; ++i)
				{
					CXmlNode oNode;
					CXmlNodeBase* pBase = m_pBase->m_nodes[i];
					oNode.SetBase(pBase);
					oXmlNodes.m_nodes.insert(oXmlNodes.m_nodes.end(), oNode);
				}
			}
		}
		return bRes;
	}