From b00046ccc44ad3ed3368f1b62d8d1ad2bd7eeade Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Mon, 21 Jun 2010 01:51:20 +0400 Subject: [PATCH] msxml3: Support xml:lang attribute in IXMLElement::getAttribute(). --- dlls/msxml3/xmlelem.c | 60 ++++++++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 20 deletions(-) diff --git a/dlls/msxml3/xmlelem.c b/dlls/msxml3/xmlelem.c index 3ff307b3abe..7a4faa39045 100644 --- a/dlls/msxml3/xmlelem.c +++ b/dlls/msxml3/xmlelem.c @@ -238,46 +238,66 @@ static HRESULT WINAPI xmlelem_setAttribute(IXMLElement *iface, BSTR strPropertyN return (attr) ? S_OK : S_FALSE; } -static HRESULT WINAPI xmlelem_getAttribute(IXMLElement *iface, BSTR strPropertyName, - VARIANT *PropertyValue) +static HRESULT WINAPI xmlelem_getAttribute(IXMLElement *iface, BSTR name, + VARIANT *value) { + static const WCHAR xmllangW[] = { 'x','m','l',':','l','a','n','g',0 }; xmlelem *This = impl_from_IXMLElement(iface); - xmlChar *val = NULL, *name; - xmlAttrPtr ptr; + xmlChar *val = NULL; - 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; - VariantInit(PropertyValue); - V_BSTR(PropertyValue) = NULL; + VariantInit(value); + V_BSTR(value) = NULL; - if (!strPropertyName) + if (!name) return E_INVALIDARG; - name = xmlChar_from_wchar(strPropertyName); - ptr = This->node->properties; - while (ptr) + /* case for xml:lang attribute */ + if (!lstrcmpiW(name, xmllangW)) { - 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 + { + xmlAttrPtr attr; + xmlChar *xml_name; + + xml_name = xmlChar_from_wchar(name); + attr = This->node->properties; + while (attr) { - val = xmlNodeListGetString(ptr->doc, ptr->children, 1); - break; + 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; + } + + attr = attr->next; + SysFreeString(attr_name); } - ptr = ptr->next; + heap_free(xml_name); } if (val) { - V_VT(PropertyValue) = VT_BSTR; - V_BSTR(PropertyValue) = bstr_from_xmlChar(val); + V_VT(value) = VT_BSTR; + V_BSTR(value) = bstr_from_xmlChar(val); } - heap_free(name); 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; }