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 <libxml/tree.h> | 10 #include <libxml/tree.h> |
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 ret = exsltStrReplaceInternal(str, searchStr, replaceStr); | 582 ret = exsltStrReplaceInternal(str, searchStr, replaceStr); |
583 } | 583 } |
584 else { | 584 else { |
585 searchSet = xmlXPathPopNodeSet(ctxt); | 585 searchSet = xmlXPathPopNodeSet(ctxt); |
586 if (searchSet == NULL || xmlXPathCheckError(ctxt)) { | 586 if (searchSet == NULL || xmlXPathCheckError(ctxt)) { |
587 xmlXPathSetTypeError(ctxt); | 587 xmlXPathSetTypeError(ctxt); |
588 goto fail; | 588 goto fail; |
589 } | 589 } |
590 | 590 |
591 str = xmlXPathPopString(ctxt); | 591 str = xmlXPathPopString(ctxt); |
592 » » » ret = xmlStrdup(str); | 592 ret = xmlStrdup(str); |
593 | 593 |
594 » » » for (i = 0; i < searchSet->nodeNr; i++) { | 594 for (i = 0; i < searchSet->nodeNr; i++) { |
595 | 595 » searchStr = xmlXPathCastNodeToString(searchSet->nodeTab[i]); |
596 » » » » searchStr = xmlXPathCastNodeToString(searchSet->
nodeTab[i]); | |
597 | 596 |
598 if (replaceSet != NULL) { | 597 if (replaceSet != NULL) { |
599 replaceStr = NULL; | 598 replaceStr = NULL; |
600 if (i <= replaceSet->nodeNr) { | 599 if (i < replaceSet->nodeNr) { |
601 replaceStr = xmlXPathCastNodeToString(replaceSet->nodeTab[i]); | 600 replaceStr = xmlXPathCastNodeToString(replaceSet->nodeTab[i]); |
602 } | 601 } |
603 | 602 |
604 retSwap = exsltStrReplaceInternal(ret, searchStr, replaceStr); | 603 retSwap = exsltStrReplaceInternal(ret, searchStr, replaceStr); |
605 | 604 |
606 if (replaceStr != NULL) { | 605 if (replaceStr != NULL) { |
607 xmlFree(replaceStr); | 606 xmlFree(replaceStr); |
608 replaceStr = NULL; | 607 replaceStr = NULL; |
609 } | 608 } |
610 } | 609 } |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
667 xsltRegisterExtModuleFunction ((const xmlChar *) "align", | 666 xsltRegisterExtModuleFunction ((const xmlChar *) "align", |
668 EXSLT_STRINGS_NAMESPACE, | 667 EXSLT_STRINGS_NAMESPACE, |
669 exsltStrAlignFunction); | 668 exsltStrAlignFunction); |
670 xsltRegisterExtModuleFunction ((const xmlChar *) "concat", | 669 xsltRegisterExtModuleFunction ((const xmlChar *) "concat", |
671 EXSLT_STRINGS_NAMESPACE, | 670 EXSLT_STRINGS_NAMESPACE, |
672 exsltStrConcatFunction); | 671 exsltStrConcatFunction); |
673 xsltRegisterExtModuleFunction ((const xmlChar *) "replace", | 672 xsltRegisterExtModuleFunction ((const xmlChar *) "replace", |
674 EXSLT_STRINGS_NAMESPACE, | 673 EXSLT_STRINGS_NAMESPACE, |
675 exsltStrReplaceFunction); | 674 exsltStrReplaceFunction); |
676 } | 675 } |
| 676 |
| 677 /** |
| 678 * exsltStrXpathCtxtRegister: |
| 679 * |
| 680 * Registers the EXSLT - Strings module for use outside XSLT |
| 681 */ |
| 682 int |
| 683 exsltStrXpathCtxtRegister (xmlXPathContextPtr ctxt, const xmlChar *prefix) |
| 684 { |
| 685 if (ctxt |
| 686 && prefix |
| 687 && !xmlXPathRegisterNs(ctxt, |
| 688 prefix, |
| 689 (const xmlChar *) EXSLT_STRINGS_NAMESPACE) |
| 690 && !xmlXPathRegisterFuncNS(ctxt, |
| 691 (const xmlChar *) "encode-uri", |
| 692 (const xmlChar *) EXSLT_STRINGS_NAMESPACE, |
| 693 exsltStrEncodeUriFunction) |
| 694 && !xmlXPathRegisterFuncNS(ctxt, |
| 695 (const xmlChar *) "decode-uri", |
| 696 (const xmlChar *) EXSLT_STRINGS_NAMESPACE, |
| 697 exsltStrDecodeUriFunction) |
| 698 && !xmlXPathRegisterFuncNS(ctxt, |
| 699 (const xmlChar *) "padding", |
| 700 (const xmlChar *) EXSLT_STRINGS_NAMESPACE, |
| 701 exsltStrPaddingFunction) |
| 702 && !xmlXPathRegisterFuncNS(ctxt, |
| 703 (const xmlChar *) "align", |
| 704 (const xmlChar *) EXSLT_STRINGS_NAMESPACE, |
| 705 exsltStrAlignFunction) |
| 706 && !xmlXPathRegisterFuncNS(ctxt, |
| 707 (const xmlChar *) "concat", |
| 708 (const xmlChar *) EXSLT_STRINGS_NAMESPACE, |
| 709 exsltStrConcatFunction) |
| 710 && !xmlXPathRegisterFuncNS(ctxt, |
| 711 (const xmlChar *) "replace", |
| 712 (const xmlChar *) EXSLT_STRINGS_NAMESPACE, |
| 713 exsltStrReplaceFunction)) { |
| 714 return 0; |
| 715 } |
| 716 return -1; |
| 717 } |
OLD | NEW |