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

Function xmlCtxtParseEntity

ThirdParty/libxml2/vtklibxml2/parser.c:12131–12239  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12129}
12130
12131static void
12132xmlCtxtParseEntity(xmlParserCtxtPtr ctxt, xmlEntityPtr ent) {
12133 xmlParserInputPtr input;
12134 xmlNodePtr list;
12135 unsigned long consumed;
12136 int isExternal;
12137 int buildTree;
12138 int oldMinNsIndex;
12139 int oldNodelen, oldNodemem;
12140
12141 isExternal = (ent->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY);
12142 buildTree = (ctxt->node != NULL);
12143
12144 /*
12145 * Recursion check
12146 */
12147 if (ent->flags & XML_ENT_EXPANDING) {
12148 xmlFatalErr(ctxt, XML_ERR_ENTITY_LOOP, NULL);
12149 xmlHaltParser(ctxt);
12150 goto error;
12151 }
12152
12153 /*
12154 * Load entity
12155 */
12156 input = xmlNewEntityInputStream(ctxt, ent);
12157 if (input == NULL)
12158 goto error;
12159
12160 /*
12161 * When building a tree, we need to limit the scope of namespace
12162 * declarations, so that entities don't reference xmlNs structs
12163 * from the parent of a reference.
12164 */
12165 oldMinNsIndex = ctxt->nsdb->minNsIndex;
12166 if (buildTree)
12167 ctxt->nsdb->minNsIndex = ctxt->nsNr;
12168
12169 oldNodelen = ctxt->nodelen;
12170 oldNodemem = ctxt->nodemem;
12171 ctxt->nodelen = 0;
12172 ctxt->nodemem = 0;
12173
12174 /*
12175 * Parse content
12176 *
12177 * This initiates a recursive call chain:
12178 *
12179 * - xmlCtxtParseContent
12180 * - xmlParseContentInternal
12181 * - xmlParseReference
12182 * - xmlCtxtParseEntity
12183 *
12184 * The nesting depth is limited by the maximum number of inputs,
12185 * see xmlPushInput.
12186 *
12187 * It's possible to make this non-recursive (minNsIndex must be
12188 * stored in the input struct) at the expense of code readability.

Callers 1

xmlParseReferenceFunction · 0.85

Calls 8

xmlFatalErrFunction · 0.85
xmlHaltParserFunction · 0.85
xmlNewEntityInputStreamFunction · 0.85
xmlCtxtParseContentFunction · 0.85
xmlSaturatedAddSizeTFunction · 0.85
xmlSetTreeDocFunction · 0.85
xmlFreeNodeListFunction · 0.85
xmlFreeInputStreamFunction · 0.85

Tested by

no test coverage detected