[PATCH] Support xml:lang attribute in IXMLElement::getAttribute()

Nikolay Sivov nsivov at codeweavers.com
Sun Jun 20 16:51:20 CDT 2010


---
 dlls/msxml3/xmlelem.c |   60 ++++++++++++++++++++++++++++++++----------------
 1 files changed, 40 insertions(+), 20 deletions(-)

diff --git a/dlls/msxml3/xmlelem.c b/dlls/msxml3/xmlelem.c
index 3ff307b..7a4faa3 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))
+    {
+        xmlNsPtr ns;
+        ns = xmlSearchNs(This->node->doc, This->node, (xmlChar*)"xml");
+        val = xmlGetNsProp(This->node, (xmlChar*)"lang", ns->href);
+        xmlFree(ns);
+    }
+    else
     {
-        if (!lstrcmpiA((LPSTR)name, (LPCSTR)ptr->name))
+        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;
 }
 
-- 
1.5.6.5


--------------000405000903050304070706--



More information about the wine-patches mailing list