当前位置: 首页>>代码示例>>C++>>正文


C++ Tag::getChildren方法代码示例

本文整理汇总了C++中Tag::getChildren方法的典型用法代码示例。如果您正苦于以下问题:C++ Tag::getChildren方法的具体用法?C++ Tag::getChildren怎么用?C++ Tag::getChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tag的用法示例。


在下文中一共展示了Tag::getChildren方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: mapsCreate

void Xmlvalidator::mapsCreate(Document *xsd) {
	// Check that the root is a schema
	if (xsd->getRoot()->getName() == "xsd:schema")
	{
		// Get all the childrens
		vector<Item*> children = xsd->getRoot()->getChildren();

		for(vector<Item *>::iterator itElem = children.begin(); itElem != children.end(); itElem++) {
			// Get the actual element name
            string name = ((Tag *) (*itElem))->getAtts().front()->value;

            // Get the contruction node
            Tag * type = (Tag *) ((Tag *) (*itElem))->getChildren().front();
            Tag * construction = (Tag *) type->getChildren().front();

            string regex = createRegex(construction, construction->getName());

			mapRegex.insert(pair<string, string>(name, regex));
			// cout << "Regex added : " << regex << " for " << name << endl;
        }
	}
	else
	{
		cout << "Error: Wrong syntax for the given xsd while creating the maps." << endl;
	}
}
开发者ID:pmdartus,项目名称:XML-processor,代码行数:26,代码来源:xmlvalidator.cpp

示例2: checkNode

// 0 -> not valid; 1 -> valid
int Xmlvalidator::checkNode(Item* node) {
	Tag* tagNode = dynamic_cast<Tag *>(node);

	if (tagNode) {
		string name = tagNode->getName();
		string transfo = "";

		vector<Item *> children = tagNode->getChildren();
		for(vector<Item *>::iterator itCh = children.begin(); itCh != children.end(); itCh++) {
			Element* elNode = dynamic_cast<Element *>(*itCh);
			if (elNode)
			{
				transfo += "<"+elNode->getName()+">";
			}
			else
			{
				Content* ctNode = dynamic_cast<Content *>(*itCh);
				if (ctNode)
				{
					transfo += ctNode->textContent();
				}

			}

			// Recursive call for each children
			if (checkNode((*itCh)) == 0)
			{
				// if it is not valid
				return 0;
			}
		}

		std::map<string,string>::iterator itRegex = mapRegex.find(name);

		if (itRegex == mapRegex.end())
		{
			std::map<string,string>::iterator itType = mapType.find(name);
		 	itRegex = mapRegex.find(itType->second);
			
			if (itRegex == mapRegex.end())
			{
		 		cerr << "XSD not exhaustive for this xml. Missing regex for the type " << itType->second << endl;
		 	}
		}

		string regex = itRegex->second;

		// cout << "DO THE CHECK " << regex << " on " << transfo << " for the node " << name << endl;
		std::regex rx(regex);
		return regex_match(transfo.begin(), transfo.end(), rx);
	}

	return 1;
}
开发者ID:pmdartus,项目名称:XML-processor,代码行数:55,代码来源:xmlvalidator.cpp


注:本文中的Tag::getChildren方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。