Fix error when running multiple xpaths or something like that.
This fixes the xqilla exception being thrown: "It is an error for the context item to be undefined when using it"
This commit is contained in:
parent
b536026f58
commit
b79d758e8e
1 changed files with 9 additions and 5 deletions
|
@ -21,6 +21,7 @@
|
|||
#include <xercesc/util/XMLString.hpp>
|
||||
#include <xqilla/exceptions/XQException.hpp>
|
||||
#include <xqilla/exceptions/XMLParseException.hpp>
|
||||
#include <xqilla/context/ContextHelpers.hpp>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <algorithm>
|
||||
|
@ -58,7 +59,8 @@ namespace duck {
|
|||
xercesc::MemBufInputSource input_buf(reinterpret_cast<const XMLByte*>(parXML.c_str()), parXML.size(), "n/a", false);
|
||||
BatchResults retval;
|
||||
try {
|
||||
AutoDelete<DynamicContext> context(xqilla.createContext(XQilla::XQUERY3_UPDATE, &xconfig));
|
||||
AutoDelete<DynamicContext> context(xqilla.createContext(XQilla::XQUERY3, &xconfig));
|
||||
xconfig.populateStaticContext(context);
|
||||
Node::Ptr ptr = context->parseDocument(input_buf);
|
||||
context->setContextItem(ptr);
|
||||
//see http://xqilla.sourceforge.net/docs/simple-api/classStaticContext.html#adc869a84712459fa49db67fe837c9b01
|
||||
|
@ -66,10 +68,12 @@ namespace duck {
|
|||
context->setDefaultElementAndTypeNS(ns_wide);
|
||||
|
||||
for (const auto& xpath : parQueries) {
|
||||
AutoDelete<XQQuery> query(nullptr);
|
||||
{
|
||||
AutoContextInfoReset resetter(context);
|
||||
AutoDeleteArray<XMLCh> xpath_wide = xercesc::XMLString::transcode(xpath.c_str());
|
||||
AutoDelete<XQQuery> query(xqilla.parse(xpath_wide, context, nullptr, XQilla::NO_ADOPT_CONTEXT));
|
||||
context->setContextPosition(1);
|
||||
context->setContextSize(1);
|
||||
query.set(xqilla.parse(xpath_wide, context, nullptr, XQilla::NO_ADOPT_CONTEXT));
|
||||
}
|
||||
|
||||
Result result = query->execute(context);
|
||||
Item::Ptr item;
|
||||
|
|
Loading…
Add table
Reference in a new issue