class OpenStackParser {

    public Compute parseComputeResponse (String response)
                                                     throws OCCIException {
    	String id, name, state;
    	Attribute flavorId;
        Compute ret = null;
        SAXBuilder builder = new SAXBuilder();
        builder.setValidation(false);
        builder.setIgnoringElementContentWhitespace(true);
        Document xmldoc;
        
        log.info("[OpenStackParser] Parsing compute response...");
        try {
            xmldoc = builder.build(new StringReader(response));
            XPath xpath = XPath.newInstance("//ns:server");
            xpath.addNamespace("ns", COMPUTENAMESPACE);
            xpath.addNamespace("atom", ATOMNAMESPACE);
            
            Element server = (Element)xpath.selectSingleNode(xmldoc);
            
            id    = server.getAttributeValue("id");
            name  = server.getAttributeValue("name");
            state = server.getAttributeValue("status");
            
            xpath = XPath.newInstance("//ns:flavor/@id");
            xpath.addNamespace("ns", COMPUTENAMESPACE);
            xpath.addNamespace("atom", ATOMNAMESPACE);
            
            flavorId = (Attribute) xpath.selectSingleNode(xmldoc);
            
            if (id   != null &&
                name != null &&
                state != null &&
                flavorId != null) {
            	ret = new Compute();
            	
                ret.setHref(id);
                ret.setName(name);
                ret.setState(fromOpenStackComputeState(state));
                ret.setInstanceType(flavorId.getValue());
            } else {
            	OCCIException exception = new OCCIException();
                exception.setMessage(MALFORMEDRESPONSE);
                log.error(MALFORMEDRESPONSE);
                throw exception;
            }
        } catch (JDOMException e) {
            log.error(e.getMessage());
        } catch (IOException e) {
            log.error(e.getMessage());
        }
        log.debug("[OpenStackParser] Compute response parsed...");
        
        return ret;
    }

}