{"record":{"id":"fb3c17a0414f5002","repo":"apache/maven","slug":"unable-to-parse-element-must-be-a-floating-p","errorCode":null,"errorMessage":"Unable to parse element '{}', must be a floating point number","messagePattern":"Unable to parse element '(.+?)', must be a floating point number","errorType":"exception","errorClass":"XMLStreamException","httpStatus":null,"severity":"error","filePath":"src/mdo/reader.vm","lineNumber":886,"sourceCode":"    /**\n     * Method getDoubleValue.\n     *\n     * @param s a s object.\n     * @param strict a strict object.\n     * @param parser a parser object.\n     * @param attribute a attribute object.\n     * @throws XMLStreamException XMLStreamException if\n     * any.\n     * @return double\n     */\n    private double getDoubleValue(String s, String attribute, XMLStreamReader parser, boolean strict)\n        throws XMLStreamException {\n        if (s != null) {\n            try {\n                return Double.valueOf(s).doubleValue();\n            } catch (NumberFormatException nfe) {\n                if (strict) {\n                    throw new XMLStreamException(\"Unable to parse element '\" + attribute + \"', must be a floating point number\", parser.getLocation(), nfe);\n                }\n            }\n        }\n        return 0;\n    } //-- double getDoubleValue(String, String, XMLStreamReader, boolean)\n\n    /**\n     * Method getFloatValue.\n     *\n     * @param s a s object.\n     * @param strict a strict object.\n     * @param parser a parser object.\n     * @param attribute a attribute object.\n     * @throws XMLStreamException XMLStreamException if\n     * any.\n     * @return float\n     */\n    private float getFloatValue(String s, String attribute, XMLStreamReader parser, boolean strict)","sourceCodeStart":868,"sourceCodeEnd":904,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/src/mdo/reader.vm#L868-L904","documentation":"Thrown by the Modello-generated StAX reader (template src/mdo/reader.vm) when a model XML field typed as double contains text Double.valueOf(String) cannot parse. In strict mode getDoubleValue wraps the NumberFormatException in a javax.xml.stream.XMLStreamException with the offending attribute/element name and parser location, aborting the document. Non-strict readers swallow it and return 0.","triggerScenarios":"Generated reader read()/read(..., strict=true) hits a double field holding an empty string, 'NaN ' with whitespace issues, '1,5' (locale comma), 'abc', or a hex string. Fails on first malformed value in the document.","commonSituations":"Model files generated on machines with comma-decimal locales; hand-edited XML where a numeric field was left empty (<delta/>); incomplete/corrupted downloads in the local repository; schema drift where a field became numeric in a newer model version.","solutions":["Inspect the element named in the message and fix the value to standard Java double syntax (no thousands separators, dot as decimal point).","Delete and re-fetch repository-derived files rather than editing them by hand.","Read with strict=false if a default of 0 is acceptable for your use case.","Fix the producing code to always format doubles with Locale.ROOT."],"exampleFix":"<!-- before -->\n<ratio>1,5</ratio>\n<!-- after -->\n<ratio>1.5</ratio>","handlingStrategy":"validation","validationCode":"static boolean isParsableDouble(String s) { try { Double.parseDouble(s); return true; } catch (NumberFormatException | NullPointerException e) { return false; } }","typeGuard":null,"tryCatchPattern":"try {\n    reader.read(in, true);\n} catch (XMLStreamException e) {\n    if (e.getMessage().contains(\"must be a floating point number\")) { /* repair value or reject input */ }\n}","preventionTips":["Serialize doubles with String.format(Locale.ROOT, \"%s\", d).","Reject empty numeric elements at authoring time.","Diff model XML after automated transformations."],"tags":["xml","stax","modello","number-format","locale"],"backgroundTag":"xml-numeric-field-parse-failed","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}