/** Evaluate in a context where a string is wanted */ public CharSequence evaluateAsString(XPathContext context) throws XPathException { int numArgs = argument.length; Controller ctrl = context.getController(); DecimalSymbols dfs = decimalFormatSymbols; AtomicValue av0 = (AtomicValue) argument[0].evaluateItem(context); if (av0 == null) { av0 = DoubleValue.NaN; } NumericValue number = (NumericValue) av0; if (dfs == null) { // the decimal-format name was not resolved statically if (requireFixup) { // we registered for a fixup, but none came dynamicError("Unknown decimal format name", "XTDE1280", context); return null; } DecimalFormatManager dfm = ctrl.getExecutable().getDecimalFormatManager(); if (numArgs == 2) { dfs = dfm.getDefaultDecimalFormat(); } else { // the decimal-format name was given as a run-time expression String lexicalName = argument[2].evaluateItem(context).getStringValue(); StructuredQName qName = null; try { qName = StructuredQName.fromLexicalQName( lexicalName, false, context.getConfiguration().getNameChecker(), nsContext); } catch (XPathException e) { dynamicError("Invalid decimal format name. " + e.getMessage(), "XTDE1280", context); } dfs = dfm.getNamedDecimalFormat(qName); if (dfs == null) { dynamicError( "format-number function: decimal-format '" + lexicalName + "' is not defined", "XTDE1280", context); return null; } } } SubPicture[] pics = subPictures; if (pics == null) { String format = argument[1].evaluateItem(context).getStringValue(); pics = getSubPictures(format, dfs); } return formatNumber(number, pics, dfs).toString(); }