本文整理汇总了C++中node::Ptr::isNode方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::isNode方法的具体用法?C++ Ptr::isNode怎么用?C++ Ptr::isNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类node::Ptr
的用法示例。
在下文中一共展示了Ptr::isNode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: executeXmlQuery
QStringList ExternalPlaylist::executeXmlQuery(const QString& filePath, const QString& xPath, const QStringList& parameters){
QStringList results;
// initialise Xerces-C and XQilla using XQillaPlatformUtils
try{
XQillaPlatformUtils::initialize();
}catch (const xercesc_3_1::XMLException& eXerces){
qDebug("Xerces exception message: %s", UTF8(eXerces.getMessage()));
return results;
}
// get the XQilla DOMImplementation object
xercesc_3_1::DOMImplementation *xqillaImplementation = xercesc_3_1::DOMImplementationRegistry::getDOMImplementation(X("XPath2 3.0"));
try{
// create a DOMLSParser object
AutoDelete<xercesc_3_1::DOMLSParser> parser(xqillaImplementation->createLSParser(xercesc_3_1::DOMImplementationLS::MODE_SYNCHRONOUS, 0));
// disable remote DTD resolution
parser->getDomConfig()->setParameter(xercesc_3_1::XMLUni::fgXercesLoadExternalDTD, false);
// parse the XML document
xercesc_3_1::DOMDocument *document = parser->parseURI(X(filePath.toLocal8Bit().constData()));
if(document == 0)
throw XQillaException(99,X("No XML document found"));
// determine whether to use lightweight query model
if(parameters.isEmpty()){
// parse XPath
AutoRelease<xercesc_3_1::DOMXPathExpression> expression(document->createExpression(X(xPath.toLocal8Bit().constData()), 0));
// execute query
AutoRelease<xercesc_3_1::DOMXPathResult> result(expression->evaluate(document, xercesc_3_1::DOMXPathResult::ITERATOR_RESULT_TYPE, 0));
// iterate over results
while(result->iterateNext())
results.push_back(QString::fromUtf8(UTF8(result->getNodeValue()->getTextContent())));
}else{
// set up a simple API query and context to evaluate the parsed document
XQilla xqilla;
AutoDelete<XQQuery> xQuery(xqilla.parse(X(xPath.toLocal8Bit().constData())));
AutoDelete<DynamicContext> xQueryContext(xQuery->createDynamicContext());
// grab document from xerces API
XercesConfiguration xc;
Node::Ptr node = xc.createNode(document, xQueryContext.get());
// prepare context
if(node && node->isNode()){
xQueryContext->setContextItem(node);
xQueryContext->setContextPosition(1);
xQueryContext->setContextSize(1);
// bind variables
for(int i=0; i<(signed)parameters.size(); i += 2){
if(i + 1 >= (signed)parameters.size())
break;
Item::Ptr value = xQueryContext->getItemFactory()->createString(X(parameters[i+1].toLocal8Bit().constData()), xQueryContext.get());
xQueryContext->setExternalVariable(X(parameters[i].toLocal8Bit().constData()), value);
}
}
// execute query
Result xQueryResults = xQuery->execute(xQueryContext);
// iterate over results
Item::Ptr item;
while(item = xQueryResults->next(xQueryContext)) {
results.push_back(QString::fromUtf8(UTF8(item->asString(xQueryContext))));
}
}
}catch(XQillaException &e){
// DOM3 (xerces) API
qDebug("XQillaException: %s", UTF8(e.getString()));
}catch(XQException &e){
// Simple API
qDebug("XQillaException: %s", UTF8(e.getError()));
}catch(...){
qDebug("Unspecified exception with XQilla");
}
// Terminate Xerces-C and XQilla using XQillaPlatformUtils
XQillaPlatformUtils::terminate();
return results;
}