本文整理汇总了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;
}
}
示例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;
}