void SE_ElementManager::handleXmlChild(SE_Element* parent, TiXmlNode* currNode, unsigned int indent) { if(!currNode) return; TiXmlNode* pChild; TiXmlText* pText; int t = currNode->Type(); int num = 0; switch(t) { case TiXmlNode::TINYXML_DOCUMENT: LOGI("...Document\n"); for(pChild = currNode->FirstChild() ; pChild != NULL ; pChild = pChild->NextSibling()) { handleXmlChild(parent, pChild, indent + 1); } break; case TiXmlNode::TINYXML_ELEMENT: LOGI("...Element[%s]\n", currNode->Value()); handleElement(parent, currNode->Value(), currNode->ToElement(), indent + 1); break; case TiXmlNode::TINYXML_COMMENT: LOGI("...Comment:[%s]\n", currNode->Value()); break; case TiXmlNode::TINYXML_TEXT: pText = currNode->ToText(); LOGI("...Text: [%s]\n", pText->Value()); handleText(parent, pText); break; case TiXmlNode::TINYXML_DECLARATION: LOGI("...Declaration\n"); handleDeclaration(currNode->ToDeclaration()); break; } }
// // 函数:build(const char* xmlFile) // // 目的:从UIXml配置文件中创建DOM // YCUIDOM* YCUIDomBuilder::build(const char* xmlFile) { if (xmlFile == NULL) { throw YCException(2002, "YCUIDomBuilder::build中xmlFile为NULL"); } std::auto_ptr<tinyxml2::XMLDocument> doc(new tinyxml2::XMLDocument()); if (tinyxml2::XML_NO_ERROR != doc->LoadFile(xmlFile)) { throw YCException(2002, doc->GetErrorStr1()); } tinyxml2::XMLElement* rootElement = doc->RootElement(); //components tinyxml2::XMLElement* containerTag = rootElement->FirstChildElement(); //window or dialog const char* tagName = containerTag->Name(); if ( (strcmp(tagName, "window") != 0) &&(strcmp(tagName, "dialog") != 0) ) { LOG_WARNING("YCUIDomBuilder::build无效文件配置名:" << tagName); throw YCException(2002, "YCUIDomBuilder::build无效文件配置"); } YCUIDOM* uiDom = handleElement(containerTag, NULL); if (uiDom != NULL) { uiDom->setFilename(xmlFile); } return uiDom; }
void KoScriptingOdfReader::start() { KoXmlElement elem = m_doc.documentElement(); handleElement(elem); setCurrentElement(KoXmlElement()); setLevel(0); }
// // 函数:Parse(const char* strValue); // // 目的:从strValue字符串中创建DOM // YCUIDOM* YCUIDomBuilder::Parse(const char* strValue) { if (strValue == 0) { return NULL; } std::auto_ptr<tinyxml2::XMLDocument> doc(new tinyxml2::XMLDocument()); if (tinyxml2::XML_NO_ERROR != doc->Parse(strValue)) { throw YCException(2002, doc->GetErrorStr1()); } return handleElement(doc->RootElement(), NULL); }
void KoScriptingOdfReader::handleElement(KoXmlElement &elem, int level) { bool ok = m_filter.isNull(); if (! ok) { if (m_filterRegExp.isEmpty()) ok = m_filter == elem.tagName(); else ok = m_filterRegExp.exactMatch(elem.tagName()); } if (ok) { setCurrentElement(elem); setLevel(level); emitOnElement(); } level++; KoXmlElement e; forEachElement(e, elem) handleElement(e, level); // recursive }
void DOMSerializer::handleNode(const Node* pNode) const { switch (pNode->nodeType()) { case Node::ELEMENT_NODE: handleElement(static_cast<const Element*>(pNode)); break; case Node::TEXT_NODE: handleCharacterData(static_cast<const Text*>(pNode)); break; case Node::CDATA_SECTION_NODE: handleCDATASection(static_cast<const CDATASection*>(pNode)); break; case Node::ENTITY_NODE: handleEntity(static_cast<const Entity*>(pNode)); break; case Node::PROCESSING_INSTRUCTION_NODE: handlePI(static_cast<const ProcessingInstruction*>(pNode)); break; case Node::COMMENT_NODE: handleComment(static_cast<const Comment*>(pNode)); break; case Node::DOCUMENT_NODE: handleDocument(static_cast<const Document*>(pNode)); break; case Node::DOCUMENT_TYPE_NODE: handleDocumentType(static_cast<const DocumentType*>(pNode)); break; case Node::DOCUMENT_FRAGMENT_NODE: handleFragment(static_cast<const DocumentFragment*>(pNode)); break; case Node::NOTATION_NODE: handleNotation(static_cast<const Notation*>(pNode)); break; } }
void SC_HID_APIManager::elementData( int id, struct hid_device_element * ele ) { handleElement( id, ele, mShouldBeRunning ); }
// // 函数:handleElement(tinyxml2::XMLElement* element, YCUIDOM* parent) // // 目的:递归处理YCUIDOM内部函数 // YCUIDOM* handleElement(const tinyxml2::XMLElement* element, YCUIDOM* parent) { if (element == NULL) { throw YCException(2002, "YCUIDomBuilder::handleElement参数为NULL"); } YCUIDOM* current = NULL; const char* name = element->Name(); if (strcmp(name, "script") == 0) { if (parent == NULL) { throw YCException(2002, "YCUIDomBuilder::handleElement文档异常:script出现在顶层节点中!"); } const tinyxml2::XMLAttribute * attr = element->FindAttribute("file"); if (attr != NULL) { parent->setScript(attr->Value()); } } else if (strcmp(name, "layout") == 0) { if (parent == NULL) { throw YCException(2002, "YCUIDomBuilder::handleElement文档异常:layout出现在顶层节点中!"); } const tinyxml2::XMLAttribute * attr = element->FindAttribute("file"); if (attr != NULL) { parent->setLayout(attr->Value()); } } else { // 设置标签名,值 current = new YCUIDOM(); current->setName(element->Name()); current->setValue(element->GetText()); current->setParent(parent); // 设置标签属性 for (const tinyxml2::XMLAttribute* attr = element->FirstAttribute(); attr != NULL; attr = attr->Next()) { current->setAttribute(attr->Name(), attr->Value()); } // 处理子标签 for (const tinyxml2::XMLElement * subElement = element->FirstChildElement(); subElement != NULL; subElement = subElement->NextSiblingElement()) { try { current->addSubDom(handleElement(subElement, current)); } catch (YCException& e) { LOG_WARNING("YCUIDomBuilder::handleElement处理节点异常:" << e.what()); } } } return current; }
void IngredientListView::checkCreateIngredient( const Element &el ) { if ( handleElement(el.name) ) { //only create this ingredient if the base class okays it createIngredient(el); } }