[PATCH] Implement createAttribute
Alistair Leslie-Hughes
leslie_alistair at hotmail.com
Tue Jan 1 19:53:37 CST 2008
---
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 d366840..b3339a3 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 1ea72c7..7207178 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','n','e','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;
@@ -507,6 +510,13 @@ static void test_domdoc( void )
r = IXMLDOMDocument_createComment(doc, szComment, &node_comment);
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");
--
1.5.3.6
--------------040804020406030102080401--
More information about the wine-patches
mailing list