protected function buildTemplateResponseProcessing(DOMElement $data){
        $returnValue = null;

        if($data->hasAttribute('template') && $data->childNodes->length === 0){
            $templateUri = (string) $data->getAttribute('template');
            $returnValue = new Template($templateUri);
        }elseif($data->childNodes->length === 1){

            //check response declaration identifier, which must be RESPONSE in standard rp
            $responses = $this->item->getResponses();
            if(count($responses) == 1){
                $response = reset($responses);
                if($response->getIdentifier() !== 'RESPONSE'){
                    throw new UnexpectedResponseProcessing('the response declaration identifier must be RESPONSE');
                }
            }else{
                //invalid number of response declaration
                throw new UnexpectedResponseProcessing('the item must have exactly one response declaration');
            }

            $patternCorrectIMS = 'responseCondition [count(./*) = 2 ] [name(./*[1]) = "responseIf" ] [count(./responseIf/*) = 2 ] [name(./responseIf/*[1]) = "match" ] [name(./responseIf/match/*[1]) = "variable" ] [name(./responseIf/match/*[2]) = "correct" ] [name(./responseIf/*[2]) = "setOutcomeValue" ] [name(./responseIf/setOutcomeValue/*[1]) = "baseValue" ] [name(./*[2]) = "responseElse" ] [count(./responseElse/*) = 1 ] [name(./responseElse/*[1]) = "setOutcomeValue" ] [name(./responseElse/setOutcomeValue/*[1]) = "baseValue"]';
            $patternMappingIMS = 'responseCondition [count(./*) = 2] [name(./*[1]) = "responseIf"] [count(./responseIf/*) = 2] [name(./responseIf/*[1]) = "isNull"] [name(./responseIf/isNull/*[1]) = "variable"] [name(./responseIf/*[2]) = "setOutcomeValue"] [name(./responseIf/setOutcomeValue/*[1]) = "variable"] [name(./*[2]) = "responseElse"] [count(./responseElse/*) = 1] [name(./responseElse/*[1]) = "setOutcomeValue"] [name(./responseElse/setOutcomeValue/*[1]) = "mapResponse"]';
            $patternMappingPointIMS = 'responseCondition [count(./*) = 2] [name(./*[1]) = "responseIf"] [count(./responseIf/*) = 2] [name(./responseIf/*[1]) = "isNull"] [name(./responseIf/isNull/*[1]) = "variable"] [name(./responseIf/*[2]) = "setOutcomeValue"] [name(./responseIf/setOutcomeValue/*[1]) = "variable"] [name(./*[2]) = "responseElse"] [count(./responseElse/*) = 1] [name(./responseElse/*[1]) = "setOutcomeValue"] [name(./responseElse/setOutcomeValue/*[1]) = "mapResponsePoint"]';
            if(count($this->queryXPath($patternCorrectIMS)) == 1){
                $returnValue = new Template(Template::MATCH_CORRECT);
            }elseif(count($this->queryXPath($patternMappingIMS)) == 1){
                $returnValue = new Template(Template::MAP_RESPONSE);
            }elseif(count($this->queryXPath($patternMappingPointIMS)) == 1){
                $returnValue = new Template(Template::MAP_RESPONSE_POINT);
            }else{
                throw new UnexpectedResponseProcessing('not Template, wrong rule');
            }
            $returnValue->setRelatedItem($this->item);
        }else{
            throw new UnexpectedResponseProcessing('not Template');
        }

        return $returnValue;
    }