* xmlAddID: * @ctxt: the validation context * @doc: pointer to the document * @value: the value name * @attr: the attribute holding the ID * * Register a new id declaration * * Returns NULL if not, otherwise the new xmlIDPtr */
| 2414 | * Returns NULL if not, otherwise the new xmlIDPtr |
| 2415 | */ |
| 2416 | xmlIDPtr |
| 2417 | xmlAddID(xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *value, |
| 2418 | xmlAttrPtr attr) { |
| 2419 | xmlIDPtr id; |
| 2420 | int res; |
| 2421 | |
| 2422 | if ((attr == NULL) || (doc != attr->doc)) |
| 2423 | return(NULL); |
| 2424 | |
| 2425 | res = xmlAddIDInternal(attr, value, &id); |
| 2426 | if (res < 0) { |
| 2427 | xmlVErrMemory(ctxt); |
| 2428 | } |
| 2429 | #ifdef LIBXML_VALID_ENABLED |
| 2430 | else if (res == 0) { |
| 2431 | if (ctxt != NULL) { |
| 2432 | /* |
| 2433 | * The id is already defined in this DTD. |
| 2434 | */ |
| 2435 | xmlErrValidNode(ctxt, attr->parent, XML_DTD_ID_REDEFINED, |
| 2436 | "ID %s already defined\n", value, NULL, NULL); |
| 2437 | } |
| 2438 | } |
| 2439 | #endif /* LIBXML_VALID_ENABLED */ |
| 2440 | |
| 2441 | return(id); |
| 2442 | } |
| 2443 | |
| 2444 | static void |
| 2445 | xmlFreeIDTableEntry(void *id, const xmlChar *name ATTRIBUTE_UNUSED) { |
no test coverage detected