Index: third_party/libxslt/libxslt/functions.c |
diff --git a/third_party/libxslt/libxslt/functions.c b/third_party/libxslt/libxslt/functions.c |
index ec22203f4ca21f7ac5ac13da4b39695e22466fa0..5cc9da59244e6e49f56fb9fbb4537fe5eda7d7d7 100644 |
--- a/third_party/libxslt/libxslt/functions.c |
+++ b/third_party/libxslt/libxslt/functions.c |
@@ -603,12 +603,15 @@ xsltFormatNumberFunction(xmlXPathParserContextPtr ctxt, int nargs) |
xmlXPathObjectPtr formatObj = NULL; |
xmlXPathObjectPtr decimalObj = NULL; |
xsltStylesheetPtr sheet; |
- xsltDecimalFormatPtr formatValues; |
+ xsltDecimalFormatPtr formatValues = NULL; |
xmlChar *result; |
+ const xmlChar *ncname; |
+ const xmlChar *prefix = NULL; |
+ const xmlChar *nsUri = NULL; |
xsltTransformContextPtr tctxt; |
tctxt = xsltXPathGetTransformContext(ctxt); |
- if (tctxt == NULL) |
+ if ((tctxt == NULL) || (tctxt->inst == NULL)) |
return; |
sheet = tctxt->style; |
if (sheet == NULL) |
@@ -619,7 +622,21 @@ xsltFormatNumberFunction(xmlXPathParserContextPtr ctxt, int nargs) |
case 3: |
CAST_TO_STRING; |
decimalObj = valuePop(ctxt); |
- formatValues = xsltDecimalFormatGetByName(sheet, decimalObj->stringval); |
+ ncname = xsltSplitQName(sheet->dict, decimalObj->stringval, &prefix); |
+ if (prefix != NULL) { |
+ xmlNsPtr ns = xmlSearchNs(tctxt->inst->doc, tctxt->inst, prefix); |
+ if (ns == NULL) { |
+ xsltTransformError(tctxt, NULL, NULL, |
+ "format-number : No namespace found for QName '%s:%s'\n", |
+ prefix, ncname); |
+ sheet->errors++; |
+ ncname = NULL; |
+ } |
+ nsUri = ns->href; |
+ } |
+ if (ncname != NULL) { |
+ formatValues = xsltDecimalFormatGetByQName(sheet, nsUri, ncname); |
+ } |
if (formatValues == NULL) { |
xsltTransformError(tctxt, NULL, NULL, |
"format-number() : undeclared decimal format '%s'\n", |