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

Function xmlTextReaderRelaxNGSetSchema

ThirdParty/libxml2/vtklibxml2/xmlreader.c:4083–4122  ·  view source on GitHub ↗

* xmlTextReaderRelaxNGSetSchema: * @reader: the xmlTextReaderPtr used * @schema: a precompiled RelaxNG schema * * Use RelaxNG to validate the document as it is processed. * Activation is only possible before the first Read(). * if @schema is NULL, then RelaxNG validation is deactivated. @ The @schema should not be freed until the reader is deallocated * or its use has been deactivated.

Source from the content-addressed store, hash-verified

4081 * -1 in case of error.
4082 */
4083int
4084xmlTextReaderRelaxNGSetSchema(xmlTextReaderPtr reader, xmlRelaxNGPtr schema) {
4085 if (reader == NULL)
4086 return(-1);
4087 if (schema == NULL) {
4088 if (reader->rngSchemas != NULL) {
4089 xmlRelaxNGFree(reader->rngSchemas);
4090 reader->rngSchemas = NULL;
4091 }
4092 if (reader->rngValidCtxt != NULL) {
4093 if (! reader->rngPreserveCtxt)
4094 xmlRelaxNGFreeValidCtxt(reader->rngValidCtxt);
4095 reader->rngValidCtxt = NULL;
4096 }
4097 reader->rngPreserveCtxt = 0;
4098 return(0);
4099 }
4100 if (reader->mode != XML_TEXTREADER_MODE_INITIAL)
4101 return(-1);
4102 if (reader->rngSchemas != NULL) {
4103 xmlRelaxNGFree(reader->rngSchemas);
4104 reader->rngSchemas = NULL;
4105 }
4106 if (reader->rngValidCtxt != NULL) {
4107 if (! reader->rngPreserveCtxt)
4108 xmlRelaxNGFreeValidCtxt(reader->rngValidCtxt);
4109 reader->rngValidCtxt = NULL;
4110 }
4111 reader->rngPreserveCtxt = 0;
4112 reader->rngValidCtxt = xmlRelaxNGNewValidCtxt(schema);
4113 if (reader->rngValidCtxt == NULL)
4114 return(-1);
4115 if ((reader->errorFunc != NULL) || (reader->sErrorFunc != NULL))
4116 xmlRelaxNGSetValidStructuredErrors(reader->rngValidCtxt,
4117 xmlTextReaderStructuredRelay, reader);
4118 reader->rngValidErrors = 0;
4119 reader->rngFullNode = NULL;
4120 reader->validate = XML_TEXTREADER_VALIDATE_RNG;
4121 return(0);
4122}
4123
4124/**
4125 * xmlTextReaderLocator:

Callers

nothing calls this directly

Calls 4

xmlRelaxNGFreeFunction · 0.85
xmlRelaxNGFreeValidCtxtFunction · 0.85
xmlRelaxNGNewValidCtxtFunction · 0.85

Tested by

no test coverage detected