gboolean write_book_parts (FILE* out, QofBook* book) { xmlNodePtr domnode, slotsnode; domnode = guid_to_dom_tree (book_id_string, qof_book_get_guid (book)); xmlElemDump (out, NULL, domnode); xmlFreeNode (domnode); if (ferror (out) || fprintf (out, "\n") < 0) return FALSE; slotsnode = qof_instance_slots_to_dom_tree (book_slots_string, QOF_INSTANCE (book)); if (slotsnode) { xmlElemDump (out, NULL, slotsnode); xmlFreeNode (slotsnode); if (ferror (out) || fprintf (out, "\n") < 0) return FALSE; } return TRUE; }
/* * 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; }
/* 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; } } }
/* Root is not converted to xmlNodePtr, we skip immediately to children */ static int node2xml(xmlNodePtr *xml_node, freesasa_node *node, int exclude_type, int options) { freesasa_node *child; xmlNodePtr xml_child = NULL; assert(xml_node); assert(node); child = freesasa_node_children(node); *xml_node = NULL; if (freesasa_node_type(node) == exclude_type) return FREESASA_SUCCESS; switch (freesasa_node_type(node)) { case FREESASA_NODE_STRUCTURE: *xml_node = structure2xml(node, options); break; case FREESASA_NODE_CHAIN: *xml_node = chain2xml(node, options); break; case FREESASA_NODE_RESIDUE: *xml_node = residue2xml(node, options); break; case FREESASA_NODE_ATOM: *xml_node = atom2xml(node, options); break; case FREESASA_NODE_ROOT: default: assert(0 && "tree illegal"); } if (*xml_node == NULL) return fail_msg("error creating XML-node"); /* simplify? */ while (child != NULL) { if (node2xml(&xml_child, child, exclude_type, options) == FREESASA_FAIL) { return fail_msg(""); } if (xml_child != NULL && xmlAddChild(*xml_node, xml_child) == NULL) { xmlFreeNode(*xml_node); xmlFreeNode(xml_child); return fail_msg(""); } child = freesasa_node_next(child); } return FREESASA_SUCCESS; }
static xmlNodePtr structure2xml(const freesasa_node *node, int options) { xmlNodePtr xml_node = NULL, xml_area = NULL; char buf[20]; const freesasa_selection **selections; assert(node); selections = freesasa_node_structure_selections(node); xml_node = xmlNewNode(NULL, BAD_CAST "structure"); if (xml_node == NULL) { fail_msg(""); return NULL; } if (xmlNewProp(xml_node, BAD_CAST "chains", BAD_CAST freesasa_node_structure_chain_labels(node)) == NULL) { fail_msg(""); goto cleanup; } sprintf(buf, "%d", freesasa_node_structure_model(node)); if (xmlNewProp(xml_node, BAD_CAST "model", BAD_CAST buf) == NULL) { fail_msg(""); goto cleanup; } xml_area = nodearea2xml(freesasa_node_area(node), "area"); if (xml_area == NULL) { fail_msg(""); goto cleanup; } if (xmlAddChild(xml_node, xml_area) == NULL) { fail_msg(""); xmlFreeNode(xml_area); goto cleanup; } if (selections) { if (add_selections_to_xmlNode(selections, xml_node) == NULL) { fail_msg(""); goto cleanup; } } return xml_node; cleanup: xmlFreeNode(xml_node); return NULL; }
/*Remove - removes element from xml tree*/ void CXMLElement::Remove() { if (!isinited()) return; xmlUnlinkNode(element); xmlFreeNode(element); element = NULL; }
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 (); }
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; }
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); } }
virtual bool PatchCamFlags(xmlDocPtr doc, const char *uuid, const char *slot, const char *flags) { bool uuid_match=false; bool flags_set =false; xmlNode *node = xmlDocGetRootElement(doc); node = node ? node->children : NULL; while(node && xmlStrcmp(node->name, (const xmlChar *)"Description")) node=node->next; node = node ? node->children : NULL; while(node) { if(node && !xmlStrcmp(node->name, (const xmlChar *)"component")) { xmlNode *item = node->children; while(item && xmlStrcmp(item->name, (const xmlChar *)"Description")) { item = item->next; } // while xmlChar *about = item ? xmlGetProp(item, (const xmlChar *)"about") : NULL; if(about) { if (!xmlStrcmp(about, (const xmlChar *)"Platform")) { xmlNode *sub = item->children; while(sub) { if(!xmlStrcmp(sub->name, (const xmlChar *)"UUID")) { xmlChar *value=xmlNodeListGetString(doc, sub->children, 1); if(value) { uuid_match=!xmlStrcmp(value, (const xmlChar *)uuid); xmlFree(value); } // if } // if sub = sub->next; } // while } else if(!xmlStrcmp(about, (const xmlChar *)"CAM")) { xmlNode *sub = item->children; while(sub) { if(!xmlStrcmp(sub->name, (const xmlChar *)"Slot")) { xmlChar *value=xmlNodeListGetString(doc, sub->children, 1); if(value) { if (!xmlStrcmp(value, (const xmlChar *)slot)) { xmlNode *tst = item->children; while(tst) { if(!xmlStrcmp(tst->name, (const xmlChar *)"Flags")) { xmlReplaceNode(tst, xmlNewChild(item, xmlSearchNs(doc, tst, (const xmlChar *)"prf"), (const xmlChar *)"Flags", (const xmlChar *)flags)); xmlFreeNode(tst); flags_set=true; tst = NULL; continue; } // if tst = tst->next; } // while } // if xmlFree(value); } // if } // if sub = sub->next; } // while } // if xmlFree(about); } // if } // if node = node->next; } // while return uuid_match && flags_set; }; // PatchCamFlags
void qt_dbtableview_impl :: _store() { if (!(_model && _parent && _xml)) return; if (!_model->columnCount()) return; xpath_object_ptr tmp(0); string expr = _tag_model+ "/columns/column[@number=\"%s\"]"; for(int i=0; i<_model->columnCount(); ++i) { string s(expr); s.replace(s.find("%s"), 2, int_to_str(i)); tmp = _xml->xpath_eval_expr((s + "/width[text()!=\"\"]").c_str()); if (tmp->size()) { tmp->set_content(0, int_to_str(_parent->columnWidth(i)).c_str()); continue; } tmp = _xml->xpath_eval_expr(s.c_str()); if (tmp->size()) { xmlNodePtr node = xmlNewNode(NULL, (xmlChar*)"width"); if (!node) { _lprintf(LOG_ERR, "can't create xml node\n"); continue; } xmlNodeAddContent(node, (xmlChar*)int_to_str(_parent->columnWidth(i)).c_str()); try { tmp->insert_node(0, node); } catch (xpath_error& e) { xmlFreeNode(node); _lprintf(LOG_ERR, "%s\n", e.what()); } } } _xml->save(); }
static void gda_report_engine_dispose (GObject *object) { GdaReportEngine *eng = (GdaReportEngine *) object; g_return_if_fail (GDA_IS_REPORT_ENGINE (eng)); /* free memory */ if (eng->priv) { if (eng->priv->objects) { g_hash_table_destroy (eng->priv->objects); eng->priv->objects = NULL; } if (eng->priv->doc) { xmlFreeDoc (eng->priv->doc); eng->priv->doc = NULL; } if (eng->priv->spec) { xmlFreeNode (eng->priv->spec); eng->priv->spec = NULL; } g_free (eng->priv->output_dir); g_free (eng->priv); eng->priv = NULL; } /* chain to parent class */ parent_class->dispose (object); }
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; }
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); } } }
/** * \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; }
/*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; }
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; }
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; }
xmlNodePtr design_tolerance_to_xml_node(design_tolerance_s *t) { xmlNodePtr n = NULL; xmlNodePtr vn = NULL; char sn[MAX_SN]; // Sanity check parameters. assert(t); n = xmlNewNode(NULL, BAD_CAST "tolerance"); if (!n) return NULL; vn = vertex_to_xml_node(t->location); if (vn) { xmlAddChild(n, xmlCopyNode(vn, 1)); xmlFreeNode(vn); } snprintf(sn, MAX_SN, "%f", t->text_size); xmlNewChild(n, NULL, BAD_CAST "text-size", BAD_CAST sn); snprintf(sn, MAX_SN, "%f", t->plus); xmlNewChild(n, NULL, BAD_CAST "plus", BAD_CAST sn); snprintf(sn, MAX_SN, "%f", t->minus); xmlNewChild(n, NULL, BAD_CAST "minus", BAD_CAST sn); snprintf(sn, MAX_SN, "%d", t->precision); xmlNewChild(n, NULL, BAD_CAST "precision", BAD_CAST sn); // Return RETVAL return n; }
static gboolean gnc_order_end_handler(gpointer data_for_children, GSList* data_from_children, GSList* sibling_data, gpointer parent_data, gpointer global_data, gpointer *result, const gchar *tag) { GncOrder *order; xmlNodePtr tree = (xmlNodePtr)data_for_children; gxpf_data *gdata = (gxpf_data*)global_data; QofBook *book = gdata->bookdata; if (parent_data) { return TRUE; } /* OK. For some messed up reason this is getting called again with a NULL tag. So we ignore those cases */ if (!tag) { return TRUE; } g_return_val_if_fail(tree, FALSE); order = dom_tree_to_order(tree, book); if (order != NULL) { gdata->cb(tag, gdata->parsedata, order); } xmlFreeNode(tree); return order != NULL; }
static void test_dom_tree_to_guid(void) { int i; for (i = 0; i < 20; i++) { GncGUID *test_guid1; GncGUID *test_guid2; xmlNodePtr test_node; test_guid1 = get_random_guid(); if (!(test_node = guid_to_dom_tree("test-guid", test_guid1))) { failure_args("guid_to_dom_tree", __FILE__, __LINE__, "conversion to dom tree failed"); } test_guid2 = dom_tree_to_guid(test_node); do_test(guid_equal(test_guid1, test_guid2), "dom_tree_to_guid" ); xmlFreeNode(test_node); g_free(test_guid1); g_free(test_guid2); } }
void Node::rebind(_xmlNode *newNode) { if ( _xml == newNode ) return; typedef LibXML2Private<Node> _Private; if ( _xml != nullptr ) { if ( _xml->parent == nullptr && _xml->next == nullptr && _xml->prev == nullptr ) { xmlNodePtr __n = _xml; this->release(); xmlFreeNode(__n); // releases libxml's reference to this object } } _xml = newNode; typedef std::shared_ptr<Node> NodePtr; if (_xml->_private != nullptr && *((unsigned int*)(_xml->_private)) == _READIUM_XML_SIGNATURE) { // reassign the bridge ptr on the libxml node _Private* ptr = reinterpret_cast<_Private*>(newNode->_private); ptr->__ptr = shared_from_this(); } else if (_xml->_private != nullptr) { auto ptr = shared_from_this(); _xml->_private = new _Private(ptr); } }
/* 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; }
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; }
void osync_xmlfield_free(OSyncXMLField *xmlfield) { osync_assert(xmlfield); xmlFreeNode(xmlfield->node); g_free(xmlfield); }
static void test_dom_tree_to_commodity_ref(void) { int i; for (i = 0; i < 20; i++) { gnc_commodity *test_com1; gchar *test_str1; gchar *test_str2; gnc_commodity *test_com2; xmlNodePtr test_node; QofBook *book; book = qof_book_new (); test_str1 = get_random_string(); test_str2 = get_random_string(); test_com1 = gnc_commodity_new(book, NULL, test_str1, test_str2, NULL, 0); test_node = commodity_ref_to_dom_tree("test-com", test_com1); test_com2 = dom_tree_to_commodity_ref_no_engine(test_node, book); do_test(gnc_commodity_equiv(test_com1, test_com2), "dom_tree_to_commodity_ref_no_engine"); xmlFreeNode(test_node); gnc_commodity_destroy(test_com1); gnc_commodity_destroy(test_com2); g_free(test_str1); g_free(test_str2); qof_book_destroy (book); } }
/* 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; }