public function wrap($parser, $nodes, $charset = null) {
        switch ($parser) {
            case Validator::PARSER_XML:
            case Validator::PARSER_XMLDTD:
                return $this->wrapInXmlDocument($nodes, $charset);
            case Validator::PARSER_HTML:
            case Validator::PARSER_HTML5:
                return $this->wrapInHtml5Document($nodes, $charset);
            case Validator::PARSER_HTML4:
            case Validator::PARSER_HTML4TR:
                return $this->wrapInHtml4Document($nodes, $charset, $parser);
            default:
                throw new UnknownParserException('Unknown parser "' . $parser . '"');
        }
    }