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

Function xmlTextReaderSetSchema

ThirdParty/libxml2/vtklibxml2/xmlreader.c:4192–4255  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

4190 * -1 in case of error.
4191 */
4192int
4193xmlTextReaderSetSchema(xmlTextReaderPtr reader, xmlSchemaPtr schema) {
4194 if (reader == NULL)
4195 return(-1);
4196 if (schema == NULL) {
4197 if (reader->xsdPlug != NULL) {
4198 xmlSchemaSAXUnplug(reader->xsdPlug);
4199 reader->xsdPlug = NULL;
4200 }
4201 if (reader->xsdValidCtxt != NULL) {
4202 if (! reader->xsdPreserveCtxt)
4203 xmlSchemaFreeValidCtxt(reader->xsdValidCtxt);
4204 reader->xsdValidCtxt = NULL;
4205 }
4206 reader->xsdPreserveCtxt = 0;
4207 if (reader->xsdSchemas != NULL) {
4208 xmlSchemaFree(reader->xsdSchemas);
4209 reader->xsdSchemas = NULL;
4210 }
4211 return(0);
4212 }
4213 if (reader->mode != XML_TEXTREADER_MODE_INITIAL)
4214 return(-1);
4215 if (reader->xsdPlug != NULL) {
4216 xmlSchemaSAXUnplug(reader->xsdPlug);
4217 reader->xsdPlug = NULL;
4218 }
4219 if (reader->xsdValidCtxt != NULL) {
4220 if (! reader->xsdPreserveCtxt)
4221 xmlSchemaFreeValidCtxt(reader->xsdValidCtxt);
4222 reader->xsdValidCtxt = NULL;
4223 }
4224 reader->xsdPreserveCtxt = 0;
4225 if (reader->xsdSchemas != NULL) {
4226 xmlSchemaFree(reader->xsdSchemas);
4227 reader->xsdSchemas = NULL;
4228 }
4229 reader->xsdValidCtxt = xmlSchemaNewValidCtxt(schema);
4230 if (reader->xsdValidCtxt == NULL) {
4231 xmlSchemaFree(reader->xsdSchemas);
4232 reader->xsdSchemas = NULL;
4233 return(-1);
4234 }
4235 reader->xsdPlug = xmlSchemaSAXPlug(reader->xsdValidCtxt,
4236 &(reader->ctxt->sax),
4237 &(reader->ctxt->userData));
4238 if (reader->xsdPlug == NULL) {
4239 xmlSchemaFree(reader->xsdSchemas);
4240 reader->xsdSchemas = NULL;
4241 xmlSchemaFreeValidCtxt(reader->xsdValidCtxt);
4242 reader->xsdValidCtxt = NULL;
4243 return(-1);
4244 }
4245 xmlSchemaValidateSetLocator(reader->xsdValidCtxt,
4246 xmlTextReaderLocator,
4247 (void *) reader);
4248
4249 if ((reader->errorFunc != NULL) || (reader->sErrorFunc != NULL))

Callers

nothing calls this directly

Calls 7

xmlSchemaSAXUnplugFunction · 0.85
xmlSchemaFreeValidCtxtFunction · 0.85
xmlSchemaFreeFunction · 0.85
xmlSchemaNewValidCtxtFunction · 0.85
xmlSchemaSAXPlugFunction · 0.85

Tested by

no test coverage detected