/* removes all empty text, comments and other insignoficant nodes */ static void cleanup_xml_node(xmlNodePtr node) { xmlNodePtr trav; xmlNodePtr del = NULL; trav = node->children; while (trav != NULL) { if (del != NULL) { xmlUnlinkNode(del); xmlFreeNode(del); del = NULL; } if (trav->type == XML_TEXT_NODE) { if (is_blank(trav->content)) { del = trav; } } else if ((trav->type != XML_ELEMENT_NODE) && (trav->type != XML_CDATA_SECTION_NODE)) { del = trav; } else if (trav->children != NULL) { cleanup_xml_node(trav); } trav = trav->next; } if (del != NULL) { xmlUnlinkNode(del); xmlFreeNode(del); } }
/* * Interprets nodes from @topnode and for all of @topnode's next siblings */ static gboolean real_run_at_node (GdaReportEngine *engine, xmlNodePtr topnode, RunContext *context, GError **error) { xmlNodePtr node; xmlNodePtr next_node = NULL; for (node = topnode; node; node = next_node) { next_node = node->next; if (!strncmp ((gchar *) node->name, "gda_report", 10)) { GSList *created_nodes = NULL; gboolean cmd_res = TRUE; gsize i; gboolean command_found = FALSE; for (i = 0; i < sizeof (commands) / sizeof (EngineCommand); i++) { EngineCommand *ec = (EngineCommand *) &(commands [i]); if (ec->has_prefix) { if (!strcmp (((gchar *) node->name) + 10, ec->tag_name + 10)) { command_found = TRUE; if (ec->func) cmd_res = (ec->func) (engine, node, &created_nodes, context, error); break; } } } if (!command_found) { /* gda_ node not implemented */ TO_IMPLEMENT; g_warning ("Engine command '%s' is not yet implemented", (gchar *) node->name); } if (created_nodes) { /* put @node's contents before @node */ GSList *list; for (list = created_nodes; list; list = list->next) { next_node = xmlAddPrevSibling (node, (xmlNodePtr) list->data); g_assert (next_node); } g_slist_free (created_nodes); /* destroy @node */ xmlUnlinkNode (node); xmlFreeNode (node); next_node = next_node->next; } else { /* destroy @node */ xmlUnlinkNode (node); xmlFreeNode (node); } if (!cmd_res) return FALSE; } else if (node->children) { if (!real_run_at_node (engine, node->children, context, error)) return FALSE; } } return TRUE; }
static void gda_report_engine_set_property (GObject *object, guint param_id, const GValue *value, GParamSpec *pspec) { GdaReportEngine *eng; eng = GDA_REPORT_ENGINE (object); if (eng->priv) { switch (param_id) { case PROP_SPEC_NODE: { if (eng->priv->spec) { xmlFreeNode (eng->priv->spec); eng->priv->spec = NULL; } eng->priv->spec = g_value_get_pointer (value); break; } case PROP_SPEC_STRING: { xmlDocPtr doc; doc = xmlParseDoc (BAD_CAST g_value_get_string (value)); if (doc) { if (eng->priv->spec) xmlFreeNode (eng->priv->spec); eng->priv->spec = xmlDocGetRootElement (doc); xmlUnlinkNode (eng->priv->spec); if (eng->priv->doc) xmlFreeDoc (eng->priv->doc); eng->priv->doc = doc; } break; } case PROP_SPEC_FILE: { xmlDocPtr doc; doc = xmlParseFile (g_value_get_string (value)); if (doc) { if (eng->priv->spec) xmlFreeNode (eng->priv->spec); eng->priv->spec = xmlDocGetRootElement (doc); xmlUnlinkNode (eng->priv->spec); if (eng->priv->doc) xmlFreeDoc (eng->priv->doc); eng->priv->doc = doc; } break; } case PROP_OUTPUT_DIR: g_free (eng->priv->output_dir); eng->priv->output_dir = g_value_dup_string (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); break; } } }
void Editor_Export::processNoteCitation (xmlNodePtr node) { // Remove the note citation from the text. xmlNodePtr child = node->xmlChildrenNode; while (child != NULL) { xmlNodePtr cache = child; child = child->next; xmlUnlinkNode (cache); xmlFree (cache); } // Get more information about the footnote to retrieve. string href; string id; xmlChar * property = xmlGetProp (node, BAD_CAST "href"); if (property) { href = (char *) property; xmlFree (property); id = href.substr (1); } // Sample footnote body. // <p class="x"><a href="#citation1" id="note1">x</a><span> </span><span>+ 2 Joh. 1.1</span></p> // Retrieve the <a> element from it. // At first this was done through an XPath expression: // http://www.grinninglizard.com/tinyxml2docs/index.html // But XPath crashes on Android. // Therefore now it iterates of all the nodes to find the required <a> element. xmlNodePtr aElement = get_note_pointer (xmlDocGetRootElement (document), id); if (aElement) { // It now has the 'a' element: Get its 'p' parent, and then remove that 'a' element. // So we remain with: // <p class="x"><span> </span><span>+ 2 Joh. 1.1</span></p> xmlNodePtr pElement = aElement->parent; xmlUnlinkNode (aElement); xmlFree (aElement); // Preserve active character styles in the main text, and reset them for the note. vector <string> preservedCharacterStyles = characterStyles; characterStyles.clear(); // Process this 'p' element. processingNote = true; processNode (pElement); processingNote = false; // Restore the active character styles for the main text. characterStyles = preservedCharacterStyles; // Remove this element so it can't be processed again. xmlUnlinkNode (pElement); xmlFree (pElement); } else { Database_Logs::log ("Discarding note with id " + id + " and href " + href); } }
/* * Handles incomplete html fragments as may occur on the clipboard, * e.g. a <td> without <tr> and <table> in front of it. */ static void html_search_for_tables (htmlNodePtr cur, htmlDocPtr doc, WorkbookView *wb_view, GnmHtmlTableCtxt *tc) { htmlNodePtr ptr; if (cur == NULL) { xmlGenericError(xmlGenericErrorContext, "htmlNodeDumpFormatOutput : node == NULL\n"); return; } if (cur->type != XML_ELEMENT_NODE) return; if (xmlStrEqual (cur->name, CC2XML ("table"))) { html_read_table (cur, doc, wb_view, tc); } else if (starts_inferred_table (cur) || starts_inferred_row (cur)) { htmlNodePtr tnode = xmlNewNode (NULL, "table"); /* Link in a table node */ xmlAddPrevSibling (cur, tnode); if (starts_inferred_row (cur)) { htmlNodePtr rnode = xmlNewNode (NULL, "tr"); /* Link in a row node */ xmlAddChild (tnode, rnode); /* Make following elements children of the row node, * until we meet one which isn't legal in a row. */ while ((ptr = tnode->next) != NULL) { if (ends_inferred_row (ptr)) break; xmlUnlinkNode (ptr); xmlAddChild (rnode, ptr); } } /* Make following elements children of the row node, * until we meet one which isn't legal in a table. */ while ((ptr = tnode->next) != NULL) { if (ends_inferred_table (ptr)) break; xmlUnlinkNode (ptr); xmlAddChild (tnode, ptr); } html_read_table (tnode, doc, wb_view, tc); } else { for (ptr = cur->children; ptr != NULL ; ptr = ptr->next) { html_search_for_tables (ptr, doc, wb_view, tc); /* ptr may now have been pushed down in the tree, * if so, ptr->next is not the right pointer to * follow */ while (ptr->parent != cur) ptr = ptr->parent; } } }
void XMLElement::setChildren(const XMLElement & elem) const { xmlNode *n = elem.getRealNode(); if (n && n->parent != node) { xmlNode *cpy = xmlCopyNode(n, 1); xmlUnlinkNode(cpy); xmlUnlinkNode(node->children); xmlFreeNodeList(node->children); node->children = 0; xmlAddChild(node, cpy); } }
static VALUE rxml_node_remove_ex(VALUE self) { xmlNodePtr xnode, xresult; xnode = rxml_get_xnode(self); /* First unlink the node from its parent. */ xmlUnlinkNode(xnode); /* Now copy the node we want to remove and make the current Ruby object point to it. We do this because a node has a number of dependencies on its parent document - its name (if using a dictionary), entities, namespaces, etc. For a node to live on its own, it needs to get its own copies of this information.*/ xresult = xmlDocCopyNode(xnode, NULL, 1); /* Now free the original node. */ xmlFreeNode(xnode); /* Now wrap the new node */ RDATA(self)->data = xresult; xresult->_private = (void*) self; /* Now return the removed node so the user can do something with it.*/ return self; }
/*Remove - removes element from xml tree*/ void CXMLElement::Remove() { if (!isinited()) return; xmlUnlinkNode(element); xmlFreeNode(element); element = NULL; }
bool CXMLElement::MoveElement(CXMLElement* p_element, bool p_sibling, bool p_before) { xmlNodePtr t_parent; for(t_parent = element; t_parent != NULL; t_parent = t_parent -> parent) if (t_parent == p_element -> GetNodePtr()) return false; xmlUnlinkNode(p_element -> GetNodePtr()); if (p_sibling) { if (p_before) xmlAddPrevSibling(element, p_element -> GetNodePtr()); else xmlAddNextSibling(element, p_element -> GetNodePtr()); } else { if (p_before && element -> children != NULL) xmlAddPrevSibling(element -> children, p_element -> GetNodePtr()); else xmlAddChild(element, p_element -> GetNodePtr()); } return true; }
bool gpl::xml::eraseNodeByXPath() { if (m_xml->resource == NULL) return false; //cout<<"resource->type:"<<m_xml->resource->type<<endl; switch (m_xml->resource->type) { case XPATH_NODESET://Object is a Node Set if (m_xml->resource->nodesetval == NULL) return false; xmlNodePtr cur; //取得第一个节点 if ((cur = (*(m_xml->resource->nodesetval->nodeTab))) == NULL) return true; xmlUnlinkNode(cur); xmlFreeNode(cur); cur = NULL; break; case XPATH_XSLT_TREE://Object is an XSLT value tree case XPATH_BOOLEAN://Object is a Boolean case XPATH_NUMBER://Object is a number case XPATH_STRING://Object is a string case XPATH_POINT://Object is a point case XPATH_RANGE://是一个范围 case XPATH_LOCATIONSET://Object is a Location Set case XPATH_USERS://Object is user defined case XPATH_UNDEFINED://Object is uninitialized return false; break; } return true; }
void Local::Presentity::rename_group (const std::string old_name, const std::string new_name) { bool old_name_present = false; bool already_in_new_name = false; std::set<xmlNodePtr> nodes_to_remove; /* remove the old name's node * and check if we aren't already in the new name's group */ for (xmlNodePtr child = node->children ; child != NULL ; child = child->next) { if (child->type == XML_ELEMENT_NODE && child->name != NULL) { if (xmlStrEqual (BAD_CAST ("group"), child->name)) { xmlChar* xml_str = xmlNodeGetContent (child); if (xml_str != NULL) { if (!xmlStrcasecmp ((const xmlChar*)old_name.c_str (), xml_str)) { nodes_to_remove.insert (child); // don't free what we loop on! old_name_present = true; } if (!xmlStrcasecmp ((const xmlChar*)new_name.c_str (), xml_str)) { already_in_new_name = true; } xmlFree (xml_str); } } } } // ok, now we can clean up! for (std::set<xmlNodePtr>::iterator iter = nodes_to_remove.begin (); iter != nodes_to_remove.end (); ++iter) { xmlUnlinkNode (*iter); xmlFreeNode (*iter); } if (old_name_present && !already_in_new_name) { xmlNewChild (node, NULL, BAD_CAST "group", BAD_CAST robust_xmlEscape (node->doc, new_name).c_str ()); } updated (); trigger_saving (); }
/*delete one level xml node*/ int delete_eag_onelevel(char *fpath,char *node_name,char *attribute,char *ruler) { xmlDocPtr pdoc = NULL; xmlNodePtr pcurnode = NULL; char *psfilename; int flag=-1; psfilename = fpath; pdoc = xmlReadFile(psfilename,"utf-8",256); if(NULL == pdoc) { return 1; } pcurnode = xmlDocGetRootElement(pdoc); pcurnode = pcurnode->xmlChildrenNode; xmlNodePtr propNodePtr = pcurnode; while (NULL != pcurnode) { if (!xmlStrcmp(pcurnode->name, BAD_CAST node_name)) { propNodePtr = pcurnode; xmlChar* szAttr = xmlGetProp(propNodePtr,BAD_CAST attribute); if(!xmlStrcmp(szAttr,BAD_CAST ruler)) { xmlNodePtr tempNode; tempNode = pcurnode->next; xmlUnlinkNode(pcurnode); xmlFreeNode(pcurnode); pcurnode = tempNode; flag=0; continue; } xmlFree(szAttr); } pcurnode = pcurnode->next; } xmlSaveFile(fpath,pdoc); return flag; }
static void remove_doc_from_content_list(xmlNodePtr cl_node, struct IdTab *id_tab, int start, int end) { xmlNodePtr node, next; char *str_id; int id, i; if (cl_node == NULL) return; for(node = cl_node; node != NULL; node = next) { next = node->next; if (node->type == XML_ELEMENT_NODE && !xmlStrcmp(node->name, (xmlChar *)"doc")) { str_id = (char *)xmlGetProp(node, (xmlChar *)"docid"); id = atoi(str_id); xmlFree(str_id); for(i = start; id_tab[i].id != id && i < end; i++) ; if (i < end && id_tab[i].id == id) { xmlUnlinkNode(node); xmlFreeNode((void *)node); } } else remove_doc_from_content_list(node->children, id_tab, start, end); } }
/* * COMMAND: <gda_report_section> * * Creates copies of its contents, one copy per row in the new run context's * data model. * * uses node's contents: yes * requested attributes: none * * REM: either "query_name" or a <gda_report_query> sub node must be provided to create a data model. */ static gboolean command_gda_report_iter_run (GdaReportEngine *engine, xmlNodePtr node, GSList **created_nodes, RunContext *context, GError **error) { if (!context || !context->iter) return TRUE; gda_data_model_iter_move_next (context->iter); while (gda_data_model_iter_is_valid (context->iter)) { xmlNodePtr dup, child; dup = xmlCopyNode (node, 1); if (!real_run_at_node (engine, dup->children, context, error)) { xmlFreeNode (dup); return FALSE; } else { for (child = dup->children; child; child = dup->children) { xmlUnlinkNode (child); *created_nodes = g_slist_prepend (*created_nodes, child); } } xmlFreeNode (dup); gda_data_model_iter_move_next (context->iter); } *created_nodes = g_slist_reverse (*created_nodes); return TRUE; }
int xmlUnlinkNodeWithCheck(xmlNode *node) { if (xmlNodePtrCheck(node->parent)) { xmlUnlinkNode(node); return 1; } return 0; }
/* * call-seq: * curr_node << "Some text" * curr_node << node * * Add the specified text or XML::Node as a new child node to the * current node. * * If the specified argument is a string, it should be a raw string * that contains unescaped XML special characters. Entity references * are not supported. * * The method will return the current node. */ static VALUE rxml_node_content_add(VALUE self, VALUE obj) { xmlNodePtr xnode; VALUE str; Data_Get_Struct(self, xmlNode, xnode); /* XXX This should only be legal for a CDATA type node, I think, * resulting in a merge of content, as if a string were passed * danj 070827 */ if (rb_obj_is_kind_of(obj, cXMLNode)) { xmlNodePtr xtarget; Data_Get_Struct(obj, xmlNode, xtarget); xmlUnlinkNode(xtarget); rxml_node_modify_dom(self, obj, xmlAddChild); } else { str = rb_obj_as_string(obj); if (NIL_P(str) || TYPE(str) != T_STRING) rb_raise(rb_eTypeError, "invalid argument: must be string or XML::Node"); xmlNodeAddContent(xnode, (xmlChar*) StringValuePtr(str)); } return self; }
void XMLNodeList::replaceAtIndex(int index, const XMLElement & elem) { xmlNode *n = getListNode(index); if (n && n != elem.getRealNode()) { if (index == 1) { scope->unregisterNodeListPointer(parent->children); } xmlNode *previous = n->prev; xmlNode *next = n->next; xmlNode *cpy = xmlCopyNode(elem.getRealNode(), 1); xmlUnlinkNode(cpy); xmlReplaceNode(n, cpy); xmlFreeNode(n); prevNode = cpy; cpy->prev = previous; cpy->next = next; if (index == 1) { scope->registerPointers(parent->children, this); } } }
void Document::importDocument(Document& other, Node& importNode) { std::lock_guard<std::mutex> lock(_lock); // Locate the top-level node(s) of the other document xml::NodeList topLevelNodes = other.findXPath("/*"); xmlNodePtr targetNode = importNode.getNodePtr(); if (targetNode->name == NULL) { // invalid importnode return; } // greebo: Not all target nodes already have a valid child node, use a modified algorithm // to handle that situation as suggested by malex984 // Add each of the imported nodes to the target importNode for (std::size_t i = 0; i < topLevelNodes.size(); ++i) { if (targetNode->children == NULL) { xmlUnlinkNode(topLevelNodes[i].getNodePtr()); xmlAddChild(targetNode, topLevelNodes[i].getNodePtr()); } else { xmlAddPrevSibling(targetNode->children, topLevelNodes[i].getNodePtr()); } } }
/* * call-seq: * unlink * * Unlink this node from its current context. */ static VALUE unlink_node(VALUE self) { xmlNodePtr node; Data_Get_Struct(self, xmlNode, node); xmlUnlinkNode(node); return self; }
/** * \brief Remove input plugin from supportedCollectors tag * * \param info tool configuration * \return 0 on success */ int remove_supported(conf_info_t *info) { int i; xmlNodePtr children1; xmlXPathObjectPtr xpath_obj_file = eval_xpath(info, TAG_SUPPORTED); if (!xpath_obj_file) { return 1; } for (i = 0; i < xpath_obj_file->nodesetval->nodeNr; i++) { children1 = xpath_obj_file->nodesetval->nodeTab[i]->children; while (children1) { if ((!strncmp ((char*) children1->name, "name", strlen ("name") + 1)) && (!xmlStrncmp (children1->children->content, (xmlChar *) info->name, xmlStrlen ((xmlChar *)info->name) + 1))) { /* element found*/ xmlUnlinkNode(children1); xmlFreeNode(children1); return 0; } children1 = children1->next; } } return 0; }
static VALUE rxml_node_modify_dom(VALUE self, VALUE target, xmlNodePtr (*xmlFunc)(xmlNodePtr, xmlNodePtr)) { xmlNodePtr xnode, xtarget, xresult; if (rb_obj_is_kind_of(target, cXMLNode) == Qfalse) rb_raise(rb_eTypeError, "Must pass an XML::Node object"); xnode = rxml_get_xnode(self); xtarget = rxml_get_xnode(target); if (xtarget->doc != NULL && xtarget->doc != xnode->doc) rb_raise(eXMLError, "Nodes belong to different documents. You must first import the node by calling XML::Document.import"); xmlUnlinkNode(xtarget); /* This target node could be freed here. */ xresult = xmlFunc(xnode, xtarget); if (!xresult) rxml_raise(&xmlLastError); /* Was the target freed? If yes, then wrap the new node */ if (xresult != xtarget) { RDATA(target)->data = xresult; xresult->_private = (void*) target; } return target; }
static void parseEnvFile(const char* path, xmlNodeSetPtr nodes) { if(!path) return; int inp = open(path,O_RDONLY); size_t plen = strlen(path); xmlDoc* doc = readFunky(inp,path,plen); close(inp); if(!doc) { fprintf(stderr,"Couldn't parse %.*s",plen,path); exit(5); } xmlNode* root = xmlDocGetRootElement(doc); xmlNode* cur = root; // body nodes->nodeNr = 0; for(;cur;cur = cur->next) { ++nodes->nodeNr; } nodes->nodeTab = malloc(sizeof(xmlNode*)*nodes->nodeNr); cur = root; int i = 0; for(;cur;++i) { xmlNode* next = cur->next; nodes->nodeTab[i] = cur; xmlUnlinkNode(cur); cur = next; } xmlFreeDoc(doc); }
/* convert a GstCmmlTagHead to its string representation */ guchar * gst_cmml_parser_tag_head_to_string (GstCmmlParser * parser, GstCmmlTagHead * head) { xmlNodePtr node; xmlNodePtr tmp; guchar *ret; node = gst_cmml_parser_new_node (parser, "head", NULL); if (head->title) { tmp = gst_cmml_parser_new_node (parser, "title", NULL); xmlNodeSetContent (tmp, head->title); xmlAddChild (node, tmp); } if (head->base) { tmp = gst_cmml_parser_new_node (parser, "base", "uri", head->base, NULL); xmlAddChild (node, tmp); } if (head->meta) gst_cmml_parser_meta_to_string (parser, node, head->meta); ret = gst_cmml_parser_node_to_string (parser, node); xmlUnlinkNode (node); xmlFreeNode (node); return ret; }
/* ############################################################################# * * Description remove all DTDs from the XML document * Author Harry Brueckner * Date 2005-05-06 * Arguments void * Return void */ void xmlRemoveDtd(void) { xmlNode* curnode; xmlNode* delnode = NULL; TRACE(99, "xmlRemoveDtd()", NULL); if (!xmldoc) { return; } /* we delete all DTDs in the document */ curnode = xmldoc -> children; while (curnode) { if (curnode -> type == XML_DTD_NODE) { delnode = curnode; } curnode = curnode -> next; if (delnode) { xmlUnlinkNode(delnode); delnode = NULL; } } }
int xml_parser_node_remove(WsXmlNodeH node) { destroy_node_private_data(((xmlNodePtr) node)->_private); xmlUnlinkNode((xmlNodePtr) node); xmlFreeNode((xmlNodePtr) node); return 0; }
int do_remove_empty(xmlNode* node) { xmlNode* n; int i, is_empty, len; xmlChar* val; for(n = node; n; n = n->next) { if(n->type == XML_TEXT_NODE) { val = xmlNodeGetContent(n); len = strlen((const char*)val); is_empty = 1; for(i = 0; i < len; i++) { if(!isspace(val[i])) { is_empty = 0; } } xmlFree(val); if(is_empty) { xmlUnlinkNode(n); xmlFreeNode(n); return 1; } } } for(n = node; n; n = n->next) { if(n->type == XML_ELEMENT_NODE) { do { }while(do_remove_empty(n->children)); } } return 0; }
guchar * gst_cmml_parser_tag_stream_to_string (GstCmmlParser * parser, GstCmmlTagStream * stream) { xmlNodePtr node; xmlNodePtr import; guchar *ret; node = gst_cmml_parser_new_node (parser, "stream", NULL); if (stream->timebase) xmlSetProp (node, (xmlChar *) "timebase", stream->timebase); if (stream->utc) xmlSetProp (node, (xmlChar *) "utc", stream->utc); if (stream->imports) { gint i; GValue *val; for (i = 0; i < stream->imports->n_values; ++i) { val = g_value_array_get_nth (stream->imports, i); import = gst_cmml_parser_new_node (parser, "import", "src", g_value_get_string (val), NULL); xmlAddChild (node, import); } } ret = gst_cmml_parser_node_to_string (parser, node); xmlUnlinkNode (node); xmlFreeNode (node); return ret; }
OSyncXMLField *osync_xmlfield_new(OSyncXMLFormat *xmlformat, const char *name, OSyncError **error) { xmlNodePtr node = NULL; OSyncXMLField *xmlfield = NULL; osync_trace(TRACE_ENTRY, "%s(%p, %s, %p)", __func__, xmlformat, name, error); osync_assert(xmlformat); osync_assert(name); node = xmlNewTextChild(xmlDocGetRootElement(xmlformat->doc), NULL, BAD_CAST name, NULL); xmlfield = osync_xmlfield_new_node(xmlformat, node, error); if(!xmlfield) { xmlUnlinkNode(node); xmlFreeNode(node); osync_trace(TRACE_EXIT_ERROR, "%s: %s" , __func__, osync_error_print(error)); return NULL; } /* XMLFormat entry got added - not sure if it is still sorted */ osync_xmlformat_set_unsorted(xmlformat); /* This XMLField has no keys, so it's for sure it's sorted */ xmlfield->sorted = TRUE; osync_trace(TRACE_EXIT, "%s: %p", __func__, xmlfield); return xmlfield; }
static GUPnPDIDLLiteFragmentResult apply_temporary_addition (DocNode *modified, xmlNodePtr sibling, xmlNodePtr new_node, XSDData *xsd_data) { xmlNodePtr mod_sibling; xmlNodePtr new_node_copy = av_xml_util_copy_node (new_node); if (sibling->doc == modified->doc) mod_sibling = sibling; else mod_sibling = av_xml_util_find_node (modified->node, sibling); if (mod_sibling == NULL) return GUPNP_DIDL_LITE_FRAGMENT_RESULT_UNKNOWN_ERROR; xmlUnlinkNode (new_node_copy); if (xmlAddNextSibling (mod_sibling, new_node_copy) == NULL) { xmlFreeNode (new_node_copy); return GUPNP_DIDL_LITE_FRAGMENT_RESULT_UNKNOWN_ERROR; } if (!xsd_data_validate_doc (xsd_data, modified->doc)) return GUPNP_DIDL_LITE_FRAGMENT_RESULT_NEW_INVALID; return GUPNP_DIDL_LITE_FRAGMENT_RESULT_OK; }
/* Adapted from yelp-toc-pager.c */ static xmlChar * xml_get_and_trim_names (xmlNodePtr node) { xmlNodePtr cur; xmlChar *keep_lang = NULL; xmlChar *value; int j, keep_pri = INT_MAX; const gchar * const * langs = g_get_language_names (); value = NULL; for (cur = node->children; cur; cur = cur->next) { if (! xmlStrcmp (cur->name, GVC_SOUND_NAME)) { xmlChar *cur_lang = NULL; int cur_pri = INT_MAX; cur_lang = xmlNodeGetLang (cur); if (cur_lang) { for (j = 0; langs[j]; j++) { if (g_str_equal (cur_lang, langs[j])) { cur_pri = j; break; } } } else { cur_pri = INT_MAX - 1; } if (cur_pri <= keep_pri) { if (keep_lang) xmlFree (keep_lang); if (value) xmlFree (value); value = xmlNodeGetContent (cur); keep_lang = cur_lang; keep_pri = cur_pri; } else { if (cur_lang) xmlFree (cur_lang); } } } /* Delete all GVC_SOUND_NAME nodes */ cur = node->children; while (cur) { xmlNodePtr this = cur; cur = cur->next; if (! xmlStrcmp (this->name, GVC_SOUND_NAME)) { xmlUnlinkNode (this); xmlFreeNode (this); } } return value; }