* xmlDOMWrapStoreNs: * @doc: the doc * @nsName: the namespace name * @prefix: the prefix * * Creates or reuses an xmlNs struct on doc->oldNs with * the given prefix and namespace name. * * Returns the acquired ns struct or NULL in case of an API * or internal error. */
| 7960 | * or internal error. |
| 7961 | */ |
| 7962 | static xmlNsPtr |
| 7963 | xmlDOMWrapStoreNs(xmlDocPtr doc, |
| 7964 | const xmlChar *nsName, |
| 7965 | const xmlChar *prefix) |
| 7966 | { |
| 7967 | xmlNsPtr ns; |
| 7968 | |
| 7969 | if (doc == NULL) |
| 7970 | return (NULL); |
| 7971 | ns = xmlTreeEnsureXMLDecl(doc); |
| 7972 | if (ns == NULL) |
| 7973 | return (NULL); |
| 7974 | if (ns->next != NULL) { |
| 7975 | /* Reuse. */ |
| 7976 | ns = ns->next; |
| 7977 | while (ns != NULL) { |
| 7978 | if (((ns->prefix == prefix) || |
| 7979 | xmlStrEqual(ns->prefix, prefix)) && |
| 7980 | xmlStrEqual(ns->href, nsName)) { |
| 7981 | return (ns); |
| 7982 | } |
| 7983 | if (ns->next == NULL) |
| 7984 | break; |
| 7985 | ns = ns->next; |
| 7986 | } |
| 7987 | } |
| 7988 | /* Create. */ |
| 7989 | if (ns != NULL) { |
| 7990 | ns->next = xmlNewNs(NULL, nsName, prefix); |
| 7991 | return (ns->next); |
| 7992 | } |
| 7993 | return(NULL); |
| 7994 | } |
| 7995 | |
| 7996 | /* |
| 7997 | * xmlDOMWrapNewCtxt: |
no test coverage detected