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

Function xmlSchemaAddSchemaDoc

ThirdParty/libxml2/vtklibxml2/xmlschemas.c:10252–10665  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10250 */
10251
10252static int
10253xmlSchemaAddSchemaDoc(xmlSchemaParserCtxtPtr pctxt,
10254 int type, /* import or include or redefine */
10255 const xmlChar *schemaLocation,
10256 xmlDocPtr schemaDoc,
10257 const char *schemaBuffer,
10258 int schemaBufferLen,
10259 xmlNodePtr invokingNode,
10260 const xmlChar *sourceTargetNamespace,
10261 const xmlChar *importNamespace,
10262 xmlSchemaBucketPtr *bucket)
10263{
10264 const xmlChar *targetNamespace = NULL;
10265 xmlSchemaSchemaRelationPtr relation = NULL;
10266 xmlDocPtr doc = NULL;
10267 int res = 0, err = 0, located = 0, preserveDoc = 0;
10268 xmlSchemaBucketPtr bkt = NULL;
10269
10270 if (bucket != NULL)
10271 *bucket = NULL;
10272
10273 switch (type) {
10274 case XML_SCHEMA_SCHEMA_IMPORT:
10275 case XML_SCHEMA_SCHEMA_MAIN:
10276 err = XML_SCHEMAP_SRC_IMPORT;
10277 break;
10278 case XML_SCHEMA_SCHEMA_INCLUDE:
10279 err = XML_SCHEMAP_SRC_INCLUDE;
10280 break;
10281 case XML_SCHEMA_SCHEMA_REDEFINE:
10282 err = XML_SCHEMAP_SRC_REDEFINE;
10283 break;
10284 }
10285
10286
10287 /* Special handling for the main schema:
10288 * skip the location and relation logic and just parse the doc.
10289 * We need just a bucket to be returned in this case.
10290 */
10291 if ((type == XML_SCHEMA_SCHEMA_MAIN) || (! WXS_HAS_BUCKETS(pctxt)))
10292 goto doc_load;
10293
10294 /* Note that we expect the location to be an absolute URI. */
10295 if (schemaLocation != NULL) {
10296 bkt = xmlSchemaGetSchemaBucket(pctxt, schemaLocation);
10297 if ((bkt != NULL) &&
10298 (pctxt->constructor->bucket == bkt)) {
10299 /* Report self-imports/inclusions/redefinitions. */
10300
10301 xmlSchemaCustomErr(ACTXT_CAST pctxt, err,
10302 invokingNode, NULL,
10303 "The schema must not import/include/redefine itself",
10304 NULL, NULL);
10305 goto exit;
10306 }
10307 }
10308 /*
10309 * Create a relation for the graph of schemas.

Callers 4

xmlSchemaParseImportFunction · 0.85
xmlSchemaParseFunction · 0.85

Calls 15

xmlSchemaGetSchemaBucketFunction · 0.85
xmlStrEqualFunction · 0.85
xmlDictLookupFunction · 0.85
xmlNewParserCtxtFunction · 0.85
xmlSchemaPErrMemoryFunction · 0.85
xmlCtxtSetErrorHandlerFunction · 0.85
xmlDictFreeFunction · 0.85
xmlDictReferenceFunction · 0.85

Tested by

no test coverage detected