From: Daniel Lehman dlehman25@gmail.com
--- dlls/msxml3/element.c | 13 +++++++++---- dlls/msxml3/tests/domdoc.c | 9 +++++++-- 2 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/dlls/msxml3/element.c b/dlls/msxml3/element.c index 302849aced6..d2a14fdabcd 100644 --- a/dlls/msxml3/element.c +++ b/dlls/msxml3/element.c @@ -1827,11 +1827,16 @@ static HRESULT domelem_get_item(const xmlNodePtr node, LONG index, IXMLDOMNode * if (attrIndex < index) return S_FALSE;
- xmlns = xmlNewNs(NULL, BAD_CAST "http://www.w3.org/2000/xmlns/", BAD_CAST "xmlns"); - if (!xmlns) - return E_OUTOFMEMORY; + if (!ns->prefix) { + xmlns = NULL; + curr = xmlNewProp(NULL, BAD_CAST "xmlns", ns->href); + } else { + xmlns = xmlNewNs(NULL, BAD_CAST "http://www.w3.org/2000/xmlns/", BAD_CAST "xmlns"); + if (!xmlns) + return E_OUTOFMEMORY;
- curr = xmlNewNsProp(NULL, xmlns, ns->prefix, ns->href); + curr = xmlNewNsProp(NULL, xmlns, ns->prefix, ns->href); + } if (!curr) { xmlFreeNs(xmlns); return E_OUTOFMEMORY; diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c index 964addf90d1..f20538e0c27 100644 --- a/dlls/msxml3/tests/domdoc.c +++ b/dlls/msxml3/tests/domdoc.c @@ -13735,6 +13735,7 @@ static void test_namespaces_as_attributes(void) const char *xmls[3]; MSXML_VERSION versions; BOOL todo; + BOOL todo2; }; static const struct test tests[] = { { @@ -13777,6 +13778,7 @@ static void test_namespaces_as_attributes(void) { "xmlns="nshref"" }, /* xml */ ~MSXML6, /* versions */ TRUE, /* todo */ + TRUE, /* todo2 */ }, { "<a xmlns="nshref" />", 1, @@ -13848,9 +13850,7 @@ static void test_namespaces_as_attributes(void) { item = NULL; hr = IXMLDOMNamedNodeMap_get_item(map, i, &item); - todo_wine_if(test->todo) ok(SUCCEEDED(hr), "Failed to get item, hr %#lx.\n", hr); - if (FAILED(hr)) continue;
str = NULL; hr = IXMLDOMNode_get_nodeName(item, &str); @@ -13863,10 +13863,12 @@ static void test_namespaces_as_attributes(void) if (test->prefixes[i]) { /* MSXML4 can report different results with different service packs */ + todo_wine_if(test->todo) { ok(hr == S_OK || broken(entry->ver == MSXML4 && hr == S_FALSE), "Failed to get prefix, hr %#lx.\n", hr); ok(!lstrcmpW(str, _bstr_(test->prefixes[i])) || broken(!str && entry->ver == MSXML4), "got %s\n", wine_dbgstr_w(str)); + } SysFreeString(str); } else @@ -13876,6 +13878,7 @@ static void test_namespaces_as_attributes(void) hr = IXMLDOMNode_get_baseName(item, &str); ok(SUCCEEDED(hr), "Failed to get base name, hr %#lx.\n", hr); /* MSXML4 can report different results with different service packs */ + todo_wine_if(test->todo2) ok(!lstrcmpW(str, _bstr_(test->basenames[i])) || broken(entry->ver == MSXML4 && !lstrcmpW(str, L"xmlns")), "got %s\n", wine_dbgstr_w(str)); @@ -13885,11 +13888,13 @@ static void test_namespaces_as_attributes(void) hr = IXMLDOMNode_get_namespaceURI(item, &str); if (test->uris[i]) { + todo_wine_if(test->todo) { ok(hr == S_OK, "Failed to get node namespace URI, hr %#lx.\n", hr); if (test->prefixes[i] && !strcmp(test->prefixes[i], "xmlns")) ok(!lstrcmpW(str, _bstr_(entry->xmlns_uri)), "got %s\n", wine_dbgstr_w(str)); else ok(!lstrcmpW(str, _bstr_(test->uris[i])), "got %s\n", wine_dbgstr_w(str)); + } SysFreeString(str); } else