double (final Element element, final String attributeName, double defaultValue) { final String str = element.getAttributeValue(attributeName); if (str == null) { return defaultValue; } try { return Double.parseDouble(str); } catch (NumberFormatException e) { throw new IllegalArgumentException("attribute '" + attributeName + "' is not a proper double: " + str); } }