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

Function xmlSchematronAddTest

ThirdParty/libxml2/vtklibxml2/schematron.c:358–405  ·  view source on GitHub ↗

* xmlSchematronAddTest: * @ctxt: the schema parsing context * @type: the type of test * @rule: the parent rule * @node: the node hosting the test * @test: the associated test * @report: the associated report string * * Add a test to a schematron * * Returns the new pointer or NULL in case of error */

Source from the content-addressed store, hash-verified

356 * Returns the new pointer or NULL in case of error
357 */
358static xmlSchematronTestPtr
359xmlSchematronAddTest(xmlSchematronParserCtxtPtr ctxt,
360 xmlSchematronTestType type,
361 xmlSchematronRulePtr rule,
362 xmlNodePtr node, xmlChar *test, xmlChar *report)
363{
364 xmlSchematronTestPtr ret;
365 xmlXPathCompExprPtr comp;
366
367 if ((ctxt == NULL) || (rule == NULL) || (node == NULL) ||
368 (test == NULL))
369 return(NULL);
370
371 /*
372 * try first to compile the test expression
373 */
374 comp = xmlXPathCtxtCompile(ctxt->xctxt, test);
375 if (comp == NULL) {
376 xmlSchematronPErr(ctxt, node,
377 XML_SCHEMAP_NOROOT,
378 "Failed to compile test expression %s",
379 test, NULL);
380 return(NULL);
381 }
382
383 ret = (xmlSchematronTestPtr) xmlMalloc(sizeof(xmlSchematronTest));
384 if (ret == NULL) {
385 xmlSchematronPErrMemory(ctxt);
386 return (NULL);
387 }
388 memset(ret, 0, sizeof(xmlSchematronTest));
389 ret->type = type;
390 ret->node = node;
391 ret->test = test;
392 ret->comp = comp;
393 ret->report = report;
394 ret->next = NULL;
395 if (rule->tests == NULL) {
396 rule->tests = ret;
397 } else {
398 xmlSchematronTestPtr prev = rule->tests;
399
400 while (prev->next != NULL)
401 prev = prev->next;
402 prev->next = ret;
403 }
404 return (ret);
405}
406
407/**
408 * xmlSchematronFreeTests:

Callers 1

xmlSchematronParseRuleFunction · 0.85

Calls 2

xmlXPathCtxtCompileFunction · 0.85
xmlSchematronPErrMemoryFunction · 0.85

Tested by

no test coverage detected