public function xmlSerialize(SabreWriter $writer)
    {
        // Validate the attributes and value.
        if ($this->validate() === true) {
            // Start serializing all allowed child elements
            if (empty($this->elements)) {
                if (property_exists($this, 'value')) {
                    $writer->write($this->value);
                }
            } else {
                $writer->write($this->getChildren());
            }
        } else {
            die("\nValidation on element <".$this->getShortName()."> failed, see details above.\n");
        }
    }