本文整理汇总了C++中XPath::execute方法的典型用法代码示例。如果您正苦于以下问题:C++ XPath::execute方法的具体用法?C++ XPath::execute怎么用?C++ XPath::execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XPath
的用法示例。
在下文中一共展示了XPath::execute方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
XALAN_CPP_NAMESPACE_USE
XERCES_CPP_NAMESPACE_USE
const XObjectPtr
ExecuteXPath(
XPathProcessor& theXPathProcessor,
XPathConstructionContext& theXPathConstructionContext,
XPath& theXPath,
const XalanDOMString& theXPathString,
XalanNode* theContextNode,
const PrefixResolver& thePrefixResolver,
const NodeRefListBase& theContextNodeList,
XPathExecutionContext& theExecutionContext)
{
theXPathProcessor.initXPath(
theXPath,
theXPathConstructionContext,
theXPathString,
thePrefixResolver);
const XObjectPtr theResult =
theXPath.execute(theContextNode, thePrefixResolver, theContextNodeList, theExecutionContext);
return theResult;
}
示例2:
XObjectPtr
XPathEvaluator::evaluate(
DOMSupport& domSupport,
XalanNode* contextNode,
const XPath& xpath,
const PrefixResolver& prefixResolver,
XPathEnvSupport& envSupport)
{
// Reset these, in case we've been here before...
m_executionContext->reset();
m_xobjectFactory->reset();
// Set up the connections between the execution context and
// the provided support objects...
m_executionContext->setXPathEnvSupport(&envSupport);
m_executionContext->setXObjectFactory(m_xobjectFactory.get());
m_executionContext->setDOMSupport(&domSupport);
// OK, evaluate the expression...
const XObjectPtr theResult(
xpath.execute(
contextNode,
prefixResolver,
*m_executionContext.get()));
// Break the connectons we set...
m_executionContext->setXPathEnvSupport(0);
m_executionContext->setXObjectFactory(0);
m_executionContext->setDOMSupport(0);
return theResult;
}
示例3: evaluateExpr
//.........这里部分代码省略.........
XPathEnvSupportDefault xpesd;
XObjectFactoryDefault xof;
XPathExecutionContextDefault xpec(xpesd, xds, xof);
ElementPrefixResolverProxy pr(xd->getDocumentElement(), xpesd, xds);
// Work around the fact that the XPath implementation is designed for XSLT, so does
// not allow here() as a NCName.
// THIS IS A KLUDGE AND SHOULD BE DONE BETTER
int offset = 0;
safeBuffer k(KLUDGE_PREFIX);
k.sbStrcatIn(":");
offset = inexpr.sbStrstr("here()");
while (offset >= 0) {
if (offset == 0 || offset == 1 ||
(!(inexpr[offset - 1] == ':' && inexpr[offset - 2] != ':') &&
separator(inexpr[offset - 1]))) {
inexpr.sbStrinsIn(k.rawCharBuffer(), offset);
}
offset = inexpr.sbOffsetStrstr("here()", offset + 11);
}
// Install the External function in the Environment handler
if (hereNode != NULL) {
xpesd.installExternalFunctionLocal(XalanDOMString(URI_ID_DSIG), XalanDOMString("here"), DSIGXPathHere(hereNode));
}
str.sbStrcpyIn("(descendant-or-self::node() | descendant-or-self::node()/attribute::* | descendant-or-self::node()/namespace::*)[");
str.sbStrcatIn(inexpr);
str.sbStrcatIn("]");
XPath * xp = xpf.create();
XalanDOMString Xexpr((char *) str.rawBuffer());
xppi.initXPath(*xp, xpcc, Xexpr, pr);
// Now resolve
XObjectPtr xObj = xp->execute(contextNode, pr, xpec);
// Now map to a list that others can use (naieve list at this time)
const NodeRefListBase& lst = xObj->nodeset();
int size = (int) lst.getLength();
const DOMNode *item;
for (int i = 0; i < size; ++ i) {
if (lst.item(i) == xd)
m_XPathMap.addNode(document);
else {
item = xwn.mapNode(lst.item(i));
m_XPathMap.addNode(item);
}
}
if (inputType == DOM_NODE_XPATH_NODESET) {
//the input list was a XPATH nodeset, so we must intersect the
// results of the XPath processing done above with the input nodeset
m_XPathMap.intersect(input->getXPathNodeList());
}
}
catch (XSLException &e) {
safeBuffer msg;
// Whatever happens - fix any changes to the original document
clearXPathNS(document, addedNodes, formatter, mp_nse);
// Collate the exception message into an XSEC message.
msg.sbTranscodeIn("Xalan Exception : ");
#if defined (XSEC_XSLEXCEPTION_RETURNS_DOMSTRING)
msg.sbXMLChCat(e.getType().c_str());
#else
msg.sbXMLChCat(e.getType());
#endif
msg.sbXMLChCat(" caught. Message : ");
msg.sbXMLChCat(e.getMessage().c_str());
throw XSECException(XSECException::XPathError,
msg.rawXMLChBuffer());
}
clearXPathNS(document, addedNodes, formatter, mp_nse);
}
示例4: xwn
//.........这里部分代码省略.........
int offset = 0;
safeBuffer k(KLUDGE_PREFIX);
k.sbStrcatIn(":");
// Map the expression into a local code page string (silly - should be XMLCh)
safeBuffer exprSB;
exprSB << (*mp_formatter << expr->m_expr.rawXMLChBuffer());
offset = exprSB.sbStrstr("here()");
while (offset >= 0) {
if (offset == 0 || offset == 1 ||
(!(exprSB[offset - 1] == ':' && exprSB[offset - 2] != ':') &&
separator(exprSB[offset - 1]))) {
exprSB.sbStrinsIn(k.rawCharBuffer(), offset);
}
offset = exprSB.sbOffsetStrstr("here()", offset + 11);
}
// Install the External function in the Environment handler
if (hereNode != NULL) {
xpesd.installExternalFunctionLocal(XalanDOMString(URI_ID_DSIG), XalanDOMString("here"), DSIGXPathHere(hereNode));
}
XPath * xp = xpf.create();
XalanDOMString Xexpr((char *) exprSB.rawBuffer());
xppi.initXPath(*xp, xpcc, Xexpr, pr);
// Now resolve
XObjectPtr xObj = xp->execute(contextNode, pr, xpec);
// Now map to a list that others can use (naieve list at this time)
const NodeRefListBase& lst = xObj->nodeset();
int size = (int) lst.getLength();
const DOMNode *item;
XSECXPathNodeList * ret;
XSECnew(ret, XSECXPathNodeList);
Janitor<XSECXPathNodeList> j_ret(ret);
for (int i = 0; i < size; ++ i) {
if (lst.item(i) == xd)
ret->addNode(document);
else {
item = xwn.mapNode(lst.item(i));
ret->addNode(item);
}
}
xpesd.uninstallExternalFunctionGlobal(XalanDOMString(URI_ID_DSIG), XalanDOMString("here"));
clearXPathNS(document, addedNodes, mp_formatter, mp_nse);
j_ret.release();
return ret;
}
catch (XSLException &e) {
safeBuffer msg;
// Whatever happens - fix any changes to the original document
clearXPathNS(document, addedNodes, mp_formatter, mp_nse);
// Collate the exception message into an XSEC message.
msg.sbTranscodeIn("Xalan Exception : ");
#if defined (XSEC_XSLEXCEPTION_RETURNS_DOMSTRING)
msg.sbXMLChCat(e.getType().c_str());
#else
msg.sbXMLChCat(e.getType());
#endif
msg.sbXMLChCat(" caught. Message : ");
msg.sbXMLChCat(e.getMessage().c_str());
throw XSECException(XSECException::XPathFilterError,
msg.rawXMLChBuffer());
}
catch (...) {
clearXPathNS(document, addedNodes, mp_formatter, mp_nse);
throw;
}
return NULL;
}