SourceForge.net Logo
simple-basic.cpp

This example executes a simple XQuery expression ("1 to 100"), which returns the numbers from 1 to 100 inclusive.

#include <iostream>
int main(int argc, char *argv[]) {
// Initialise Xerces-C and XQilla by creating the factory object
XQilla xqilla;
// Parse an XQuery expression
// (AutoDelete deletes the object at the end of the scope)
AutoDelete<XQQuery> query(xqilla.parse(X("1 to 100")));
// Create a context object
// Execute the query, using the context
Result result = query->execute(context);
// Iterate over the results, printing them
Item::Ptr item;
while(item = result->next(context)) {
std::cout << UTF8(item->asString(context)) << std::endl;
}
return 0;
}
XQQuery::execute
Result execute(DynamicContext *context) const
Executes the query using the given DynamicContext, returning a lazy iterator over the results.
RefCountPointer< const Item >
XQQuery::createDynamicContext
DynamicContext * createDynamicContext(xercesc::MemoryManager *memMgr=xercesc::XMLPlatformUtils::fgMemoryManager) const
Creates a DynamicContext based on the static context used to parse this query.
XQilla::parse
static XQQuery * parse(const XMLCh *query, DynamicContext *context=0, const XMLCh *queryFile=NULL, unsigned int flags=0, xercesc::MemoryManager *memMgr=xercesc::XMLPlatformUtils::fgMemoryManager, XQQuery *result=0)
Parse the expression contained in the given query string.
Item::asString
virtual const XMLCh * asString(const DynamicContext *context) const =0
Result
A scoped pointer wrapper for the lazily evaluated query result.
Definition: Result.hpp:37
ResultImpl::next
virtual Item::Ptr next(DynamicContext *context)
Get the next item from the iterator. Returns null if the is no next value.
XQilla
Provides factory methods for creating XQQuery and DynamicContext objects.
Definition: XQilla.hpp:52
xqilla-simple.hpp
AutoDelete
Definition: XPath2MemoryManager.hpp:260