本文整理汇总了C++中XPath::eval方法的典型用法代码示例。如果您正苦于以下问题:C++ XPath::eval方法的具体用法?C++ XPath::eval怎么用?C++ XPath::eval使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XPath
的用法示例。
在下文中一共展示了XPath::eval方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: evalFunctionKeyGet
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" );
}
}
}
}
示例2: 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 );
}
示例3: evalFunctionKeyBuild
void XPath::evalFunctionKeyBuild ( ElementRef& baseElement, ElementMultiMapRef& map,
XPath& matchXPath, XPath& useXPath, XPath& scopeXPath, KeyId mapId )
{
bool recursive = true; // Warn !!
Log_EvalKey ( "evalFunctionKeyBuild(baseElement=%s, match=%s, use=%s, scope=%s\n",
baseElement.getKey().c_str(), matchXPath.expression, useXPath.expression, scopeXPath.expression);
if ( ! recursive )
{
Warn ( "Building key in a non-recursive mode ! This is against XSL specifications !\n" );
}
if ( ! baseElement.getChild() )
{
Log_EvalKey ( "Base element has no children !\n" );
return;
}
ElementRef current = baseElement;
Log_EvalKey ( "Building Key !\n" );
Log_EvalKey ( "baseElement = '%s'\n", baseElement.getKey().c_str() );
Log_EvalKey ( "baseElement = '%s'\n", baseElement.generateVersatileXPath().c_str() );
__ui64 iterated = 0, found = 0;
bool currentMatches;
while ( true )
{
Log_EvalKey ( "[At element %s (0x%llx:%x/%s), matching '%s' ?\n",
current.generateVersatileXPath().c_str(), current.getElementId(), current.getKeyId(), current.getKey().c_str(),
matchXPath.expression );
currentMatches = false;
iterated++;
if ( matchXPath.matches ( current ) )
{
Log_EvalKey ( "Matches !\n" );
currentMatches = true;
found++;
if ( map )
{
map.insert ( current, useXPath );
}
else
{
NodeSet scopeNodeSet;
scopeXPath.eval ( scopeNodeSet, current );
if ( scopeNodeSet.size() == 1 && scopeNodeSet.front().isElement() )
{
ElementRef scopeElement = scopeNodeSet.toElement();
ElementMultiMapRef currentMap = scopeElement.findAttr ( mapId, AttributeType_SKMap );
if ( ! currentMap )
{
Info ( "New skMap at '%s'\n", scopeElement.generateVersatileXPath().c_str() );
currentMap = scopeElement.addSKMap ( mapId, SKMapType_ElementMultiMap );
}
Log_EvalKey ( "Inserting '%s'\n", current.generateVersatileXPath().c_str() );
currentMap.insert ( current, useXPath );
}
else
{
Info ( "Silently ignoring '%s' : scope did not eval to an Element.\n",
current.generateVersatileXPath().c_str() );
}
}
}
if ( current.getChild() && ( !currentMatches || recursive ) )
{
Log_EvalKey ( "Don't match, but has children.\n" );
current = current.getChild();
continue;
}
else
{
Log_EvalKey ( "Don't match, but no has child.\n" );
}
while ( ! current.getYounger() )
{
AssertBug ( current != baseElement, "How did I get there ?\n" );
current = current.getFather();
if ( ! current )
{
throwException ( Exception, "Preliminary end of element !\n" );
}
AssertBug ( current, "current had no father !\n" );
if ( current == baseElement )
{
Log_EvalKey ( "Indexing finished : iterated over %llu, found %llu.\n", iterated, found );
return;
}
}
current = current.getYounger ();
//.........这里部分代码省略.........