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

Alexandre Julliard julliard at winehq.org
Mon Jun 21 11:07:08 CDT 2010


Module: wine
Branch: master
Commit: b00046ccc44ad3ed3368f1b62d8d1ad2bd7eeade
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=b00046ccc44ad3ed3368f1b62d8d1ad2bd7eeade

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Mon Jun 21 01:51:20 2010 +0400

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

---

 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;
 }
 




More information about the wine-cvs mailing list