public function toXHTML()
    {
        ob_start();

        $this->displayStyleSheet();

        echo '<div class="swat-exception">';

        printf(
            '<h3>%s</h3>' .
                '<div class="swat-exception-body">' .
                'Message:<div class="swat-exception-message">%s</div>' .
                'Occurred in file <strong>%s</strong> ' .
                'on line <strong>%s</strong>.<br /><br />',
            $this->getSeverityString(),
            nl2br(htmlspecialchars($this->message)),
            $this->file,
            $this->line
        );

        echo 'Stack Trace:<br /><dl>';
        $count = count($this->backtrace);

        foreach ($this->backtrace as $entry) {
            $class = array_key_exists('class', $entry) ? $entry['class'] : null;

            $function = array_key_exists('function', $entry)
                ? $entry['function']
                : null;

            if (array_key_exists('args', $entry)) {
                $arguments = htmlspecialchars(
                    $this->getArguments($entry['args'], $function, $class),
                    null,
                    'UTF-8'
                );
            } else {
                $arguments = '';
            }

            printf(
                '<dt>%s.</dt><dd>In file <strong>%s</strong> ' .
                    'line&nbsp;<strong>%s</strong>.<br />Method: ' .
                    '<strong>%s%s%s(</strong>%s<strong>)</strong></dd>',
                --$count,
                array_key_exists('file', $entry) ? $entry['file'] : 'unknown',
                array_key_exists('line', $entry) ? $entry['line'] : 'unknown',
                $class === null ? '' : $class,
                array_key_exists('type', $entry) ? $entry['type'] : '',
                $function === null ? '' : $function,
                $arguments
            );
        }

        echo '</dl></div></div>';

        return ob_get_clean();
    }