public function process()
    {
        $printedVariable = $this->getComponent();
        $identifier = $printedVariable->getIdentifier();
        $state = $this->getContext();

        if ($state[$identifier] === null) {
            return '';
        }

        $variable = $state->getVariable($identifier);
        $value = $variable->getValue();

        if ($value === null || $value === '' || ($value instanceof Container && $value->isNull() === true)) {
            return '';
        }

        if ($variable->getCardinality() === Cardinality::SINGLE) {
            return $this->processValue($variable->getBaseType(), $value);
        } elseif ($variable->getCardinality() === Cardinality::ORDERED) {
            $index = $printedVariable->getIndex();

            // $index might be a variable reference.
            if (is_string($index) === true && $state[$index] !== null) {
                $refIndex = $state[$index];

                if ($refIndex instanceof QtiInteger) {
                    // $index references an integer, that's correct.
                    $index = $refIndex->getValue();
                } else {
                    // $index references something else than an integer.
                    // This is not correct. We consider then we have
                    // no index given.
                    $index = -1;
                }
            }

            if (is_int($index) && $index >= 0 && isset($value[$index])) {
                return $this->processValue($variable->getBaseType(), $value[$index]);
            } else {
                // Display all values.
                return $this->processOrderedMultiple($variable);
            }
        } elseif ($variable->getCardinality() === Cardinality::MULTIPLE) {
            // Display all values.
            return $this->processOrderedMultiple($variable);
        } else {
            // This is a record.
            $field = $printedVariable->getField();

            if (empty($field) === false && isset($value[$field])) {
                $v = $value[$field];

                return $this->processValue(Utils::inferBaseType($v), $v);
            } else {
                // Display all values.
                return $this->processRecord($variable);
            }
        }
    }