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

Function xmlSchematronRunTest

ThirdParty/libxml2/vtklibxml2/schematron.c:1832–1886  ·  view source on GitHub ↗

* xmlSchematronRunTest: * @ctxt: the schema validation context * @test: the current test * @instance: the document instance tree * @cur: the current node in the instance * * Validate a rule against a tree instance at a given position * * Returns 1 in case of success, 0 if error and -1 in case of internal error */

Source from the content-addressed store, hash-verified

1830 * Returns 1 in case of success, 0 if error and -1 in case of internal error
1831 */
1832static int
1833xmlSchematronRunTest(xmlSchematronValidCtxtPtr ctxt,
1834 xmlSchematronTestPtr test, xmlDocPtr instance, xmlNodePtr cur, xmlSchematronPatternPtr pattern)
1835{
1836 xmlXPathObjectPtr ret;
1837 int failed;
1838
1839 failed = 0;
1840 ctxt->xctxt->doc = instance;
1841 ctxt->xctxt->node = cur;
1842 ret = xmlXPathCompiledEval(test->comp, ctxt->xctxt);
1843 if (ret == NULL) {
1844 failed = 1;
1845 } else {
1846 switch (ret->type) {
1847 case XPATH_XSLT_TREE:
1848 case XPATH_NODESET:
1849 if ((ret->nodesetval == NULL) ||
1850 (ret->nodesetval->nodeNr == 0))
1851 failed = 1;
1852 break;
1853 case XPATH_BOOLEAN:
1854 failed = !ret->boolval;
1855 break;
1856 case XPATH_NUMBER:
1857 if ((xmlXPathIsNaN(ret->floatval)) ||
1858 (ret->floatval == 0.0))
1859 failed = 1;
1860 break;
1861 case XPATH_STRING:
1862 if ((ret->stringval == NULL) ||
1863 (ret->stringval[0] == 0))
1864 failed = 1;
1865 break;
1866 case XPATH_UNDEFINED:
1867#ifdef LIBXML_XPTR_LOCS_ENABLED
1868 case XPATH_POINT:
1869 case XPATH_RANGE:
1870 case XPATH_LOCATIONSET:
1871#endif
1872 case XPATH_USERS:
1873 failed = 1;
1874 break;
1875 }
1876 xmlXPathFreeObject(ret);
1877 }
1878 if ((failed) && (test->type == XML_SCHEMATRON_ASSERT))
1879 ctxt->nberrors++;
1880 else if ((!failed) && (test->type == XML_SCHEMATRON_REPORT))
1881 ctxt->nberrors++;
1882
1883 xmlSchematronReportSuccess(ctxt, test, cur, pattern, !failed);
1884
1885 return(!failed);
1886}
1887
1888/**
1889 * xmlSchematronRegisterVariables:

Callers 1

xmlSchematronValidateDocFunction · 0.85

Calls 4

xmlXPathCompiledEvalFunction · 0.85
xmlXPathIsNaNFunction · 0.85
xmlXPathFreeObjectFunction · 0.85

Tested by

no test coverage detected