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.

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
AutoDelete<DynamicContext> context(query->createDynamicContext());
// 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;
}
Definition XPath2MemoryManager.hpp:261
virtual const XMLCh * asString(const DynamicContext *context) const =0
virtual Item::Ptr next(DynamicContext *context)
Get the next item from the iterator. Returns null if the is no next value.
A scoped pointer wrapper for the lazily evaluated query result.
Definition Result.hpp:38
Provides factory methods for creating XQQuery and DynamicContext objects.
Definition XQilla.hpp:53
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.