MCPcopy Create free account
hub / github.com/Kitware/VTK / xmlSchematronFormatReport

Function xmlSchematronFormatReport

ThirdParty/libxml2/vtklibxml2/schematron.c:1467–1583  ·  view source on GitHub ↗

* xmlSchematronFormatReport: * @ctxt: the validation context * @test: the test node * @cur: the current node tested * * Build the string being reported to the user. * * Returns a report string or NULL in case of error. The string needs * to be deallocated by the caller */

Source from the content-addressed store, hash-verified

1465 * to be deallocated by the caller
1466 */
1467static xmlChar *
1468xmlSchematronFormatReport(xmlSchematronValidCtxtPtr ctxt,
1469 xmlNodePtr test, xmlNodePtr cur) {
1470 xmlChar *ret = NULL;
1471 xmlNodePtr child, node;
1472 xmlXPathCompExprPtr comp;
1473
1474 if ((test == NULL) || (cur == NULL))
1475 return(ret);
1476
1477 child = test->children;
1478 while (child != NULL) {
1479 if ((child->type == XML_TEXT_NODE) ||
1480 (child->type == XML_CDATA_SECTION_NODE))
1481 ret = xmlStrcat(ret, child->content);
1482 else if (IS_SCHEMATRON(child, "name")) {
1483 xmlChar *path;
1484
1485 path = xmlGetNoNsProp(child, BAD_CAST "path");
1486
1487 node = cur;
1488 if (path != NULL) {
1489 node = xmlSchematronGetNode(ctxt, cur, path);
1490 if (node == NULL)
1491 node = cur;
1492 xmlFree(path);
1493 }
1494
1495 if ((node->ns == NULL) || (node->ns->prefix == NULL))
1496 ret = xmlStrcat(ret, node->name);
1497 else {
1498 ret = xmlStrcat(ret, node->ns->prefix);
1499 ret = xmlStrcat(ret, BAD_CAST ":");
1500 ret = xmlStrcat(ret, node->name);
1501 }
1502 } else if (IS_SCHEMATRON(child, "value-of")) {
1503 xmlChar *select;
1504 xmlXPathObjectPtr eval;
1505
1506 select = xmlGetNoNsProp(child, BAD_CAST "select");
1507 comp = xmlXPathCtxtCompile(ctxt->xctxt, select);
1508 eval = xmlXPathCompiledEval(comp, ctxt->xctxt);
1509
1510 switch (eval->type) {
1511 case XPATH_NODESET: {
1512 int indx;
1513 xmlChar *spacer = BAD_CAST " ";
1514
1515 if (eval->nodesetval) {
1516 for (indx = 0; indx < eval->nodesetval->nodeNr; indx++) {
1517 if (indx > 0)
1518 ret = xmlStrcat(ret, spacer);
1519 ret = xmlStrcat(ret, eval->nodesetval->nodeTab[indx]->name);
1520 }
1521 }
1522 break;
1523 }
1524 case XPATH_BOOLEAN: {

Callers 1

Calls 8

xmlStrcatFunction · 0.85
xmlGetNoNsPropFunction · 0.85
xmlSchematronGetNodeFunction · 0.85
xmlXPathCtxtCompileFunction · 0.85
xmlXPathCompiledEvalFunction · 0.85
xmlXPathFreeObjectFunction · 0.85
xmlXPathFreeCompExprFunction · 0.85
xmlStrlenFunction · 0.85

Tested by

no test coverage detected