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

Function xmlShellRNGValidate

ThirdParty/libxml2/vtklibxml2/debugXML.c:2347–2381  ·  view source on GitHub ↗

* xmlShellRNGValidate: * @ctxt: the shell context * @schemas: the path to the Relax-NG schemas * @node: a node * @node2: unused * * Implements the XML shell function "relaxng" * validating the instance against a Relax-NG schemas * * Returns 0 */

Source from the content-addressed store, hash-verified

2345 * Returns 0
2346 */
2347static int
2348xmlShellRNGValidate(xmlShellCtxtPtr sctxt, char *schemas,
2349 xmlNodePtr node ATTRIBUTE_UNUSED,
2350 xmlNodePtr node2 ATTRIBUTE_UNUSED)
2351{
2352 xmlRelaxNGPtr relaxngschemas;
2353 xmlRelaxNGParserCtxtPtr ctxt;
2354 xmlRelaxNGValidCtxtPtr vctxt;
2355 int ret;
2356
2357 ctxt = xmlRelaxNGNewParserCtxt(schemas);
2358 xmlRelaxNGSetParserErrors(ctxt, xmlShellPrintf, xmlShellPrintf, sctxt);
2359 relaxngschemas = xmlRelaxNGParse(ctxt);
2360 xmlRelaxNGFreeParserCtxt(ctxt);
2361 if (relaxngschemas == NULL) {
2362 fprintf(sctxt->output,
2363 "Relax-NG schema %s failed to compile\n", schemas);
2364 return(-1);
2365 }
2366 vctxt = xmlRelaxNGNewValidCtxt(relaxngschemas);
2367 xmlRelaxNGSetValidErrors(vctxt, xmlShellPrintf, xmlShellPrintf, sctxt);
2368 ret = xmlRelaxNGValidateDoc(vctxt, sctxt->doc);
2369 if (ret == 0) {
2370 fprintf(sctxt->output, "%s validates\n", sctxt->filename);
2371 } else if (ret > 0) {
2372 fprintf(sctxt->output, "%s fails to validate\n", sctxt->filename);
2373 } else {
2374 fprintf(sctxt->output, "%s validation generated an internal error\n",
2375 sctxt->filename);
2376 }
2377 xmlRelaxNGFreeValidCtxt(vctxt);
2378 if (relaxngschemas != NULL)
2379 xmlRelaxNGFree(relaxngschemas);
2380 return(0);
2381}
2382#endif
2383
2384#ifdef LIBXML_OUTPUT_ENABLED

Callers 1

xmlShellFunction · 0.85

Calls 10

xmlRelaxNGNewParserCtxtFunction · 0.85
xmlRelaxNGParseFunction · 0.85
xmlRelaxNGFreeParserCtxtFunction · 0.85
fprintfFunction · 0.85
xmlRelaxNGNewValidCtxtFunction · 0.85
xmlRelaxNGSetValidErrorsFunction · 0.85
xmlRelaxNGValidateDocFunction · 0.85
xmlRelaxNGFreeValidCtxtFunction · 0.85
xmlRelaxNGFreeFunction · 0.85

Tested by

no test coverage detected