msxml3: Don't add a <?xml...?> decl in domdoc_get_xml().

This commit is contained in:
Adam Martinson 2011-05-04 15:38:03 -05:00 committed by Alexandre Julliard
parent 62b5d12c0e
commit 11df66af0b
2 changed files with 24 additions and 9 deletions

View File

@ -2,7 +2,7 @@
* DOM Document implementation
*
* Copyright 2005 Mike McCormack
* Copyright 2010 Adam Martinson for CodeWeavers
* Copyright 2010-2011 Adam Martinson for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -370,11 +370,6 @@ static void free_properties(domdoc_properties* properties)
}
}
static BOOL xmldoc_has_decl(xmlDocPtr doc)
{
return doc->children && (xmlStrEqual(doc->children->name, (xmlChar*)"xml") == 1);
}
/* links a "<?xml" node as a first child */
void xmldoc_link_xmldecl(xmlDocPtr doc, xmlNodePtr node)
{
@ -1394,8 +1389,7 @@ static HRESULT WINAPI domdoc_get_xml(
if(!buf)
return E_OUTOFMEMORY;
options = xmldoc_has_decl(get_doc(This)) ? XML_SAVE_NO_DECL : 0;
options |= XML_SAVE_FORMAT;
options = XML_SAVE_FORMAT | XML_SAVE_NO_DECL;
ctxt = xmlSaveToIO(domdoc_get_xml_writecallback, NULL, buf, "UTF-8", options);
if(!ctxt)

View File

@ -3,7 +3,7 @@
*
* Copyright 2005 Mike McCormack for CodeWeavers
* Copyright 2007-2008 Alistair Leslie-Hughes
* Copyright 2010 Adam Martinson for CodeWeavers
* Copyright 2010-2011 Adam Martinson for CodeWeavers
* Copyright 2010-2011 Nikolay Sivov for CodeWeavers
*
* This library is free software; you can redistribute it and/or
@ -8972,8 +8972,10 @@ static void test_put_nodeTypedValue(void)
static void test_get_xml(void)
{
static const char xmlA[] = "<?xml version=\"1.0\" encoding=\"UTF-16\"?>\r\n<a>test</a>\r\n";
static const char fooA[] = "<foo/>";
IXMLDOMProcessingInstruction *pi;
IXMLDOMNode *first;
IXMLDOMElement *elem = NULL;
IXMLDOMDocument *doc;
VARIANT_BOOL b;
VARIANT v;
@ -9012,6 +9014,25 @@ static void test_get_xml(void)
SysFreeString(xml);
IXMLDOMDocument_Release(doc);
doc = create_document(&IID_IXMLDOMDocument);
hr = IXMLDOMDocument_createElement(doc, _bstr_("foo"), &elem);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IXMLDOMDocument_putref_documentElement(doc, elem);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IXMLDOMDocument_get_xml(doc, &xml);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(memcmp(xml, _bstr_(fooA), (sizeof(fooA)-1)*sizeof(WCHAR)) == 0,
"got %s, expected %s\n", wine_dbgstr_w(xml), fooA);
SysFreeString(xml);
IXMLDOMElement_Release(elem);
IXMLDOMDocument_Release(doc);
free_bstrs();
}