* xmlGetID: * @doc: pointer to the document * @ID: the ID value * * Search the attribute declaring the given ID * * Returns NULL if not found, otherwise the xmlAttrPtr defining the ID */
| 2568 | * Returns NULL if not found, otherwise the xmlAttrPtr defining the ID |
| 2569 | */ |
| 2570 | xmlAttrPtr |
| 2571 | xmlGetID(xmlDocPtr doc, const xmlChar *ID) { |
| 2572 | xmlIDTablePtr table; |
| 2573 | xmlIDPtr id; |
| 2574 | |
| 2575 | if (doc == NULL) { |
| 2576 | return(NULL); |
| 2577 | } |
| 2578 | |
| 2579 | if (ID == NULL) { |
| 2580 | return(NULL); |
| 2581 | } |
| 2582 | |
| 2583 | table = (xmlIDTablePtr) doc->ids; |
| 2584 | if (table == NULL) |
| 2585 | return(NULL); |
| 2586 | |
| 2587 | id = xmlHashLookup(table, ID); |
| 2588 | if (id == NULL) |
| 2589 | return(NULL); |
| 2590 | if (id->attr == NULL) { |
| 2591 | /* |
| 2592 | * We are operating on a stream, return a well known reference |
| 2593 | * since the attribute node doesn't exist anymore |
| 2594 | */ |
| 2595 | return((xmlAttrPtr) doc); |
| 2596 | } |
| 2597 | return(id->attr); |
| 2598 | } |
| 2599 | |
| 2600 | /************************************************************************ |
| 2601 | * * |
no test coverage detected