ElementHandler::Data UnitSpecializedElementHandler::extract(const xmlpp::Element & element) const { Data ret; ret.parameter = parameter_; ret.unit = unitName_; std::string value = element.get_attribute_value(ret.unit); if ( value.empty() ) throw ExtractionError("Missing value attribute in element"); try { ret.value = boost::lexical_cast<float>(value); } catch ( boost::bad_lexical_cast & ) { throw ExtractionError("Unable to parse value as float: " + value); } return ret; }