msxml3: Support xml:lang attribute in IXMLElement::getAttribute().

This commit is contained in:
Nikolay Sivov 2010-06-21 01:51:20 +04:00 committed by Alexandre Julliard
parent 6f778a79f4
commit b00046ccc4
1 changed files with 40 additions and 20 deletions

View File

@ -238,46 +238,66 @@ static HRESULT WINAPI xmlelem_setAttribute(IXMLElement *iface, BSTR strPropertyN
return (attr) ? S_OK : S_FALSE; return (attr) ? S_OK : S_FALSE;
} }
static HRESULT WINAPI xmlelem_getAttribute(IXMLElement *iface, BSTR strPropertyName, static HRESULT WINAPI xmlelem_getAttribute(IXMLElement *iface, BSTR name,
VARIANT *PropertyValue) VARIANT *value)
{ {
static const WCHAR xmllangW[] = { 'x','m','l',':','l','a','n','g',0 };
xmlelem *This = impl_from_IXMLElement(iface); xmlelem *This = impl_from_IXMLElement(iface);
xmlChar *val = NULL, *name; xmlChar *val = NULL;
xmlAttrPtr ptr;
TRACE("(%p, %s, %p)\n", iface, debugstr_w(strPropertyName), PropertyValue); TRACE("(%p, %s, %p)\n", iface, debugstr_w(name), value);
if (!PropertyValue) if (!value)
return E_INVALIDARG; return E_INVALIDARG;
VariantInit(PropertyValue); VariantInit(value);
V_BSTR(PropertyValue) = NULL; V_BSTR(value) = NULL;
if (!strPropertyName) if (!name)
return E_INVALIDARG; return E_INVALIDARG;
name = xmlChar_from_wchar(strPropertyName); /* case for xml:lang attribute */
ptr = This->node->properties; if (!lstrcmpiW(name, xmllangW))
while (ptr)
{ {
if (!lstrcmpiA((LPSTR)name, (LPCSTR)ptr->name)) xmlNsPtr ns;
ns = xmlSearchNs(This->node->doc, This->node, (xmlChar*)"xml");
val = xmlGetNsProp(This->node, (xmlChar*)"lang", ns->href);
xmlFree(ns);
}
else
{ {
val = xmlNodeListGetString(ptr->doc, ptr->children, 1); xmlAttrPtr attr;
xmlChar *xml_name;
xml_name = xmlChar_from_wchar(name);
attr = This->node->properties;
while (attr)
{
BSTR attr_name;
attr_name = bstr_from_xmlChar(attr->name);
if (!lstrcmpiW(name, attr_name))
{
val = xmlNodeListGetString(attr->doc, attr->children, 1);
SysFreeString(attr_name);
break; break;
} }
ptr = ptr->next; attr = attr->next;
SysFreeString(attr_name);
}
heap_free(xml_name);
} }
if (val) if (val)
{ {
V_VT(PropertyValue) = VT_BSTR; V_VT(value) = VT_BSTR;
V_BSTR(PropertyValue) = bstr_from_xmlChar(val); V_BSTR(value) = bstr_from_xmlChar(val);
} }
heap_free(name);
xmlFree(val); xmlFree(val);
TRACE("returning %s\n", debugstr_w(V_BSTR(PropertyValue))); TRACE("returning %s\n", debugstr_w(V_BSTR(value)));
return (val) ? S_OK : S_FALSE; return (val) ? S_OK : S_FALSE;
} }