OLD | NEW |
1 /* | 1 /* |
2 * attrvt.c: Implementation of the XSL Transformation 1.0 engine | 2 * attrvt.c: Implementation of the XSL Transformation 1.0 engine |
3 * attribute value template handling part. | 3 * attribute value template handling part. |
4 * | 4 * |
5 * References: | 5 * References: |
6 * http://www.w3.org/TR/1999/REC-xslt-19991116 | 6 * http://www.w3.org/TR/1999/REC-xslt-19991116 |
7 * | 7 * |
8 * Michael Kay "XSLT Programmer's Reference" pp 637-643 | 8 * Michael Kay "XSLT Programmer's Reference" pp 637-643 |
9 * Writing Multiple Output Files | 9 * Writing Multiple Output Files |
10 * | 10 * |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 * needs to be added to the 'segments' array within the xsltAttrVT | 140 * needs to be added to the 'segments' array within the xsltAttrVT |
141 * structure, and at each place the allocated size may have to be | 141 * structure, and at each place the allocated size may have to be |
142 * re-allocated. This routine takes care of that situation. | 142 * re-allocated. This routine takes care of that situation. |
143 * | 143 * |
144 * Returns the avt pointer, which may have been changed by a re-alloc | 144 * Returns the avt pointer, which may have been changed by a re-alloc |
145 */ | 145 */ |
146 static xsltAttrVTPtr | 146 static xsltAttrVTPtr |
147 xsltSetAttrVTsegment(xsltAttrVTPtr avt, void *val) { | 147 xsltSetAttrVTsegment(xsltAttrVTPtr avt, void *val) { |
148 if (avt->nb_seg >= avt->max_seg) { | 148 if (avt->nb_seg >= avt->max_seg) { |
149 avt = (xsltAttrVTPtr) xmlRealloc(avt, sizeof(xsltAttrVT) + | 149 avt = (xsltAttrVTPtr) xmlRealloc(avt, sizeof(xsltAttrVT) + |
150 » » » avt->max_seg * sizeof(void *)); | 150 » » » avt->max_seg * sizeof(void *)); |
151 if (avt == NULL) { | 151 if (avt == NULL) { |
152 return NULL; | 152 return NULL; |
153 } | 153 } |
154 memset(&avt->segments[avt->nb_seg], 0, MAX_AVT_SEG*sizeof(void *)); | 154 memset(&avt->segments[avt->nb_seg], 0, MAX_AVT_SEG*sizeof(void *)); |
155 avt->max_seg += MAX_AVT_SEG; | 155 avt->max_seg += MAX_AVT_SEG; |
156 } | 156 } |
157 avt->segments[avt->nb_seg++] = val; | 157 avt->segments[avt->nb_seg++] = val; |
158 return avt; | 158 return avt; |
159 } | 159 } |
160 | 160 |
(...skipping 10 matching lines...) Expand all Loading... |
171 xsltCompileAttr(xsltStylesheetPtr style, xmlAttrPtr attr) { | 171 xsltCompileAttr(xsltStylesheetPtr style, xmlAttrPtr attr) { |
172 const xmlChar *str; | 172 const xmlChar *str; |
173 const xmlChar *cur; | 173 const xmlChar *cur; |
174 xmlChar *ret = NULL; | 174 xmlChar *ret = NULL; |
175 xmlChar *expr = NULL; | 175 xmlChar *expr = NULL; |
176 xsltAttrVTPtr avt; | 176 xsltAttrVTPtr avt; |
177 int i = 0, lastavt = 0; | 177 int i = 0, lastavt = 0; |
178 | 178 |
179 if ((style == NULL) || (attr == NULL) || (attr->children == NULL)) | 179 if ((style == NULL) || (attr == NULL) || (attr->children == NULL)) |
180 return; | 180 return; |
181 if ((attr->children->type != XML_TEXT_NODE) || | 181 if ((attr->children->type != XML_TEXT_NODE) || |
182 (attr->children->next != NULL)) { | 182 (attr->children->next != NULL)) { |
183 xsltTransformError(NULL, style, attr->parent, | 183 xsltTransformError(NULL, style, attr->parent, |
184 "Attribute '%s': The content is expected to be a single text " | 184 "Attribute '%s': The content is expected to be a single text " |
185 "node when compiling an AVT.\n", attr->name); | 185 "node when compiling an AVT.\n", attr->name); |
186 style->errors++; | 186 style->errors++; |
187 return; | 187 return; |
188 } | 188 } |
189 str = attr->children->content; | 189 str = attr->children->content; |
190 if ((xmlStrchr(str, '{') == NULL) && | 190 if ((xmlStrchr(str, '{') == NULL) && |
191 (xmlStrchr(str, '}') == NULL)) return; | 191 (xmlStrchr(str, '}') == NULL)) return; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 goto error; | 241 goto error; |
242 ret = NULL; | 242 ret = NULL; |
243 lastavt = 0; | 243 lastavt = 0; |
244 } | 244 } |
245 | 245 |
246 cur++; | 246 cur++; |
247 while ((*cur != 0) && (*cur != '}')) { | 247 while ((*cur != 0) && (*cur != '}')) { |
248 /* Need to check for literal (bug539741) */ | 248 /* Need to check for literal (bug539741) */ |
249 if ((*cur == '\'') || (*cur == '"')) { | 249 if ((*cur == '\'') || (*cur == '"')) { |
250 char delim = *(cur++); | 250 char delim = *(cur++); |
251 » » while ((*cur != 0) && (*cur != delim)) | 251 » » while ((*cur != 0) && (*cur != delim)) |
252 cur++; | 252 cur++; |
253 if (*cur != 0) | 253 if (*cur != 0) |
254 cur++; /* skip the ending delimiter */ | 254 cur++; /* skip the ending delimiter */ |
255 } else | 255 } else |
256 cur++; | 256 cur++; |
257 } | 257 } |
258 if (*cur == 0) { | 258 if (*cur == 0) { |
259 xsltTransformError(NULL, style, attr->parent, | 259 xsltTransformError(NULL, style, attr->parent, |
260 "Attribute '%s': The AVT has an unmatched '{'.\n", | 260 "Attribute '%s': The AVT has an unmatched '{'.\n", |
261 attr->name); | 261 attr->name); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 xmlFree(tmp); | 378 xmlFree(tmp); |
379 } else { | 379 } else { |
380 ret = tmp; | 380 ret = tmp; |
381 } | 381 } |
382 } | 382 } |
383 } | 383 } |
384 str = !str; | 384 str = !str; |
385 } | 385 } |
386 return(ret); | 386 return(ret); |
387 } | 387 } |
OLD | NEW |