msxml3: Treat namespace as attribute in IXMLDOMElement::getAttribute.
Signed-off-by: Daniel Lehman <dlehman@esri.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
2fb791b0eb
commit
a20d152282
|
@ -1203,7 +1203,9 @@ static HRESULT WINAPI domelem_getAttribute(
|
|||
domelem *This = impl_from_IXMLDOMElement( iface );
|
||||
xmlNodePtr element;
|
||||
xmlChar *xml_name, *xml_value = NULL;
|
||||
xmlChar *local, *prefix;
|
||||
HRESULT hr = S_FALSE;
|
||||
xmlNsPtr ns;
|
||||
|
||||
TRACE("(%p)->(%s %p)\n", This, debugstr_w(name), value);
|
||||
|
||||
|
@ -1222,7 +1224,28 @@ static HRESULT WINAPI domelem_getAttribute(
|
|||
if(!xmlValidateNameValue(xml_name))
|
||||
hr = E_FAIL;
|
||||
else
|
||||
xml_value = xmlGetNsProp(element, xml_name, NULL);
|
||||
{
|
||||
if ((local = xmlSplitQName2(xml_name, &prefix)))
|
||||
{
|
||||
if (xmlStrEqual(prefix, BAD_CAST "xmlns"))
|
||||
{
|
||||
ns = xmlSearchNs(element->doc, element, local);
|
||||
if (ns)
|
||||
xml_value = xmlStrdup(ns->href);
|
||||
}
|
||||
else
|
||||
{
|
||||
ns = xmlSearchNs(element->doc, element, prefix);
|
||||
if (ns)
|
||||
xml_value = xmlGetNsProp(element, local, ns->href);
|
||||
}
|
||||
|
||||
xmlFree(prefix);
|
||||
xmlFree(local);
|
||||
}
|
||||
else
|
||||
xml_value = xmlGetNsProp(element, xml_name, NULL);
|
||||
}
|
||||
|
||||
heap_free(xml_name);
|
||||
if(xml_value)
|
||||
|
|
|
@ -10882,6 +10882,56 @@ static void test_getAttributeNode(void)
|
|||
free_bstrs();
|
||||
}
|
||||
|
||||
static void test_getAttribute(void)
|
||||
{
|
||||
IXMLDOMDocument *doc;
|
||||
IXMLDOMElement *elem;
|
||||
VARIANT_BOOL v;
|
||||
VARIANT var;
|
||||
HRESULT hr;
|
||||
|
||||
doc = create_document(&IID_IXMLDOMDocument);
|
||||
|
||||
hr = IXMLDOMDocument_loadXML(doc, _bstr_(szExampleXML), &v);
|
||||
EXPECT_HR(hr, S_OK);
|
||||
|
||||
hr = IXMLDOMDocument_get_documentElement(doc, &elem);
|
||||
EXPECT_HR(hr, S_OK);
|
||||
|
||||
VariantInit(&var);
|
||||
hr = IXMLDOMElement_getAttribute( elem, _bstr_("xmlns:foo"), &var );
|
||||
EXPECT_HR(hr, S_OK);
|
||||
ok( V_VT(&var) == VT_BSTR, "vt = %x\n", V_VT(&var));
|
||||
ok( !lstrcmpW(V_BSTR(&var), _bstr_("urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29")), "wrong attr value: %s\n", wine_dbgstr_w(V_BSTR(&var)));
|
||||
VariantClear(&var);
|
||||
|
||||
hr = IXMLDOMElement_getAttribute( elem, _bstr_("a"), &var );
|
||||
EXPECT_HR(hr, S_OK);
|
||||
ok( V_VT(&var) == VT_BSTR, "vt = %x\n", V_VT(&var));
|
||||
ok( !lstrcmpW(V_BSTR(&var), _bstr_("attr a")), "wrong attr value: %s\n", wine_dbgstr_w(V_BSTR(&var)));
|
||||
VariantClear(&var);
|
||||
|
||||
hr = IXMLDOMElement_getAttribute( elem, _bstr_("foo:b"), &var );
|
||||
EXPECT_HR(hr, S_OK);
|
||||
ok( V_VT(&var) == VT_BSTR, "vt = %x\n", V_VT(&var));
|
||||
ok( !lstrcmpW(V_BSTR(&var), _bstr_("attr b")), "wrong attr value: %s\n", wine_dbgstr_w(V_BSTR(&var)));
|
||||
VariantClear(&var);
|
||||
|
||||
hr = IXMLDOMElement_getAttribute( elem, _bstr_("b"), &var );
|
||||
EXPECT_HR(hr, S_FALSE);
|
||||
ok( V_VT(&var) == VT_NULL, "vt = %x\n", V_VT(&var));
|
||||
VariantClear(&var);
|
||||
|
||||
hr = IXMLDOMElement_getAttribute( elem, _bstr_("non-existent"), &var );
|
||||
EXPECT_HR(hr, S_FALSE);
|
||||
ok( V_VT(&var) == VT_NULL, "vt = %x\n", V_VT(&var));
|
||||
VariantClear(&var);
|
||||
|
||||
IXMLDOMElement_Release(elem);
|
||||
IXMLDOMDocument_Release(doc);
|
||||
free_bstrs();
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
DOMNodeType type;
|
||||
const char *name;
|
||||
|
@ -12071,6 +12121,7 @@ START_TEST(domdoc)
|
|||
test_dispex();
|
||||
test_parseerror();
|
||||
test_getAttributeNode();
|
||||
test_getAttribute();
|
||||
test_supporterrorinfo();
|
||||
test_nodeValue();
|
||||
test_get_namespaces();
|
||||
|
|
Loading…
Reference in New Issue