Package net.sf.saxon.trans

Examples of net.sf.saxon.trans.DecimalFormatManager


        checked = true;
        super.checkArguments(visitor);
        decimalFormatManager = env.getDecimalFormatManager();
        if (decimalFormatManager == null) {
            // create a decimal format manager which will allow a "default default" format only
            decimalFormatManager = new DecimalFormatManager();
        }
        if (argument[1] instanceof StringLiteral) {
            // picture is known statically - optimize for this common case
            picture = ((StringLiteral)argument[1]).getStringValue();
        }
View Full Code Here


            av0 = DoubleValue.NaN;
        }
        NumericValue number = (NumericValue)av0;

        if (dfs == null) {
            DecimalFormatManager dfm = decimalFormatManager;
            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) {
                    XPathException err = new XPathException("Invalid decimal format name. " + e.getMessage());
                    err.setErrorCode("XTDE1280");
                    err.setLocator(this);
                    err.setXPathContext(context);
                    throw err;
                }

                dfs = dfm.getNamedDecimalFormat(qName);
                if (dfs==null) {
                    XPathException err = new XPathException("format-number function: decimal-format '" + lexicalName + "' is not defined");
                    err.setErrorCode("XTDE1280");
                    err.setLocator(this);
                    err.setXPathContext(context);
View Full Code Here

     *         formats are not supported in this environment.
     */

    public DecimalFormatManager getDecimalFormatManager() {
        if (decimalFormatManager == null) {
            decimalFormatManager = new DecimalFormatManager();
        }
        return decimalFormatManager;
    }
View Full Code Here

    public void index(XSLStylesheet top) throws XPathException
    {
        prepareAttributes();
        DecimalSymbols d = makeDecimalFormatSymbols();
        DecimalFormatManager dfm = getPreparedStylesheet().getDecimalFormatManager();
        if (name==null) {
            try {
                dfm.setDefaultDecimalFormat(d, getPrecedence());
            } catch (XPathException err) {
                compileError(err.getMessage(), err.getErrorCodeQName());
            }
        } else {
            try {
                StructuredQName formatName = makeQName(name);
                try {
                    dfm.setNamedDecimalFormat(formatName, d, getPrecedence());
                } catch (XPathException err) {
                    compileError(err.getMessage(), err.getErrorCodeQName());
                }
            } catch (XPathException err) {
                compileError("Invalid decimal format name. " + err.getMessage(), "XTSE0020");
View Full Code Here

     * @return the DecimalFormatManager containing the named xsl:decimal-format definitions
     */

    public DecimalFormatManager getDecimalFormatManager() {
        if (decimalFormatManager == null) {
            decimalFormatManager = new DecimalFormatManager();
        }
        return decimalFormatManager;
    }
View Full Code Here

    */

    public String evaluateAsString(XPathContext context) throws XPathException {
        int numArgs = argument.length;
        Controller ctrl = context.getController();
        DecimalFormatManager dfm = ctrl.getDecimalFormatManager();
        DecimalFormatSymbols dfs;

        AtomicValue av0 = (AtomicValue)argument[0].evaluateItem(context);
        NumericValue number = (NumericValue)av0.getPrimitiveValue();
        String format = argument[1].evaluateItem(context).getStringValue();

        if (numArgs==2) {
            dfs = dfm.getDefaultDecimalFormat();
        } else {
            String uri = dfURI;
            String localName = dfLocalName;
            if (localName==null) {
                // the decimal-format name was given as a run-time expression
                String qname = argument[2].evaluateItem(context).getStringValue();
                if (!Name.isQName(qname)) {
                    DynamicError e = new DynamicError("Decimal format name '" + qname + "' is not a valid QName");
                    e.setXPathContext(context);
                    e.setErrorCode("XT1280");
                    throw e;
                }
                try {
                    String[] parts = Name.getQNameParts(qname);
                    localName = parts[1];
                    uri = nsContext.getURIForPrefix(parts[0], false);
                    if (uri==null) {
                        DynamicError e = new DynamicError("Namespace prefix '" + parts[0] + "' has not been defined");
                        e.setXPathContext(context);
                        e.setErrorCode("XT1280");
                        throw e;
                    }
                } catch (QNameException e) {
                    dynamicError("Invalid decimal format name. " + e.getMessage(), "XT1280", context);
                }
            }
            dfs = dfm.getNamedDecimalFormat(uri, localName);
            if (dfs==null) {
                DynamicError e = new DynamicError(
                    "format-number function: decimal-format '" + localName + "' is not defined");
                e.setXPathContext(context);
                e.setErrorCode("XT1280");
View Full Code Here

                    dfURI = env.getURIForPrefix(parts[0]);
                } catch (QNameException e) {
                    throw new StaticError("Invalid decimal format name. " + e.getMessage());
                }

                DecimalFormatManager dfm = ((ExpressionContext)env).getXSLStylesheet().getDecimalFormatManager();
                requireFixup = true;
                dfm.registerUsage(dfURI, dfLocalName, this);
                    // this causes a callback to the fixup() method, either now, or later if it's a forwards reference
            } else {
                // we need to save the namespace context
                nsContext = env.getNamespaceResolver();
            }
        } else {
            // two arguments only: it uses the default decimal format
            if (env instanceof ExpressionContext) {
                // this is XSLT
                DecimalFormatManager dfm = ((ExpressionContext)env).getXSLStylesheet().getDecimalFormatManager();
                dfm.registerUsage("", "", this);
                // Note: if using the "default default", there will be no fixup call.
            } else {
                // using saxon:decimal-format in some other environment
            }
        }
View Full Code Here

        }
        if (patternSeparator!=null) {
            d.setPatternSeparator(toChar(patternSeparator));
        }

        DecimalFormatManager dfm = getPrincipalStylesheet().getDecimalFormatManager();
        if (name==null) {
            try {
                dfm.setDefaultDecimalFormat(d);
            } catch (TransformerConfigurationException err) {
                compileError(err.getMessage());
            }
        } else {
            try {
                makeNameCode(name);   // checks for reserved namespaces
                String[] parts = Name.getQNameParts(name);
              String uri = getURIForPrefix(parts[0], false);
                try {
                    dfm.setNamedDecimalFormat(uri, parts[1], d);
                } catch (TransformerConfigurationException err) {
                    compileError(err.getMessage());
                }
            } catch (XPathException err) {
                compileError("Invalid decimal format name. " + err.getMessage());
View Full Code Here

    * @return the DecimalFormatManager containing the named xsl:decimal-format definitions
    */

    public DecimalFormatManager getDecimalFormatManager() {
        if (decimalFormatManager==null) {
            decimalFormatManager = new DecimalFormatManager();
        }
        return decimalFormatManager;
    }
View Full Code Here

            if (requireFixup) {
                // we registered for a fixup, but none came
                dynamicError("Unknown decimal format name", "XT1280", context);
                return null;
            }
            DecimalFormatManager dfm = ctrl.getDecimalFormatManager();
            if (numArgs==2) {
                dfs = dfm.getDefaultDecimalFormat();
            } else {
                // the decimal-format name was given as a run-time expression
                String qname = argument[2].evaluateItem(context).getStringValue();
                try {
                    String[] parts = Name.getQNameParts(qname);
                    String localName = parts[1];
                    String uri = nsContext.getURIForPrefix(parts[0], false);
                    if (uri==null) {
                        dynamicError("Namespace prefix '" + parts[0] + "' has not been defined", "XT1280", context);
                        return null;
                    }
                    dfs = dfm.getNamedDecimalFormat(uri, localName);
                    if (dfs==null) {
                        dynamicError(
                            "format-number function: decimal-format '" + localName + "' is not defined", "XT1280", context);
                        return null;
                    }
View Full Code Here

TOP

Related Classes of net.sf.saxon.trans.DecimalFormatManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.