diff --git a/dlls/msxml3/domdoc.c b/dlls/msxml3/domdoc.c
index 68f47a71601..4bb4fa4ff0d 100644
--- a/dlls/msxml3/domdoc.c
+++ b/dlls/msxml3/domdoc.c
@@ -78,7 +78,7 @@ static const WCHAR PropertyResolveExternalsW[] = {'R','e','s','o','l','v','e','E
* tests can go here (data shared between all instances).
* We need to preserve this when reloading a document,
* and also need access to it from the libxml backend. */
-typedef struct _domdoc_properties {
+typedef struct {
MSXML_VERSION version;
VARIANT_BOOL preserving;
IXMLDOMSchemaCollection2* schemaCache;
@@ -285,7 +285,7 @@ static xmldoc_priv * create_priv(void)
return priv;
}
-static domdoc_properties * create_properties(MSXML_VERSION version)
+static domdoc_properties *create_properties(MSXML_VERSION version)
{
domdoc_properties *properties = heap_alloc(sizeof(domdoc_properties));
@@ -2230,18 +2230,17 @@ static HRESULT WINAPI domdoc_abort(
return E_NOTIMPL;
}
-
/* don't rely on data to be in BSTR format, treat it as WCHAR string */
static HRESULT WINAPI domdoc_loadXML(
IXMLDOMDocument3 *iface,
- BSTR bstrXML,
+ BSTR data,
VARIANT_BOOL* isSuccessful )
{
domdoc *This = impl_from_IXMLDOMDocument3( iface );
xmlDocPtr xmldoc = NULL;
HRESULT hr = S_FALSE, hr2;
- TRACE("(%p)->(%s %p)\n", This, debugstr_w( bstrXML ), isSuccessful );
+ TRACE("(%p)->(%s %p)\n", This, debugstr_w(data), isSuccessful );
assert ( &This->node );
@@ -2249,9 +2248,16 @@ static HRESULT WINAPI domdoc_loadXML(
{
*isSuccessful = VARIANT_FALSE;
- if ( bstrXML )
+ if (data)
{
- xmldoc = doparse(This, (LPCSTR)bstrXML, lstrlenW(bstrXML) * sizeof(*bstrXML), XML_CHAR_ENCODING_UTF16LE);
+ WCHAR *ptr = data;
+
+ /* skip leading spaces if needed */
+ if (This->properties->version == MSXML_DEFAULT || This->properties->version == MSXML26)
+ while (*ptr)
+ if (isspaceW(*ptr)) ptr++; else break;
+
+ xmldoc = doparse(This, (char*)ptr, strlenW(ptr)*sizeof(WCHAR), XML_CHAR_ENCODING_UTF16LE);
if ( !xmldoc )
{
This->error = E_FAIL;
diff --git a/dlls/msxml3/factory.c b/dlls/msxml3/factory.c
index 11927803f54..e3b910a070e 100644
--- a/dlls/msxml3/factory.c
+++ b/dlls/msxml3/factory.c
@@ -59,24 +59,24 @@ struct clsid_version_t
static const struct clsid_version_t clsid_versions_table[] =
{
{ &CLSID_DOMDocument, MSXML_DEFAULT },
- { &CLSID_DOMDocument2, MSXML_DEFAULT },
- { &CLSID_DOMDocument26, MSXML_DEFAULT },
- { &CLSID_DOMDocument30, MSXML3 },
- { &CLSID_DOMDocument40, MSXML4 },
- { &CLSID_DOMDocument60, MSXML6 },
+ { &CLSID_DOMDocument2, MSXML2 },
+ { &CLSID_DOMDocument26, MSXML26 },
+ { &CLSID_DOMDocument30, MSXML3 },
+ { &CLSID_DOMDocument40, MSXML4 },
+ { &CLSID_DOMDocument60, MSXML6 },
{ &CLSID_DOMFreeThreadedDocument, MSXML_DEFAULT },
{ &CLSID_FreeThreadedDOMDocument, MSXML_DEFAULT },
- { &CLSID_FreeThreadedDOMDocument26, MSXML_DEFAULT },
- { &CLSID_FreeThreadedDOMDocument30, MSXML3 },
- { &CLSID_FreeThreadedDOMDocument40, MSXML4 },
- { &CLSID_FreeThreadedDOMDocument60, MSXML6 },
+ { &CLSID_FreeThreadedDOMDocument26, MSXML26 },
+ { &CLSID_FreeThreadedDOMDocument30, MSXML3 },
+ { &CLSID_FreeThreadedDOMDocument40, MSXML4 },
+ { &CLSID_FreeThreadedDOMDocument60, MSXML6 },
{ &CLSID_XMLSchemaCache, MSXML_DEFAULT },
- { &CLSID_XMLSchemaCache26, MSXML_DEFAULT },
- { &CLSID_XMLSchemaCache30, MSXML3 },
- { &CLSID_XMLSchemaCache40, MSXML4 },
- { &CLSID_XMLSchemaCache60, MSXML6 },
+ { &CLSID_XMLSchemaCache26, MSXML26 },
+ { &CLSID_XMLSchemaCache30, MSXML3 },
+ { &CLSID_XMLSchemaCache40, MSXML4 },
+ { &CLSID_XMLSchemaCache60, MSXML6 },
{ &CLSID_MXXMLWriter, MSXML_DEFAULT },
{ &CLSID_MXXMLWriter30, MSXML3 },
diff --git a/dlls/msxml3/msxml_private.h b/dlls/msxml3/msxml_private.h
index ad9e5c00dc8..141c08ccdd5 100644
--- a/dlls/msxml3/msxml_private.h
+++ b/dlls/msxml3/msxml_private.h
@@ -31,9 +31,11 @@
typedef enum {
MSXML_DEFAULT = 0,
- MSXML3 = 30,
- MSXML4 = 40,
- MSXML6 = 60
+ MSXML2 = 20,
+ MSXML26 = 26,
+ MSXML3 = 30,
+ MSXML4 = 40,
+ MSXML6 = 60
} MSXML_VERSION;
/* typelibs */
diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c
index 32b1b2b0139..0a2dbcf7900 100644
--- a/dlls/msxml3/tests/domdoc.c
+++ b/dlls/msxml3/tests/domdoc.c
@@ -41,6 +41,9 @@
#include "wine/test.h"
+/* undef the #define in msxml2 so that we can access all versions */
+#undef CLSID_DOMDocument
+
DEFINE_GUID(SID_SContainerDispatch, 0xb722be00, 0x4e68, 0x101b, 0xa2, 0xbc, 0x00, 0xaa, 0x00, 0x40, 0x47, 0x70);
DEFINE_GUID(SID_UnknownSID, 0x75dd09cb, 0x6c40, 0x11d5, 0x85, 0x43, 0x00, 0xc0, 0x4f, 0xa0, 0xfb, 0xa3);
DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
@@ -1737,15 +1740,6 @@ static const char xpath_simple_list[] =
" "
"";
-static const char* leading_spaces[] = {
- "\n",
- " ",
- "\t",
- "\r\n",
- "\r",
- 0
-};
-
static const char default_ns_doc[] = {
""
"",
+ " ",
+ "\n",
+ "\t",
+ "\r\n",
+ "\r",
+ "\r\r\r\r\t\t \n\n ",
+ 0
+};
+
static void test_domdoc( void )
{
HRESULT r, hr;
@@ -2024,13 +2050,59 @@ static void test_domdoc( void )
IXMLDOMAttribute *node_attr = NULL;
IXMLDOMNode *nodeChild = NULL;
IXMLDOMProcessingInstruction *nodePI = NULL;
+ const struct leading_spaces_t *class_ptr;
+ const char **data_ptr;
VARIANT_BOOL b;
VARIANT var;
BSTR str;
LONG code, ref;
LONG nLength = 0;
WCHAR buff[100];
- const char **ptr;
+ int index;
+
+ /* Load document with leading spaces
+ *
+ * Test all CLSIDs with all test data XML strings
+ */
+ class_ptr = leading_spaces_classdata;
+ index = 0;
+ while (class_ptr->clsid)
+ {
+ HRESULT hr;
+ int i;
+
+ hr = CoCreateInstance(class_ptr->clsid, NULL, CLSCTX_INPROC_SERVER,
+ &IID_IXMLDOMDocument, (void**)&doc);
+ if (hr != S_OK) {
+ win_skip("%d: failed to create class instance for %s\n", index, class_ptr->name);
+ class_ptr++;
+ index++;
+ continue;
+ }
+
+ data_ptr = leading_spaces_xmldata;
+ i = 0;
+ while (*data_ptr) {
+ BSTR data = _bstr_(*data_ptr);
+
+ b = 0xc;
+ V_VT(&var) = VT_BSTR;
+ V_BSTR(&var) = data;
+ hr = IXMLDOMDocument_load(doc, var, &b);
+ EXPECT_HR(hr, class_ptr->ret[0].hr);
+ ok(b == class_ptr->ret[0].b, "%d:%d, got %d, expected %d\n", index, i, b, class_ptr->ret[0].b);
+
+ b = 0xc;
+ hr = IXMLDOMDocument_loadXML(doc, data, &b);
+ EXPECT_HR(hr, class_ptr->ret[1].hr);
+ ok(b == class_ptr->ret[1].b, "%d:%d, got %d, expected %d\n", index, i, b, class_ptr->ret[1].b);
+
+ data_ptr++;
+ i++;
+ }
+ class_ptr++;
+ index++;
+ }
doc = create_document(&IID_IXMLDOMDocument);
if (!doc) return;
@@ -2050,19 +2122,6 @@ if (0)
EXPECT_HR(hr, S_FALSE);
ok( b == VARIANT_FALSE, "failed to load XML string\n");
- /* load document with leading spaces */
- ptr = leading_spaces;
- while (*ptr)
- {
- b = VARIANT_TRUE;
- V_VT(&var) = VT_BSTR;
- V_BSTR(&var) = _bstr_(*ptr);
- hr = IXMLDOMDocument_load( doc, var, &b);
- EXPECT_HR(hr, S_FALSE);
- ok( b == VARIANT_FALSE, "got %x\n", b);
- ptr++;
- }
-
/* try to load a document from a nonexistent file */
b = VARIANT_TRUE;
str = SysAllocString( nonexistent_fileW );