protected function unmarshall(DOMElement $element)
    {
        $object = null;

        if (($baseType = $this->getDOMElementAttributeAs($element, 'baseType', 'string')) !== null) {
            // baseType attribute is set -> part of a record.
            $baseTypeCst = BaseType::getConstantByName($baseType);
            if ($baseTypeCst !== false) {
                $object = new Value(Utils::stringToDatatype(trim($element->nodeValue), $baseTypeCst), $baseTypeCst);
                $object->setPartOfRecord(true);
            } else {
                $msg = "The 'baseType' attribute value ('${value}') is not a valid QTI baseType in element '" . $element->localName . "'.";
                throw new UnmarshallingException($msg, $element);
            }
        } else {
            // baseType attribute not set -> not part of a record.
            $nodeValue = trim($element->nodeValue);
            if ($nodeValue !== '') {
                // Try to use the marshaller as parametric to know how to unserialize the value.
                if ($this->getBaseType() != -1) {
                    $object = new Value(Utils::stringToDatatype($nodeValue, $this->getBaseType()), $this->getBaseType());
                } else {
                    // value used as plain string (at your own risks).
                    $object = new Value($nodeValue);
                }

            } else {
                $msg = "The element '" . $element->localName . "' has no value.";
                throw new UnmarshallingException($msg, $element);
            }
        }

        if (($value = $this->getDOMElementAttributeAs($element, 'fieldIdentifier', 'string')) !== null) {
            $object->setFieldIdentifier($value);
        }

        return $object;
    }