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

Function xmlValidateRef

ThirdParty/libxml2/vtklibxml2/valid.c:6280–6355  ·  view source on GitHub ↗

* xmlValidateRef: * @ref: A reference to be validated * @ctxt: Validation context * @name: Name of ID we are searching for * */

Source from the content-addressed store, hash-verified

6278 *
6279 */
6280static void
6281xmlValidateRef(xmlRefPtr ref, xmlValidCtxtPtr ctxt,
6282 const xmlChar *name) {
6283 xmlAttrPtr id;
6284 xmlAttrPtr attr;
6285
6286 if (ref == NULL)
6287 return;
6288 if ((ref->attr == NULL) && (ref->name == NULL))
6289 return;
6290 attr = ref->attr;
6291 if (attr == NULL) {
6292 xmlChar *dup, *str = NULL, *cur, save;
6293
6294 dup = xmlStrdup(name);
6295 if (dup == NULL) {
6296 xmlVErrMemory(ctxt);
6297 return;
6298 }
6299 cur = dup;
6300 while (*cur != 0) {
6301 str = cur;
6302 while ((*cur != 0) && (!IS_BLANK_CH(*cur))) cur++;
6303 save = *cur;
6304 *cur = 0;
6305 id = xmlGetID(ctxt->doc, str);
6306 if (id == NULL) {
6307 xmlErrValidNodeNr(ctxt, NULL, XML_DTD_UNKNOWN_ID,
6308 "attribute %s line %d references an unknown ID \"%s\"\n",
6309 ref->name, ref->lineno, str);
6310 ctxt->valid = 0;
6311 }
6312 if (save == 0)
6313 break;
6314 *cur = save;
6315 while (IS_BLANK_CH(*cur)) cur++;
6316 }
6317 xmlFree(dup);
6318 } else if (attr->atype == XML_ATTRIBUTE_IDREF) {
6319 id = xmlGetID(ctxt->doc, name);
6320 if (id == NULL) {
6321 xmlErrValidNode(ctxt, attr->parent, XML_DTD_UNKNOWN_ID,
6322 "IDREF attribute %s references an unknown ID \"%s\"\n",
6323 attr->name, name, NULL);
6324 ctxt->valid = 0;
6325 }
6326 } else if (attr->atype == XML_ATTRIBUTE_IDREFS) {
6327 xmlChar *dup, *str = NULL, *cur, save;
6328
6329 dup = xmlStrdup(name);
6330 if (dup == NULL) {
6331 xmlVErrMemory(ctxt);
6332 ctxt->valid = 0;
6333 return;
6334 }
6335 cur = dup;
6336 while (*cur != 0) {
6337 str = cur;

Callers 1

xmlWalkValidateListFunction · 0.85

Calls 3

xmlStrdupFunction · 0.85
xmlVErrMemoryFunction · 0.85
xmlGetIDFunction · 0.85

Tested by

no test coverage detected