Project

Profile

Help

Why is testCallSystemFunction not called in testXSLT30.cpp and why is the test for size 3?

Added by Martin Honnen 4 months ago

In https://saxonica.plan.io/projects/saxonmirrorhe/repository/he/revisions/he_mirror_saxon_12_4_1/entry/src/main/c/samples/cppTests/testXSLT30.cpp#L2157 there is a function testCallSystemFunction.

I wonder why it is never call further down in the whole file, that looks like it is never used for a test.

Furthermore, I wonder, as the code does

void testCallSystemFunction(SaxonProcessor *proc, sResultCount *sresult) {

  XdmFunctionItem *fi = XdmFunctionItem::getSystemFunction(
      proc, "{http://www.w3.org/2005/xpath-functions}parse-json", 1);
  if (fi == nullptr) {
    sresult->failure++;
    sresult->failureList.push_back("testCallSystemFunction");
    return;
  }

  XdmValue **xdmValue = new XdmValue *[1];
  xdmValue[0] = new XdmValue();
  xdmValue[0]->addXdmItem(proc->makeStringValue("[1,2,3]"));
  XdmValue *result = fi->call(proc, xdmValue, 1);

  std::cerr << "Result = " << result->toString() << endl;
  if (result->size() == 3) {

    cout << "testCallSystemFunction = " << result->getHead()->getStringValue()
         << endl;
    sresult->success++;

  } else {
    sresult->failure++;
    sresult->failureList.push_back("testCallSystemFunction");
  }
}

so it is parses the string "[1,2,3]" (which represents a single JSON array with three items) into an XdmValue, why there is that check if (result->size() == 3) {, as a single JSON array is represented as a single XDM map, it appears the XDM value is a sequence of size 1 and not 3.


Replies (1)

    (1-1/1)

    Please register to reply