private function parseDocument()
    {
        $doc = $this->getDocument();
        if ($doc === null) {
            $this->isParsed = true;
            return;
        }

        $errors = new ErrorCollection();

        if (($data = $doc->getData()) === false) {
            // only single resource is supported in input
            $errors->addDataError("Invalid element");
            throw new JsonApiException($errors);
        }

        $schema        = $this->getSchema();
        $type          = $data->getType();
        $idx           = $data->getIdentifier();
        $attributes    =
            array_intersect_key($data->getAttributes(), $schema->getAttributesMap());

        if ($errors->count() > 0) {
            throw new JsonApiException($errors);
        }

        $this->type          = $type;
        $this->idx           = $idx;
        $this->resourceAttr  = $attributes;

        $this->validateParsed();

        $this->isParsed = true;
    }