本文整理汇总了C++中XPath类的典型用法代码示例。如果您正苦于以下问题:C++ XPath类的具体用法?C++ XPath怎么用?C++ XPath使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了XPath类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: TEST_F
TEST_F(XPathAcceptanceTest, variables)
{
XPath xpath = compile("$variable");
xpath.bind_variable("variable", 5.2);
ASSERT_DOUBLE_EQ(5.2, xpath.number());
}
开发者ID:shepmaster,项目名称:sxd-cpp,代码行数:7,代码来源:xpath-acceptance-test.cpp
示例2: selectXPath
void PersistenceModule::instructionDrop ( __XProcHandlerArgs__ )
{
XPath selectXPath ( getXProcessor(), item, xem_pers.select() );
Document& doc = selectXPath.evalElement().getDocument();
if ( item.hasAttr ( xem_pers.branchRevId() ) )
{
String branchRevStr = item.getEvaledAttr ( getXProcessor(), xem_pers.branchRevId() );
BranchRevId branchRevId = BranchManager::parseBranchRevId ( branchRevStr.c_str() );
if ( ! branchRevId.branchId || ! branchRevId.revisionId )
{
throwException ( Exception, "Invalid branch and revision id '%s'\n", branchRevStr.c_str() );
}
Log_Pers ( "[XEM:BRANCH] Dropping alter revision [%llu:%llu]\n", _brid(doc.getBranchRevId()) );
NotImplemented ( "We shall schedule revision removal here !\n" );
#if 0
// store.dropRevisions ( branchRevId.branchId, branchRevId.revisionId, branchRevId.revisionId );
persistentDocument = store.createPersistentDocument ( branchRevId.branchId, branchRevId.revisionId, Document_Read );
persistentDocument->scheduleRevisionForRemoval ();
persistentDocument->release ();
#endif
return;
}
Log_Pers ( "[XEM:BRANCH] Dropping current revision [%llu:%llu]\n", _brid(doc.getBranchRevId()) );
doc.scheduleRevisionForRemoval ();
}
开发者ID:Doloops,项目名称:Xemeiah,代码行数:30,代码来源:xempersmodule.cpp
示例3: xemInstructionSetDocument
static void xemInstructionSetDocument ( __XProcHandlerArgs__ )
{
if ( ! item.hasAttr(xem.href() ) )
{
throwXemProcessorException ( "Instruction xem:set-document has no attribute xem:href\n" );
}
if ( ! item.hasAttr(xem.select() ) )
{
throwXemProcessorException ( "Instruction xem:set-document has no attribute xem:select\n" );
}
String href = item.getEvaledAttr ( xproc, currentNode, xem.href() );
XPath selectXPath ( item, xem.select() );
NodeSet document;
selectXPath.eval ( xproc, document, currentNode );
if ( ! document.isScalar() )
{
throwXemProcessorException ( "Instruction xem:set-document : xem:select '%s' returns a non-scalar result !\n",
item.getAttr (xem.select() ).c_str() );
}
if ( ! document.front().isElement() )
{
throwXemProcessorException ( "Instruction xem:set-document : xem:select '%s' returns a non-element result !\n",
item.getAttr (xem.select() ).c_str() );
}
ElementRef rootDocument = document.front().toElement();
xproc.setDocument ( href, rootDocument );
}
开发者ID:Doloops,项目名称:Xemeiah,代码行数:27,代码来源:xem-common.cpp
示例4: filter
/// copy matching tree nodes using the given XPath filter expression
bool XMLNode::filter(const XPath& xpath, XMLNode& target) const
{
XMLNode* ret = filter(xpath.begin(), xpath.end());
if (ret) {
// move returned nodes to target node
target._children.move(ret->_children);
target._attributes = ret->_attributes;
delete ret;
return true;
} else
return false;
}
开发者ID:GYGit,项目名称:reactos,代码行数:16,代码来源:xmlstorage.cpp
示例5: SetDataDirPath
void XFileManager::SetDataDirPath(const XPath& dataDirPath)
{
if (dataDirPath.IsRelPath())
{
size_t relNodeCount;
XPath leafPath;
dataDirPath.GetLeafExceptRelNodes(relNodeCount, leafPath);
m_execDirAbsPath.GetBranchExceptLeafs(relNodeCount, m_dataDirAbsPath);
m_dataDirAbsPath.AppendPath(leafPath);
}
else
{
m_dataDirAbsPath.AssignPath(m_execDirAbsPath);
m_dataDirAbsPath.AppendPath(dataDirPath);
}
}
开发者ID:myevan,项目名称:xapp,代码行数:16,代码来源:XFileManager.cpp
示例6: SetExecFilePath
void XFileManager::SetExecFilePath(const XPath& execFilePath)
{
char execFileAbsPathChars[PATH_MAX];
x_verify(realpath(execFilePath.GetChars(), execFileAbsPathChars), "CHECK_EXEC_PATH"); // TODO: x_vertifyf
m_execFileAbsPath.AssignXStr(execFileAbsPathChars);
m_execFileAbsPath.SplitBranchAndLeaf(m_execDirAbsPath, m_execFileName);
}
开发者ID:myevan,项目名称:xapp,代码行数:7,代码来源:XFileManager.cpp
示例7: ExecuteXPath
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;
}
开发者ID:rherardi,项目名称:xml-xalan-c-src_1_10_0,代码行数:27,代码来源:TestXPath.cpp
示例8: Log_EvalKey
void XPath::evalFunctionKeyGet ( ElementMultiMapRef& map,
XPath& useXPath, NodeSet& resultNodeSet, String& value )
{
__ui64 hash = SKMapRef::hashString ( value );
Log_EvalKey ( "Computed value : '%s', hash='%llx'\n", value.c_str(), hash );
for ( SKMultiMapRef::multi_iterator miter ( map, hash ); miter ; miter++ )
{
Log_EvalKey ( "Found iter %llx, val=%llx\n", miter.getHash(), miter.getValue() );
if ( miter.getHash() != hash )
{
Log_EvalKey ( "Diverging keys : %llx != %llx\n", miter.getHash(), hash );
break;
}
ElementRef foundElt = map.get ( miter );
Log_EvalKey ( "Found elt=0x%llx\n", foundElt.getElementId() );
// AssertBug ( foundElt.getElementId(), "Null elementId ! Element was deleted ?\n" );
NodeSet foundValue;
useXPath.eval ( foundValue, foundElt );
for ( NodeSet::iterator valiter ( foundValue ) ; valiter ; valiter++ )
{
String eltValue = valiter->toString();
Log_EvalKey ( "Found node 0x%llx:%s, eltValue='%s'\n", foundElt.getElementId(), foundElt.getKey().c_str(), eltValue.c_str() );
if ( eltValue == value )
{
resultNodeSet.pushBack ( foundElt, true );
Log_EvalKey ( "Matches !\n" );
}
}
}
}
开发者ID:Doloops,项目名称:Xemeiah,代码行数:32,代码来源:xpath-key.cpp
示例9: evalStepAsKeyId
void XPath::evalFunctionKeyGet ( __XPath_Functor_Args )
{
KeyId keyNameId = evalStepAsKeyId ( node, step->functionArguments[0] );
__evalArgNodeSet(1);
Log_EvalKey ( "xsl:key : expression '%s'\n", expression );
XPath matchXPath ( xproc );
XPath useXPath ( xproc );
XPath scopeXPath(xproc);
getXProcessor().getXPathKeyExpressions(keyNameId, matchXPath,useXPath);
ElementMultiMapRef map = node.getDocument().getKeyMapping ( keyNameId );
if ( ! map )
{
map = node.getDocument().createKeyMapping ( keyNameId );
AssertBug ( map, "Could not create SKMultiMapRef !\n" );
Log_EvalKey ( "Building for key '%x'\n", keyNameId );
ElementRef baseElement = node.getRootElement ();
#if 0
if ( instructKey.findAttr ( __builtinKey(xsl.base) ) )
{
throwXPathException ( "Invalid xsl:base attribute set !\n" );
XPath baseXPath ( instructKey, __builtinKey(xsl.base) );
Log_EvalKey ( "xsl:base : expression '%s'\n", baseXPath.expression );
Log_EvalKey ( "xsl:base - before : base : %llx:%s\n", baseElement.getElementId(), baseElement.getKey().c_str() );
baseElement = baseXPath.evalElement ( baseElement );
Log_EvalKey ( "xsl:base - after : base : %llx:%s\n", baseElement.getElementId(), baseElement.getKey().c_str() );
}
#endif
evalFunctionKeyBuild ( baseElement, map, matchXPath, useXPath, scopeXPath, 0 );
}
evalFunctionKeyGet ( map, useXPath, result, res1 );
}
开发者ID:Doloops,项目名称:Xemeiah,代码行数:41,代码来源:xpath-key.cpp
示例10: main
int main()
{
char* fileName = new char[MAX_CHAR_SIZE];
char* cmdBuf = new char[MAX_CHAR_SIZE];
XPath Xpath;
XMLParser XParser;
XMLNode* XpathRoute = new XMLNode;
while(1)
{
cout << "Input FileName(quit) : ";
cin >> fileName;
if(!strcmp(fileName, "quit"))
{
delete[] fileName;
delete[] cmdBuf;
delete XpathRoute;
return 0;
}
else if(!XParser.parser(fileName, XpathRoute)) break;
}
while(1)
{
cout << "cmd : ";
cin >> cmdBuf;
if(!strcmp(cmdBuf, "quit")) break;
else Xpath.XPathCmdParser(cmdBuf, XpathRoute);
}
delete[] fileName;
delete[] cmdBuf;
delete XpathRoute;
return 0;
}
开发者ID:sdhad77,项目名称:hw01,代码行数:40,代码来源:HW01.cpp
示例11: theResult
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;
}
开发者ID:rherardi,项目名称:xml-xalan-c-src_1_10_0,代码行数:36,代码来源:XPathEvaluator.cpp
示例12: TestBooleanResult
bool
TestBooleanResult(
XPathProcessor& theXPathProcessor,
XPath& theXPath,
XPathConstructionContext& theXPathConstructionContext,
const XalanDOMString& theXPathString,
PrintWriter& thePrintWriter,
bool theExpectedResult,
XalanNode* theContextNode,
const PrefixResolver& thePrefixResolver,
const NodeRefListBase& theContextNodeList,
XPathExecutionContext& theExecutionContext)
{
bool fError = false;
const XObjectPtr theResult =
ExecuteXPath(
theXPathProcessor,
theXPathConstructionContext,
theXPath,
theXPathString,
theContextNode,
thePrefixResolver,
theContextNodeList,
theExecutionContext);
bool fDump = false;
if (fDump == true)
{
thePrintWriter.println();
thePrintWriter.println();
theXPath.getExpression().dumpOpCodeMap(thePrintWriter);
thePrintWriter.println();
theXPath.getExpression().dumpTokenQueue(thePrintWriter);
thePrintWriter.println();
thePrintWriter.println();
}
thePrintWriter.print("Execution of XPath ");
thePrintWriter.print(theXPathString);
if (theResult->boolean() == theExpectedResult)
{
thePrintWriter.println(" succeeded.");
thePrintWriter.print("The result was ");
thePrintWriter.print(theResult->boolean());
thePrintWriter.println(".");
}
else
{
fError = true;
thePrintWriter.println(" failed!");
thePrintWriter.print("The expected result was \"");
thePrintWriter.print(theExpectedResult);
thePrintWriter.println("\".");
thePrintWriter.print("The actual result was \"");
thePrintWriter.print(theResult->boolean());
thePrintWriter.println("\".");
}
return fError;
}
开发者ID:rherardi,项目名称:xml-xalan-c-src_1_10_0,代码行数:64,代码来源:TestXPath.cpp
示例13: setXPathNS
void TXFMXPath::evaluateExpr(DOMNode *h, safeBuffer inexpr) {
// Temporarily add any necessary name spaces into the document
XSECXPathNodeList addedNodes;
setXPathNS(document, XPathAtts, addedNodes, formatter, mp_nse);
XPathProcessorImpl xppi; // The processor
XercesParserLiaison xpl;
#if XALAN_VERSION_MAJOR == 1 && XALAN_VERSION_MINOR > 10
XercesDOMSupport xds(xpl);
#else
XercesDOMSupport xds;
#endif
XPathEvaluator xpe;
XPathFactoryDefault xpf;
XPathConstructionContextDefault xpcc;
XalanDocument * xd;
XalanNode * contextNode;
// Xalan can throw exceptions in all functions, so do one broad catch point.
try {
// Map to Xalan
xd = xpl.createDocument(document);
// For performing mapping
XercesDocumentWrapper *xdw = xpl.mapDocumentToWrapper(xd);
XercesWrapperNavigator xwn(xdw);
// Map the "here" node - but only if part of current document
XalanNode * hereNode = NULL;
if (h->getOwnerDocument() == document) {
hereNode = xwn.mapNode(h);
if (hereNode == NULL) {
hereNode = findHereNodeFromXalan(&xwn, xd, h);
if (hereNode == NULL) {
throw XSECException(XSECException::XPathError,
"Unable to find here node in Xalan Wrapper map");
}
}
}
// Now work out what we have to set up in the new processing
TXFMBase::nodeType inputType = input->getNodeType();
XalanDOMString cd; // For the moment assume the root is the context
const XalanDOMChar * cexpr;
safeBuffer contextExpr;
switch (inputType) {
case DOM_NODE_DOCUMENT :
case DOM_NODE_XPATH_NODESET :
// do XPath over the whole document and, if the input was an
// XPath Nodeset, then later intersect the result with the input nodelist
cd = XalanDOMString("/"); // Root node
cexpr = cd.c_str();
// The context node is the "root" node
contextNode =
xpe.selectSingleNode(
xds,
xd,
cexpr,
xd->getDocumentElement());
break;
case DOM_NODE_DOCUMENT_FRAGMENT :
{
// Need to map the DOM_Node that we are given from the input to the appropriate XalanNode
// Create the XPath expression to find the node
if (input->getFragmentId() != NULL) {
contextExpr.sbTranscodeIn("//descendant-or-self::node()[attribute::Id='");
contextExpr.sbXMLChCat(input->getFragmentId());
contextExpr.sbXMLChCat("']");
// Map the node
contextNode =
xpe.selectSingleNode(
xds,
//.........这里部分代码省略.........
开发者ID:okean,项目名称:cpputils,代码行数:101,代码来源:TXFMXPath.cpp
示例14: setXPathNS
XSECXPathNodeList * TXFMXPathFilter::evaluateSingleExpr(DSIGXPathFilterExpr *expr) {
// Have a single expression that we wish to find the resultant nodeset
// for
XSECXPathNodeList addedNodes;
setXPathNS(document, expr->mp_NSMap, addedNodes, mp_formatter, mp_nse);
XPathProcessorImpl xppi; // The processor
XercesParserLiaison xpl;
#if XALAN_VERSION_MAJOR == 1 && XALAN_VERSION_MINOR > 10
XercesDOMSupport xds(xpl);
#else
XercesDOMSupport xds;
#endif
XPathEvaluator xpe;
XPathFactoryDefault xpf;
XPathConstructionContextDefault xpcc;
XalanDocument * xd;
XalanNode * contextNode;
// Xalan can throw exceptions in all functions, so do one broad catch point.
try {
// Map to Xalan
xd = xpl.createDocument(document);
// For performing mapping
XercesDocumentWrapper *xdw = xpl.mapDocumentToWrapper(xd);
XercesWrapperNavigator xwn(xdw);
// Map the "here" node
XalanNode * hereNode = NULL;
hereNode = xwn.mapNode(expr->mp_xpathFilterNode);
if (hereNode == NULL) {
hereNode = findHereNodeFromXalan(&xwn, xd, expr->mp_exprTextNode);
if (hereNode == NULL) {
throw XSECException(XSECException::XPathFilterError,
"Unable to find here node in Xalan Wrapper map");
}
}
// Now work out what we have to set up in the new processing
XalanDOMString cd; // For XPath Filter, the root is always the context node
cd = XalanDOMString("/"); // Root node
// The context node is the "root" node
contextNode =
xpe.selectSingleNode(
xds,
xd,
cd.c_str(),
xd->getDocumentElement());
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(":");
// 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);
}
//.........这里部分代码省略.........
开发者ID:okean,项目名称:cpputils,代码行数:101,代码来源:TXFMXPathFilter.cpp
注:本文中的XPath类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论