static void _parse_security(xmlDocPtr doc, xmlNodePtr node, ice_config_t *configuration) { char *tmp; xmlNodePtr oldnode; do { if (node == NULL) break; if (xmlIsBlankNode(node)) continue; if (xmlStrcmp (node->name, XMLSTR("chroot")) == 0) { tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); configuration->chroot = atoi(tmp); if (tmp) xmlFree(tmp); } else if (xmlStrcmp (node->name, XMLSTR("changeowner")) == 0) { configuration->chuid = 1; oldnode = node; node = node->xmlChildrenNode; do { if(node == NULL) break; if(xmlIsBlankNode(node)) continue; if(xmlStrcmp (node->name, XMLSTR("user")) == 0) { if(configuration->user) xmlFree(configuration->user); configuration->user = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); } else if(xmlStrcmp (node->name, XMLSTR("group")) == 0) { if(configuration->group) xmlFree(configuration->group); configuration->group = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); } } while((node = node->next)); node = oldnode; } } while ((node = node->next)); }
/** Find an attribute in a composite XML node. * @param composite_node The composite node to search. * @param attrname The name of the attribute node to find. * @return The desired node, or NULL if none exists in `composite_node'. * @bug Describe in more detail how a composite node differs from an * object node. */ AttributeNode composite_find_attribute(DataNode composite_node, const char *attrname) { AttributeNode attr; xmlChar *name; while (composite_node && xmlIsBlankNode(composite_node)) composite_node = composite_node->next; if (!composite_node) return NULL; attr = composite_node->xmlChildrenNode; while (attr != NULL) { if (xmlIsBlankNode(attr)) { attr = attr->next; continue; } name = xmlGetProp(attr, (const xmlChar *)"name"); if ( (name!=NULL) && (strcmp((char *) name, attrname)==0) ) { xmlFree(name); return attr; } if (name) xmlFree(name); attr = attr->next; } return NULL; }
/** * nmp_parse_xml: process XML document tree * * @doc: iutput, XML document tree * @seq: input, sequence of message * @return: succeed NmpMsgInfo, else NULL */ NmpMsgInfo * nmp_parse_xml(NmpCmdType *self, xmlDocPtr doc, unsigned int seq) { xmlNodePtr cur; char *cmd; char msg_id[MAX_CMD_ID_LEN]={0}; NmpParseXml parse_xml; NmpMsgInfo *sys_msg; int i; cur = xmlDocGetRootElement(doc); //确定文档根元素 if (cur == NULL) { xml_error("empty document\n"); return NULL; } while ( cur && xmlIsBlankNode ( cur ) ) { cur = cur->next; } while (cur != NULL) { if (!xmlStrcmp(cur->name, (const xmlChar *) "message")) { cmd = (char *)xmlGetProp(cur, (const xmlChar *)"type"); xml_error("1---parse cmd =%s\n",cmd); if (!cmd) { return NULL; } msg_id[MAX_CMD_ID_LEN - 1] = 0; strncpy(msg_id, cmd, MAX_CMD_ID_LEN - 1); xmlFree(cmd); for (i = 0; i < CMD_TYPE_COUNTS(self); i++) { if (!CMD_CMP(msg_id,GET_CMD_BYINDEX(self,i))) continue; parse_xml = GET_PARSE_XML_BYINDEX(self,i); sys_msg = (*parse_xml)(doc, cur, msg_id); // invoke function to parse return sys_msg; } } cur = cur->next; while ( cur && xmlIsBlankNode ( cur ) ) { cur = cur->next; } } xml_error(" message not exists \n"); return NULL; }
LineInfo* line_info_load_and_apply_from_xmlfile(const gchar *filename, LineInfo* info) { xmlDocPtr doc = xmlDoParseFile(filename); xmlNodePtr node, root; xmlChar *tmp; int i; if (!doc) { g_warning("parse error for %s", filename); return NULL; } /* skip (emacs) comments */ root = doc->xmlRootNode; while (root && (root->type != XML_ELEMENT_NODE)) root = root->next; if (!root) return NULL; if (xmlIsBlankNode(root)) return NULL; i = 0; for (node = root->xmlChildrenNode; node != NULL; node = node->next) { if (xmlIsBlankNode(node)) continue; else if (node->type != XML_ELEMENT_NODE) continue; else if (!strcmp((char*)node->name, "name")) { tmp = xmlNodeGetContent(node); /* g_free(info->name);*/ info->name = g_strdup((char*)tmp); /* fprintf( stderr, "New shape of type: `%s'\n", info->name ); */ xmlFree(tmp); } else if ( !strcmp((char*)node->name, "icon")) { tmp = xmlNodeGetContent(node); g_free(info->icon_filename); info->icon_filename = custom_get_relative_filename(filename, (char*)tmp); xmlFree(tmp); } else if ( !strcmp((char*)node->name, "type")) { info->type = line_info_get_line_type(filename, node); } else if ( !strcmp((char*)node->name, "line-style")) { info->line_style = line_info_get_line_style(filename, node); } else if ( !strcmp((char*)node->name, "dash-length")) { info->dashlength = line_info_get_as_float(filename, node); } else if ( !strcmp((char*)node->name, "line-width")) { info->line_width = line_info_get_as_float(filename, node); } else if ( !strcmp((char*)node->name, "corner-radius")) { info->corner_radius = line_info_get_as_float(filename, node); } else if ( !strcmp((char*)node->name, "arrows")) { line_info_get_arrows(filename, node, info); } else if ( !strcmp((char*)node->name, "line-color")) { line_info_get_line_color(filename, node, info); } } return( info ); }
static xmlNode * empathy_plist_parse_one_dict_entry (xmlNode *a_node, GHashTable *dict) { xmlNode *cur_node = a_node; xmlChar *key_name; GValue *value; while (cur_node && (xmlStrcmp (cur_node->name, (xmlChar *) "key") != 0)) { cur_node = cur_node->next; } if (!cur_node) { return NULL; } key_name = xmlNodeGetContent (cur_node); cur_node = cur_node->next; while (cur_node && xmlIsBlankNode (cur_node)) { cur_node = cur_node->next; } if (!cur_node) { xmlFree (key_name); return NULL; } value = empathy_plist_parse_node (cur_node); if (value) { g_hash_table_insert (dict, g_strdup ((char *) key_name), value); } xmlFree (key_name); return cur_node->next; }
static void _parse_logging(xmlDocPtr doc, xmlNodePtr node, ice_config_t *configuration) { do { if (node == NULL) break; if (xmlIsBlankNode(node)) continue; if (strcmp(node->name, "accesslog") == 0) { if (configuration->access_log && configuration->access_log != CONFIG_DEFAULT_ACCESS_LOG) xmlFree(configuration->access_log); configuration->access_log = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); } else if (strcmp(node->name, "errorlog") == 0) { if (configuration->error_log && configuration->error_log != CONFIG_DEFAULT_ERROR_LOG) xmlFree(configuration->error_log); configuration->error_log = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); } else if (strcmp(node->name, "playlistlog") == 0) { if (configuration->playlist_log && configuration->playlist_log != CONFIG_DEFAULT_PLAYLIST_LOG) xmlFree(configuration->playlist_log); configuration->playlist_log = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); } else if (strcmp(node->name, "logsize") == 0) { char *tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); configuration->logsize = atoi(tmp); if (tmp) xmlFree(tmp); } else if (strcmp(node->name, "loglevel") == 0) { char *tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); configuration->loglevel = atoi(tmp); if (tmp) xmlFree(tmp); } else if (strcmp(node->name, "logarchive") == 0) { char *tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); configuration->logarchive = atoi(tmp); if (tmp) xmlFree(tmp); } } while ((node = node->next)); }
static void _parse_directory(xmlDocPtr doc, xmlNodePtr node, ice_config_t *configuration) { char *tmp; if (configuration->num_yp_directories >= MAX_YP_DIRECTORIES) { ERROR0("Maximum number of yp directories exceeded!"); return; } do { if (node == NULL) break; if (xmlIsBlankNode(node)) continue; if (strcmp(node->name, "yp-url") == 0) { if (configuration->yp_url[configuration->num_yp_directories]) xmlFree(configuration->yp_url[configuration->num_yp_directories]); configuration->yp_url[configuration->num_yp_directories] = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); } else if (strcmp(node->name, "yp-url-timeout") == 0) { tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); configuration->yp_url_timeout[configuration->num_yp_directories] = atoi(tmp); if (tmp) xmlFree(tmp); } else if (strcmp(node->name, "server") == 0) { _add_server(doc, node->xmlChildrenNode, configuration); } else if (strcmp(node->name, "touch-interval") == 0) { tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); configuration->yp_touch_interval[configuration->num_yp_directories] = atoi(tmp); if (tmp) xmlFree(tmp); } } while ((node = node->next)); configuration->num_yp_directories++; }
LVAVSPresetContainer *lvavs_preset_container_from_xml_node(LVAVSPresetContainer *cont, xmlNodePtr node) { xmlNodePtr child; LVAVSPresetElement *element; int i; for(child = node->children; child; child = child->next) { if (xmlIsBlankNode (child) || child->type != XML_ELEMENT_NODE) continue; if(xmlStrcmp(child->name, (xmlChar *)"container_child") == 0) { LVAVSPresetContainer *cont2 = lvavs_preset_container_new(); VisParamContainer *pcont = visual_param_container_new(); LVAVS_PRESET_ELEMENT(cont2)->pcont = pcont; visual_param_container_add_many(pcont, container_params); visual_list_add(cont->members, cont2); lvavs_preset_container_from_xml_node(cont2, child); } for(i = 0; id_to_name_map[i] != NULL; i++) if (xmlStrcmp (child->name, (const xmlChar *) id_to_name_map[i]) == 0) break; if(id_to_name_map[i] == NULL) continue; element = lvavs_preset_element_new(LVAVS_PRESET_ELEMENT_TYPE_PLUGIN, (char*)child->name); if(parse_element(child, element)) visual_list_add(cont->members, element); } return cont; }
/* cur->name should be the element name */ static int parse_element (xmlNodePtr cur, LVAVSPresetElement *element) { char *content; LVAVSPresetElement *child; VisParamEntry *param; for (cur = cur->xmlChildrenNode; cur; cur = cur->next) { if (xmlIsBlankNode (cur) || cur->type != XML_ELEMENT_NODE) continue; LVAVSPresetElementType type; xmlChar *prop = xmlGetProp(cur, (xmlChar *)"type"); content = (char*)xmlNodeGetContent (cur); param = visual_param_entry_new((char *)cur->name); if(strcmp((char *)prop, "string") == 0) { visual_param_entry_set_string(param, content); } else if( strcmp((char *)prop, "float") == 0) { visual_param_entry_set_double(param, strtod(content, NULL)); } else if( strcmp((char *)prop, "integer") == 0) { visual_param_entry_set_integer(param, (int)strtol(content, NULL, 0)); } else if( strcmp((char *)prop, "color") == 0) { int r,g,b; char *s = content+1; r = strtoul (s, &s, 0); if (r > 255 || ! (s = strchr (s, ','))) continue; g = strtoul (s+1, &s, 0); if (g > 255 || ! (s = strchr (s, ','))) continue; b = strtoul (s+1, NULL, 0); if (b > 255) continue; visual_param_entry_set_color(param, r, g, b); } else if( strcmp((char *)prop, "bool") == 0) { char *c, *d; int val; #define isspace(c) (c == ' ' || c == '\t' || c == '\n') for (c=content; isspace (*c); c++); for (d=c; !isspace(*d); d++); *d = '\0'; if (g_strcasecmp (c, "true") == 0) val = TRUE; else if (g_strcasecmp (c, "false") == 0) val = FALSE; else continue; visual_param_entry_set_integer(param, val); } visual_param_container_add(element->pcont, param); xmlFree ((xmlChar*)content); } return TRUE; }
static unsigned long xmlChildElementCountN(xmlNodePtr node) { g_return_val_if_fail(node != NULL, 0); xmlNodePtr elements = NULL; unsigned long count = 0; switch(node->type) { case XML_ELEMENT_NODE: case XML_DOCUMENT_NODE: case XML_PI_NODE: case XML_HTML_DOCUMENT_NODE: elements = (xmlNodePtr)node->properties; while(elements != NULL) { count++; elements = elements->next; } case XML_DTD_NODE: elements = node->children; while (elements != NULL) { if(xmlIsBlankNode(elements)==0) count++; elements = elements->next; } default: break; } return count; }
static void _parse_logging(xmlDocPtr doc, xmlNodePtr node, ice_config_t *configuration) { do { if (node == NULL) break; if (xmlIsBlankNode(node)) continue; if (xmlStrcmp (node->name, XMLSTR("accesslog")) == 0) { if (configuration->access_log) xmlFree(configuration->access_log); configuration->access_log = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); } else if (xmlStrcmp (node->name, XMLSTR("errorlog")) == 0) { if (configuration->error_log) xmlFree(configuration->error_log); configuration->error_log = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); } else if (xmlStrcmp (node->name, XMLSTR("playlistlog")) == 0) { if (configuration->playlist_log) xmlFree(configuration->playlist_log); configuration->playlist_log = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); } else if (xmlStrcmp (node->name, XMLSTR("logsize")) == 0) { char *tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); configuration->logsize = atoi(tmp); if (tmp) xmlFree(tmp); } else if (xmlStrcmp (node->name, XMLSTR("loglevel")) == 0) { char *tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); configuration->loglevel = atoi(tmp); if (tmp) xmlFree(tmp); } else if (xmlStrcmp (node->name, XMLSTR("logarchive")) == 0) { char *tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); configuration->logarchive = atoi(tmp); if (tmp) xmlFree(tmp); } } while ((node = node->next)); }
static void _parse_root(config_t *config, xmlDocPtr doc, xmlNodePtr node) { do { if (node == NULL) break; if (xmlIsBlankNode(node)) continue; if (strcmp(node->name, "background") == 0) SET_INT(config->background); else if (strcmp(node->name, "logpath") == 0) SET_STRING(config->logpath); else if (strcmp(node->name, "logfile") == 0) SET_STRING(config->logfile); else if (strcmp(node->name, "loglevel") == 0) SET_INT(config->loglevel); else if (strcmp(node->name, "logsize") == 0) SET_INT(config->logsize); else if (strcmp(node->name, "consolelog") == 0) SET_INT(config->log_stderr); else if (strcmp(node->name, "pidfile") == 0) SET_STRING(config->pidfile); else if (strcmp(node->name, "stream") == 0) _parse_stream(config, doc, node->xmlChildrenNode); } while ((node = node->next)); }
static void _parse_encode(instance_t *instance,xmlDocPtr doc, xmlNodePtr node) { instance->encode = 1; do { if (node == NULL) break; if (xmlIsBlankNode(node)) continue; if (strcmp(node->name, "nominal-bitrate") == 0) SET_INT(instance->nom_br); else if (strcmp(node->name, "minimum-bitrate") == 0) SET_INT(instance->min_br); else if (strcmp(node->name, "maximum-bitrate") == 0) SET_INT(instance->max_br); else if (strcmp(node->name, "quality") == 0) SET_FLOAT(instance->quality); else if (strcmp(node->name, "samplerate") == 0) SET_INT(instance->samplerate); else if (strcmp(node->name, "channels") == 0) SET_INT(instance->channels); else if (strcmp(node->name, "managed") == 0) SET_INT(instance->managed); else if (strcmp(node->name, "flush-samples") == 0) SET_INT(instance->max_samples_ppage); } while ((node = node->next)); if (instance->max_samples_ppage == 0) instance->max_samples_ppage = instance->samplerate; if (instance->max_samples_ppage < instance->samplerate/100) instance->max_samples_ppage = instance->samplerate/100; }
static void interpret_bookmarks(xmlDocPtr doc, xmlNodePtr cur) { xmlChar *s; cur = cur->xmlChildrenNode; while(cur != NULL) { if(!xmlIsBlankNode(cur)) { if(!strcmp("autosave", cur->name)) { if((s = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1))) { if(!strcmp("yes", s)) { bookmarks_autosave = 1; } free(s); } } else if(!strcmp("autoload", cur->name)) { if((s = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1))) { if(!strcmp("yes", s)) { bookmarks_autoload = 1; } free(s); } } } cur = cur->next; } }
static void _parse_metadata(instance_t *instance, config_t *config, xmlDocPtr doc, xmlNodePtr node) { do { if (node == NULL) break; if (xmlIsBlankNode(node)) continue; if (strcmp(node->name, "name") == 0) { if(instance) SET_STRING(instance->stream_name); else SET_STRING(config->stream_name); } else if (strcmp(node->name, "genre") == 0) { if(instance) SET_STRING(instance->stream_genre); else SET_STRING(config->stream_genre); } else if (strcmp(node->name, "description") == 0) { if(instance) SET_STRING(instance->stream_description); else SET_STRING(config->stream_description); } else if (strcmp(node->name, "url") == 0) { if(instance) SET_STRING(instance->stream_url); else SET_STRING(config->stream_url); } } while ((node = node->next)); }
static BOOL __cfgFillHostListScore(PLINKSEQ plsHostList, xmlNodePtr pNode, BOOL fSplitOnWords) { ULONG cbHosts; PSZ pszHosts; PSZ pszScore; LONG lScore; for( pNode = pNode->children; pNode != NULL; pNode = pNode->next ) { if ( xmlIsBlankNode( pNode ) || ( pNode->name == NULL ) || ( ( stricmp( pNode->name, "addr" ) != 0 ) && ( stricmp( pNode->name, "pattern" ) != 0 ) ) ) continue; pszHosts = xmluGetNodeTextSZ( pNode ); pszScore = xmlGetNoNsProp( pNode, "score" ); if ( pszScore == NULL ) lScore = SF_SCORE_NONE; else if ( !_cfgStrToScore( strlen( pszScore ), pszScore, &lScore ) ) { xmluLog( pNode, "Invalid score value: \"%s\".", pszScore ); return FALSE; } cbHosts = strlen( pszHosts ); if ( fSplitOnWords ) cfgHostListAddList( plsHostList, lScore, cbHosts, pszHosts ); else cfgHostListAdd( plsHostList, lScore, cbHosts, pszHosts ); } return TRUE; }
static void _parse_input(config_t *config, xmlDocPtr doc, xmlNodePtr node) { module_param_t *param, *p; do { if (node == NULL) break; if (xmlIsBlankNode(node)) continue; if (strcmp(node->name, "module") == 0) SET_STRING(config->playlist_module); else if (strcmp(node->name, "param") == 0) { param = (module_param_t *)calloc(1, sizeof(module_param_t)); SET_PARM_STRING("name", param->name); SET_STRING(param->value); param->next = NULL; if (config->module_params == NULL) { config->module_params = param; } else { p = config->module_params; while (p->next != NULL) p = p->next; p->next = param; } } } while ((node = node->next)); }
static xmlNodePtr xmlFirstElementChildN(xmlNodePtr node) { g_return_val_if_fail(node != NULL, NULL); xmlNodePtr record = NULL; switch(node->type) { case XML_ELEMENT_NODE: case XML_DOCUMENT_NODE: case XML_HTML_DOCUMENT_NODE: case XML_PI_NODE: record = (xmlNodePtr)node->properties; case XML_DTD_NODE: if(record == NULL) record = node->children; while(xmlIsBlankNode(record)==1) { record = record->next; } break; default: break; } return record; }
void XML::parseChildren(xmlDocPtr doc, xmlNodePtr child, DomElement *parent) { xmlNode *cur_node = NULL; XMLElement *new_element = NULL; xmlAttrPtr attr; for(cur_node = child ; cur_node ; cur_node = cur_node->next ) { if( cur_node->type == XML_ELEMENT_NODE) { if(!parent) { new_element = newElement((char *)cur_node->name); } else { new_element = (XMLElement *)parent->newElement((char *)cur_node->name); } } else if (cur_node->type == XML_TEXT_NODE && xmlIsBlankNode(cur_node)==0) { parent->setValue((char *)cur_node->content); } parseChildren(doc,cur_node->children,new_element); attr = cur_node->properties; while(attr) { std::string name = (char *)attr->name; std::string value = (char *)attr->children->content; new_element->setAttribute(name,value); attr = attr->next; } } }
bool XMLMetadata::parseXML(xmlNodePtr xn) { for (xmlAttrPtr xmlAttr = xn->properties; xmlAttr; xmlAttr = xmlAttr->next) { setParameter((char *)xmlAttr->name, (char *)xmlAttr->children->content); } for (xmlNodePtr xnc = xn->children; xnc; xnc = xnc->next) { if (xnc->type == XML_ELEMENT_NODE) { XMLMetadata *m; if (xnc->children && xnc->children->type == XML_TEXT_NODE && !xmlIsBlankNode(xnc->children)) { xmlChar *content = xmlNodeGetContent(xnc); m = static_cast<XMLMetadata *>(addMetadata((char *)xnc->name, (char *)content)); xmlFree(content); } else { m = static_cast<XMLMetadata *>(addMetadata((char *)xnc->name)); } // Parse any children if (!m || !m->parseXML(xnc)) return false; } } #if defined(ENABLE_METADATAPARSER) MetadataParser *mp = MetadataParser::getParser(name); if (mp) return mp->onParseMetadata(this); #endif return true; }
/** Get the first data node in an attribute node. * @param attribute The attribute node to look through. * @return The first non-black data node in the attribute node. */ DataNode attribute_first_data(AttributeNode attribute) { xmlNode *data = attribute ? attribute->xmlChildrenNode : NULL; while (data && xmlIsBlankNode(data)) data = data->next; return (DataNode) data; }
/* * call-seq: * blank? * * Is this node blank? */ static VALUE blank_eh(VALUE self) { xmlNodePtr node; Data_Get_Struct(self, xmlNode, node); if(1 == xmlIsBlankNode(node)) return Qtrue; return Qfalse; }
static xmlNode * soup_xml_real_node (xmlNode *node) { while (node && (node->type == XML_COMMENT_NODE || xmlIsBlankNode (node))) node = node->next; return node; }
int clish_xmlnode_get_content(clish_xmlnode_t *node, char *content, unsigned int *contentlen) { xmlNode *n; xmlNode *c; int rlen = 0; if (content && contentlen && *contentlen) *content = 0; if (!node || !content || !contentlen) return -EINVAL; if (*contentlen <= 1) return -EINVAL; *content = 0; n = xmlnode_to_node(node); /* first, get the content length */ c = n->children; while (c) { if ((c->type == XML_TEXT_NODE || c->type == XML_CDATA_SECTION_NODE) && !xmlIsBlankNode(c)) { rlen += strlen((char*)c->content); } c = c->next; } ++rlen; if (rlen <= *contentlen) { c = n->children; while (c) { if ((c->type == XML_TEXT_NODE || c->type == XML_CDATA_SECTION_NODE) && !xmlIsBlankNode(c)) { strcat(content, (char*)c->content); } c = c->next; } return 0; } else { *contentlen = rlen; return -E2BIG; } }
void get_value_content(xmlNodePtr record, GValue * value) { g_return_if_fail(record != NULL); switch(record->type) { case XML_ATTRIBUTE_NODE: case XML_TEXT_NODE: case XML_COMMENT_NODE: case XML_CDATA_SECTION_NODE: { g_value_set_string(value,g_strstrip((gchar *)xmlNodeGetContent(record))); break; } case XML_DTD_NODE: { xmlDtdPtr dtd = (xmlDtdPtr)record; g_value_set_string(value,dtd->SystemID); break; } case XML_DOCUMENT_NODE: case XML_ELEMENT_NODE: { if(record->children) { record = record->children; while(xmlIsBlankNode(record)==1) record = record->next; g_return_if_fail(record != NULL); if(record->type == XML_TEXT_NODE) g_value_set_string(value,g_strstrip((gchar *)xmlNodeGetContent(record))); } break; } case XML_PI_NODE: { /* int n; gchar** tokens; tokens = g_strsplit_set(g_strstrip((gchar *)xmlNodeGetContent(record)),"=\"\' ",-1); gchar * token; n = g_strv_length(tokens); for(int i = 0; i<n; ++i) { token = tokens[i]; } g_strfreev(tokens); */ g_value_set_string(value,g_strstrip((gchar *)xmlNodeGetContent(record))); break; } default: break; } }
/* * call-seq: * node.empty? -> (true|false) * * Determine whether this node is an empty or whitespace only text-node. */ static VALUE rxml_node_empty_q(VALUE self) { xmlNodePtr xnode; xnode = rxml_get_xnode(self); if (xnode == NULL) return (Qnil); return ((xmlIsBlankNode(xnode) == 1) ? Qtrue : Qfalse); }
/* * call-seq: * node.empty? -> (true|false) * * Determine whether this node is empty. */ static VALUE rxml_node_empty_q(VALUE self) { xmlNodePtr xnode; Data_Get_Struct(self, xmlNode, xnode); if (xnode == NULL) return (Qnil); return ((xmlIsBlankNode(xnode) == 1) ? Qtrue : Qfalse); }
static xmlNodePtr xmlPreviousElementSiblingN(xmlNodePtr node) { g_return_val_if_fail(node != NULL, NULL); xmlNodePtr record = NULL; // = node->prev; switch(node->type) { case XML_ELEMENT_NODE: record = node->prev; while(xmlIsBlankNode(record)==1) record = record->prev; if(record == NULL) { record = xmlGetParentNode(node); record = record->properties; if(record != NULL) { while(record->next != NULL) record = record->next; } } break; case XML_TEXT_NODE: while(xmlIsBlankNode(record)==1) record = record->prev; break; case XML_ATTRIBUTE_NODE: record = node->prev; break; case XML_DOCUMENT_NODE: case XML_HTML_DOCUMENT_NODE: record = NULL; break; default: record = xmlPreviousElementSibling(node); break; } return record; }
/** Get the next data node (sibling). * @param data A data node to start from (e.g. just processed) * @returns The next sibling data node. */ DataNode data_next(DataNode data) { if (data) { data = data->next; while (data && xmlIsBlankNode(data)) data = data->next; } return (DataNode) data; }
/*! * \brief Parse _DiaObject from the given node * Fill a GList* with objects which is to be put in a * diagram or a group by the caller. * Can be called recursively to allow groups in groups. * This is only using the render branch of the file, if the * object type is not registered with Dia. Otherwise the objects * are just created from their type and properties. * \ingroup DiaRenderScriptImport */ static GList* read_items (xmlNodePtr startnode, DiaContext *ctx) { xmlNodePtr node; GList *items = NULL; for (node = startnode; node != NULL; node = node->next) { if (xmlIsBlankNode(node)) continue; if (node->type != XML_ELEMENT_NODE) continue; if (!xmlStrcmp(node->name, (const xmlChar *)"object")) { xmlChar *sType = xmlGetProp(node, (const xmlChar *)"type"); const DiaObjectType *ot = object_get_type ((gchar *)sType); xmlNodePtr props = NULL, render = NULL; props = find_child_named (node, "properties"); render = find_child_named (node, "render"); if (ot && !ot->ops) { GList *moreitems; /* FIXME: 'render' is also the grouping element */ moreitems = read_items (render->children, ctx); if (moreitems) { DiaObject *group = group_create (moreitems); /* apply group props, e.g. transform */ object_load_props (group, props, ctx); /* group eats list */ items = g_list_append (items, group); } } else if (ot) { Point startpoint = {0.0,0.0}; Handle *handle1,*handle2; DiaObject *o; o = ot->ops->create(&startpoint, ot->default_user_data, &handle1,&handle2); if (o) { object_load_props (o, props, ctx); items = g_list_append (items, o); } } else if (render) { DiaObject *o = _render_object (render, ctx); if (o) items = g_list_append (items, o); } else { g_debug ("DRS-Import: %s?", node->name); } } else { g_debug ("DRS-Import: %s?", node->name); } } return items; }