Alistair Leslie-Hughes : msxml3: Implement createAttribute.

Alexandre Julliard julliard at winehq.org
Fri Jan 4 07:12:41 CST 2008


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

Author: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Date:   Fri Jan  4 09:11:27 2008 +1100

msxml3: Implement createAttribute.

---

 dlls/msxml3/domdoc.c       |   25 +++++++++++++++++++++++--
 dlls/msxml3/tests/domdoc.c |   10 ++++++++++
 2 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/dlls/msxml3/domdoc.c b/dlls/msxml3/domdoc.c
index ab5f03e..d955926 100644
--- a/dlls/msxml3/domdoc.c
+++ b/dlls/msxml3/domdoc.c
@@ -981,8 +981,29 @@ static HRESULT WINAPI domdoc_createAttribute(
     BSTR name,
     IXMLDOMAttribute** attribute )
 {
-    FIXME("\n");
-    return E_NOTIMPL;
+    domdoc *This = impl_from_IXMLDOMDocument2( iface );
+    xmlNodePtr xmlnode;
+    xmlChar *xml_name;
+
+    TRACE("%p->(%s %p)\n", iface, debugstr_w(name), attribute);
+
+    if(!attribute)
+        return E_INVALIDARG;
+
+    *attribute = NULL;
+
+    xml_name = xmlChar_from_wchar((WCHAR*)name);
+    xmlnode = (xmlNode *)xmlNewProp(NULL, xml_name, NULL);
+    HeapFree(GetProcessHeap(), 0, xml_name);
+
+    if(!xmlnode)
+        return E_FAIL;
+
+    xmlnode->doc = get_doc( This );
+
+    *attribute = (IXMLDOMAttribute*)create_attribute(xmlnode);
+
+    return S_OK;
 }
 
 
diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c
index 7865d9b..3084e33 100644
--- a/dlls/msxml3/tests/domdoc.c
+++ b/dlls/msxml3/tests/domdoc.c
@@ -137,6 +137,8 @@ static const WCHAR szfn1_txt[] = {'f','n','1','.','t','x','t',0};
 
 static WCHAR szComment[] = {'A',' ','C','o','m','m','e','n','t',0 };
 
+static WCHAR szAttribute[] = {'A','t','t','r',0 };
+
 #define expect_bstr_eq_and_free(bstr, expect) { \
     BSTR bstrExp = alloc_str_from_narrow(expect); \
     ok(lstrcmpW(bstr, bstrExp) == 0, "String differs\n"); \
@@ -337,6 +339,7 @@ static void test_domdoc( void )
     IXMLDOMNode *node;
     IXMLDOMText *nodetext = NULL;
     IXMLDOMComment *node_comment = NULL;
+    IXMLDOMAttribute *node_attr = NULL;
     VARIANT_BOOL b;
     VARIANT var;
     BSTR str;
@@ -508,6 +511,13 @@ static void test_domdoc( void )
     ok( r == S_OK, "returns %08x\n", r );
     IXMLDOMText_Release( node_comment );
 
+    /* test Create Attribute */
+    r = IXMLDOMDocument_createAttribute(doc, NULL, NULL);
+    ok( r == E_INVALIDARG, "returns %08x\n", r );
+    r = IXMLDOMDocument_createAttribute(doc, szAttribute, &node_attr);
+    ok( r == S_OK, "returns %08x\n", r );
+    IXMLDOMText_Release( node_attr);
+
     r = IXMLDOMDocument_Release( doc );
     ok( r == 0, "document ref count incorrect\n");
 




More information about the wine-cvs mailing list