The method getTextContent() is undefined for the type Node

本文详细介绍了在J2EE环境下,由于xml-apis.jar与Java类查找机制的冲突导致的问题,以及通过调整Jar库优先级来解决此问题的步骤和方法。
 
The method getTextContent() is undefined for the type Node
 
J2EE里的xml-apis.jar下的org.w3c.dom干扰了Java的类查找.使用JDK的包就好了,方法是,调整Jar库的优先级,如下图:
 
 
 
~~THE END~~
尹曙光
void XMLProcessor::generateDriver(DOMNode *pNode) { DOMNode *t_node = pNode->getFirstChild(); while (t_node != NULL) { //if the node is element node, then do... if (isElementNode(t_node)) { string attrType = getNodeAttribute(t_node, "type"); if (strcasecmp(attrType.c_str(), "instance") == 0) { string claName = getNodeAttribute(t_node, "class"); const ClassJoint *t_joint = ManagedObject::load(claName); if (t_joint == NULL) { throw XMLParseException("Build drivers failed! There is no such joint named \"" + claName + "\" in class-joint list."); } // create object by the classjoint related to the class ManagedObject *t_obj = NULL; try { t_obj = t_joint->createObject(); // user may throw exception here } catch (const exception &err) { throw XMLParseException("Build drivers failed! Cannot create object at the node \"" + getNodeFullName(t_node) + "\". " + string(err.what())); } catch (const string &err) { throw XMLParseException("Build drivers failed! Cannot create object at the node \"" + getNodeFullName(t_node) + "\". " + err); } catch (const char *err) { throw XMLParseException("Build drivers failed! Cannot create object at the node \"" + getNodeFullName(t_node) + "\". " + string(err)); } catch (...) { throw XMLParseException("Build drivers failed! Cannot create object at the node \"" + getNodeFullName(t_node) + "\". "); } string simulated = getNodeAttribute(t_node, "simulated"); // check if the sub-method node contains "setSimulated" // for (DOMNode *node = t_node->getFirstChild(); node != NULL; node = node->getNextSibling()) { if (isElementNode(node)) { XStr nodeName(node->getNodeName()); XStr content(node->getTextContent()); if (strcmp(nodeName.self(), "setSimulated")==0 && simulated=="") { simulated = string(content.self()); } } } if (!simulated.empty()) // is NOT default (false) { if (simulated == "true") { t_obj->setSimulated(true); } else if ((simulated != "false") && (simulated != "")) { delete t_obj; // destroy t_obj throw XMLParseException("Build drivers failed! Invalid simulated flag at the node \"" + getNodeFullName(t_node) + "\". "); } } // parse the method-node and config for (DOMNode *node=t_node->getFirstChild(); node!=NULL; node=node->getNextSibling()) { XStr nodeName(node->getNodeName()); XStr content(node->getTextContent()); string attrMType = getNodeAttribute(node, "type"); // skip the no-method node if ((attrMType=="") || (strcasecmp(attrMType.c_str(), "method")!=0)) continue; try { ((CmdTarget*)t_obj)->dispatchMsg(nodeName.self(), content.self()); // throw DispatchMsgFailedException } catch (const exception &err) { // Cannot delete t_obj without error, because the t_obj may be registered in DeviceManager // through init() method already. <><><> If the t_obj has NOT been registered, its resource // will be release by the Process. TODO: Delete t_obj properly! // throw XMLParseException("Build drivers failed! Configuration error occurred at the node \"" + getNodeFullName(node) + "\". " + string(err.what())); } } } } else { generateDriver(t_node); } t_node = t_node->getNextSibling(); } } 逐行解释代码
最新发布
08-02
评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值