Index: third_party/libxslt/libexslt/strings.c |
=================================================================== |
--- third_party/libxslt/libexslt/strings.c (revision 39981) |
+++ third_party/libxslt/libexslt/strings.c (working copy) |
@@ -589,15 +589,14 @@ |
} |
str = xmlXPathPopString(ctxt); |
- ret = xmlStrdup(str); |
+ ret = xmlStrdup(str); |
- for (i = 0; i < searchSet->nodeNr; i++) { |
+ for (i = 0; i < searchSet->nodeNr; i++) { |
+ searchStr = xmlXPathCastNodeToString(searchSet->nodeTab[i]); |
- searchStr = xmlXPathCastNodeToString(searchSet->nodeTab[i]); |
- |
if (replaceSet != NULL) { |
replaceStr = NULL; |
- if (i <= replaceSet->nodeNr) { |
+ if (i < replaceSet->nodeNr) { |
replaceStr = xmlXPathCastNodeToString(replaceSet->nodeTab[i]); |
} |
@@ -674,3 +673,45 @@ |
EXSLT_STRINGS_NAMESPACE, |
exsltStrReplaceFunction); |
} |
+ |
+/** |
+ * exsltStrXpathCtxtRegister: |
+ * |
+ * Registers the EXSLT - Strings module for use outside XSLT |
+ */ |
+int |
+exsltStrXpathCtxtRegister (xmlXPathContextPtr ctxt, const xmlChar *prefix) |
+{ |
+ if (ctxt |
+ && prefix |
+ && !xmlXPathRegisterNs(ctxt, |
+ prefix, |
+ (const xmlChar *) EXSLT_STRINGS_NAMESPACE) |
+ && !xmlXPathRegisterFuncNS(ctxt, |
+ (const xmlChar *) "encode-uri", |
+ (const xmlChar *) EXSLT_STRINGS_NAMESPACE, |
+ exsltStrEncodeUriFunction) |
+ && !xmlXPathRegisterFuncNS(ctxt, |
+ (const xmlChar *) "decode-uri", |
+ (const xmlChar *) EXSLT_STRINGS_NAMESPACE, |
+ exsltStrDecodeUriFunction) |
+ && !xmlXPathRegisterFuncNS(ctxt, |
+ (const xmlChar *) "padding", |
+ (const xmlChar *) EXSLT_STRINGS_NAMESPACE, |
+ exsltStrPaddingFunction) |
+ && !xmlXPathRegisterFuncNS(ctxt, |
+ (const xmlChar *) "align", |
+ (const xmlChar *) EXSLT_STRINGS_NAMESPACE, |
+ exsltStrAlignFunction) |
+ && !xmlXPathRegisterFuncNS(ctxt, |
+ (const xmlChar *) "concat", |
+ (const xmlChar *) EXSLT_STRINGS_NAMESPACE, |
+ exsltStrConcatFunction) |
+ && !xmlXPathRegisterFuncNS(ctxt, |
+ (const xmlChar *) "replace", |
+ (const xmlChar *) EXSLT_STRINGS_NAMESPACE, |
+ exsltStrReplaceFunction)) { |
+ return 0; |
+ } |
+ return -1; |
+} |