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

Function xmlXIncludeMergeEntity

ThirdParty/libxml2/vtklibxml2/xinclude.c:1158–1229  ·  view source on GitHub ↗

* xmlXIncludeMergeOneEntity: * @ent: the entity * @doc: the including doc * @name: the entity name * * Implements the merge of one entity */

Source from the content-addressed store, hash-verified

1156 * Implements the merge of one entity
1157 */
1158static void
1159xmlXIncludeMergeEntity(void *payload, void *vdata,
1160 const xmlChar *name ATTRIBUTE_UNUSED) {
1161 xmlEntityPtr ent = (xmlEntityPtr) payload;
1162 xmlXIncludeMergeDataPtr data = (xmlXIncludeMergeDataPtr) vdata;
1163 xmlEntityPtr ret, prev;
1164 xmlDocPtr doc;
1165 xmlXIncludeCtxtPtr ctxt;
1166
1167 if ((ent == NULL) || (data == NULL))
1168 return;
1169 ctxt = data->ctxt;
1170 doc = data->doc;
1171 if ((ctxt == NULL) || (doc == NULL))
1172 return;
1173 switch (ent->etype) {
1174 case XML_INTERNAL_PARAMETER_ENTITY:
1175 case XML_EXTERNAL_PARAMETER_ENTITY:
1176 case XML_INTERNAL_PREDEFINED_ENTITY:
1177 return;
1178 case XML_INTERNAL_GENERAL_ENTITY:
1179 case XML_EXTERNAL_GENERAL_PARSED_ENTITY:
1180 case XML_EXTERNAL_GENERAL_UNPARSED_ENTITY:
1181 break;
1182 }
1183 prev = xmlGetDocEntity(doc, ent->name);
1184 if (prev == NULL) {
1185 ret = xmlAddDocEntity(doc, ent->name, ent->etype, ent->ExternalID,
1186 ent->SystemID, ent->content);
1187 if (ret == NULL) {
1188 xmlXIncludeErrMemory(ctxt);
1189 return;
1190 }
1191 if (ent->URI != NULL) {
1192 ret->URI = xmlStrdup(ent->URI);
1193 if (ret->URI == 0)
1194 xmlXIncludeErrMemory(ctxt);
1195 }
1196 } else {
1197 if (ent->etype != prev->etype)
1198 goto error;
1199
1200 if ((ent->SystemID != NULL) && (prev->SystemID != NULL)) {
1201 if (!xmlStrEqual(ent->SystemID, prev->SystemID))
1202 goto error;
1203 } else if ((ent->ExternalID != NULL) &&
1204 (prev->ExternalID != NULL)) {
1205 if (!xmlStrEqual(ent->ExternalID, prev->ExternalID))
1206 goto error;
1207 } else if ((ent->content != NULL) && (prev->content != NULL)) {
1208 if (!xmlStrEqual(ent->content, prev->content))
1209 goto error;
1210 } else {
1211 goto error;
1212 }
1213 }
1214 return;
1215error:

Callers

nothing calls this directly

Calls 5

xmlGetDocEntityFunction · 0.85
xmlAddDocEntityFunction · 0.85
xmlXIncludeErrMemoryFunction · 0.85
xmlStrdupFunction · 0.85
xmlStrEqualFunction · 0.85

Tested by

no test coverage detected