From: Daniel Lehman dlehman25@gmail.com
--- dlls/msxml3/attribute.c | 45 +++++++++++++++++++++++++------------- dlls/msxml3/tests/domdoc.c | 8 ++----- 2 files changed, 32 insertions(+), 21 deletions(-)
diff --git a/dlls/msxml3/attribute.c b/dlls/msxml3/attribute.c index 6b8c7fba6d9..ebab7fdb03a 100644 --- a/dlls/msxml3/attribute.c +++ b/dlls/msxml3/attribute.c @@ -543,10 +543,12 @@ static HRESULT WINAPI domattr_get_namespaceURI( IXMLDOMAttribute *iface, BSTR* p) { - static const WCHAR w3xmlns[] = { 'h','t','t','p',':','/','/', 'w','w','w','.','w','3','.', - 'o','r','g','/','2','0','0','0','/','x','m','l','n','s','/',0 }; + static const WCHAR *w3xmlns = L"http://www.w3.org/2000/xmlns/"; domattr *This = impl_from_IXMLDOMAttribute( iface ); xmlNsPtr ns = This->node.node->ns; + BSTR nodename, pfx; + BOOL is6, isdefault; + HRESULT hr;
TRACE("(%p)->(%p)\n", This, p);
@@ -554,22 +556,35 @@ static HRESULT WINAPI domattr_get_namespaceURI( return E_INVALIDARG;
*p = NULL; + nodename = NULL; + hr = IXMLDOMAttribute_get_nodeName(iface, &nodename); + if (FAILED(hr)) + return hr; + + pfx = NULL; + hr = IXMLDOMAttribute_get_prefix(iface, &pfx); + if (FAILED(hr)) + { + SysFreeString(nodename); + return hr; + }
- if (ns) + is6 = xmldoc_version(This->node.node->doc) == MSXML6; + isdefault = !wcscmp(nodename, L"xmlns"); + if (isdefault || (pfx && !wcscmp(L"xmlns", pfx))) { - /* special case for default namespace definition */ - if (xmlStrEqual(This->node.node->name, xmlns)) - *p = bstr_from_xmlChar(xmlns); - else if (xmlStrEqual(ns->prefix, xmlns)) - { - if (xmldoc_version(This->node.node->doc) == MSXML6) - *p = SysAllocString(w3xmlns); - else - *p = SysAllocStringLen(NULL, 0); - } - else if (ns->href) - *p = bstr_from_xmlChar(ns->href); + if (is6) + *p = SysAllocString(w3xmlns); + else if (!ns || !isdefault) + *p = SysAllocStringLen(NULL, 0); + else + *p = SysAllocString(L"xmlns"); } + else if (ns && ns->href) + *p = bstr_from_xmlChar(ns->href); + + SysFreeString(nodename); + SysFreeString(pfx);
TRACE("uri: %s\n", debugstr_w(*p));
diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c index 29bcf7abd45..dcc131afa9d 100644 --- a/dlls/msxml3/tests/domdoc.c +++ b/dlls/msxml3/tests/domdoc.c @@ -13319,14 +13319,13 @@ struct attrtest_t { const char *prefix; const char *href; MSXML_VERSION versions; - BOOL todo; };
static struct attrtest_t attrtests[] = { { "xmlns", "http://www.w3.org/2000/xmlns/", "xmlns", "xmlns", ~MSXML6 }, - { "xmlns", "http://www.w3.org/2000/xmlns/", NULL, "http://www.w3.org/2000/xmlns/", MSXML6, TRUE }, + { "xmlns", "http://www.w3.org/2000/xmlns/", NULL, "http://www.w3.org/2000/xmlns/", MSXML6 }, { "xmlns", "nondefaulturi", "xmlns", "xmlns", ~MSXML6 }, - { "xmlns", "nondefaulturi", NULL, "http://www.w3.org/2000/xmlns/", MSXML6, TRUE }, + { "xmlns", "nondefaulturi", NULL, "http://www.w3.org/2000/xmlns/", MSXML6 }, { "c", "http://www.w3.org/2000/xmlns/", NULL, "http://www.w3.org/2000/xmlns/" }, { "c", "nsref1", NULL, "nsref1" }, { "ns:c", "nsref1", "ns", "nsref1" }, @@ -13409,7 +13408,6 @@ static void test_create_attribute(void) str = NULL; hr = IXMLDOMNode_get_namespaceURI(node, &str); ok(hr == S_OK, "%d: unexpected hr %#lx\n", i, hr); - todo_wine_if(ptr->todo) ok(!lstrcmpW(str, _bstr_(ptr->href)) || broken(!ptr->prefix && entry->ver == MSXML6 && !lstrcmpW(str, L"xmlns")), /* win7 msxml6 */ "%d: got uri %s, expected %s\n", i, wine_dbgstr_w(str), ptr->href); @@ -13881,13 +13879,11 @@ 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