OLD | NEW |
1 #define IN_LIBEXSLT | 1 #define IN_LIBEXSLT |
2 #include "libexslt/libexslt.h" | 2 #include "libexslt/libexslt.h" |
3 | 3 |
4 #if defined(WIN32) && !defined (__CYGWIN__) && (!__MINGW32__) | 4 #if defined(WIN32) && !defined (__CYGWIN__) && (!__MINGW32__) |
5 #include <win32config.h> | 5 #include <win32config.h> |
6 #else | 6 #else |
7 #include "config.h" | 7 #include "config.h" |
8 #endif | 8 #endif |
9 | 9 |
10 #include <string.h> | 10 #include <string.h> |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 exsltFuncRegisterImportFunc (exsltFuncFunctionData *data, | 99 exsltFuncRegisterImportFunc (exsltFuncFunctionData *data, |
100 exsltFuncImportRegData *ch, | 100 exsltFuncImportRegData *ch, |
101 const xmlChar *URI, const xmlChar *name, | 101 const xmlChar *URI, const xmlChar *name, |
102 ATTRIBUTE_UNUSED const xmlChar *ignored) { | 102 ATTRIBUTE_UNUSED const xmlChar *ignored) { |
103 exsltFuncFunctionData *func=NULL; | 103 exsltFuncFunctionData *func=NULL; |
104 | 104 |
105 if ((data == NULL) || (ch == NULL) || (URI == NULL) || (name == NULL)) | 105 if ((data == NULL) || (ch == NULL) || (URI == NULL) || (name == NULL)) |
106 return; | 106 return; |
107 | 107 |
108 if (ch->ctxt == NULL || ch->hash == NULL) | 108 if (ch->ctxt == NULL || ch->hash == NULL) |
109 » return; | 109 » return; |
110 | 110 |
111 /* Check if already present */ | 111 /* Check if already present */ |
112 func = (exsltFuncFunctionData*)xmlHashLookup2(ch->hash, URI, name); | 112 func = (exsltFuncFunctionData*)xmlHashLookup2(ch->hash, URI, name); |
113 if (func == NULL) { /* Not yet present - copy it in */ | 113 if (func == NULL) { /* Not yet present - copy it in */ |
114 » func = exsltFuncNewFunctionData(); | 114 » func = exsltFuncNewFunctionData(); |
| 115 if (func == NULL) |
| 116 return; |
115 memcpy(func, data, sizeof(exsltFuncFunctionData)); | 117 memcpy(func, data, sizeof(exsltFuncFunctionData)); |
116 if (xmlHashAddEntry2(ch->hash, URI, name, func) < 0) { | 118 if (xmlHashAddEntry2(ch->hash, URI, name, func) < 0) { |
117 xsltGenericError(xsltGenericErrorContext, | 119 xsltGenericError(xsltGenericErrorContext, |
118 » » "Failed to register function {%s}%s\n", | 120 » » "Failed to register function {%s}%s\n", |
119 URI, name); | 121 URI, name); |
120 } else { /* Do the registration */ | 122 } else { /* Do the registration */ |
121 xsltGenericDebug(xsltGenericDebugContext, | 123 xsltGenericDebug(xsltGenericDebugContext, |
122 "exsltFuncRegisterImportFunc: register {%s}%s\n", | 124 "exsltFuncRegisterImportFunc: register {%s}%s\n", |
123 URI, name); | 125 URI, name); |
124 xsltRegisterExtFunction(ch->ctxt, name, URI, | 126 xsltRegisterExtFunction(ch->ctxt, name, URI, |
125 exsltFuncFunctionFunction); | 127 exsltFuncFunctionFunction); |
126 } | 128 } |
127 } | 129 } |
128 } | 130 } |
(...skipping 10 matching lines...) Expand all Loading... |
139 * functions with lower import precedence. | 141 * functions with lower import precedence. |
140 * | 142 * |
141 * Returns the data for this transformation | 143 * Returns the data for this transformation |
142 */ | 144 */ |
143 static exsltFuncData * | 145 static exsltFuncData * |
144 exsltFuncInit (xsltTransformContextPtr ctxt, const xmlChar *URI) { | 146 exsltFuncInit (xsltTransformContextPtr ctxt, const xmlChar *URI) { |
145 exsltFuncData *ret; | 147 exsltFuncData *ret; |
146 xsltStylesheetPtr tmp; | 148 xsltStylesheetPtr tmp; |
147 exsltFuncImportRegData ch; | 149 exsltFuncImportRegData ch; |
148 xmlHashTablePtr hash; | 150 xmlHashTablePtr hash; |
149 | 151 |
150 ret = (exsltFuncData *) xmlMalloc (sizeof(exsltFuncData)); | 152 ret = (exsltFuncData *) xmlMalloc (sizeof(exsltFuncData)); |
151 if (ret == NULL) { | 153 if (ret == NULL) { |
152 xsltGenericError(xsltGenericErrorContext, | 154 xsltGenericError(xsltGenericErrorContext, |
153 "exsltFuncInit: not enough memory\n"); | 155 "exsltFuncInit: not enough memory\n"); |
154 return(NULL); | 156 return(NULL); |
155 } | 157 } |
156 memset(ret, 0, sizeof(exsltFuncData)); | 158 memset(ret, 0, sizeof(exsltFuncData)); |
157 | 159 |
158 ret->result = NULL; | 160 ret->result = NULL; |
159 ret->error = 0; | 161 ret->error = 0; |
160 | 162 |
161 ch.hash = (xmlHashTablePtr) xsltStyleGetExtData(ctxt->style, URI); | 163 ch.hash = (xmlHashTablePtr) xsltStyleGetExtData(ctxt->style, URI); |
162 ret->funcs = ch.hash; | 164 ret->funcs = ch.hash; |
163 xmlHashScanFull(ch.hash, (xmlHashScannerFull) exsltFuncRegisterFunc, ctxt); | 165 xmlHashScanFull(ch.hash, (xmlHashScannerFull) exsltFuncRegisterFunc, ctxt); |
164 tmp = ctxt->style; | 166 tmp = ctxt->style; |
165 ch.ctxt = ctxt; | 167 ch.ctxt = ctxt; |
166 while ((tmp=xsltNextImport(tmp))!=NULL) { | 168 while ((tmp=xsltNextImport(tmp))!=NULL) { |
167 hash = xsltGetExtInfo(tmp, URI); | 169 hash = xsltGetExtInfo(tmp, URI); |
168 if (hash != NULL) { | 170 if (hash != NULL) { |
169 » xmlHashScanFull(hash, | 171 » xmlHashScanFull(hash, |
170 (xmlHashScannerFull) exsltFuncRegisterImportFunc, &ch); | 172 (xmlHashScannerFull) exsltFuncRegisterImportFunc, &ch); |
171 } | 173 } |
172 } | 174 } |
173 | 175 |
174 return(ret); | 176 return(ret); |
175 } | 177 } |
176 | 178 |
177 /** | 179 /** |
178 * exsltFuncShutdown: | 180 * exsltFuncShutdown: |
179 * @ctxt: an XSLT transformation context | 181 * @ctxt: an XSLT transformation context |
180 * @URI: the namespace URI for the extension | 182 * @URI: the namespace URI for the extension |
181 * @data: the module data to free up | 183 * @data: the module data to free up |
182 * | 184 * |
183 * Shutdown the EXSLT - Functions module | 185 * Shutdown the EXSLT - Functions module |
184 * Called at transformation-time. | 186 * Called at transformation-time. |
185 */ | 187 */ |
186 static void | 188 static void |
187 exsltFuncShutdown (xsltTransformContextPtr ctxt ATTRIBUTE_UNUSED, | 189 exsltFuncShutdown (xsltTransformContextPtr ctxt ATTRIBUTE_UNUSED, |
188 const xmlChar *URI ATTRIBUTE_UNUSED, | 190 const xmlChar *URI ATTRIBUTE_UNUSED, |
189 exsltFuncData *data) { | 191 exsltFuncData *data) { |
190 if (data->result != NULL) | 192 if (data->result != NULL) |
191 xmlXPathFreeObject(data->result); | 193 xmlXPathFreeObject(data->result); |
192 xmlFree(data); | 194 xmlFree(data); |
(...skipping 12 matching lines...) Expand all Loading... |
205 static xmlHashTablePtr | 207 static xmlHashTablePtr |
206 exsltFuncStyleInit (xsltStylesheetPtr style ATTRIBUTE_UNUSED, | 208 exsltFuncStyleInit (xsltStylesheetPtr style ATTRIBUTE_UNUSED, |
207 const xmlChar *URI ATTRIBUTE_UNUSED) { | 209 const xmlChar *URI ATTRIBUTE_UNUSED) { |
208 return xmlHashCreate(1); | 210 return xmlHashCreate(1); |
209 } | 211 } |
210 | 212 |
211 /** | 213 /** |
212 * exsltFuncStyleShutdown: | 214 * exsltFuncStyleShutdown: |
213 * @style: an XSLT stylesheet | 215 * @style: an XSLT stylesheet |
214 * @URI: the namespace URI for the extension | 216 * @URI: the namespace URI for the extension |
215 * @data: the stylesheet data to free up | 217 * @data: the stylesheet data to free up |
216 * | 218 * |
217 * Shutdown the EXSLT - Function module | 219 * Shutdown the EXSLT - Function module |
218 * Called at compile-time. | 220 * Called at compile-time. |
219 */ | 221 */ |
220 static void | 222 static void |
221 exsltFuncStyleShutdown (xsltStylesheetPtr style ATTRIBUTE_UNUSED, | 223 exsltFuncStyleShutdown (xsltStylesheetPtr style ATTRIBUTE_UNUSED, |
222 const xmlChar *URI ATTRIBUTE_UNUSED, | 224 const xmlChar *URI ATTRIBUTE_UNUSED, |
223 xmlHashTablePtr data) { | 225 xmlHashTablePtr data) { |
224 xmlHashFree(data, (xmlHashDeallocator) xmlFree); | 226 xmlHashFree(data, (xmlHashDeallocator) xmlFree); |
225 } | 227 } |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 * order (since a variable is "in scope" as soon as it is declared). | 345 * order (since a variable is "in scope" as soon as it is declared). |
344 * However, on entry to this routine, the values (from the caller) are | 346 * However, on entry to this routine, the values (from the caller) are |
345 * in reverse order (held on the XPath context variable stack). To | 347 * in reverse order (held on the XPath context variable stack). To |
346 * accomplish what is required, I have added code to pop the XPath | 348 * accomplish what is required, I have added code to pop the XPath |
347 * objects off of the stack at the beginning and save them, then use | 349 * objects off of the stack at the beginning and save them, then use |
348 * them (in the reverse order) as the params are evaluated. This | 350 * them (in the reverse order) as the params are evaluated. This |
349 * requires an xmlMalloc/xmlFree for each param set by the caller, | 351 * requires an xmlMalloc/xmlFree for each param set by the caller, |
350 * which is not very nice. There is probably a much better solution | 352 * which is not very nice. There is probably a much better solution |
351 * (like change other code to delay the evaluation). | 353 * (like change other code to delay the evaluation). |
352 */ | 354 */ |
353 /* | 355 /* |
354 * In order to give the function params and variables a new 'scope' | 356 * In order to give the function params and variables a new 'scope' |
355 * we change varsBase in the context. | 357 * we change varsBase in the context. |
356 */ | 358 */ |
357 oldBase = tctxt->varsBase; | 359 oldBase = tctxt->varsBase; |
358 tctxt->varsBase = tctxt->varsNr; | 360 tctxt->varsBase = tctxt->varsNr; |
359 /* If there are any parameters */ | 361 /* If there are any parameters */ |
360 if (paramNode != NULL) { | 362 if (paramNode != NULL) { |
361 /* Fetch the stored argument values from the caller */ | 363 /* Fetch the stored argument values from the caller */ |
362 for (i = 0; i < nargs; i++) { | 364 for (i = 0; i < nargs; i++) { |
363 savedObj = xmlMalloc(sizeof(struct objChain)); | 365 savedObj = xmlMalloc(sizeof(struct objChain)); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 fake = xmlNewDocNode(tctxt->output, NULL, | 406 fake = xmlNewDocNode(tctxt->output, NULL, |
405 (const xmlChar *)"fake", NULL); | 407 (const xmlChar *)"fake", NULL); |
406 oldInsert = tctxt->insert; | 408 oldInsert = tctxt->insert; |
407 tctxt->insert = fake; | 409 tctxt->insert = fake; |
408 xsltApplyOneTemplate (tctxt, xmlXPathGetContextNode(ctxt), | 410 xsltApplyOneTemplate (tctxt, xmlXPathGetContextNode(ctxt), |
409 func->content, NULL, NULL); | 411 func->content, NULL, NULL); |
410 xsltLocalVariablePop(tctxt, tctxt->varsBase, -2); | 412 xsltLocalVariablePop(tctxt, tctxt->varsBase, -2); |
411 tctxt->insert = oldInsert; | 413 tctxt->insert = oldInsert; |
412 tctxt->varsBase = oldBase; /* restore original scope */ | 414 tctxt->varsBase = oldBase; /* restore original scope */ |
413 if (params != NULL) | 415 if (params != NULL) |
414 » xsltFreeStackElemList(params); | 416 » xsltFreeStackElemList(params); |
415 | 417 |
416 if (data->error != 0) | 418 if (data->error != 0) |
417 goto error; | 419 goto error; |
418 | 420 |
419 if (data->result != NULL) { | 421 if (data->result != NULL) { |
420 ret = data->result; | 422 ret = data->result; |
421 } else | 423 } else |
422 ret = xmlXPathNewCString(""); | 424 ret = xmlXPathNewCString(""); |
423 | 425 |
424 data->result = oldResult; | 426 data->result = oldResult; |
(...skipping 27 matching lines...) Expand all Loading... |
452 } | 454 } |
453 | 455 |
454 | 456 |
455 static void | 457 static void |
456 exsltFuncFunctionComp (xsltStylesheetPtr style, xmlNodePtr inst) { | 458 exsltFuncFunctionComp (xsltStylesheetPtr style, xmlNodePtr inst) { |
457 xmlChar *name, *prefix; | 459 xmlChar *name, *prefix; |
458 xmlNsPtr ns; | 460 xmlNsPtr ns; |
459 xmlHashTablePtr data; | 461 xmlHashTablePtr data; |
460 exsltFuncFunctionData *func; | 462 exsltFuncFunctionData *func; |
461 | 463 |
462 if ((style == NULL) || (inst == NULL)) | 464 if ((style == NULL) || (inst == NULL) || (inst->type != XML_ELEMENT_NODE)) |
463 return; | 465 return; |
464 | 466 |
465 | |
466 { | 467 { |
467 xmlChar *qname; | 468 xmlChar *qname; |
468 | 469 |
469 qname = xmlGetProp(inst, (const xmlChar *) "name"); | 470 qname = xmlGetProp(inst, (const xmlChar *) "name"); |
470 name = xmlSplitQName2 (qname, &prefix); | 471 name = xmlSplitQName2 (qname, &prefix); |
471 xmlFree(qname); | 472 xmlFree(qname); |
472 } | 473 } |
473 if ((name == NULL) || (prefix == NULL)) { | 474 if ((name == NULL) || (prefix == NULL)) { |
474 xsltGenericError(xsltGenericErrorContext, | 475 xsltGenericError(xsltGenericErrorContext, |
475 "func:function: not a QName\n"); | 476 "func:function: not a QName\n"); |
476 if (name != NULL) | 477 if (name != NULL) |
477 xmlFree(name); | 478 xmlFree(name); |
478 return; | 479 return; |
479 } | 480 } |
480 /* namespace lookup */ | 481 /* namespace lookup */ |
481 ns = xmlSearchNs (inst->doc, inst, prefix); | 482 ns = xmlSearchNs (inst->doc, inst, prefix); |
482 if (ns == NULL) { | 483 if (ns == NULL) { |
483 xsltGenericError(xsltGenericErrorContext, | 484 xsltGenericError(xsltGenericErrorContext, |
484 "func:function: undeclared prefix %s\n", | 485 "func:function: undeclared prefix %s\n", |
485 prefix); | 486 prefix); |
486 xmlFree(name); | 487 xmlFree(name); |
487 xmlFree(prefix); | 488 xmlFree(prefix); |
488 return; | 489 return; |
489 } | 490 } |
490 xmlFree(prefix); | 491 xmlFree(prefix); |
491 | 492 |
| 493 xsltParseTemplateContent(style, inst); |
| 494 |
492 /* | 495 /* |
493 * Create function data | 496 * Create function data |
494 */ | 497 */ |
495 func = exsltFuncNewFunctionData(); | 498 func = exsltFuncNewFunctionData(); |
| 499 if (func == NULL) { |
| 500 xmlFree(name); |
| 501 return; |
| 502 } |
496 func->content = inst->children; | 503 func->content = inst->children; |
497 while (IS_XSLT_ELEM(func->content) && | 504 while (IS_XSLT_ELEM(func->content) && |
498 IS_XSLT_NAME(func->content, "param")) { | 505 IS_XSLT_NAME(func->content, "param")) { |
499 func->content = func->content->next; | 506 func->content = func->content->next; |
500 func->nargs++; | 507 func->nargs++; |
501 } | 508 } |
502 | 509 |
503 xsltParseTemplateContent(style, inst); | |
504 | |
505 /* | 510 /* |
506 * Register the function data such that it can be retrieved | 511 * Register the function data such that it can be retrieved |
507 * by exslFuncFunctionFunction | 512 * by exslFuncFunctionFunction |
508 */ | 513 */ |
509 #ifdef XSLT_REFACTORED | 514 #ifdef XSLT_REFACTORED |
510 /* | 515 /* |
511 * Ensure that the hash table will be stored in the *current* | 516 * Ensure that the hash table will be stored in the *current* |
512 * stylesheet level in order to correctly evaluate the | 517 * stylesheet level in order to correctly evaluate the |
513 * import precedence. | 518 * import precedence. |
514 */ | 519 */ |
(...skipping 24 matching lines...) Expand all Loading... |
539 xmlFree(name); | 544 xmlFree(name); |
540 } | 545 } |
541 | 546 |
542 static xsltElemPreCompPtr | 547 static xsltElemPreCompPtr |
543 exsltFuncResultComp (xsltStylesheetPtr style, xmlNodePtr inst, | 548 exsltFuncResultComp (xsltStylesheetPtr style, xmlNodePtr inst, |
544 xsltTransformFunction function) { | 549 xsltTransformFunction function) { |
545 xmlNodePtr test; | 550 xmlNodePtr test; |
546 xmlChar *sel; | 551 xmlChar *sel; |
547 exsltFuncResultPreComp *ret; | 552 exsltFuncResultPreComp *ret; |
548 | 553 |
| 554 if ((style == NULL) || (inst == NULL) || (inst->type != XML_ELEMENT_NODE)) |
| 555 return (NULL); |
| 556 |
549 /* | 557 /* |
550 * "Validity" checking | 558 * "Validity" checking |
551 */ | 559 */ |
552 /* it is an error to have any following sibling elements aside | 560 /* it is an error to have any following sibling elements aside |
553 * from the xsl:fallback element. | 561 * from the xsl:fallback element. |
554 */ | 562 */ |
555 for (test = inst->next; test != NULL; test = test->next) { | 563 for (test = inst->next; test != NULL; test = test->next) { |
556 if (test->type != XML_ELEMENT_NODE) | 564 if (test->type != XML_ELEMENT_NODE) |
557 continue; | 565 continue; |
558 if (IS_XSLT_ELEM(test) && IS_XSLT_NAME(test, "fallback")) | 566 if (IS_XSLT_ELEM(test) && IS_XSLT_NAME(test, "fallback")) |
559 continue; | 567 continue; |
560 xsltGenericError(xsltGenericErrorContext, | 568 xsltGenericError(xsltGenericErrorContext, |
561 "exsltFuncResultElem: only xsl:fallback is " | 569 "exsltFuncResultElem: only xsl:fallback is " |
562 "allowed to follow func:result\n"); | 570 "allowed to follow func:result\n"); |
| 571 style->errors++; |
563 return (NULL); | 572 return (NULL); |
564 } | 573 } |
565 /* it is an error for a func:result element to not be a descendant | 574 /* it is an error for a func:result element to not be a descendant |
566 * of func:function. | 575 * of func:function. |
567 * it is an error if a func:result occurs within a func:result | 576 * it is an error if a func:result occurs within a func:result |
568 * element. | 577 * element. |
569 * it is an error if instanciating the content of a variable | 578 * it is an error if instanciating the content of a variable |
570 * binding element (i.e. xsl:variable, xsl:param) results in the | 579 * binding element (i.e. xsl:variable, xsl:param) results in the |
571 * instanciation of a func:result element. | 580 * instanciation of a func:result element. |
572 */ | 581 */ |
573 for (test = inst->parent; test != NULL; test = test->parent) { | 582 for (test = inst->parent; test != NULL; test = test->parent) { |
574 if (IS_XSLT_ELEM(test) && | 583 if (IS_XSLT_ELEM(test) && |
575 IS_XSLT_NAME(test, "stylesheet")) { | 584 IS_XSLT_NAME(test, "stylesheet")) { |
576 xsltGenericError(xsltGenericErrorContext, | 585 xsltGenericError(xsltGenericErrorContext, |
577 "func:result element not a descendant " | 586 "func:result element not a descendant " |
578 "of a func:function\n"); | 587 "of a func:function\n"); |
| 588 style->errors++; |
579 return (NULL); | 589 return (NULL); |
580 } | 590 } |
581 if ((test->ns != NULL) && | 591 if ((test->ns != NULL) && |
582 (xmlStrEqual(test->ns->href, EXSLT_FUNCTIONS_NAMESPACE))) { | 592 (xmlStrEqual(test->ns->href, EXSLT_FUNCTIONS_NAMESPACE))) { |
583 if (xmlStrEqual(test->name, (const xmlChar *) "function")) { | 593 if (xmlStrEqual(test->name, (const xmlChar *) "function")) { |
584 break; | 594 break; |
585 } | 595 } |
586 if (xmlStrEqual(test->name, (const xmlChar *) "result")) { | 596 if (xmlStrEqual(test->name, (const xmlChar *) "result")) { |
587 xsltGenericError(xsltGenericErrorContext, | 597 xsltGenericError(xsltGenericErrorContext, |
588 "func:result element not allowed within" | 598 "func:result element not allowed within" |
589 " another func:result element\n"); | 599 " another func:result element\n"); |
| 600 style->errors++; |
590 return (NULL); | 601 return (NULL); |
591 } | 602 } |
592 } | 603 } |
593 if (IS_XSLT_ELEM(test) && | 604 if (IS_XSLT_ELEM(test) && |
594 (IS_XSLT_NAME(test, "variable") || | 605 (IS_XSLT_NAME(test, "variable") || |
595 IS_XSLT_NAME(test, "param"))) { | 606 IS_XSLT_NAME(test, "param"))) { |
596 xsltGenericError(xsltGenericErrorContext, | 607 xsltGenericError(xsltGenericErrorContext, |
597 "func:result element not allowed within" | 608 "func:result element not allowed within" |
598 " a variable binding element\n"); | 609 " a variable binding element\n"); |
| 610 style->errors++; |
599 return (NULL); | 611 return (NULL); |
600 } | 612 } |
601 } | 613 } |
602 | 614 |
603 /* | 615 /* |
604 * Precomputation | 616 * Precomputation |
605 */ | 617 */ |
606 ret = (exsltFuncResultPreComp *) | 618 ret = (exsltFuncResultPreComp *) |
607 xmlMalloc (sizeof(exsltFuncResultPreComp)); | 619 xmlMalloc (sizeof(exsltFuncResultPreComp)); |
608 if (ret == NULL) { | 620 if (ret == NULL) { |
609 xsltPrintErrorContext(NULL, NULL, NULL); | 621 xsltPrintErrorContext(NULL, NULL, NULL); |
610 xsltGenericError(xsltGenericErrorContext, | 622 xsltGenericError(xsltGenericErrorContext, |
611 "exsltFuncResultComp : malloc failed\n"); | 623 "exsltFuncResultComp : malloc failed\n"); |
| 624 style->errors++; |
612 return (NULL); | 625 return (NULL); |
613 } | 626 } |
614 memset(ret, 0, sizeof(exsltFuncResultPreComp)); | 627 memset(ret, 0, sizeof(exsltFuncResultPreComp)); |
615 | 628 |
616 xsltInitElemPreComp ((xsltElemPreCompPtr) ret, style, inst, function, | 629 xsltInitElemPreComp ((xsltElemPreCompPtr) ret, style, inst, function, |
617 (xsltElemPreCompDeallocator) exsltFreeFuncResultPreComp); | 630 (xsltElemPreCompDeallocator) exsltFreeFuncResultPreComp); |
618 ret->select = NULL; | 631 ret->select = NULL; |
619 | 632 |
620 /* | 633 /* |
621 * Precompute the select attribute | 634 * Precompute the select attribute |
(...skipping 15 matching lines...) Expand all Loading... |
637 } | 650 } |
638 return ((xsltElemPreCompPtr) ret); | 651 return ((xsltElemPreCompPtr) ret); |
639 } | 652 } |
640 | 653 |
641 static void | 654 static void |
642 exsltFuncResultElem (xsltTransformContextPtr ctxt, | 655 exsltFuncResultElem (xsltTransformContextPtr ctxt, |
643 xmlNodePtr node ATTRIBUTE_UNUSED, xmlNodePtr inst, | 656 xmlNodePtr node ATTRIBUTE_UNUSED, xmlNodePtr inst, |
644 exsltFuncResultPreComp *comp) { | 657 exsltFuncResultPreComp *comp) { |
645 exsltFuncData *data; | 658 exsltFuncData *data; |
646 xmlXPathObjectPtr ret; | 659 xmlXPathObjectPtr ret; |
647 | 660 |
648 | 661 |
649 /* It is an error if instantiating the content of the | 662 /* It is an error if instantiating the content of the |
650 * func:function element results in the instantiation of more than | 663 * func:function element results in the instantiation of more than |
651 * one func:result elements. | 664 * one func:result elements. |
652 */ | 665 */ |
653 data = (exsltFuncData *) xsltGetExtData (ctxt, EXSLT_FUNCTIONS_NAMESPACE); | 666 data = (exsltFuncData *) xsltGetExtData (ctxt, EXSLT_FUNCTIONS_NAMESPACE); |
654 if (data == NULL) { | 667 if (data == NULL) { |
655 xsltGenericError(xsltGenericErrorContext, | 668 xsltGenericError(xsltGenericErrorContext, |
656 "exsltFuncReturnElem: data == NULL\n"); | 669 "exsltFuncReturnElem: data == NULL\n"); |
657 return; | 670 return; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 xmlNodePtr oldInsert; | 726 xmlNodePtr oldInsert; |
714 xmlDocPtr container; | 727 xmlDocPtr container; |
715 | 728 |
716 container = xsltCreateRVT(ctxt); | 729 container = xsltCreateRVT(ctxt); |
717 if (container == NULL) { | 730 if (container == NULL) { |
718 xsltGenericError(xsltGenericErrorContext, | 731 xsltGenericError(xsltGenericErrorContext, |
719 "exsltFuncResultElem: out of memory\n"); | 732 "exsltFuncResultElem: out of memory\n"); |
720 data->error = 1; | 733 data->error = 1; |
721 return; | 734 return; |
722 } | 735 } |
723 » xsltRegisterLocalRVT(ctxt, container);» | 736 » xsltRegisterLocalRVT(ctxt, container); |
724 | 737 |
725 oldInsert = ctxt->insert; | 738 oldInsert = ctxt->insert; |
726 ctxt->insert = (xmlNodePtr) container; | 739 ctxt->insert = (xmlNodePtr) container; |
727 xsltApplyOneTemplate (ctxt, ctxt->xpathCtxt->node, | 740 xsltApplyOneTemplate (ctxt, ctxt->xpathCtxt->node, |
728 inst->children, NULL, NULL); | 741 inst->children, NULL, NULL); |
729 ctxt->insert = oldInsert; | 742 ctxt->insert = oldInsert; |
730 | 743 |
731 ret = xmlXPathNewValueTree((xmlNodePtr) container); | 744 ret = xmlXPathNewValueTree((xmlNodePtr) container); |
732 if (ret == NULL) { | 745 if (ret == NULL) { |
733 xsltGenericError(xsltGenericErrorContext, | 746 xsltGenericError(xsltGenericErrorContext, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
765 (xsltStyleExtShutdownFunction) exsltFuncStyleShutdown); | 778 (xsltStyleExtShutdownFunction) exsltFuncStyleShutdown); |
766 | 779 |
767 xsltRegisterExtModuleTopLevel ((const xmlChar *) "function", | 780 xsltRegisterExtModuleTopLevel ((const xmlChar *) "function", |
768 EXSLT_FUNCTIONS_NAMESPACE, | 781 EXSLT_FUNCTIONS_NAMESPACE, |
769 exsltFuncFunctionComp); | 782 exsltFuncFunctionComp); |
770 xsltRegisterExtModuleElement ((const xmlChar *) "result", | 783 xsltRegisterExtModuleElement ((const xmlChar *) "result", |
771 EXSLT_FUNCTIONS_NAMESPACE, | 784 EXSLT_FUNCTIONS_NAMESPACE, |
772 (xsltPreComputeFunction)exsltFuncResultComp, | 785 (xsltPreComputeFunction)exsltFuncResultComp, |
773 (xsltTransformFunction) exsltFuncResultElem); | 786 (xsltTransformFunction) exsltFuncResultElem); |
774 } | 787 } |
OLD | NEW |