/** * register_namespaces: * @xpathCtx:the pointer to an XPath context. * @nsList:the list of known namespaces in *"<prefix1>=<href1> <prefix2>=href2> ..." format. * * Registers namespaces from @nsList in @xpathCtx. * * Returns 0 on success and a negative value otherwise. */ int register_namespaces(xmlXPathContextPtr xpathCtx, const xmlChar* nsList) { xmlChar* nsListDup; xmlChar* prefix; xmlChar* href; xmlChar* next; assert(xpathCtx); assert(nsList); nsListDup = xmlStrdup(nsList); if(nsListDup == NULL) { fprintf(stderr, "Error: unable to strdup namespaces list\n"); return(-1); } next = nsListDup; while(next != NULL) { /* skip spaces */ while((*next) == ' ') next++; if((*next) == '\0') break; /* find prefix */ prefix = next; next = (xmlChar*)xmlStrchr(next, '='); if(next == NULL) { fprintf(stderr,"Error: invalid namespaces list format\n"); xmlFree(nsListDup); return(-1); } *(next++) = '\0'; /* find href */ href = next; next = (xmlChar*)xmlStrchr(next, ' '); if(next != NULL) { *(next++) = '\0'; } /* do register namespace */ if(xmlXPathRegisterNs(xpathCtx, prefix, href) != 0) { fprintf(stderr,"Error: unable to register NS with prefix=\"%s\" and href=\"%s\"\n", prefix, href); xmlFree(nsListDup); return(-1); } } xmlFree(nsListDup); return(0); }
int SDOXMLString::lastIndexOf(const char ch) const { const xmlChar* index = 0; const xmlChar* loc = xmlStrchr(xmlForm, ch); while (loc !=0) { index = loc; loc = xmlStrchr(loc+1, ch); } if (index == 0) return -1; return int(index-xmlForm); }
/** * xsltEvalStaticAttrValueTemplate: * @style: the XSLT stylesheet * @inst: the instruction (or LRE) in the stylesheet holding the * attribute with an AVT * @name: the attribute Name * @ns: the attribute namespace URI * @found: indicator whether the attribute is present * * Check if an attribute value template has a static value, i.e. the * attribute value does not contain expressions contained in curly braces ({}) * * Returns the static string value or NULL, must be deallocated by the * caller. */ const xmlChar * xsltEvalStaticAttrValueTemplate(xsltStylesheetPtr style, xmlNodePtr inst, const xmlChar *name, const xmlChar *ns, int *found) { const xmlChar *ret; xmlChar *expr; if ((style == NULL) || (inst == NULL) || (name == NULL)) return(NULL); expr = xsltGetNsProp(inst, name, ns); if (expr == NULL) { *found = 0; return(NULL); } *found = 1; ret = xmlStrchr(expr, '{'); if (ret != NULL) { xmlFree(expr); return(NULL); } ret = xmlDictLookup(style->dict, expr, -1); xmlFree(expr); return(ret); }
/* {{{ proto DOMDocumentType dom_domimplementation_create_document_type(string qualifiedName, string publicId, string systemId); URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Level-2-Core-DOM-createDocType Since: DOM Level 2 */ PHP_METHOD(domimplementation, createDocumentType) { xmlDtd *doctype; int ret; size_t name_len = 0, publicid_len = 0, systemid_len = 0; char *name = NULL, *publicid = NULL, *systemid = NULL; xmlChar *pch1 = NULL, *pch2 = NULL, *localname = NULL; xmlURIPtr uri; if (zend_parse_parameters(ZEND_NUM_ARGS(), "|sss", &name, &name_len, &publicid, &publicid_len, &systemid, &systemid_len) == FAILURE) { return; } if (name_len == 0) { php_error_docref(NULL, E_WARNING, "qualifiedName is required"); RETURN_FALSE; } if (publicid_len > 0) { pch1 = (xmlChar *) publicid; } if (systemid_len > 0) { pch2 = (xmlChar *) systemid; } uri = xmlParseURI(name); if (uri != NULL && uri->opaque != NULL) { localname = xmlStrdup((xmlChar *) uri->opaque); if (xmlStrchr(localname, (xmlChar) ':') != NULL) { php_dom_throw_error(NAMESPACE_ERR, 1); xmlFreeURI(uri); xmlFree(localname); RETURN_FALSE; } } else { localname = xmlStrdup((xmlChar *) name); } /* TODO: Test that localname has no invalid chars php_dom_throw_error(INVALID_CHARACTER_ERR,); */ if (uri) { xmlFreeURI(uri); } doctype = xmlCreateIntSubset(NULL, localname, pch1, pch2); xmlFree(localname); if (doctype == NULL) { php_error_docref(NULL, E_WARNING, "Unable to create DocumentType"); RETURN_FALSE; } DOM_RET_OBJ((xmlNodePtr) doctype, &ret, NULL); }
gchar* feed_remove_markup (gchar* markup) { const xmlChar* stag; if (((stag = xmlStrchr (BAD_CAST markup, '<')) && xmlStrchr (stag, '>')) || xmlStrchr (BAD_CAST markup, '&')) { gchar* text = NULL; htmlSAXHandlerPtr psax; psax = g_new0 (htmlSAXHandler, 1); psax->characters = handle_markup_chars; htmlSAXParseDoc (BAD_CAST markup, "UTF-8", psax, &text); g_free (psax); g_free (markup); return text; } return markup; }
int SDOXMLString::firstIndexOf(const char ch) const { const xmlChar* loc = xmlStrchr(xmlForm, ch); if (loc == 0) { return -1; } return int(loc-xmlForm); }
/* {{{ php_xsl_xslt_string_to_xpathexpr() Translates a string to a XPath Expression */ static char *php_xsl_xslt_string_to_xpathexpr(const char *str) { const xmlChar *string = (const xmlChar *)str; xmlChar *value; int str_len; str_len = xmlStrlen(string) + 3; if (xmlStrchr(string, '"')) { if (xmlStrchr(string, '\'')) { php_error_docref(NULL, E_WARNING, "Cannot create XPath expression (string contains both quote and double-quotes)"); return NULL; } value = (xmlChar*) safe_emalloc (str_len, sizeof(xmlChar), 0); snprintf((char*)value, str_len, "'%s'", string); } else { value = (xmlChar*) safe_emalloc (str_len, sizeof(xmlChar), 0); snprintf((char *)value, str_len, "\"%s\"", string); } return (char *) value; }
/** * Parse command line for -N <prefix>=<namespace> arguments */ int parseNSArr(xmlChar** ns_arr, int* plen, int argc, char **argv) { int i = 0; *plen = 0; ns_arr[0] = 0; for (i=0; i<argc; i++) { int prefix_len; xmlChar *name, *value; const xmlChar *equal_sign; /* check for end of arguments */ if (argv[i] == 0 || argv[i][0] != '-') break; if (strcmp(argv[i], "-N") != 0) continue; i++; if (i >= argc) bad_ns_opt("-N without argument"); equal_sign = xmlStrchr((const xmlChar*) argv[i], '='); if (!equal_sign) bad_ns_opt("namespace should have the form <prefix>=<url>"); prefix_len = equal_sign - (const xmlChar*) argv[i]; name = xmlStrndup((const xmlChar*) argv[i], prefix_len); value = xmlStrdup((const xmlChar*) argv[i]+prefix_len+1); if (*plen >= MAX_NS_ARGS) { fprintf(stderr, "too many namespaces increase MAX_NS_ARGS\n"); exit(EXIT_BAD_ARGS); } ns_arr[*plen] = name; (*plen)++; ns_arr[*plen] = value; (*plen)++; ns_arr[*plen] = 0; } return i; }
/** * xsltFormatNumberConversion: * @self: the decimal format * @format: the format requested * @number: the value to format * @result: the place to ouput the result * * format-number() uses the JDK 1.1 DecimalFormat class: * * http://java.sun.com/products/jdk/1.1/docs/api/java.text.DecimalFormat.html * * Structure: * * pattern := subpattern{;subpattern} * subpattern := {prefix}integer{.fraction}{suffix} * prefix := '\\u0000'..'\\uFFFD' - specialCharacters * suffix := '\\u0000'..'\\uFFFD' - specialCharacters * integer := '#'* '0'* '0' * fraction := '0'* '#'* * * Notation: * X* 0 or more instances of X * (X | Y) either X or Y. * X..Y any character from X up to Y, inclusive. * S - T characters in S, except those in T * * Special Characters: * * Symbol Meaning * 0 a digit * # a digit, zero shows as absent * . placeholder for decimal separator * , placeholder for grouping separator. * ; separates formats. * - default negative prefix. * % multiply by 100 and show as percentage * ? multiply by 1000 and show as per mille * X any other characters can be used in the prefix or suffix * ' used to quote special characters in a prefix or suffix. */ xmlXPathError xsltFormatNumberConversion(xsltDecimalFormatPtr self, xmlChar *format, double number, xmlChar **result) { xmlXPathError status = XPATH_EXPRESSION_OK; xmlBufferPtr buffer; xmlChar *the_format, *prefix = NULL, *suffix = NULL; xmlChar *nprefix, *nsuffix = NULL; xmlChar pchar; int prefix_length, suffix_length = 0, nprefix_length, nsuffix_length; double scale; int j; xsltFormatNumberInfo format_info; /* delayed_multiplier allows a 'trailing' percent or permille to be treated as suffix */ int delayed_multiplier = 0; /* flag to show no -ve format present for -ve number */ char default_sign = 0; /* flag to show error found, should use default format */ char found_error = 0; *result = NULL; switch (xmlXPathIsInf(number)) { case -1: if (self->minusSign == NULL) *result = xmlStrdup(BAD_CAST "-"); else *result = xmlStrdup(self->minusSign); /* no-break on purpose */ case 1: if ((self == NULL) || (self->infinity == NULL)) *result = xmlStrcat(*result, BAD_CAST "Infinity"); else *result = xmlStrcat(*result, self->infinity); return(status); default: if (xmlXPathIsNaN(number)) { if ((self == NULL) || (self->noNumber == NULL)) *result = xmlStrdup(BAD_CAST "NaN"); else *result = xmlStrdup(self->noNumber); return(status); } } buffer = xmlBufferCreate(); if (buffer == NULL) { return XPATH_MEMORY_ERROR; } format_info.integer_digits = 0; format_info.frac_digits = 0; format_info.frac_hash = 0; format_info.group = -1; format_info.multiplier = 1; format_info.is_multiplier_set = FALSE; format_info.is_negative_pattern = FALSE; the_format = format; /* First we process the +ve pattern to get percent / permille, as well as main format */ prefix = the_format; prefix_length = xsltFormatNumberPreSuffix(self, &the_format, &format_info); if (prefix_length < 0) { found_error = 1; goto OUTPUT_NUMBER; } /* Here we process the "number" part of the format. It gets a little messy because of */ /* the percent/per-mille - if that appears at the end, it may be part of the suffix */ /* instead of part of the number, so the variable delayed_multiplier is used to handle it */ while ((*the_format != 0) && (*the_format != self->decimalPoint[0]) && (*the_format != self->patternSeparator[0])) { if (delayed_multiplier != 0) { format_info.multiplier = delayed_multiplier; format_info.is_multiplier_set = TRUE; delayed_multiplier = 0; } if (*the_format == self->digit[0]) { if (format_info.integer_digits > 0) { found_error = 1; goto OUTPUT_NUMBER; } if (format_info.group >= 0) format_info.group++; } else if (*the_format == self->zeroDigit[0]) { format_info.integer_digits++; if (format_info.group >= 0) format_info.group++; } else if (*the_format == self->grouping[0]) { /* Reset group count */ format_info.group = 0; } else if (*the_format == self->percent[0]) { if (format_info.is_multiplier_set) { found_error = 1; goto OUTPUT_NUMBER; } delayed_multiplier = 100; } else if (*the_format == self->permille[0]) { if (format_info.is_multiplier_set) { found_error = 1; goto OUTPUT_NUMBER; } delayed_multiplier = 1000; } else break; /* while */ the_format++; } /* We have finished the integer part, now work on fraction */ if (*the_format == self->decimalPoint[0]) the_format++; /* Skip over the decimal */ while (*the_format != 0) { if (*the_format == self->zeroDigit[0]) { if (format_info.frac_hash != 0) { found_error = 1; goto OUTPUT_NUMBER; } format_info.frac_digits++; } else if (*the_format == self->digit[0]) { format_info.frac_hash++; } else if (*the_format == self->percent[0]) { if (format_info.is_multiplier_set) { found_error = 1; goto OUTPUT_NUMBER; } delayed_multiplier = 100; the_format++; continue; /* while */ } else if (*the_format == self->permille[0]) { if (format_info.is_multiplier_set) { found_error = 1; goto OUTPUT_NUMBER; } delayed_multiplier = 1000; the_format++; continue; /* while */ } else if (*the_format != self->grouping[0]) { break; /* while */ } the_format++; if (delayed_multiplier != 0) { format_info.multiplier = delayed_multiplier; delayed_multiplier = 0; format_info.is_multiplier_set = TRUE; } } /* If delayed_multiplier is set after processing the "number" part, should be in suffix */ if (delayed_multiplier != 0) { the_format--; delayed_multiplier = 0; } suffix = the_format; suffix_length = xsltFormatNumberPreSuffix(self, &the_format, &format_info); if ( (suffix_length < 0) || ((*the_format != 0) && (*the_format != self->patternSeparator[0])) ) { found_error = 1; goto OUTPUT_NUMBER; } /* We have processed the +ve prefix, number part and +ve suffix. */ /* If the number is -ve, we must substitute the -ve prefix / suffix */ if (number < 0) { the_format = (xmlChar *)xmlStrchr(format, self->patternSeparator[0]); if (the_format == NULL) { /* No -ve pattern present, so use default signing */ default_sign = 1; } else { /* Flag changes interpretation of percent/permille in -ve pattern */ the_format++; /* Skip over pattern separator */ format_info.is_negative_pattern = TRUE; format_info.is_multiplier_set = FALSE; /* First do the -ve prefix */ nprefix = the_format; nprefix_length = xsltFormatNumberPreSuffix(self, &the_format, &format_info); if (nprefix_length<0) { found_error = 1; goto OUTPUT_NUMBER; } /* Next skip over the -ve number info */ the_format += prefix_length; while (*the_format != 0) { if ( (*the_format == (self)->percent[0]) || (*the_format == (self)->permille[0]) ) { if (format_info.is_multiplier_set) { found_error = 1; goto OUTPUT_NUMBER; } format_info.is_multiplier_set = TRUE; delayed_multiplier = 1; } else if (IS_SPECIAL(self, *the_format)) delayed_multiplier = 0; else break; /* while */ the_format++; } if (delayed_multiplier != 0) { format_info.is_multiplier_set = FALSE; the_format--; } /* Finally do the -ve suffix */ if (*the_format != 0) { nsuffix = the_format; nsuffix_length = xsltFormatNumberPreSuffix(self, &the_format, &format_info); if (nsuffix_length < 0) { found_error = 1; goto OUTPUT_NUMBER; } } else nsuffix_length = 0; if (*the_format != 0) { found_error = 1; goto OUTPUT_NUMBER; } /* Here's another Java peculiarity: * if -ve prefix/suffix == +ve ones, discard & use default */ if ((nprefix_length != prefix_length) || (nsuffix_length != suffix_length) || ((nprefix_length > 0) && (xmlStrncmp(nprefix, prefix, prefix_length) !=0 )) || ((nsuffix_length > 0) && (xmlStrncmp(nsuffix, suffix, suffix_length) !=0 ))) { prefix = nprefix; prefix_length = nprefix_length; suffix = nsuffix; suffix_length = nsuffix_length; } else { default_sign = 1; } } } OUTPUT_NUMBER: if (found_error != 0) { xsltPrintErrorContext(NULL, NULL, NULL); xsltGenericError(xsltGenericErrorContext, "xsltFormatNumberConversion : error in format string, using default\n"); default_sign = (number < 0.0) ? 1 : 0; prefix_length = suffix_length = 0; format_info.integer_digits = 1; format_info.frac_digits = 1; format_info.frac_hash = 4; format_info.group = -1; format_info.multiplier = 1; } /* Ready to output our number. First see if "default sign" is required */ if (default_sign != 0) xmlBufferAdd(buffer, self->minusSign, 1); /* Put the prefix into the buffer */ for (j = 0; j < prefix_length; j++) { if ((pchar = *prefix++) == SYMBOL_QUOTE) { pchar = *prefix++; prefix++; } xmlBufferAdd(buffer, &pchar, 1); } /* Next do the integer part of the number */ number = fabs(number) * (double)format_info.multiplier; scale = pow(10.0, (double)(format_info.frac_digits + format_info.frac_hash)); number = floor((scale * number + 0.5)) / scale; if ((self->grouping != NULL) && (self->grouping[0] != 0)) xsltNumberFormatDecimal(buffer, floor(number), self->zeroDigit[0], format_info.integer_digits, format_info.group, (xmlChar) self->grouping[0]); else xsltNumberFormatDecimal(buffer, floor(number), self->zeroDigit[0], format_info.integer_digits, format_info.group, (xmlChar) ','); /* Next the fractional part, if required */ if (format_info.frac_digits + format_info.frac_hash > 0) { number -= floor(number); if ((number != 0) || (format_info.frac_digits != 0)) { xmlBufferAdd(buffer, self->decimalPoint, 1); number = floor(scale * number + 0.5); for (j = format_info.frac_hash; j > 0; j--) { if (fmod(number, 10.0) >= 1.0) break; /* for */ number /= 10.0; } xsltNumberFormatDecimal(buffer, floor(number), self->zeroDigit[0], format_info.frac_digits + j, 0, (xmlChar)0); } } /* Put the suffix into the buffer */ for (j = 0; j < suffix_length; j++) { if ((pchar = *suffix++) == SYMBOL_QUOTE) { pchar = *suffix++; suffix++; } xmlBufferAdd(buffer, &pchar, 1); } *result = xmlStrdup(xmlBufferContent(buffer)); xmlBufferFree(buffer); return status; }
/** * read file and print element paths */ int parse_xml_file(const char *filename) { int ret, prev_depth = 0; xmlTextReaderPtr reader; for (reader = xmlReaderForFile(filename, NULL, 0);;) { int depth; const xmlChar *name; xmlReaderTypes type; if (!reader) { fprintf(stderr, "couldn't read file '%s'\n", filename); exit(EXIT_BAD_FILE); } ret = xmlTextReaderRead(reader); if (ret <= 0) break; type = xmlTextReaderNodeType(reader); depth = xmlTextReaderDepth(reader); name = xmlTextReaderConstName(reader); if (type != XML_READER_TYPE_ELEMENT) continue; while (curXPath && depth <= prev_depth) { xmlChar *slash = BAD_CAST strrchr((char*) curXPath, '/'); if (slash) *slash = '\0'; prev_depth--; } prev_depth = depth; if (depth > 0) curXPath = xmlStrcat(curXPath, BAD_CAST "/"); curXPath = xmlStrcat(curXPath, name); if (elOps.show_attr) { int have_attr; fprintf(stdout, "%s\n", curXPath); for (have_attr = xmlTextReaderMoveToFirstAttribute(reader); have_attr; have_attr = xmlTextReaderMoveToNextAttribute(reader)) { const xmlChar *aname = xmlTextReaderConstName(reader); fprintf(stdout, "%s/@%s\n", curXPath, aname); } } else if (elOps.show_attr_and_val) { fprintf(stdout, "%s", curXPath); if (xmlTextReaderHasAttributes(reader)) { int have_attr, first = 1; fprintf(stdout, "["); for (have_attr = xmlTextReaderMoveToFirstAttribute(reader); have_attr; have_attr = xmlTextReaderMoveToNextAttribute(reader)) { const xmlChar *aname = xmlTextReaderConstName(reader), *avalue = xmlTextReaderConstValue(reader); char quote; if (!first) fprintf(stdout, " and "); first = 0; quote = xmlStrchr(avalue, '\'')? '"' : '\''; fprintf(stdout, "@%s=%c%s%c", aname, quote, avalue, quote); } fprintf(stdout, "]"); } fprintf(stdout, "\n"); } else if (elOps.sort_uniq) { if ((elOps.check_depth == 0) || (elOps.check_depth != 0 && depth < elOps.check_depth)) { xmlHashAddEntry(uniq, curXPath, (void*) 1); } } else fprintf(stdout, "%s\n", curXPath); } return ret == -1? EXIT_LIB_ERROR : ret; }
/** * Parse command line for XSLT parameters */ int trParseParams(const char** params, int* plen, int count, char **argv) { int i; *plen = 0; params[0] = 0; for (i=0; i<count; i++) { if (argv[i][0] == '-') { if (!strcmp(argv[i], "-p")) { int j; xmlChar *name, *value; i++; if (i >= count) trUsage(argv[0], EXIT_BAD_ARGS); for(j=0; argv[i][j] && (argv[i][j] != '='); j++); if (argv[i][j] != '=') trUsage(argv[0], EXIT_BAD_ARGS); name = xmlStrndup((const xmlChar *) argv[i], j); value = xmlStrdup((const xmlChar *) argv[i]+j+1); if (*plen >= MAX_PARAMETERS) { fprintf(stderr, "too many params increase MAX_PARAMETERS\n"); exit(EXIT_INTERNAL_ERROR); } params[*plen] = (char *)name; (*plen)++; params[*plen] = (char *)value; (*plen)++; params[*plen] = 0; } else if (!strcmp(argv[i], "-s")) { int j; const xmlChar *string; xmlChar *name, *value; i++; if (i >= count) trUsage(argv[0], EXIT_BAD_ARGS); for(j=0; argv[i][j] && (argv[i][j] != '='); j++); if (argv[i][j] != '=') trUsage(argv[0], EXIT_BAD_ARGS); name = xmlStrndup((const xmlChar *)argv[i], j); string = (const xmlChar *)(argv[i]+j+1); if (xmlStrchr(string, '"')) { if (xmlStrchr(string, '\'')) { fprintf(stderr, "string parameter contains both quote and double-quotes\n"); exit(EXIT_INTERNAL_ERROR); } value = xmlStrdup((const xmlChar *)"'"); value = xmlStrcat(value, string); value = xmlStrcat(value, (const xmlChar *)"'"); } else { value = xmlStrdup((const xmlChar *)"\""); value = xmlStrcat(value, string); value = xmlStrcat(value, (const xmlChar *)"\""); } if (*plen >= MAX_PARAMETERS) { fprintf(stderr, "too many params increase MAX_PARAMETERS\n"); exit(EXIT_INTERNAL_ERROR); } params[*plen] = (char *)name; (*plen)++; params[*plen] = (char *)value; (*plen)++; params[*plen] = 0; } } else break; } return i; }
/** * xsltCompileAttr: * @style: a XSLT process context * @attr: the attribute coming from the stylesheet. * * Precompile an attribute in a stylesheet, basically it checks if it is * an attrubute value template, and if yes establish some structures needed * to process it at transformation time. */ void xsltCompileAttr(xsltStylesheetPtr style, xmlAttrPtr attr) { const xmlChar *str; const xmlChar *cur; xmlChar *ret = NULL; xmlChar *expr = NULL; xsltAttrVTPtr avt; int i = 0, lastavt = 0; if ((style == NULL) || (attr == NULL) || (attr->children == NULL)) return; if ((attr->children->type != XML_TEXT_NODE) || (attr->children->next != NULL)) { xsltTransformError(NULL, style, attr->parent, "Attribute '%s': The content is expected to be a single text " "node when compiling an AVT.\n", attr->name); style->errors++; return; } str = attr->children->content; if ((xmlStrchr(str, '{') == NULL) && (xmlStrchr(str, '}') == NULL)) return; #ifdef WITH_XSLT_DEBUG_AVT xsltGenericDebug(xsltGenericDebugContext, "Found AVT %s: %s\n", attr->name, str); #endif if (attr->psvi != NULL) { #ifdef WITH_XSLT_DEBUG_AVT xsltGenericDebug(xsltGenericDebugContext, "AVT %s: already compiled\n", attr->name); #endif return; } /* * Create a new AVT object. */ avt = xsltNewAttrVT(style); if (avt == NULL) return; attr->psvi = avt; avt->nsList = xmlGetNsList(attr->doc, attr->parent); if (avt->nsList != NULL) { while (avt->nsList[i] != NULL) i++; } avt->nsNr = i; cur = str; while (*cur != 0) { if (*cur == '{') { if (*(cur+1) == '{') { /* escaped '{' */ cur++; ret = xmlStrncat(ret, str, cur - str); cur++; str = cur; continue; } if (*(cur+1) == '}') { /* skip empty AVT */ ret = xmlStrncat(ret, str, cur - str); cur += 2; str = cur; continue; } if ((ret != NULL) || (cur - str > 0)) { ret = xmlStrncat(ret, str, cur - str); str = cur; if (avt->nb_seg == 0) avt->strstart = 1; if ((avt = xsltSetAttrVTsegment(avt, (void *) ret)) == NULL) goto error; ret = NULL; lastavt = 0; } cur++; while ((*cur != 0) && (*cur != '}')) { /* Need to check for literal (bug539741) */ if ((*cur == '\'') || (*cur == '"')) { char delim = *(cur++); while ((*cur != 0) && (*cur != delim)) cur++; if (*cur != 0) cur++; /* skip the ending delimiter */ } else cur++; } if (*cur == 0) { xsltTransformError(NULL, style, attr->parent, "Attribute '%s': The AVT has an unmatched '{'.\n", attr->name); style->errors++; goto error; } str++; expr = xmlStrndup(str, cur - str); if (expr == NULL) { /* * TODO: What needs to be done here? */ XSLT_TODO goto error; } else { xmlXPathCompExprPtr comp; comp = xsltXPathCompile(style, expr); if (comp == NULL) { xsltTransformError(NULL, style, attr->parent, "Attribute '%s': Failed to compile the expression " "'%s' in the AVT.\n", attr->name, expr); style->errors++; goto error; } if (avt->nb_seg == 0) avt->strstart = 0; if (lastavt == 1) { if ((avt = xsltSetAttrVTsegment(avt, NULL)) == NULL) goto error; } if ((avt = xsltSetAttrVTsegment(avt, (void *) comp)) == NULL) goto error; lastavt = 1; xmlFree(expr); expr = NULL; } cur++; str = cur; } else if (*cur == '}') {