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

Function xmlSetNsProp

ThirdParty/libxml2/vtklibxml2/tree.c:6969–7025  ·  view source on GitHub ↗

* xmlSetNsProp: * @node: the node * @ns: the namespace definition * @name: the attribute name * @value: the attribute value * * Set (or reset) an attribute carried by a node. * The ns structure must be in scope, this is not checked * * Returns the attribute pointer. */

Source from the content-addressed store, hash-verified

6967 * Returns the attribute pointer.
6968 */
6969xmlAttrPtr
6970xmlSetNsProp(xmlNodePtr node, xmlNsPtr ns, const xmlChar *name,
6971 const xmlChar *value)
6972{
6973 xmlAttrPtr prop;
6974
6975 if (ns && (ns->href == NULL))
6976 return(NULL);
6977 if (name == NULL)
6978 return(NULL);
6979 prop = xmlGetPropNodeInternal(node, name,
6980 (ns != NULL) ? ns->href : NULL, 0);
6981 if (prop != NULL) {
6982 xmlNodePtr children = NULL;
6983
6984 /*
6985 * Modify the attribute's value.
6986 */
6987 if (value != NULL) {
6988 children = xmlNewDocText(node->doc, value);
6989 if (children == NULL)
6990 return(NULL);
6991 }
6992
6993 if (prop->atype == XML_ATTRIBUTE_ID) {
6994 xmlRemoveID(node->doc, prop);
6995 prop->atype = XML_ATTRIBUTE_ID;
6996 }
6997 if (prop->children != NULL)
6998 xmlFreeNodeList(prop->children);
6999 prop->children = NULL;
7000 prop->last = NULL;
7001 prop->ns = ns;
7002 if (value != NULL) {
7003 xmlNodePtr tmp;
7004
7005 prop->children = children;
7006 prop->last = NULL;
7007 tmp = prop->children;
7008 while (tmp != NULL) {
7009 tmp->parent = (xmlNodePtr) prop;
7010 if (tmp->next == NULL)
7011 prop->last = tmp;
7012 tmp = tmp->next;
7013 }
7014 }
7015 if ((prop->atype == XML_ATTRIBUTE_ID) &&
7016 (xmlAddIDSafe(prop, value) < 0)) {
7017 return(NULL);
7018 }
7019 return(prop);
7020 }
7021 /*
7022 * No equal attr found; create a new one.
7023 */
7024 return(xmlNewPropInternal(node, ns, name, value, 0));
7025}
7026

Callers 5

xmlDumpXMLCatalogNodeFunction · 0.85
xmlNodeSetLangFunction · 0.85
xmlNodeSetSpacePreserveFunction · 0.85
xmlNodeSetBaseFunction · 0.85
xmlSetPropFunction · 0.85

Calls 6

xmlGetPropNodeInternalFunction · 0.85
xmlNewDocTextFunction · 0.85
xmlRemoveIDFunction · 0.85
xmlFreeNodeListFunction · 0.85
xmlAddIDSafeFunction · 0.85
xmlNewPropInternalFunction · 0.85

Tested by

no test coverage detected