static void parseSyntaxItem (xmlNodePtr cur, const gchar *id, xmlChar *style, GtkSourceContextData *ctx_data, GtkSourceLanguage *language) { xmlChar *start_regex = NULL; xmlChar *end_regex = NULL; xmlNodePtr child; child = cur->xmlChildrenNode; while (child != NULL) { if (!xmlStrcmp (child->name, (const xmlChar *)"start-regex")) { start_regex = xmlNodeListGetString (child->doc, child->xmlChildrenNode, 1); } else if (!xmlStrcmp (child->name, (const xmlChar *)"end-regex")) { end_regex = xmlNodeListGetString (child->doc, child->xmlChildrenNode, 1); } child = child->next; } if (start_regex == NULL) { g_warning ("Missing start-regex in tag 'syntax-item' (%s, line %ld)", child->doc->name, xmlGetLineNo (cur)); return; } if (end_regex == NULL) { xmlFree (start_regex); g_warning ("Missing end-regex in tag 'syntax-item' (%s, line %ld)", child->doc->name, xmlGetLineNo (cur)); return; } ctx_data_add_syntax_pattern (ctx_data, language, id, (gchar*) style, (gchar*) start_regex, (gchar*) end_regex, FALSE); xmlFree (start_regex); xmlFree (end_regex); }
/** @brief Parse restrictions for a single resource and call proper handlers. * * @param cur Pointer to the \<resource\> node. * @param res Pointer to the resource struct for this resource. * @return 1 if there were unknown restrictions or 0 otherwise. */ static int parser_resource_restrictions_one(xmlNodePtr cur, resource *res) { xmlChar *restriction, *content; int result; int unknown; unknown=0; while (cur!=NULL) { if(!xmlStrcmp(cur->name, XMLCHAR "restriction")) { restriction=parser_getprop_str(cur, XMLCHAR "type"); content=xmlNodeGetContent(cur); result=handler_res_call(res, CHAR restriction, CHAR content); if(result==1) FAIL("Restriction handler failed", cur); if(result==2) { info(_("Unknown resource restriction '%s'" " (line %d)"), restriction, xmlGetLineNo(cur)); unknown=1; } xmlFree(restriction); xmlFree(content); } cur=cur->next; } return unknown; }
static void parsePatternItem (xmlNodePtr cur, gchar *id, xmlChar *style, GtkSourceContextData *ctx_data, GtkSourceLanguage *language) { xmlNodePtr child; child = cur->xmlChildrenNode; if ((child != NULL) && !xmlStrcmp (child->name, (const xmlChar *)"regex")) { xmlChar *regex; regex = xmlNodeListGetString (child->doc, child->xmlChildrenNode, 1); ctx_data_add_simple_pattern (ctx_data, language, id, (gchar*) style, (gchar*) regex); xmlFree (regex); } else { g_warning ("Missing regex in tag 'pattern-item' (%s, line %ld)", child->doc->name, xmlGetLineNo (child)); } }
static void parseLineComment (xmlNodePtr cur, gchar *id, xmlChar *style, GtkSourceContextData *ctx_data, GtkSourceLanguage *language) { xmlNodePtr child; child = cur->xmlChildrenNode; if ((child != NULL) && !xmlStrcmp (child->name, (const xmlChar *)"start-regex")) { xmlChar *start_regex; start_regex = xmlNodeListGetString (child->doc, child->xmlChildrenNode, 1); ctx_data_add_syntax_pattern (ctx_data, language, id, (gchar*) style, (gchar*) start_regex, NULL, TRUE); xmlFree (start_regex); } else { g_warning ("Missing start-regex in tag 'line-comment' (%s, line %ld)", child->doc->name, xmlGetLineNo (child)); } }
/** * breakPointIsPresentNode: * @node: node != NULL * * Determine if a node is a break point * * Returns 1 on success, * 0 otherwise */ int breakPointIsPresentNode(xmlNodePtr node) { int result = 0; if (!node || !node->doc) return result; if (xmlGetLineNo(node) == -1) return result; if (node->doc->URL) { result = breakPointIsPresent(node->doc->URL, xmlGetLineNo(node)); } return result; }
int parse_xml_tags (xmlNodePtr parent, const struct cfg_tag *args) { int ret = 0, seen_element = 0; xmlNodePtr node = parent->xmlChildrenNode; for (; node != NULL && ret == 0; node = node->next) { const struct cfg_tag *argp; if (xmlIsBlankNode (node) || node->type != XML_ELEMENT_NODE) continue; seen_element = 1; argp = args; while (argp->name) { if (strcmp ((const char*)node->name, argp->name) == 0) { ret = argp->retrieve (node, argp->storage); if (ret > 0) { if (ret == 2) { argp++; ret = 0; continue; } xmlParserWarning (NULL, "skipping element \"%s\" parsing \"%s\" " "at line %ld\n", node->name, parent->name, xmlGetLineNo(node)); ret = 0; } break; } argp++; } if (argp->name == NULL) WARN3 ("unknown element \"%s\" parsing \"%s\" at line %ld", node->name, parent->name, xmlGetLineNo(node)); } if (ret == 0 && seen_element == 0) return 2; return ret; }
static void __view_error(xmlNode *node, const gchar *msg, ...) { g_assert(node != NULL); va_list args; va_start (args, msg); g_logv(G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, msg, args); va_end(args); g_error("Failed to parse %s view (line %ld)", parsed_view, xmlGetLineNo(node)); }
static int processDoc(xmlNode *node, xml2lpc_context *ctx) { dumpNode(node, ctx); if (node->type == XML_ELEMENT_NODE && strcmp((const char*)node->name, "config") == 0 ) { processConfig((xmlElement*)node, ctx); } else { xml2lpc_log(ctx, XML2LPC_WARNING, "root element is not \"config\", line:%d", xmlGetLineNo(node)); } return 0; }
/** * xmlSchematronReportSuccess: * @ctxt: the validation context * @test: the compiled test * @cur: the current node tested * @success: boolean value for the result * * called from the validation engine when an assert or report test have * been done. */ static void xmlSchematronReportSuccess(xmlSchematronValidCtxtPtr ctxt, xmlSchematronTestPtr test, xmlNodePtr cur, int success) { if ((ctxt == NULL) || (cur == NULL) || (test == NULL)) return; /* if quiet and not SVRL report only failures */ if ((ctxt->flags & XML_SCHEMATRON_OUT_QUIET) && ((ctxt->flags & XML_SCHEMATRON_OUT_XML) == 0) && (test->type == XML_SCHEMATRON_REPORT)) return; if (ctxt->flags & XML_SCHEMATRON_OUT_XML) { TODO } else { xmlChar *path; char msg[1000]; long line; const xmlChar *report = NULL; if (((test->type == XML_SCHEMATRON_REPORT) & (!success)) || ((test->type == XML_SCHEMATRON_ASSERT) & (success))) return; line = xmlGetLineNo(cur); path = xmlGetNodePath(cur); if (path == NULL) path = (xmlChar *) cur->name; #if 0 if ((test->report != NULL) && (test->report[0] != 0)) report = test->report; #endif if (test->node != NULL) report = xmlSchematronFormatReport(ctxt, test->node, cur); if (report == NULL) { if (test->type == XML_SCHEMATRON_ASSERT) { snprintf(msg, 999, "%s line %ld: node failed assert\n", (const char *) path, line); } else { snprintf(msg, 999, "%s line %ld: node failed report\n", (const char *) path, line); } } else { snprintf(msg, 999, "%s line %ld: %s\n", (const char *) path, line, (const char *) report); xmlFree((char *) report); } xmlSchematronReportOutput(ctxt, cur, &msg[0]); if ((path != NULL) && (path != (xmlChar *) cur->name)) xmlFree(path); } }
/* * call-seq: * node.line_num -> num * * Obtain the line number (in the XML document) that this * node was read from. If +default_line_numbers+ is set * false (the default), this method returns zero. */ static VALUE rxml_node_line_num(VALUE self) { xmlNodePtr xnode; long line_num; xnode = rxml_get_xnode(self); if (!xmlLineNumbersDefaultValue) rb_warn( "Line numbers were not retained: use XML::Parser::default_line_numbers=true"); line_num = xmlGetLineNo(xnode); if (line_num == -1) return (Qnil); else return (INT2NUM((long) line_num)); }
static void simpleXpathMakeTag (xmlNode *node, const tagXpathMakeTagSpec *spec, const kindOption* const kinds, void *userData) { tagEntryInfo tag; xmlChar* str; const kindOption *kind; char *path; str = xmlNodeGetContent(node); if (str == NULL) return; kind = kinds + spec->kind; if (spec->role == ROLE_INDEX_DEFINITION) initTagEntry (&tag, (char *)str, kind); else if (isXtagEnabled(XTAG_REFERENCE_TAGS)) initRefTagEntry (&tag, (char *)str, kind, spec->role); else goto out; tag.lineNumber = xmlGetLineNo (node); tag.filePosition = getInputFilePositionForLine (tag.lineNumber); path = (char *)xmlGetNodePath (node); tag.extensionFields.xpath = path; if (spec->make) spec->make (node, spec, &tag, userData); else makeTagEntry (&tag); if (path) xmlFree (path); out: xmlFree (str); }
/** @brief Get a resource definition for an event from the XML tree. * * @param cur Pointer to the \<event\> node. * @param restype Get a resource definition for this resource type. */ static resource *parser_event_get_res(xmlNodePtr cur, resourcetype *restype) { resource *res; xmlChar *type, *name; assert(restype!=NULL); assert(cur!=NULL); res=NULL; cur=cur->children; while(cur!=NULL) { if(!xmlStrcmp(cur->name, XMLCHAR "resource")) { type=parser_getprop_str(cur, XMLCHAR "type"); if(xmlStrcmp(type, XMLCHAR restype->type)) { free(type); cur=cur->next; continue; } name=parser_getprop_str(cur, XMLCHAR "name"); if(res!=NULL) { fatal(_("Definition of event has multiple " "definitions for resource type '%s' (line %d)"), restype->type, xmlGetLineNo(cur)); } res=res_find(restype, CHAR name); if(res==NULL) INVPROP("name", cur); xmlFree(type); xmlFree(name); } cur=cur->next; } return(res); }
/** * lgl_xml_get_prop_length: * @node: the libxml2 #xmlNodePtr of the node * @property: the property name * @default_val: a default value to return if property not found * * Return value of a length property as a double, converting to internal * units (points). The property is expected to be formatted as a number * followed by a units string. If there is no units string, the length * is assumed to be in points. Valid units strings are "pt" for points, * "in" for inches, "mm" for millimeters, "cm" for centimeters, and * "pc" for picas. * * Returns: the length in points. * */ gdouble lgl_xml_get_prop_length (xmlNodePtr node, const gchar *property, gdouble default_val) { gdouble val; xmlChar *string; xmlChar *unit_id; lglUnits units; string = xmlGetProp (node, (xmlChar *)property); if ( string != NULL ) { val = g_strtod ((gchar *)string, (gchar **)&unit_id); if (unit_id != string) { unit_id = (xmlChar *)g_strchug ((gchar *)unit_id); units = lgl_units_from_id ((gchar *)unit_id); if (units != LGL_UNITS_INVALID) { val *= lgl_units_get_points_per_unit (units); } else { g_message ("Line %ld, Node \"%s\", Property \"%s\": Unknown unit \"%s\", assuming points", xmlGetLineNo (node), node->name, property, unit_id); } } else { val = 0.0; } xmlFree (string); return val; } return default_val; }
/** @brief Parse restrictions for a single event and call proper restriction * handlers. * * @param cur Pointer to the \<event\> node. * @param tupleid Tuple ID for this event. * @param repeats Number of repeats of this event. * @return 1 if there were unknown restrictions or 0 otherwise. */ static int parser_event_restrictions(xmlNodePtr cur, int tupleid, int repeats) { int n; int result; xmlChar *restriction; xmlChar *content; int unknown; unknown=0; while(cur!=NULL) { if(!xmlStrcmp(cur->name, XMLCHAR "restriction")) { restriction=parser_getprop_str(cur, XMLCHAR "type"); content=xmlNodeGetContent(cur); for(n=tupleid; n<tupleid+repeats; n++) { result=handler_tup_call(&dat_tuplemap[n], CHAR restriction, CHAR content); if(result==1) { FAIL("Restriction handler failed", cur); } else if(result==2) { info(_("Unknown event restriction '%s'" " (line %d)"), restriction, xmlGetLineNo(cur)); unknown=1; } } xmlFree(restriction); xmlFree(content); } cur=cur->next; } return(unknown); }
/** @brief Parse a single event. * * @param event Pointer to the \<event\> node. * @param tuple Pointer to the tuple info struct for this event. */ static void parser_event(xmlNodePtr event, tupleinfo *tuple) { resource *res; resourcetype *restype; xmlChar *type; int n; xmlNodePtr cur; assert(tuple!=NULL); assert(event!=NULL); cur=event->children; while(cur!=NULL) { if(!xmlStrcmp(cur->name, XMLCHAR "resource")) { type=parser_getprop_str(cur, XMLCHAR "type"); restype=restype_find(CHAR type); if(restype==NULL) INVPROP("type", cur); xmlFree(type); } cur=cur->next; } for(n=0; n<dat_typenum; n++) { restype=&dat_restype[n]; res=parser_event_get_res(event, restype); if(res==NULL&&(!restype->var)) { fatal(_("Definition of event '%s' is missing constant " "resource type '%s' (line %d)"), tuple->name, restype->type, xmlGetLineNo(event)); } if(res!=NULL) tuple_set(tuple, res); } }
/** * xmlSchematronReportSuccess: * @ctxt: the validation context * @test: the compiled test * @cur: the current node tested * @success: boolean value for the result * * called from the validation engine when an assert or report test have * been done. */ static void xmlSchematronReportSuccess(xmlSchematronValidCtxtPtr ctxt, xmlSchematronTestPtr test, xmlNodePtr cur, xmlSchematronPatternPtr pattern, int success) { if ((ctxt == NULL) || (cur == NULL) || (test == NULL)) return; /* if quiet and not SVRL report only failures */ if ((ctxt->flags & XML_SCHEMATRON_OUT_QUIET) && ((ctxt->flags & XML_SCHEMATRON_OUT_XML) == 0) && (test->type == XML_SCHEMATRON_REPORT)) return; if (ctxt->flags & XML_SCHEMATRON_OUT_XML) { TODO } else { xmlChar *path; char msg[1000]; long line; const xmlChar *report = NULL; if (((test->type == XML_SCHEMATRON_REPORT) & (!success)) || ((test->type == XML_SCHEMATRON_ASSERT) & (success))) return; line = xmlGetLineNo(cur); path = xmlGetNodePath(cur); if (path == NULL) path = (xmlChar *) cur->name; #if 0 if ((test->report != NULL) && (test->report[0] != 0)) report = test->report; #endif if (test->node != NULL) report = xmlSchematronFormatReport(ctxt, test->node, cur); if (report == NULL) { if (test->type == XML_SCHEMATRON_ASSERT) { report = xmlStrdup((const xmlChar *) "node failed assert"); } else { report = xmlStrdup((const xmlChar *) "node failed report"); } } snprintf(msg, 999, "%s line %ld: %s\n", (const char *) path, line, (const char *) report); if (ctxt->flags & XML_SCHEMATRON_OUT_ERROR) { xmlStructuredErrorFunc schannel = NULL; xmlGenericErrorFunc channel = NULL; void *data = NULL; if (ctxt != NULL) { if (ctxt->serror != NULL) schannel = ctxt->serror; else channel = ctxt->error; data = ctxt->userData; } __xmlRaiseError(schannel, channel, data, NULL, cur, XML_FROM_SCHEMATRONV, (test->type == XML_SCHEMATRON_ASSERT)?XML_SCHEMATRONV_ASSERT:XML_SCHEMATRONV_REPORT, XML_ERR_ERROR, NULL, line, (pattern == NULL)?NULL:((const char *) pattern->name), (const char *) path, (const char *) report, 0, 0, msg); } else { xmlSchematronReportOutput(ctxt, cur, &msg[0]); } xmlFree((char *) report); if ((path != NULL) && (path != (xmlChar *) cur->name)) xmlFree(path); } }
int config_get_port (xmlNodePtr node, void *x) { int val = 0, ret = config_get_int (node, &val); if (ret == 0) { if (val < 0 || val > 65535) { WARN2 ("port out of range \"%s\" at line %ld, assuming 8000", node->name, xmlGetLineNo(node)); val = 8000; } *(int*)x = val; } return ret; }
static void xml_tree_model_get_value ( GtkTreeModel *model, GtkTreeIter *iter, gint column, GValue *value) { g_return_if_fail (XML_IS_TREE_MODEL (model)); g_return_if_fail (XML_TREE_MODEL (model)->xmldoc != NULL); g_return_if_fail (iter != NULL); g_return_if_fail (iter->user_data != NULL ); g_return_if_fail (column < XML_TREE_MODEL(model)->n_columns); xmlNodePtr record = iter->user_data; GType column_type = XML_TREE_MODEL(model)->column_types[column]; //if(g_value_get_gtype(value) != column_type) { g_value_init (value, column_type); //} switch(column) { case XML_TREE_MODEL_COL_TYPE: g_value_set_int(value, record->type); break; case XML_TREE_MODEL_COL_NS: get_value_ns (record, value); break; case XML_TREE_MODEL_COL_NAME: { switch(record->type) { case XML_CDATA_SECTION_NODE: g_value_set_string(value,"CDATA"); break; case XML_DOCUMENT_NODE: case XML_HTML_DOCUMENT_NODE: { xmlDocPtr dorec = record; g_value_set_string(value,(const gchar *)dorec->version); break; } default: g_value_set_string(value,(gchar *) record->name); break; } break; } case XML_TREE_MODEL_COL_CONTENT: get_value_content(record, value); break; case XML_TREE_MODEL_COL_LINE: g_value_set_int(value, (gint) xmlGetLineNo(record)); break; case XML_TREE_MODEL_COL_POS: { xmlParserNodeInfo *nodeinfo; gulong pos = NULL; nodeinfo = xmlParserFindNodeInfo(XML_TREE_MODEL (model)->parser, record); if(nodeinfo != NULL) pos = nodeinfo->begin_pos; g_value_set_ulong(value, pos); break; } case XML_TREE_MODEL_COL_XPATH: g_value_set_string(value, (const gchar *)xmlGetNodePath(record)); break; } }
static void parseString (xmlNodePtr cur, gchar *id, xmlChar *style, GtkSourceContextData *ctx_data, GtkSourceLanguage *language) { xmlChar *start_regex = NULL; xmlChar *end_regex = NULL; xmlChar *prop = NULL; gboolean end_at_line_end = TRUE; xmlNodePtr child; prop = xmlGetProp (cur, BAD_CAST "end-at-line-end"); if (prop != NULL) { if (!xmlStrcasecmp (prop, (const xmlChar *)"TRUE") || !xmlStrcmp (prop, (const xmlChar *)"1")) end_at_line_end = TRUE; else end_at_line_end = FALSE; xmlFree (prop); } child = cur->xmlChildrenNode; while (child != NULL) { if (!xmlStrcmp (child->name, (const xmlChar *)"start-regex")) { start_regex = xmlNodeListGetString (child->doc, child->xmlChildrenNode, 1); } else if (!xmlStrcmp (child->name, (const xmlChar *)"end-regex")) { end_regex = xmlNodeListGetString (child->doc, child->xmlChildrenNode, 1); } child = child->next; } if (start_regex == NULL) { g_warning ("Missing start-regex in tag 'string' (%s, line %ld)", child->doc->name, xmlGetLineNo (cur)); return; } if (end_regex == NULL) { xmlFree (start_regex); g_warning ("Missing end-regex in tag 'string' (%s, line %ld)", child->doc->name, xmlGetLineNo (cur)); return; } ctx_data_add_syntax_pattern (ctx_data, language, id, (gchar*) style, (gchar*) start_regex, (gchar*) end_regex, end_at_line_end); xmlFree (start_regex); xmlFree (end_regex); }
static void parseKeywordList (xmlNodePtr cur, gchar *id, xmlChar *style, GtkSourceContextData *ctx_data, GtkSourceLanguage *language) { gboolean case_sensitive = TRUE; gboolean match_empty_string_at_beginning = TRUE; gboolean match_empty_string_at_end = TRUE; gchar *beginning_regex = NULL; gchar *end_regex = NULL; GSList *list = NULL; gchar *regex; xmlChar *prop; xmlNodePtr child; prop = xmlGetProp (cur, BAD_CAST "case-sensitive"); if (prop != NULL) { if (!xmlStrcasecmp (prop, (const xmlChar *)"TRUE") || !xmlStrcmp (prop, (const xmlChar *)"1")) case_sensitive = TRUE; else case_sensitive = FALSE; xmlFree (prop); } prop = xmlGetProp (cur, BAD_CAST "match-empty-string-at-beginning"); if (prop != NULL) { if (!xmlStrcasecmp (prop, (const xmlChar *)"TRUE") || !xmlStrcmp (prop, (const xmlChar *)"1")) match_empty_string_at_beginning = TRUE; else match_empty_string_at_beginning = FALSE; xmlFree (prop); } prop = xmlGetProp (cur, BAD_CAST "match-empty-string-at-end"); if (prop != NULL) { if (!xmlStrcasecmp (prop, (const xmlChar *)"TRUE") || !xmlStrcmp (prop, (const xmlChar *)"1")) match_empty_string_at_end = TRUE; else match_empty_string_at_end = FALSE; xmlFree (prop); } prop = xmlGetProp (cur, BAD_CAST "beginning-regex"); if (prop != NULL) { beginning_regex = g_strdup ((gchar *)prop); xmlFree (prop); } prop = xmlGetProp (cur, BAD_CAST "end-regex"); if (prop != NULL) { end_regex = g_strdup ((gchar *)prop); xmlFree (prop); } child = cur->xmlChildrenNode; while (child != NULL) { if (!xmlStrcmp (child->name, BAD_CAST "keyword")) { xmlChar *keyword; keyword = xmlNodeListGetString (child->doc, child->xmlChildrenNode, 1); list = g_slist_prepend (list, keyword); } child = child->next; } list = g_slist_reverse (list); if (list == NULL) { g_warning ("No keywords in tag 'keyword-list' (%s, line %ld)", child->doc->name, xmlGetLineNo (cur)); g_free (beginning_regex), g_free (end_regex); return; } regex = build_keyword_list (list, case_sensitive, match_empty_string_at_beginning, match_empty_string_at_end, beginning_regex, end_regex); g_free (beginning_regex), g_free (end_regex); g_slist_foreach (list, (GFunc) xmlFree, NULL); g_slist_free (list); ctx_data_add_simple_pattern (ctx_data, language, id, (gchar*) style, regex); g_free (regex); }
const struct sTagXpathRecurSpec *spec __unused__, xmlXPathContext *ctx __unused__, void *userData __unused__); static void makeTagForProperties (xmlNode *node, const struct sTagXpathRecurSpec *spec __unused__, xmlXPathContext *ctx __unused__, void *userData __unused__) { const xmlChar* str; tagEntryInfo tag; str = node->name; initTagEntry (&tag, (char *)str, Maven2Kinds + K_PROPERTY); tag.lineNumber = xmlGetLineNo (node); tag.filePosition = getInputFilePositionForLine (tag.lineNumber); makeTagEntry (&tag); } static tagXpathTable maven2XpathMainTable[] = { { "/*[local-name()='project']/*[local-name()='groupId']", LXPATH_TABLE_DO_MAKE, { .makeTagSpec = { K_GROUP_ID, ROLE_INDEX_DEFINITION, makeTagWithScope } } }, { "/*[local-name()='project']/*[local-name()='parent']", LXPATH_TABLE_DO_RECUR, { .recurSpec = { makeTagForParent } } },
static int processSection(xmlElement *element, xml2lpc_context *ctx) { xmlNode *cur_node = NULL; xmlNode *cur_attr = NULL; const char *name = NULL; for (cur_attr = (xmlNode *)element->attributes; cur_attr; cur_attr = cur_attr->next) { dumpAttr(cur_attr, ctx); if(strcmp((const char*)cur_attr->name, "name") == 0) { name = (const char*)cur_attr->children->content; } } if(name != NULL) { for (cur_node = element->children; cur_node; cur_node = cur_node->next) { dumpNode(cur_node, ctx); if (cur_node->type == XML_ELEMENT_NODE) { if(strcmp((const char*)cur_node->name, "entry") == 0 ) { processEntry((xmlElement*)cur_node, name, ctx); } } } } else { xml2lpc_log(ctx, XML2LPC_WARNING, "ignored section with no \"name\" attribute, line:%d", xmlGetLineNo((xmlNode*)element)); } return 0; }
/** * debugHandleDebugger: * @cur : source node being executed * @node : data node being processed * @templ : temlate that applies to node * @ctxt : the xslt transform context * * If either cur or node are a breakpoint, or xslDebugStatus in state * where debugging must occcur at this time then transfer control * to the debugXSLBreak function */ void debugHandleDebugger(xmlNodePtr cur, xmlNodePtr node, xsltTemplatePtr templ, xsltTransformContextPtr ctxt) { if (!cur && !node) { xsldbgGenericErrorFunc(i18n("Error: XSLT source and XML data are empty. Cannot enter the debugger.\n")); } else { if (optionsGetIntOption(OPTIONS_GDB)){ int doValidation = 0; switch(xsldbgValidateBreakpoints){ case BREAKPOINTS_ARE_VALID: if (!filesGetStylesheet() || !filesGetMainDoc()) { xsldbgValidateBreakpoints = BREAKPOINTS_NEED_VALIDATION; doValidation = 1; } break; case BREAKPOINTS_NEED_VALIDATION: if (filesGetStylesheet() && filesGetMainDoc() && templ){ xsldbgValidateBreakpoints = BREAKPOINTS_BEING_VALIDATED; doValidation = 1; } break; case BREAKPOINTS_BEING_VALIDATED: /*should never be in the state for any length of time */ #ifdef WITH_XSLDBG_DEBUG_BREAKPOINTS xsltGenericError(xsltGenericErrorContext, "Error: Unexpected breakpoint validation state %d", xsldbgValidateBreakpoints); #endif break; } if (doValidation){ /* breakpoints will either be marked as orphaned or not as needed */ xsldbgValidateBreakpoints = BREAKPOINTS_BEING_VALIDATED; walkBreakPoints((xmlHashScanner) xslDbgShellValidateBreakPoint, ctxt); if (filesGetStylesheet() && filesGetMainDoc() && templ){ xsldbgValidateBreakpoints = BREAKPOINTS_ARE_VALID; }else{ xsldbgValidateBreakpoints = BREAKPOINTS_NEED_VALIDATION; } } } switch (xslDebugStatus) { /* A temparary stopping point */ case DEBUG_WALK: case DEBUG_TRACE: /* only allow breakpoints at xml elements */ if (xmlGetLineNo(cur) != -1) debugXSLBreak(cur, node, templ, ctxt); break; case DEBUG_STOP: xslDebugStatus = DEBUG_CONT; /* only allow breakpoints at xml elements */ if (xmlGetLineNo(cur) != -1) debugXSLBreak(cur, node, templ, ctxt); break; case DEBUG_STEP: /* only allow breakpoints at xml elements */ if (xmlGetLineNo(cur) != -1) debugXSLBreak(cur, node, templ, ctxt); break; case DEBUG_CONT: { breakPointPtr breakPtr = NULL; xmlChar *baseUri = NULL; if (cur) { breakPtr = breakPointGet(cur->doc->URL, xmlGetLineNo(cur)); if (breakPtr && (breakPtr->flags & BREAKPOINT_ENABLED) ){ debugXSLBreak(cur, node, templ, ctxt); return; } } if (node) { baseUri = filesGetBaseUri(node); if (baseUri != NULL) { breakPtr = breakPointGet(baseUri, xmlGetLineNo(node)); } else { breakPtr = breakPointGet(node->doc->URL, xmlGetLineNo(node)); } if (breakPtr) { if (breakPtr->flags & BREAKPOINT_ENABLED) { debugXSLBreak(cur, node, templ, ctxt); } } if (baseUri) xmlFree(baseUri); } } break; } } }
static int processEntry(xmlElement *element, const char *sectionName, xml2lpc_context *ctx) { xmlNode *cur_attr = NULL; const char *name = NULL; const char *value = NULL; bool_t overwrite = FALSE; for (cur_attr = (xmlNode *)element->attributes; cur_attr; cur_attr = cur_attr->next) { dumpAttr(cur_attr, ctx); if(strcmp((const char*)cur_attr->name, "name") == 0) { name = (const char*)cur_attr->children->content; } else if(strcmp((const char*)cur_attr->name, "overwrite") == 0) { if(strcmp((const char*)cur_attr->children->content, "true") == 0) { overwrite = TRUE; } } } dumpContent((xmlNode *)element, ctx); if (element->children) value = (const char *)element->children->content; else value = ""; if(name != NULL) { const char *str = lp_config_get_string(ctx->lpc, sectionName, name, NULL); if(str == NULL || overwrite) { xml2lpc_log(ctx, XML2LPC_MESSAGE, "Set %s|%s = %s", sectionName, name, value); lp_config_set_string(ctx->lpc, sectionName, name, value); } else { xml2lpc_log(ctx, XML2LPC_MESSAGE, "Don't touch %s|%s = %s",sectionName, name, str); } } else { xml2lpc_log(ctx, XML2LPC_WARNING, "ignored entry with no \"name\" attribute line:%d",xmlGetLineNo((xmlNode*)element)); } return 0; }
bool Components::ParseXMLNode( xmlDocPtr doc, xmlNodePtr node ) { xmlNodePtr attr; Component* component = newComponent(); // All Compoents must have names! if( (attr = FirstChildNamed(node,"name")) ){ component->SetName(NodeToString(doc,attr)); } else { LogMsg(ERR,"Failed to find a name attribute for the %s node at line %d.\n", NodeToString(doc,attr).c_str(), xmlGetLineNo(node) ); return false; } if( component->FromXMLNode(doc, node) ){ Add( component ); return true; } return false; }
/** * printTemplateHelper: * @templ: Is valid * @verbose: Either 1 or 0 * @templateCount: Is valid * @count: Is valid * @templateName: template name to print, may be NULL * * This display the templates in the same order as they are in the * stylesheet. If verbose is 1 then print more information * For each template found @templateCount is increased * For each printed template @printCount is increased */ void printTemplateHelper(xsltTemplatePtr templ, int verbose, int *templateCount, int *count, xmlChar * templateName) { xmlChar *name, *defaultUrl = (xmlChar *) "<n/a>"; const xmlChar *url; if (!templ) return; *templateCount = *templateCount + 1; printTemplateHelper(templ->next, verbose, templateCount, count, templateName); if (templ->elem && templ->elem->doc && templ->elem->doc->URL) { url = templ->elem->doc->URL; } else { url = defaultUrl; } if (templ->match) name = xmlStrdup(templ->match); else name = fullQName(templ->nameURI, templ->name); if (name) { if (templateName && (xmlStrcmp(templateName, name) != 0)) { /* search for template name supplied failed */ /* empty */ } else { xmlChar *modeTemp = NULL; *count = *count + 1; if (getThreadStatus() == XSLDBG_MSG_THREAD_RUN) { notifyListQueue(templ); } else { modeTemp = fullQName(templ->modeURI, templ->mode); if (verbose) xsldbgGenericErrorFunc(i18n(" template: \"%1\" mode: \"%2\" in file \"%3\" at line %4\n").arg(xsldbgText(name)).arg(xsldbgText(modeTemp)).arg(xsldbgUrl(url)).arg(xmlGetLineNo(templ->elem))); else xsldbgGenericErrorFunc(QString("\"%s\" ").arg(xsldbgText(name))); if (modeTemp) xmlFree(modeTemp); } } xmlFree(name); } }