* xmlSetProp: * @node: the node * @name: the attribute name (a QName) * @value: the attribute value * * Set (or reset) an attribute carried by a node. * If @name has a prefix, then the corresponding * namespace-binding will be used, if in scope; it is an * error it there's no such ns-binding for the prefix in * scope. * Returns the attribute pointer. * */
| 6926 | * |
| 6927 | */ |
| 6928 | xmlAttrPtr |
| 6929 | xmlSetProp(xmlNodePtr node, const xmlChar *name, const xmlChar *value) { |
| 6930 | xmlNsPtr ns = NULL; |
| 6931 | const xmlChar *localname; |
| 6932 | xmlChar *prefix; |
| 6933 | int res; |
| 6934 | |
| 6935 | if ((node == NULL) || (name == NULL) || (node->type != XML_ELEMENT_NODE)) |
| 6936 | return(NULL); |
| 6937 | |
| 6938 | /* |
| 6939 | * handle QNames |
| 6940 | */ |
| 6941 | localname = xmlSplitQName4(name, &prefix); |
| 6942 | if (localname == NULL) |
| 6943 | return(NULL); |
| 6944 | |
| 6945 | if (prefix != NULL) { |
| 6946 | res = xmlSearchNsSafe(node, prefix, &ns); |
| 6947 | xmlFree(prefix); |
| 6948 | if (res < 0) |
| 6949 | return(NULL); |
| 6950 | if (ns != NULL) |
| 6951 | return(xmlSetNsProp(node, ns, localname, value)); |
| 6952 | } |
| 6953 | |
| 6954 | return(xmlSetNsProp(node, NULL, name, value)); |
| 6955 | } |
| 6956 | |
| 6957 | /** |
| 6958 | * xmlSetNsProp: |
no test coverage detected