blob: 7b498974c91db53b961f04da61e84554d32445ac [file] [log] [blame]
andersca5eadba02006-08-14 16:32:34 +00001/*
ddkilzer@apple.com6242b772009-01-02 21:10:30 +00002 * Copyright (C) 2003, 2006 Apple Inc. All rights reserved.
weinig7ce64cf2006-12-08 21:12:48 +00003 * Copyright (C) 2006 Samuel Weinig (sam@webkit.org)
andersca5eadba02006-08-14 16:32:34 +00004 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
ddkilzerc8eccec2007-09-26 02:29:57 +000017 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
andersca5eadba02006-08-14 16:32:34 +000018 */
19
20#include "config.h"
21#include "XMLSerializer.h"
22
23#include "Document.h"
weinig7ce64cf2006-12-08 21:12:48 +000024#include "ExceptionCode.h"
andersca5eadba02006-08-14 16:32:34 +000025#include "markup.h"
26
27namespace WebCore {
28
weinig7ce64cf2006-12-08 21:12:48 +000029String XMLSerializer::serializeToString(Node* node, ExceptionCode& ec)
andersca5eadba02006-08-14 16:32:34 +000030{
31 if (!node)
32 return String();
weinig7ce64cf2006-12-08 21:12:48 +000033
34 if (!node->document()) {
35 // Due to the fact that DocumentType nodes are created by the DOMImplementation
36 // and not the Document, it is possible for it to not have a Document associated
37 // with it. It should be the only type of node where this is possible.
38 ASSERT(node->nodeType() == Node::DOCUMENT_TYPE_NODE);
39
40 ec = INVALID_ACCESS_ERR;
41 return String();
42 }
43
andersca5eadba02006-08-14 16:32:34 +000044 return createMarkup(node);
45}
46
weinig7ce64cf2006-12-08 21:12:48 +000047} // namespace WebCore