4 * Copyright 2005 Mike McCormack for CodeWeavers
5 * Copyright 2007 Alistair Leslie-Hughes
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
32 #include "wine/test.h"
34 const CLSID CLSID_DOMDocument2 = {0xf6d90f11, 0x9c73, 0x11d3, {0xb3, 0x2e, 0x00, 0xc0, 0x4f, 0x99, 0x0b, 0xb4}};
35 const IID IID_IXMLDOMDocument2 = {0x2933bf95, 0x7b36, 0x11d2, {0xb2, 0x0e, 0x00, 0xc0, 0x4f, 0x98, 0x3e, 0x60}};
37 static const WCHAR szEmpty[] = { 0 };
38 static const WCHAR szIncomplete[] = {
39 '<','?','x','m','l',' ',
40 'v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',0
42 static const WCHAR szComplete1[] = {
43 '<','?','x','m','l',' ',
44 'v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',
45 '<','o','p','e','n','>','<','/','o','p','e','n','>','\n',0
47 static const WCHAR szComplete2[] = {
48 '<','?','x','m','l',' ',
49 'v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',
50 '<','o','>','<','/','o','>','\n',0
52 static const WCHAR szComplete3[] = {
53 '<','?','x','m','l',' ',
54 'v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',
55 '<','a','>','<','/','a','>','\n',0
57 static const WCHAR szComplete4[] = {
58 '<','?','x','m','l',' ','v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',
59 '<','l','c',' ','d','l','=','\'','s','t','r','1','\'','>','\n',
60 '<','b','s',' ','v','r','=','\'','s','t','r','2','\'',' ','s','z','=','\'','1','2','3','4','\'','>',
61 'f','n','1','.','t','x','t','\n',
62 '<','/','b','s','>','\n',
63 '<','p','r',' ','i','d','=','\'','s','t','r','3','\'',' ','v','r','=','\'','1','.','2','.','3','\'',' ',
64 'p','n','=','\'','w','i','n','e',' ','2','0','0','5','0','8','0','4','\'','>','\n',
65 'f','n','2','.','t','x','t','\n',
66 '<','/','p','r','>','\n',
67 '<','e','m','p','t','y','>','<','/','e','m','p','t','y','>','\n',
71 '<','/','b','a','>','\n',
72 '<','/','f','o','>','\n',
73 '<','/','l','c','>','\n',0
75 static const WCHAR szComplete5[] = {
76 '<','S',':','s','e','a','r','c','h',' ','x','m','l','n','s',':','D','=','"','D','A','V',':','"',' ',
77 'x','m','l','n','s',':','C','=','"','u','r','n',':','s','c','h','e','m','a','s','-','m','i','c','r','o','s','o','f','t','-','c','o','m',':','o','f','f','i','c','e',':','c','l','i','p','g','a','l','l','e','r','y','"',
78 ' ','x','m','l','n','s',':','S','=','"','u','r','n',':','s','c','h','e','m','a','s','-','m','i','c','r','o','s','o','f','t','-','c','o','m',':','o','f','f','i','c','e',':','c','l','i','p','g','a','l','l','e','r','y',':','s','e','a','r','c','h','"','>',
79 '<','S',':','s','c','o','p','e','>',
80 '<','S',':','d','e','e','p','>','/','<','/','S',':','d','e','e','p','>',
81 '<','/','S',':','s','c','o','p','e','>',
82 '<','S',':','c','o','n','t','e','n','t','f','r','e','e','t','e','x','t','>',
83 '<','C',':','t','e','x','t','o','r','p','r','o','p','e','r','t','y','/','>',
84 'c','o','m','p','u','t','e','r',
85 '<','/','S',':','c','o','n','t','e','n','t','f','r','e','e','t','e','x','t','>',
86 '<','/','S',':','s','e','a','r','c','h','>',0
89 static const CHAR szExampleXML[] =
90 "<?xml version='1.0' encoding='utf-8'?>\n"
91 "<root xmlns:foo='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'>\n"
96 " <description xmlns:foo='http://www.winehq.org' xmlns:bar='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'>\n"
97 " <html xmlns='http://www.w3.org/1999/xhtml'>\n"
98 " This is <strong>a</strong> <i>description</i>. <bar:x/>\n"
106 " <c type=\"old\">C2 field</c>\n"
109 " <elem xmlns='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'>\n"
118 " <foo:c>C4 field</foo:c>\n"
122 static const WCHAR szNonExistentFile[] = {
123 'c', ':', '\\', 'N', 'o', 'n', 'e', 'x', 'i', 's', 't', 'e', 'n', 't', '.', 'x', 'm', 'l', 0
125 static const WCHAR szDocument[] = {
126 '#', 'd', 'o', 'c', 'u', 'm', 'e', 'n', 't', 0
129 static const WCHAR szOpen[] = { 'o','p','e','n',0 };
130 static WCHAR szdl[] = { 'd','l',0 };
131 static const WCHAR szvr[] = { 'v','r',0 };
132 static const WCHAR szlc[] = { 'l','c',0 };
133 static WCHAR szbs[] = { 'b','s',0 };
134 static const WCHAR szstr1[] = { 's','t','r','1',0 };
135 static const WCHAR szstr2[] = { 's','t','r','2',0 };
136 static const WCHAR szstar[] = { '*',0 };
137 static const WCHAR szfn1_txt[] = {'f','n','1','.','t','x','t',0};
139 static WCHAR szComment[] = {'A',' ','C','o','m','m','e','n','t',0 };
140 static WCHAR szCommentXML[] = {'<','!','-','-','A',' ','C','o','m','m','e','n','t','-','-','>',0 };
141 static WCHAR szCommentNodeText[] = {'#','c','o','m','m','e','n','t',0 };
143 static WCHAR szElement[] = {'E','l','e','T','e','s','t', 0 };
144 static WCHAR szElementXML[] = {'<','E','l','e','T','e','s','t','/','>',0 };
145 static WCHAR szElementXML2[] = {'<','E','l','e','T','e','s','t',' ','A','t','t','r','=','"','"','/','>',0 };
146 static WCHAR szElementXML3[] = {'<','E','l','e','T','e','s','t',' ','A','t','t','r','=','"','"','>',
147 'T','e','s','t','i','n','g','N','o','d','e','<','/','E','l','e','T','e','s','t','>',0 };
149 static WCHAR szAttribute[] = {'A','t','t','r',0 };
150 static WCHAR szAttributeXML[] = {'A','t','t','r','=','"','"',0 };
152 static WCHAR szCData[] = {'[','1',']','*','2','=','3',';',' ','&','g','e','e',' ','t','h','a','t','s',
153 ' ','n','o','t',' ','r','i','g','h','t','!', 0};
154 static WCHAR szCDataXML[] = {'<','!','[','C','D','A','T','A','[','[','1',']','*','2','=','3',';',' ','&',
155 'g','e','e',' ','t','h','a','t','s',' ','n','o','t',' ','r','i','g','h','t',
157 static WCHAR szCDataNodeText[] = {'#','c','d','a','t','a','-','s','e','c','t','i','o','n',0 };
158 static WCHAR szDocFragmentText[] = {'#','d','o','c','u','m','e','n','t','-','f','r','a','g','m','e','n','t',0 };
160 static WCHAR szEntityRef[] = {'e','n','t','i','t','y','r','e','f',0 };
161 static WCHAR szEntityRefXML[] = {'&','e','n','t','i','t','y','r','e','f',';',0 };
163 #define expect_bstr_eq_and_free(bstr, expect) { \
164 BSTR bstrExp = alloc_str_from_narrow(expect); \
165 ok(lstrcmpW(bstr, bstrExp) == 0, "String differs\n"); \
166 SysFreeString(bstr); \
167 SysFreeString(bstrExp); \
170 #define expect_eq(expr, value, type, format) { type ret = (expr); ok((value) == ret, #expr " expected " format " got " format "\n", value, ret); }
172 #define ole_check(expr) { \
174 ok(r == S_OK, #expr " returned %x\n", r); \
177 #define ole_expect(expr, expect) { \
179 ok(r == (expect), #expr " returned %x, expected %x\n", r, expect); \
182 static BSTR alloc_str_from_narrow(const char *str)
184 int len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
185 BSTR ret = SysAllocStringLen(NULL, len - 1); /* NUL character added automatically */
186 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
190 BSTR alloced_bstrs[256];
191 int alloced_bstrs_count = 0;
193 static BSTR _bstr_(const char *str)
195 assert(alloced_bstrs_count < sizeof(alloced_bstrs)/sizeof(alloced_bstrs[0]));
196 alloced_bstrs[alloced_bstrs_count] = alloc_str_from_narrow(str);
197 return alloced_bstrs[alloced_bstrs_count++];
200 static void free_bstrs(void)
203 for (i = 0; i < alloced_bstrs_count; i++)
204 SysFreeString(alloced_bstrs[i]);
205 alloced_bstrs_count = 0;
208 static VARIANT _variantbstr_(const char *str)
212 V_BSTR(&v) = _bstr_(str);
216 static void get_str_for_type(DOMNodeType type, char *buf)
230 wsprintfA(buf, "[%d]", type);
234 static int get_node_position(IXMLDOMNode *node)
239 IXMLDOMNode_AddRef(node);
242 IXMLDOMNode *new_node;
245 r = IXMLDOMNode_get_previousSibling(node, &new_node);
246 ok(!FAILED(r), "get_previousSibling failed\n");
247 IXMLDOMNode_Release(node);
253 static void node_to_string(IXMLDOMNode *node, char *buf)
260 lstrcpyA(buf, "(null)");
264 IXMLDOMNode_AddRef(node);
267 IXMLDOMNode *new_node;
269 ole_check(IXMLDOMNode_get_nodeType(node, &type));
270 get_str_for_type(type, buf);
273 if (type == NODE_ATTRIBUTE)
276 ole_check(IXMLDOMNode_get_nodeName(node, &bstr));
278 wsprintfA(buf, "%ws", bstr);
283 r = IXMLDOMNode_selectSingleNode(node, _bstr_(".."), &new_node);
287 int pos = get_node_position(node);
288 DOMNodeType parent_type = NODE_INVALID;
289 r = IXMLDOMNode_get_parentNode(node, &new_node);
291 /* currently wine doesn't create a node for the <?xml ... ?>. To be able to test query
292 * results we "fix" it */
294 ole_check(IXMLDOMNode_get_nodeType(node, &parent_type));
295 /* we need also to workaround the no document node problem - see below */
296 if (((r == S_FALSE && type != NODE_DOCUMENT) || parent_type == NODE_DOCUMENT) && type != NODE_PROCESSING_INSTRUCTION && pos==1)
298 todo_wine ok(FALSE, "The first child of the document node in MSXML is the <?xml ... ?> processing instruction\n");
301 wsprintf(buf, "%d", pos);
305 ok(!FAILED(r), "get_parentNode failed (%08x)\n", r);
306 IXMLDOMNode_Release(node);
312 /* currently we can't access document node in wine. All our examples this is the
313 * root node so to be able to test query results we add it */
314 if (type != NODE_DOCUMENT)
316 todo_wine ok(FALSE, "Document node is not the last returned node!\n");
324 static char *list_to_string(IXMLDOMNodeList *list)
326 static char buf[4096];
333 lstrcpyA(buf, "(null)");
336 ole_check(IXMLDOMNodeList_get_length(list, &len));
337 for (i = 0; i < len; i++)
342 ole_check(IXMLDOMNodeList_nextNode(list, &node));
343 node_to_string(node, pos);
345 IXMLDOMNode_Release(node);
351 #define expect_node(node, expstr) { char str[4096]; node_to_string(node, str); ok(strcmp(str, expstr)==0, "Invalid node: %s, exptected %s\n", str, expstr); }
352 #define expect_list_and_release(list, expstr) { char *str = list_to_string(list); ok(strcmp(str, expstr)==0, "Invalid node list: %s, exptected %s\n", str, expstr); if (list) IXMLDOMNodeList_Release(list); }
354 static void test_domdoc( void )
357 IXMLDOMDocument *doc = NULL;
358 IXMLDOMParseError *error;
359 IXMLDOMElement *element = NULL;
361 IXMLDOMText *nodetext = NULL;
362 IXMLDOMComment *node_comment = NULL;
363 IXMLDOMAttribute *node_attr = NULL;
364 IXMLDOMNode *nodeChild = NULL;
365 IXMLDOMProcessingInstruction *nodePI = NULL;
372 r = CoCreateInstance( &CLSID_DOMDocument, NULL,
373 CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (LPVOID*)&doc );
377 /* try some stupid things */
378 r = IXMLDOMDocument_loadXML( doc, NULL, NULL );
379 ok( r == S_FALSE, "loadXML failed\n");
382 r = IXMLDOMDocument_loadXML( doc, NULL, &b );
383 ok( r == S_FALSE, "loadXML failed\n");
384 ok( b == VARIANT_FALSE, "failed to load XML string\n");
386 /* try to load a document from a nonexistent file */
388 str = SysAllocString( szNonExistentFile );
390 V_VT(&var) = VT_BSTR;
393 r = IXMLDOMDocument_load( doc, var, &b);
394 ok( r == S_FALSE, "load (from file) failed\n");
395 ok( b == VARIANT_FALSE, "failed to load XML file\n");
396 SysFreeString( str );
398 /* try load an empty document */
400 str = SysAllocString( szEmpty );
401 r = IXMLDOMDocument_loadXML( doc, str, &b );
402 ok( r == S_FALSE, "loadXML failed\n");
403 ok( b == VARIANT_FALSE, "failed to load XML string\n");
404 SysFreeString( str );
406 /* check that there's no document element */
408 r = IXMLDOMDocument_get_documentElement( doc, &element );
409 ok( r == S_FALSE, "should be no document element\n");
411 /* try finding a node */
413 str = SysAllocString( szstr1 );
414 r = IXMLDOMDocument_selectSingleNode( doc, str, &node );
415 ok( r == S_FALSE, "ret %08x\n", r );
416 SysFreeString( str );
419 str = SysAllocString( szIncomplete );
420 r = IXMLDOMDocument_loadXML( doc, str, &b );
421 ok( r == S_FALSE, "loadXML failed\n");
422 ok( b == VARIANT_FALSE, "failed to load XML string\n");
423 SysFreeString( str );
425 /* check that there's no document element */
426 element = (IXMLDOMElement*)1;
427 r = IXMLDOMDocument_get_documentElement( doc, &element );
428 ok( r == S_FALSE, "should be no document element\n");
429 ok( element == NULL, "Element should be NULL\n");
431 /* try to load something valid */
433 str = SysAllocString( szComplete1 );
434 r = IXMLDOMDocument_loadXML( doc, str, &b );
435 ok( r == S_OK, "loadXML failed\n");
436 ok( b == VARIANT_TRUE, "failed to load XML string\n");
437 SysFreeString( str );
439 /* try with a null out pointer */
440 r = IXMLDOMDocument_get_documentElement( doc, NULL );
441 ok( r == E_INVALIDARG, "should be no document element\n");
443 /* check if nodename is correct */
444 r = IXMLDOMDocument_get_nodeName( doc, NULL );
445 ok ( r == E_INVALIDARG, "get_nodeName (NULL) wrong code\n");
447 /* content doesn't matter here */
449 r = IXMLDOMDocument_get_nodeName( doc, &str );
450 ok ( r == S_OK, "get_nodeName wrong code\n");
451 ok ( str != NULL, "str is null\n");
452 ok( !lstrcmpW( str, szDocument ), "incorrect nodeName\n");
453 SysFreeString( str );
456 r = IXMLDOMDocument_put_text( doc, _bstr_("Should Fail") );
457 ok( r == E_FAIL, "ret %08x\n", r );
459 /* check that there's a document element */
461 r = IXMLDOMDocument_get_documentElement( doc, &element );
462 ok( r == S_OK, "should be a document element\n");
467 /* check if the tag is correct */
468 r = IXMLDOMElement_get_tagName( element, &tag );
469 ok( r == S_OK, "couldn't get tag name\n");
470 ok( tag != NULL, "tag was null\n");
471 ok( !lstrcmpW( tag, szOpen ), "incorrect tag name\n");
472 SysFreeString( tag );
474 /* figure out what happens if we try to reload the document */
475 str = SysAllocString( szComplete2 );
476 r = IXMLDOMDocument_loadXML( doc, str, &b );
477 ok( r == S_OK, "loadXML failed\n");
478 ok( b == VARIANT_TRUE, "failed to load XML string\n");
479 SysFreeString( str );
481 /* check if the tag is still correct */
483 r = IXMLDOMElement_get_tagName( element, &tag );
484 ok( r == S_OK, "couldn't get tag name\n");
485 ok( tag != NULL, "tag was null\n");
486 ok( !lstrcmpW( tag, szOpen ), "incorrect tag name\n");
487 SysFreeString( tag );
489 IXMLDOMElement_Release( element );
493 /* as soon as we call loadXML again, the document element will disappear */
495 r = IXMLDOMDocument_loadXML( doc, NULL, NULL );
496 ok( r == S_FALSE, "loadXML failed\n");
497 ok( b == 2, "variant modified\n");
498 r = IXMLDOMDocument_get_documentElement( doc, &element );
499 ok( r == S_FALSE, "should be no document element\n");
501 /* try to load something else simple and valid */
503 str = SysAllocString( szComplete3 );
504 r = IXMLDOMDocument_loadXML( doc, str, &b );
505 ok( r == S_OK, "loadXML failed\n");
506 ok( b == VARIANT_TRUE, "failed to load XML string\n");
507 SysFreeString( str );
509 /* try something a little more complicated */
511 str = SysAllocString( szComplete4 );
512 r = IXMLDOMDocument_loadXML( doc, str, &b );
513 ok( r == S_OK, "loadXML failed\n");
514 ok( b == VARIANT_TRUE, "failed to load XML string\n");
515 SysFreeString( str );
517 r = IXMLDOMDocument_get_parseError( doc, &error );
518 ok( r == S_OK, "returns %08x\n", r );
520 r = IXMLDOMParseError_get_errorCode( error, &code );
521 ok( r == S_FALSE, "returns %08x\n", r );
522 ok( code == 0, "code %ld\n", code );
523 IXMLDOMParseError_Release( error );
525 /* test createTextNode */
526 str = SysAllocString( szOpen );
527 r = IXMLDOMDocument_createTextNode(doc, str, NULL);
528 ok( r == E_INVALIDARG, "returns %08x\n", r );
529 r = IXMLDOMDocument_createTextNode(doc, str, &nodetext);
530 ok( r == S_OK, "returns %08x\n", r );
533 IXMLDOMNamedNodeMap *pAttribs;
535 /* Text Last Child Checks */
536 r = IXMLDOMText_get_lastChild(nodetext, NULL);
537 ok(r == E_INVALIDARG, "ret %08x\n", r );
539 nodeChild = (IXMLDOMNode*)0x1;
540 r = IXMLDOMText_get_lastChild(nodetext, &nodeChild);
541 ok(r == S_FALSE, "ret %08x\n", r );
542 ok(nodeChild == NULL, "nodeChild not NULL\n");
544 /* test get_attributes */
545 r = IXMLDOMText_get_attributes( nodetext, NULL );
546 ok( r == E_INVALIDARG, "get_attributes returned wrong code\n");
548 pAttribs = (IXMLDOMNamedNodeMap*)0x1;
549 r = IXMLDOMText_get_attributes( nodetext, &pAttribs);
550 ok(r == S_FALSE, "ret %08x\n", r );
551 ok( pAttribs == NULL, "pAttribs not NULL\n");
553 /* test get_dataType */
554 r = IXMLDOMText_get_dataType(nodetext, &var);
555 ok(r == S_FALSE, "ret %08x\n", r );
556 ok( V_VT(&var) == VT_NULL, "incorrect dataType type\n");
559 /* test length property */
560 r = IXMLDOMText_get_length(nodetext, NULL);
561 ok(r == E_INVALIDARG, "ret %08x\n", r );
563 r = IXMLDOMText_get_length(nodetext, &nLength);
564 ok(r == S_OK, "ret %08x\n", r );
565 ok(nLength == 4, "expected 4 got %ld\n", nLength);
567 /* test nodeTypeString */
568 r = IXMLDOMText_get_nodeTypeString(nodetext, &str);
569 ok(r == S_OK, "ret %08x\n", r );
570 ok( !lstrcmpW( str, _bstr_("text") ), "incorrect nodeTypeString string\n");
574 r = IXMLDOMText_put_data(nodetext, _bstr_("This &is a ; test <>\\"));
575 ok(r == S_OK, "ret %08x\n", r );
578 r = IXMLDOMText_get_data(nodetext, &str);
579 ok(r == S_OK, "ret %08x\n", r );
580 ok( !lstrcmpW( str, _bstr_("This &is a ; test <>\\") ), "incorrect put_data string\n");
583 /* Confirm XML text is good */
584 r = IXMLDOMText_get_xml(nodetext, &str);
585 ok(r == S_OK, "ret %08x\n", r );
586 ok( !lstrcmpW( str, _bstr_("This &is a ; test <>\\") ), "incorrect xml string\n");
589 /* Confirm we get the put_data Text back */
590 r = IXMLDOMText_get_text(nodetext, &str);
591 ok(r == S_OK, "ret %08x\n", r );
592 ok( !lstrcmpW( str, _bstr_("This &is a ; test <>\\") ), "incorrect xml string\n");
595 /* test substringData */
596 r = IXMLDOMText_substringData(nodetext, 0, 4, NULL);
597 ok(r == E_INVALIDARG, "ret %08x\n", r );
599 /* test substringData - Invalid offset */
600 str = (BSTR)&szElement;
601 r = IXMLDOMText_substringData(nodetext, -1, 4, &str);
602 ok(r == E_INVALIDARG, "ret %08x\n", r );
603 ok( str == NULL, "incorrect string\n");
605 /* test substringData - Invalid offset */
606 str = (BSTR)&szElement;
607 r = IXMLDOMText_substringData(nodetext, 30, 0, &str);
608 ok(r == S_FALSE, "ret %08x\n", r );
609 ok( str == NULL, "incorrect string\n");
611 /* test substringData - Invalid size */
612 str = (BSTR)&szElement;
613 r = IXMLDOMText_substringData(nodetext, 0, -1, &str);
614 ok(r == E_INVALIDARG, "ret %08x\n", r );
615 ok( str == NULL, "incorrect string\n");
617 /* test substringData - Invalid size */
618 str = (BSTR)&szElement;
619 r = IXMLDOMText_substringData(nodetext, 2, 0, &str);
620 ok(r == S_FALSE, "ret %08x\n", r );
621 ok( str == NULL, "incorrect string\n");
623 /* test substringData - Start of string */
624 r = IXMLDOMText_substringData(nodetext, 0, 4, &str);
625 ok(r == S_OK, "ret %08x\n", r );
626 ok( !lstrcmpW( str, _bstr_("This") ), "incorrect substringData string\n");
629 /* test substringData - Middle of string */
630 r = IXMLDOMText_substringData(nodetext, 13, 4, &str);
631 ok(r == S_OK, "ret %08x\n", r );
632 ok( !lstrcmpW( str, _bstr_("test") ), "incorrect substringData string\n");
635 /* test substringData - End of string */
636 r = IXMLDOMText_substringData(nodetext, 20, 4, &str);
637 ok(r == S_OK, "ret %08x\n", r );
638 ok( !lstrcmpW( str, _bstr_("\\") ), "incorrect substringData string\n");
641 /* test appendData */
642 r = IXMLDOMText_appendData(nodetext, NULL);
643 ok(r == S_OK, "ret %08x\n", r );
645 r = IXMLDOMText_appendData(nodetext, _bstr_(""));
646 ok(r == S_OK, "ret %08x\n", r );
648 r = IXMLDOMText_appendData(nodetext, _bstr_("Append"));
649 ok(r == S_OK, "ret %08x\n", r );
651 r = IXMLDOMText_get_text(nodetext, &str);
652 ok(r == S_OK, "ret %08x\n", r );
653 ok( !lstrcmpW( str, _bstr_("This &is a ; test <>\\Append") ), "incorrect get_text string\n");
656 /* test insertData */
657 str = SysAllocStringLen(NULL, 0);
658 r = IXMLDOMText_insertData(nodetext, -1, str);
659 ok(r == S_OK, "ret %08x\n", r );
661 r = IXMLDOMText_insertData(nodetext, -1, NULL);
662 ok(r == S_OK, "ret %08x\n", r );
664 r = IXMLDOMText_insertData(nodetext, 1000, str);
665 ok(r == S_OK, "ret %08x\n", r );
667 r = IXMLDOMText_insertData(nodetext, 1000, NULL);
668 ok(r == S_OK, "ret %08x\n", r );
670 r = IXMLDOMText_insertData(nodetext, 0, NULL);
671 ok(r == S_OK, "ret %08x\n", r );
673 r = IXMLDOMText_insertData(nodetext, 0, str);
674 ok(r == S_OK, "ret %08x\n", r );
677 r = IXMLDOMText_insertData(nodetext, -1, _bstr_("Inserting"));
678 ok(r == E_INVALIDARG, "ret %08x\n", r );
680 r = IXMLDOMText_insertData(nodetext, 1000, _bstr_("Inserting"));
681 ok(r == E_INVALIDARG, "ret %08x\n", r );
683 r = IXMLDOMText_insertData(nodetext, 0, _bstr_("Begin "));
684 ok(r == S_OK, "ret %08x\n", r );
686 r = IXMLDOMText_insertData(nodetext, 17, _bstr_("Middle"));
687 ok(r == S_OK, "ret %08x\n", r );
689 r = IXMLDOMText_insertData(nodetext, 39, _bstr_(" End"));
690 ok(r == S_OK, "ret %08x\n", r );
692 r = IXMLDOMText_get_text(nodetext, &str);
693 ok(r == S_OK, "ret %08x\n", r );
694 ok( !lstrcmpW( str, _bstr_("Begin This &is a Middle; test <>\\Append End") ), "incorrect get_text string\n");
697 IXMLDOMText_Release( nodetext );
699 SysFreeString( str );
701 /* test Create Comment */
702 r = IXMLDOMDocument_createComment(doc, NULL, NULL);
703 ok( r == E_INVALIDARG, "returns %08x\n", r );
704 r = IXMLDOMDocument_createComment(doc, szComment, &node_comment);
705 ok( r == S_OK, "returns %08x\n", r );
708 /* Last Child Checks */
709 r = IXMLDOMComment_get_lastChild(node_comment, NULL);
710 ok(r == E_INVALIDARG, "ret %08x\n", r );
712 nodeChild = (IXMLDOMNode*)0x1;
713 r = IXMLDOMComment_get_lastChild(node_comment, &nodeChild);
714 ok(r == S_FALSE, "ret %08x\n", r );
715 ok(nodeChild == NULL, "pLastChild not NULL\n");
717 IXMLDOMComment_Release( node_comment );
720 /* test Create Attribute */
721 r = IXMLDOMDocument_createAttribute(doc, NULL, NULL);
722 ok( r == E_INVALIDARG, "returns %08x\n", r );
723 r = IXMLDOMDocument_createAttribute(doc, szAttribute, &node_attr);
724 ok( r == S_OK, "returns %08x\n", r );
725 IXMLDOMText_Release( node_attr);
727 /* test Processing Instruction */
728 str = SysAllocStringLen(NULL, 0);
729 r = IXMLDOMDocument_createProcessingInstruction(doc, str, str, NULL);
730 ok( r == E_INVALIDARG, "returns %08x\n", r );
731 r = IXMLDOMDocument_createProcessingInstruction(doc, NULL, str, &nodePI);
732 ok( r == E_FAIL, "returns %08x\n", r );
733 r = IXMLDOMDocument_createProcessingInstruction(doc, str, str, &nodePI);
734 ok( r == E_FAIL, "returns %08x\n", r );
737 r = IXMLDOMDocument_createProcessingInstruction(doc, _bstr_("xml"), _bstr_("version=\"1.0\""), &nodePI);
738 ok( r == S_OK, "returns %08x\n", r );
741 /* Last Child Checks */
742 r = IXMLDOMProcessingInstruction_get_lastChild(nodePI, NULL);
743 ok(r == E_INVALIDARG, "ret %08x\n", r );
745 nodeChild = (IXMLDOMNode*)0x1;
746 r = IXMLDOMProcessingInstruction_get_lastChild(nodePI, &nodeChild);
747 ok(r == S_FALSE, "ret %08x\n", r );
748 ok(nodeChild == NULL, "nodeChild not NULL\n");
750 r = IXMLDOMProcessingInstruction_get_dataType(nodePI, &var);
751 ok(r == S_FALSE, "ret %08x\n", r );
752 ok( V_VT(&var) == VT_NULL, "incorrect dataType type\n");
756 r = IXMLDOMProcessingInstruction_get_nodeName(nodePI, &str);
757 ok(r == S_OK, "ret %08x\n", r );
758 ok( !lstrcmpW( str, _bstr_("xml") ), "incorrect nodeName string\n");
762 r = IXMLDOMProcessingInstruction_get_target(nodePI, &str);
763 ok(r == S_OK, "ret %08x\n", r );
764 ok( !lstrcmpW( str, _bstr_("xml") ), "incorrect target string\n");
767 /* test nodeTypeString */
768 r = IXMLDOMProcessingInstruction_get_nodeTypeString(nodePI, &str);
769 ok(r == S_OK, "ret %08x\n", r );
770 ok( !lstrcmpW( str, _bstr_("processinginstruction") ), "incorrect nodeTypeString string\n");
773 /* test get_nodeValue */
774 r = IXMLDOMProcessingInstruction_get_nodeValue(nodePI, &var);
775 ok(r == S_OK, "ret %08x\n", r );
776 ok( !lstrcmpW( V_BSTR(&var), _bstr_("version=\"1.0\"") ), "incorrect data string\n");
780 r = IXMLDOMProcessingInstruction_get_data(nodePI, &str);
781 ok(r == S_OK, "ret %08x\n", r );
782 ok( !lstrcmpW( str, _bstr_("version=\"1.0\"") ), "incorrect data string\n");
786 r = IXMLDOMProcessingInstruction_put_data(nodePI, _bstr_("version=\"1.0\" encoding=\"UTF-8\""));
787 ok(r == E_FAIL, "ret %08x\n", r );
789 /* test get nodeName */
790 r = IXMLDOMProcessingInstruction_get_nodeName(nodePI, &str);
791 ok( !lstrcmpW( str, _bstr_("xml") ), "incorrect nodeName string\n");
792 ok(r == S_OK, "ret %08x\n", r );
795 IXMLDOMProcessingInstruction_Release(nodePI);
798 r = IXMLDOMDocument_Release( doc );
799 ok( r == 0, "document ref count incorrect\n");
804 static void test_domnode( void )
807 IXMLDOMDocument *doc = NULL, *owner = NULL;
808 IXMLDOMElement *element = NULL;
809 IXMLDOMNamedNodeMap *map = NULL;
810 IXMLDOMNode *node = NULL, *next = NULL;
811 IXMLDOMNodeList *list = NULL;
812 DOMNodeType type = NODE_INVALID;
818 r = CoCreateInstance( &CLSID_DOMDocument, NULL,
819 CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (LPVOID*)&doc );
824 str = SysAllocString( szComplete4 );
825 r = IXMLDOMDocument_loadXML( doc, str, &b );
826 ok( r == S_OK, "loadXML failed\n");
827 ok( b == VARIANT_TRUE, "failed to load XML string\n");
828 SysFreeString( str );
833 r = IXMLDOMNode_hasChildNodes( doc, &b );
834 ok( r == S_OK, "hasChildNoes bad return\n");
835 ok( b == VARIANT_TRUE, "hasChildNoes wrong result\n");
837 r = IXMLDOMDocument_get_documentElement( doc, &element );
838 ok( r == S_OK, "should be a document element\n");
839 ok( element != NULL, "should be an element\n");
842 ok( FALSE, "no document\n");
845 ok( V_VT(&var) == VT_EMPTY, "variant init failed\n");
847 r = IXMLDOMNode_get_nodeValue( doc, NULL );
848 ok(r == E_INVALIDARG, "get_nodeValue ret %08x\n", r );
850 r = IXMLDOMNode_get_nodeValue( doc, &var );
851 ok( r == S_FALSE, "nextNode returned wrong code\n");
852 ok( V_VT(&var) == VT_NULL, "variant wasn't empty\n");
853 ok( V_BSTR(&var) == NULL, "variant value wasn't null\n");
858 r = IXMLDOMNode_get_ownerDocument( element, &owner );
860 ok( r == S_OK, "get_ownerDocument return code\n");
862 ok( owner != doc, "get_ownerDocument return\n");
865 r = IXMLDOMNode_get_nodeType( element, &type);
866 ok( r == S_OK, "getNamedItem returned wrong code\n");
867 ok( type == NODE_ELEMENT, "node not an element\n");
870 r = IXMLDOMNode_get_baseName( element, &str );
871 ok( r == S_OK, "get_baseName returned wrong code\n");
872 ok( lstrcmpW(str,szlc) == 0, "basename was wrong\n");
875 /* check if nodename is correct */
876 r = IXMLDOMElement_get_nodeName( element, NULL );
877 ok ( r == E_INVALIDARG, "get_nodeName (NULL) wrong code\n");
879 /* content doesn't matter here */
881 r = IXMLDOMElement_get_nodeName( element, &str );
882 ok ( r == S_OK, "get_nodeName wrong code\n");
883 ok ( str != NULL, "str is null\n");
884 ok( !lstrcmpW( str, szlc ), "incorrect nodeName\n");
885 SysFreeString( str );
887 str = SysAllocString( szNonExistentFile );
890 r = IXMLDOMElement_getAttribute( element, str, &var );
891 ok( r == E_FAIL, "getAttribute ret %08x\n", r );
892 ok( V_VT(&var) == VT_NULL, "vt = %x\n", V_VT(&var));
894 SysFreeString( str );
896 str = SysAllocString( szdl );
899 r = IXMLDOMElement_getAttribute( element, str, &var );
900 ok( r == S_OK, "getAttribute ret %08x\n", r );
901 ok( V_VT(&var) == VT_BSTR, "vt = %x\n", V_VT(&var));
902 ok( !lstrcmpW(V_BSTR(&var), szstr1), "wrong attr value\n");
903 VariantClear( &var );
905 r = IXMLDOMElement_getAttribute( element, NULL, &var );
906 ok( r == E_INVALIDARG, "getAttribute ret %08x\n", r );
908 r = IXMLDOMElement_getAttribute( element, str, NULL );
909 ok( r == E_INVALIDARG, "getAttribute ret %08x\n", r );
911 SysFreeString( str );
913 r = IXMLDOMElement_get_attributes( element, &map );
914 ok( r == S_OK, "get_attributes returned wrong code\n");
915 ok( map != NULL, "should be attributes\n");
918 r = IXMLDOMNode_hasChildNodes( element, &b );
919 ok( r == S_OK, "hasChildNoes bad return\n");
920 ok( b == VARIANT_TRUE, "hasChildNoes wrong result\n");
923 ok( FALSE, "no element\n");
927 ISupportErrorInfo *support_error;
928 r = IXMLDOMNamedNodeMap_QueryInterface( map, &IID_ISupportErrorInfo, (LPVOID*)&support_error );
929 ok( r == S_OK, "ret %08x\n", r );
931 r = ISupportErrorInfo_InterfaceSupportsErrorInfo( support_error, &IID_IXMLDOMNamedNodeMap );
934 ok( r == S_OK, "ret %08x\n", r );
936 ISupportErrorInfo_Release( support_error );
938 str = SysAllocString( szdl );
939 r = IXMLDOMNamedNodeMap_getNamedItem( map, str, &node );
940 ok( r == S_OK, "getNamedItem returned wrong code\n");
941 ok( node != NULL, "should be attributes\n");
942 IXMLDOMNode_Release(node);
943 SysFreeString( str );
945 str = SysAllocString( szdl );
946 r = IXMLDOMNamedNodeMap_getNamedItem( map, str, NULL );
947 ok( r == E_INVALIDARG, "getNamedItem should return E_INVALIDARG\n");
948 SysFreeString( str );
950 /* something that isn't in szComplete4 */
951 str = SysAllocString( szOpen );
952 node = (IXMLDOMNode *) 1;
953 r = IXMLDOMNamedNodeMap_getNamedItem( map, str, &node );
954 ok( r = S_FALSE, "getNamedItem found a node that wasn't there\n");
955 ok( node == NULL, "getNamedItem should have returned NULL\n");
956 SysFreeString( str );
958 /* test indexed access of attributes */
959 r = IXMLDOMNamedNodeMap_get_length( map, &count );
960 ok ( r == S_OK, "get_length wrong code\n");
961 ok ( count == 1, "get_length != 1\n");
964 r = IXMLDOMNamedNodeMap_get_item( map, -1, &node);
965 ok ( r == S_FALSE, "get_item (-1) wrong code\n");
966 ok ( node == NULL, "there is no node\n");
969 r = IXMLDOMNamedNodeMap_get_item( map, 1, &node);
970 ok ( r == S_FALSE, "get_item (1) wrong code\n");
971 ok ( node == NULL, "there is no attribute\n");
974 r = IXMLDOMNamedNodeMap_get_item( map, 0, &node);
975 ok ( r == S_OK, "get_item (0) wrong code\n");
976 ok ( node != NULL, "should be attribute\n");
978 r = IXMLDOMNode_get_nodeName( node, NULL );
979 ok ( r == E_INVALIDARG, "get_nodeName (NULL) wrong code\n");
981 /* content doesn't matter here */
983 r = IXMLDOMNode_get_nodeName( node, &str );
984 ok ( r == S_OK, "get_nodeName wrong code\n");
985 ok ( str != NULL, "str is null\n");
986 ok( !lstrcmpW( str, szdl ), "incorrect node name\n");
987 SysFreeString( str );
989 /* test sequential access of attributes */
991 r = IXMLDOMNamedNodeMap_nextNode( map, &node );
992 ok ( r == S_OK, "nextNode (first time) wrong code\n");
993 ok ( node != NULL, "nextNode, should be attribute\n");
995 r = IXMLDOMNamedNodeMap_nextNode( map, &node );
996 ok ( r != S_OK, "nextNode (second time) wrong code\n");
997 ok ( node == NULL, "nextNode, there is no attribute\n");
999 r = IXMLDOMNamedNodeMap_reset( map );
1000 ok ( r == S_OK, "reset should return S_OK\n");
1002 r = IXMLDOMNamedNodeMap_nextNode( map, &node );
1003 ok ( r == S_OK, "nextNode (third time) wrong code\n");
1004 ok ( node != NULL, "nextNode, should be attribute\n");
1007 ok( FALSE, "no map\n");
1011 type = NODE_INVALID;
1012 r = IXMLDOMNode_get_nodeType( node, &type);
1013 ok( r == S_OK, "getNamedItem returned wrong code\n");
1014 ok( type == NODE_ATTRIBUTE, "node not an attribute\n");
1017 r = IXMLDOMNode_get_baseName( node, NULL );
1018 ok( r == E_INVALIDARG, "get_baseName returned wrong code\n");
1021 r = IXMLDOMNode_get_baseName( node, &str );
1022 ok( r == S_OK, "get_baseName returned wrong code\n");
1023 ok( lstrcmpW(str,szdl) == 0, "basename was wrong\n");
1024 SysFreeString( str );
1026 r = IXMLDOMNode_get_nodeValue( node, &var );
1027 ok( r == S_OK, "returns %08x\n", r );
1028 ok( V_VT(&var) == VT_BSTR, "vt %x\n", V_VT(&var));
1029 ok( !lstrcmpW(V_BSTR(&var), szstr1), "nodeValue incorrect\n");
1032 r = IXMLDOMNode_get_childNodes( node, NULL );
1033 ok( r == E_INVALIDARG, "get_childNodes returned wrong code\n");
1035 r = IXMLDOMNode_get_childNodes( node, &list );
1036 ok( r == S_OK, "get_childNodes returned wrong code\n");
1040 r = IXMLDOMNodeList_nextNode( list, &next );
1041 ok( r == S_OK, "nextNode returned wrong code\n");
1044 ok( FALSE, "no childlist\n");
1049 r = IXMLDOMNode_hasChildNodes( next, &b );
1050 ok( r == S_FALSE, "hasChildNoes bad return\n");
1051 ok( b == VARIANT_FALSE, "hasChildNoes wrong result\n");
1053 type = NODE_INVALID;
1054 r = IXMLDOMNode_get_nodeType( next, &type);
1055 ok( r == S_OK, "getNamedItem returned wrong code\n");
1056 ok( type == NODE_TEXT, "node not text\n");
1059 r = IXMLDOMNode_get_baseName( next, &str );
1060 ok( r == S_FALSE, "get_baseName returned wrong code\n");
1061 ok( str == NULL, "basename was wrong\n");
1065 ok( FALSE, "no next\n");
1068 IXMLDOMNode_Release( next );
1071 IXMLDOMNodeList_Release( list );
1074 IXMLDOMNode_Release( node );
1077 ok( FALSE, "no node\n");
1081 IXMLDOMNamedNodeMap_Release( map );
1083 /* now traverse the tree from the root element */
1087 r = IXMLDOMNode_get_childNodes( element, &list );
1088 ok( r == S_OK, "get_childNodes returned wrong code\n");
1090 /* using get_item for child list doesn't advance the position */
1091 ole_check(IXMLDOMNodeList_get_item(list, 1, &node));
1092 expect_node(node, "E2.E2.D1");
1093 IXMLDOMNode_Release(node);
1094 ole_check(IXMLDOMNodeList_nextNode(list, &node));
1095 expect_node(node, "E1.E2.D1");
1096 IXMLDOMNode_Release(node);
1097 ole_check(IXMLDOMNodeList_reset(list));
1099 IXMLDOMNodeList_AddRef(list);
1100 expect_list_and_release(list, "E1.E2.D1 E2.E2.D1 E3.E2.D1 E4.E2.D1");
1101 ole_check(IXMLDOMNodeList_reset(list));
1104 ok( FALSE, "no element\n");
1106 node = (void*)0xdeadbeef;
1107 r = IXMLDOMNode_selectSingleNode( element, szdl, &node );
1108 ok( r == S_FALSE, "ret %08x\n", r );
1109 ok( node == NULL, "node %p\n", node );
1110 r = IXMLDOMNode_selectSingleNode( element, szbs, &node );
1111 ok( r == S_OK, "ret %08x\n", r );
1112 r = IXMLDOMNode_Release( node );
1113 ok( r == 0, "ret %08x\n", r );
1117 r = IXMLDOMNodeList_get_length( list, &count );
1118 ok( r == S_OK, "get_length returns %08x\n", r );
1119 ok( count == 4, "get_length got %ld\n", count );
1121 r = IXMLDOMNodeList_nextNode( list, &node );
1122 ok( r == S_OK, "nextNode returned wrong code\n");
1125 ok( FALSE, "no list\n");
1129 type = NODE_INVALID;
1130 r = IXMLDOMNode_get_nodeType( node, &type);
1131 ok( r == S_OK, "getNamedItem returned wrong code\n");
1132 ok( type == NODE_ELEMENT, "node not text\n");
1135 ok( V_VT(&var) == VT_EMPTY, "variant init failed\n");
1136 r = IXMLDOMNode_get_nodeValue( node, &var );
1137 ok( r == S_FALSE, "nextNode returned wrong code\n");
1138 ok( V_VT(&var) == VT_NULL, "variant wasn't empty\n");
1139 ok( V_BSTR(&var) == NULL, "variant value wasn't null\n");
1141 r = IXMLDOMNode_hasChildNodes( node, NULL );
1142 ok( r == E_INVALIDARG, "hasChildNoes bad return\n");
1145 r = IXMLDOMNode_hasChildNodes( node, &b );
1146 ok( r == S_OK, "hasChildNoes bad return\n");
1147 ok( b == VARIANT_TRUE, "hasChildNoes wrong result\n");
1150 r = IXMLDOMNode_get_baseName( node, &str );
1151 ok( r == S_OK, "get_baseName returned wrong code\n");
1152 ok( lstrcmpW(str,szbs) == 0, "basename was wrong\n");
1156 ok( FALSE, "no node\n");
1159 IXMLDOMNode_Release( node );
1161 IXMLDOMNodeList_Release( list );
1163 IXMLDOMElement_Release( element );
1166 str = SysAllocString( szComplete5 );
1167 r = IXMLDOMDocument_loadXML( doc, str, &b );
1168 ok( r == S_OK, "loadXML failed\n");
1169 ok( b == VARIANT_TRUE, "failed to load XML string\n");
1170 SysFreeString( str );
1173 r = IXMLDOMNode_hasChildNodes( doc, &b );
1174 ok( r == S_OK, "hasChildNoes bad return\n");
1175 ok( b == VARIANT_TRUE, "hasChildNoes wrong result\n");
1177 r = IXMLDOMDocument_get_documentElement( doc, &element );
1178 ok( r == S_OK, "should be a document element\n");
1179 ok( element != NULL, "should be an element\n");
1183 static const WCHAR szSSearch[] = {'S',':','s','e','a','r','c','h',0};
1186 /* check if the tag is correct */
1187 r = IXMLDOMElement_get_tagName( element, &tag );
1188 ok( r == S_OK, "couldn't get tag name\n");
1189 ok( tag != NULL, "tag was null\n");
1190 ok( !lstrcmpW( tag, szSSearch ), "incorrect tag name\n");
1191 SysFreeString( tag );
1195 IXMLDOMElement_Release( element );
1197 IXMLDOMDocument_Release( doc );
1200 static void test_refs(void)
1205 IXMLDOMDocument *doc = NULL;
1206 IXMLDOMElement *element = NULL;
1207 IXMLDOMNode *node = NULL, *node2;
1208 IXMLDOMNodeList *node_list = NULL;
1210 IUnknown *unk, *unk2;
1212 r = CoCreateInstance( &CLSID_DOMDocument, NULL,
1213 CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (LPVOID*)&doc );
1216 ref = IXMLDOMDocument_Release(doc);
1217 ok( ref == 0, "ref %d\n", ref);
1219 r = CoCreateInstance( &CLSID_DOMDocument, NULL,
1220 CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (LPVOID*)&doc );
1224 str = SysAllocString( szComplete4 );
1225 r = IXMLDOMDocument_loadXML( doc, str, &b );
1226 ok( r == S_OK, "loadXML failed\n");
1227 ok( b == VARIANT_TRUE, "failed to load XML string\n");
1228 SysFreeString( str );
1230 ref = IXMLDOMDocument_AddRef( doc );
1231 ok( ref == 2, "ref %d\n", ref );
1232 ref = IXMLDOMDocument_AddRef( doc );
1233 ok( ref == 3, "ref %d\n", ref );
1234 IXMLDOMDocument_Release( doc );
1235 IXMLDOMDocument_Release( doc );
1237 r = IXMLDOMDocument_get_documentElement( doc, &element );
1238 ok( r == S_OK, "should be a document element\n");
1239 ok( element != NULL, "should be an element\n");
1241 ref = IXMLDOMDocument_AddRef( doc );
1242 ok( ref == 2, "ref %d\n", ref );
1243 IXMLDOMDocument_Release( doc );
1245 r = IXMLDOMElement_get_childNodes( element, &node_list );
1246 ok( r == S_OK, "rets %08x\n", r);
1247 ref = IXMLDOMNodeList_AddRef( node_list );
1248 ok( ref == 2, "ref %d\n", ref );
1249 IXMLDOMNodeList_Release( node_list );
1251 IXMLDOMNodeList_get_item( node_list, 0, &node );
1252 ok( r == S_OK, "rets %08x\n", r);
1254 IXMLDOMNodeList_get_item( node_list, 0, &node2 );
1255 ok( r == S_OK, "rets %08x\n", r);
1257 ref = IXMLDOMNode_AddRef( node );
1258 ok( ref == 2, "ref %d\n", ref );
1259 IXMLDOMNode_Release( node );
1261 ref = IXMLDOMNode_Release( node );
1262 ok( ref == 0, "ref %d\n", ref );
1263 ref = IXMLDOMNode_Release( node2 );
1264 ok( ref == 0, "ref %d\n", ref );
1266 ref = IXMLDOMNodeList_Release( node_list );
1267 ok( ref == 0, "ref %d\n", ref );
1269 ok( node != node2, "node %p node2 %p\n", node, node2 );
1271 ref = IXMLDOMDocument_Release( doc );
1272 ok( ref == 0, "ref %d\n", ref );
1274 ref = IXMLDOMElement_AddRef( element );
1276 ok( ref == 3, "ref %d\n", ref );
1278 IXMLDOMElement_Release( element );
1280 /* IUnknown must be unique however we obtain it */
1281 r = IXMLDOMElement_QueryInterface( element, &IID_IUnknown, (LPVOID*)&unk );
1282 ok( r == S_OK, "rets %08x\n", r );
1283 r = IXMLDOMElement_QueryInterface( element, &IID_IXMLDOMNode, (LPVOID*)&node );
1284 ok( r == S_OK, "rets %08x\n", r );
1285 r = IXMLDOMNode_QueryInterface( node, &IID_IUnknown, (LPVOID*)&unk2 );
1286 ok( r == S_OK, "rets %08x\n", r );
1287 ok( unk == unk2, "unk %p unk2 %p\n", unk, unk2 );
1289 IUnknown_Release( unk2 );
1290 IUnknown_Release( unk );
1291 IXMLDOMNode_Release( node );
1293 IXMLDOMElement_Release( element );
1297 static void test_create(void)
1302 IXMLDOMDocument *doc;
1303 IXMLDOMElement *element;
1304 IXMLDOMNode *root, *node, *child;
1305 IXMLDOMNamedNodeMap *attr_map;
1310 r = CoCreateInstance( &CLSID_DOMDocument, NULL,
1311 CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (LPVOID*)&doc );
1316 V_I4(&var) = NODE_ELEMENT;
1317 str = SysAllocString( szlc );
1318 r = IXMLDOMDocument_createNode( doc, var, str, NULL, &node );
1319 ok( r == S_OK, "returns %08x\n", r );
1320 r = IXMLDOMDocument_appendChild( doc, node, &root );
1321 ok( r == S_OK, "returns %08x\n", r );
1322 ok( node == root, "%p %p\n", node, root );
1324 ref = IXMLDOMNode_AddRef( node );
1325 ok(ref == 3, "ref %d\n", ref);
1326 IXMLDOMNode_Release( node );
1328 ref = IXMLDOMNode_Release( node );
1329 ok(ref == 1, "ref %d\n", ref);
1330 SysFreeString( str );
1333 V_I4(&var) = NODE_ELEMENT;
1334 str = SysAllocString( szbs );
1335 r = IXMLDOMDocument_createNode( doc, var, str, NULL, &node );
1336 ok( r == S_OK, "returns %08x\n", r );
1338 ref = IXMLDOMNode_AddRef( node );
1339 ok(ref == 2, "ref = %d\n", ref);
1340 IXMLDOMNode_Release( node );
1342 r = IXMLDOMNode_QueryInterface( node, &IID_IUnknown, (LPVOID*)&unk );
1343 ok( r == S_OK, "returns %08x\n", r );
1345 ref = IXMLDOMNode_AddRef( unk );
1346 ok(ref == 3, "ref = %d\n", ref);
1347 IXMLDOMNode_Release( unk );
1349 V_VT(&var) = VT_EMPTY;
1350 r = IXMLDOMNode_insertBefore( root, (IXMLDOMNode*)unk, var, &child );
1351 ok( r == S_OK, "returns %08x\n", r );
1352 ok( unk == (IUnknown*)child, "%p %p\n", unk, child );
1353 IXMLDOMNode_Release( child );
1354 IUnknown_Release( unk );
1357 V_VT(&var) = VT_NULL;
1358 V_DISPATCH(&var) = (IDispatch*)node;
1359 r = IXMLDOMNode_insertBefore( root, node, var, &child );
1360 ok( r == S_OK, "returns %08x\n", r );
1361 ok( node == child, "%p %p\n", node, child );
1362 IXMLDOMNode_Release( child );
1365 V_VT(&var) = VT_NULL;
1366 V_DISPATCH(&var) = (IDispatch*)node;
1367 r = IXMLDOMNode_insertBefore( root, node, var, NULL );
1368 ok( r == S_OK, "returns %08x\n", r );
1369 IXMLDOMNode_Release( node );
1371 r = IXMLDOMNode_QueryInterface( root, &IID_IXMLDOMElement, (LPVOID*)&element );
1372 ok( r == S_OK, "returns %08x\n", r );
1374 r = IXMLDOMElement_get_attributes( element, &attr_map );
1375 ok( r == S_OK, "returns %08x\n", r );
1376 r = IXMLDOMNamedNodeMap_get_length( attr_map, &num );
1377 ok( r == S_OK, "returns %08x\n", r );
1378 ok( num == 0, "num %ld\n", num );
1379 IXMLDOMNamedNodeMap_Release( attr_map );
1381 V_VT(&var) = VT_BSTR;
1382 V_BSTR(&var) = SysAllocString( szstr1 );
1383 name = SysAllocString( szdl );
1384 r = IXMLDOMElement_setAttribute( element, name, var );
1385 ok( r == S_OK, "returns %08x\n", r );
1386 r = IXMLDOMElement_get_attributes( element, &attr_map );
1387 ok( r == S_OK, "returns %08x\n", r );
1388 r = IXMLDOMNamedNodeMap_get_length( attr_map, &num );
1389 ok( r == S_OK, "returns %08x\n", r );
1390 ok( num == 1, "num %ld\n", num );
1391 IXMLDOMNamedNodeMap_Release( attr_map );
1394 V_VT(&var) = VT_BSTR;
1395 V_BSTR(&var) = SysAllocString( szstr2 );
1396 r = IXMLDOMElement_setAttribute( element, name, var );
1397 ok( r == S_OK, "returns %08x\n", r );
1398 r = IXMLDOMElement_get_attributes( element, &attr_map );
1399 ok( r == S_OK, "returns %08x\n", r );
1400 r = IXMLDOMNamedNodeMap_get_length( attr_map, &num );
1401 ok( r == S_OK, "returns %08x\n", r );
1402 ok( num == 1, "num %ld\n", num );
1403 IXMLDOMNamedNodeMap_Release( attr_map );
1405 r = IXMLDOMElement_getAttribute( element, name, &var );
1406 ok( r == S_OK, "returns %08x\n", r );
1407 ok( !lstrcmpW(V_BSTR(&var), szstr2), "wrong attr value\n");
1409 SysFreeString(name);
1411 V_VT(&var) = VT_BSTR;
1412 V_BSTR(&var) = SysAllocString( szstr1 );
1413 name = SysAllocString( szlc );
1414 r = IXMLDOMElement_setAttribute( element, name, var );
1415 ok( r == S_OK, "returns %08x\n", r );
1416 r = IXMLDOMElement_get_attributes( element, &attr_map );
1417 ok( r == S_OK, "returns %08x\n", r );
1418 r = IXMLDOMNamedNodeMap_get_length( attr_map, &num );
1419 ok( r == S_OK, "returns %08x\n", r );
1420 ok( num == 2, "num %ld\n", num );
1421 IXMLDOMNamedNodeMap_Release( attr_map );
1423 SysFreeString(name);
1427 name = SysAllocString( szbs );
1428 r = IXMLDOMElement_setAttribute( element, name, var );
1429 ok( r == S_OK, "returns %08x\n", r );
1431 r = IXMLDOMElement_getAttribute( element, name, &var );
1432 ok( r == S_OK, "returns %08x\n", r );
1433 ok( V_VT(&var) == VT_BSTR, "variant type %x\n", V_VT(&var));
1435 SysFreeString(name);
1437 IXMLDOMElement_Release( element );
1438 IXMLDOMNode_Release( root );
1439 IXMLDOMDocument_Release( doc );
1442 static void test_getElementsByTagName(void)
1447 IXMLDOMDocument *doc;
1448 IXMLDOMNodeList *node_list;
1451 r = CoCreateInstance( &CLSID_DOMDocument, NULL,
1452 CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (LPVOID*)&doc );
1456 str = SysAllocString( szComplete4 );
1457 r = IXMLDOMDocument_loadXML( doc, str, &b );
1458 ok( r == S_OK, "loadXML failed\n");
1459 ok( b == VARIANT_TRUE, "failed to load XML string\n");
1460 SysFreeString( str );
1462 str = SysAllocString( szstar );
1463 r = IXMLDOMDocument_getElementsByTagName(doc, str, &node_list);
1464 ok( r == S_OK, "ret %08x\n", r );
1465 r = IXMLDOMNodeList_get_length( node_list, &len );
1466 ok( r == S_OK, "ret %08x\n", r );
1467 ok( len == 6, "len %ld\n", len );
1468 IXMLDOMNodeList_Release( node_list );
1469 SysFreeString( str );
1471 str = SysAllocString( szbs );
1472 r = IXMLDOMDocument_getElementsByTagName(doc, str, &node_list);
1473 ok( r == S_OK, "ret %08x\n", r );
1474 r = IXMLDOMNodeList_get_length( node_list, &len );
1475 ok( r == S_OK, "ret %08x\n", r );
1476 ok( len == 1, "len %ld\n", len );
1477 IXMLDOMNodeList_Release( node_list );
1478 SysFreeString( str );
1480 str = SysAllocString( szdl );
1481 r = IXMLDOMDocument_getElementsByTagName(doc, str, &node_list);
1482 ok( r == S_OK, "ret %08x\n", r );
1483 r = IXMLDOMNodeList_get_length( node_list, &len );
1484 ok( r == S_OK, "ret %08x\n", r );
1485 ok( len == 0, "len %ld\n", len );
1486 IXMLDOMNodeList_Release( node_list );
1487 SysFreeString( str );
1489 str = SysAllocString( szstr1 );
1490 r = IXMLDOMDocument_getElementsByTagName(doc, str, &node_list);
1491 ok( r == S_OK, "ret %08x\n", r );
1492 r = IXMLDOMNodeList_get_length( node_list, &len );
1493 ok( r == S_OK, "ret %08x\n", r );
1494 ok( len == 0, "len %ld\n", len );
1495 IXMLDOMNodeList_Release( node_list );
1496 SysFreeString( str );
1498 IXMLDOMDocument_Release( doc );
1501 static void test_get_text(void)
1506 IXMLDOMDocument *doc;
1507 IXMLDOMNode *node, *node2, *node3;
1508 IXMLDOMNodeList *node_list;
1509 IXMLDOMNamedNodeMap *node_map;
1511 r = CoCreateInstance( &CLSID_DOMDocument, NULL,
1512 CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (LPVOID*)&doc );
1516 str = SysAllocString( szComplete4 );
1517 r = IXMLDOMDocument_loadXML( doc, str, &b );
1518 ok( r == S_OK, "loadXML failed\n");
1519 ok( b == VARIANT_TRUE, "failed to load XML string\n");
1520 SysFreeString( str );
1522 str = SysAllocString( szbs );
1523 r = IXMLDOMDocument_getElementsByTagName( doc, str, &node_list );
1524 ok( r == S_OK, "ret %08x\n", r );
1527 r = IXMLDOMNodeList_get_item( node_list, 0, &node );
1528 ok( r == S_OK, "ret %08x\n", r );
1529 IXMLDOMNodeList_Release( node_list );
1531 /* Invalid output parameter*/
1532 r = IXMLDOMNode_get_text( node, NULL );
1533 ok( r == E_INVALIDARG, "ret %08x\n", r );
1535 r = IXMLDOMNode_get_text( node, &str );
1536 ok( r == S_OK, "ret %08x\n", r );
1538 ok( !memcmp(str, szfn1_txt, sizeof(szfn1_txt)), "wrong string\n" );
1540 ok( !memcmp(str, szfn1_txt, sizeof(szfn1_txt)-4), "wrong string\n" );
1543 r = IXMLDOMNode_get_attributes( node, &node_map );
1544 ok( r == S_OK, "ret %08x\n", r );
1546 str = SysAllocString( szvr );
1547 r = IXMLDOMNamedNodeMap_getNamedItem( node_map, str, &node2 );
1548 ok( r == S_OK, "ret %08x\n", r );
1551 r = IXMLDOMNode_get_text( node2, &str );
1552 ok( r == S_OK, "ret %08x\n", r );
1553 ok( !memcmp(str, szstr2, sizeof(szstr2)), "wrong string\n" );
1556 r = IXMLDOMNode_get_firstChild( node2, &node3 );
1557 ok( r == S_OK, "ret %08x\n", r );
1559 r = IXMLDOMNode_get_text( node3, &str );
1560 ok( r == S_OK, "ret %08x\n", r );
1561 ok( !memcmp(str, szstr2, sizeof(szstr2)), "wrong string\n" );
1565 IXMLDOMNode_Release( node3 );
1566 IXMLDOMNode_Release( node2 );
1567 IXMLDOMNamedNodeMap_Release( node_map );
1568 IXMLDOMNode_Release( node );
1569 IXMLDOMDocument_Release( doc );
1572 static void test_get_childNodes(void)
1577 IXMLDOMDocument *doc;
1578 IXMLDOMElement *element;
1579 IXMLDOMNode *node, *node2;
1580 IXMLDOMNodeList *node_list, *node_list2;
1583 r = CoCreateInstance( &CLSID_DOMDocument, NULL,
1584 CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (LPVOID*)&doc );
1588 str = SysAllocString( szComplete4 );
1589 r = IXMLDOMDocument_loadXML( doc, str, &b );
1590 ok( r == S_OK, "loadXML failed\n");
1591 ok( b == VARIANT_TRUE, "failed to load XML string\n");
1592 SysFreeString( str );
1594 r = IXMLDOMDocument_get_documentElement( doc, &element );
1595 ok( r == S_OK, "ret %08x\n", r);
1597 r = IXMLDOMElement_get_childNodes( element, &node_list );
1598 ok( r == S_OK, "ret %08x\n", r);
1600 r = IXMLDOMNodeList_get_length( node_list, &len );
1601 ok( r == S_OK, "ret %08x\n", r);
1602 ok( len == 4, "len %ld\n", len);
1604 r = IXMLDOMNodeList_get_item( node_list, 2, &node );
1605 ok( r == S_OK, "ret %08x\n", r);
1607 r = IXMLDOMNode_get_childNodes( node, &node_list2 );
1608 ok( r == S_OK, "ret %08x\n", r);
1610 r = IXMLDOMNodeList_get_length( node_list2, &len );
1611 ok( r == S_OK, "ret %08x\n", r);
1612 ok( len == 0, "len %ld\n", len);
1614 r = IXMLDOMNodeList_get_item( node_list2, 0, &node2);
1615 ok( r == S_FALSE, "ret %08x\n", r);
1617 IXMLDOMNodeList_Release( node_list2 );
1618 IXMLDOMNode_Release( node );
1619 IXMLDOMNodeList_Release( node_list );
1620 IXMLDOMElement_Release( element );
1621 IXMLDOMDocument_Release( doc );
1624 static void test_removeChild(void)
1629 IXMLDOMDocument *doc;
1630 IXMLDOMElement *element;
1631 IXMLDOMNode *node, *node2, *node3, *node4;
1632 IXMLDOMNodeList *node_list, *node_list2;
1634 r = CoCreateInstance( &CLSID_DOMDocument, NULL,
1635 CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (LPVOID*)&doc );
1639 str = SysAllocString( szComplete4 );
1640 r = IXMLDOMDocument_loadXML( doc, str, &b );
1641 ok( r == S_OK, "loadXML failed\n");
1642 ok( b == VARIANT_TRUE, "failed to load XML string\n");
1643 SysFreeString( str );
1645 r = IXMLDOMDocument_get_documentElement( doc, &element );
1646 ok( r == S_OK, "ret %08x\n", r);
1648 r = IXMLDOMElement_get_childNodes( element, &node_list );
1649 ok( r == S_OK, "ret %08x\n", r);
1651 r = IXMLDOMNodeList_get_item( node_list, 3, &node );
1652 ok( r == S_OK, "ret %08x\n", r);
1654 r = IXMLDOMNode_get_childNodes( node, &node_list2 );
1655 ok( r == S_OK, "ret %08x\n", r);
1657 r = IXMLDOMNodeList_get_item( node_list, 0, &node4 );
1658 ok( r == S_OK, "ret %08x\n", r);
1660 r = IXMLDOMElement_removeChild( element, NULL, &node2 );
1661 ok( r == E_INVALIDARG, "ret %08x\n", r );
1663 r = IXMLDOMElement_removeChild( element, node4, &node2 );
1664 ok( r == S_OK, "ret %08x\n", r);
1665 ok( node4 == node2, "node %p node2 %p\n", node4, node2 );
1667 r = IXMLDOMNode_get_parentNode( node4, &node3 );
1668 ok( r == S_FALSE, "ret %08x\n", r);
1669 ok( node3 == NULL, "%p\n", node3 );
1671 IXMLDOMNode_Release( node2 );
1672 IXMLDOMNode_Release( node4 );
1673 IXMLDOMNodeList_Release( node_list2 );
1674 IXMLDOMNode_Release( node );
1675 IXMLDOMNodeList_Release( node_list );
1676 IXMLDOMElement_Release( element );
1677 IXMLDOMDocument_Release( doc );
1680 static void test_XMLHTTP(void)
1682 static const WCHAR wszBody[] = {'m','o','d','e','=','T','e','s','t',0};
1683 static WCHAR wszPOST[] = {'P','O','S','T',0};
1684 static WCHAR wszUrl[] = {'h','t','t','p',':','/','/',
1685 'c','r','o','s','s','o','v','e','r','.','c','o','d','e','w','e','a','v','e','r','s','.','c','o','m','/',
1686 'p','o','s','t','t','e','s','t','.','p','h','p',0};
1687 static const WCHAR wszExpectedResponse[] = {'F','A','I','L','E','D',0};
1688 IXMLHttpRequest *pXMLHttpRequest;
1693 HRESULT hr = CoCreateInstance(&CLSID_XMLHTTPRequest, NULL,
1694 CLSCTX_INPROC_SERVER, &IID_IXMLHttpRequest,
1695 (void **)&pXMLHttpRequest);
1697 ok(hr == S_OK, "CoCreateInstance(CLSID_XMLHTTPRequest) should have succeeded instead of failing with 0x%08x\n", hr);
1702 VariantInit(&dummy);
1703 V_VT(&dummy) = VT_ERROR;
1704 V_ERROR(&dummy) = DISP_E_MEMBERNOTFOUND;
1705 VariantInit(&varfalse);
1706 V_VT(&varfalse) = VT_BOOL;
1707 V_BOOL(&varfalse) = VARIANT_FALSE;
1708 V_VT(&varbody) = VT_BSTR;
1709 V_BSTR(&varbody) = SysAllocString(wszBody);
1711 hr = IXMLHttpRequest_open(pXMLHttpRequest, wszPOST, wszUrl, varfalse, dummy, dummy);
1712 ok(hr == S_OK, "IXMLHttpRequest_open should have succeeded instead of failing with 0x%08x\n", hr);
1714 hr = IXMLHttpRequest_send(pXMLHttpRequest, varbody);
1715 ok(hr == S_OK, "IXMLHttpRequest_send should have succeeded instead of failing with 0x%08x\n", hr);
1716 VariantClear(&varbody);
1718 hr = IXMLHttpRequest_get_responseText(pXMLHttpRequest, &bstrResponse);
1719 ok(hr == S_OK, "IXMLHttpRequest_get_responseText should have succeeded instead of failing with 0x%08x\n", hr);
1720 /* the server currently returns "FAILED" because the Content-Type header is
1721 * not what the server expects */
1722 ok(!memcmp(bstrResponse, wszExpectedResponse, sizeof(wszExpectedResponse)), "bstrResponse differs from what was expected\n");
1723 SysFreeString(bstrResponse);
1726 static void test_IXMLDOMDocument2(void)
1731 IXMLDOMDocument *doc;
1732 IXMLDOMDocument2 *doc2;
1736 r = CoCreateInstance( &CLSID_DOMDocument, NULL,
1737 CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (LPVOID*)&doc );
1741 str = SysAllocString( szComplete4 );
1742 r = IXMLDOMDocument_loadXML( doc, str, &b );
1743 ok( r == S_OK, "loadXML failed\n");
1744 ok( b == VARIANT_TRUE, "failed to load XML string\n");
1745 SysFreeString( str );
1747 r = IXMLDOMDocument_QueryInterface( doc, &IID_IXMLDOMDocument2, (void**)&doc2 );
1748 ok( r == S_OK, "ret %08x\n", r );
1749 ok( doc == (IXMLDOMDocument*)doc2, "interfaces differ\n");
1751 /* we will check if the variant got cleared */
1752 ref = IXMLDOMDocument2_AddRef(doc2);
1753 expect_eq(ref, 3, int, "%d"); /* doc, doc2, AddRef*/
1754 V_VT(&var) = VT_UNKNOWN;
1755 V_UNKNOWN(&var) = (IUnknown *)doc2;
1758 ole_expect(IXMLDOMDocument2_getProperty(doc2, _bstr_("askldhfaklsdf"), &var), E_FAIL);
1759 expect_eq(V_VT(&var), VT_UNKNOWN, int, "%x");
1760 ole_expect(IXMLDOMDocument2_getProperty(doc2, _bstr_("SelectionLanguage"), NULL), E_INVALIDARG);
1763 ole_check(IXMLDOMDocument2_getProperty(doc2, _bstr_("SelectionLanguage"), &var));
1764 expect_eq(V_VT(&var), VT_BSTR, int, "%x");
1765 expect_bstr_eq_and_free(V_BSTR(&var), "XSLPattern");
1768 /* the variant didn't get cleared*/
1769 expect_eq(IXMLDOMDocument2_Release(doc2), 2, int, "%d");
1771 /* setProperty tests */
1772 ole_expect(IXMLDOMDocument2_setProperty(doc2, _bstr_("askldhfaklsdf"), var), E_FAIL);
1773 ole_expect(IXMLDOMDocument2_setProperty(doc2, _bstr_("SelectionLanguage"), var), E_FAIL);
1774 ole_expect(IXMLDOMDocument2_setProperty(doc2, _bstr_("SelectionLanguage"), _variantbstr_("alskjdh faklsjd hfk")), E_FAIL);
1775 ole_check(IXMLDOMDocument2_setProperty(doc2, _bstr_("SelectionLanguage"), _variantbstr_("XSLPattern")));
1776 ole_check(IXMLDOMDocument2_setProperty(doc2, _bstr_("SelectionLanguage"), _variantbstr_("XPath")));
1777 ole_check(IXMLDOMDocument2_setProperty(doc2, _bstr_("SelectionLanguage"), _variantbstr_("XSLPattern")));
1779 /* contrary to what MSDN calims you can switch back from XPath to XSLPattern */
1780 ole_check(IXMLDOMDocument2_getProperty(doc2, _bstr_("SelectionLanguage"), &var));
1781 expect_eq(V_VT(&var), VT_BSTR, int, "%x");
1782 expect_bstr_eq_and_free(V_BSTR(&var), "XSLPattern");
1784 IXMLDOMDocument2_Release( doc2 );
1785 IXMLDOMDocument_Release( doc );
1789 static void test_XPath(void)
1794 IXMLDOMDocument2 *doc;
1795 IXMLDOMNode *rootNode;
1796 IXMLDOMNode *elem1Node;
1798 IXMLDOMNodeList *list;
1800 r = CoCreateInstance( &CLSID_DOMDocument, NULL,
1801 CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (LPVOID*)&doc );
1805 ole_check(IXMLDOMDocument_loadXML(doc, _bstr_(szExampleXML), &b));
1806 ok(b == VARIANT_TRUE, "failed to load XML string\n");
1808 /* switch to XPath */
1809 ole_check(IXMLDOMDocument2_setProperty(doc, _bstr_("SelectionLanguage"), _variantbstr_("XPath")));
1811 /* some simple queries*/
1812 ole_check(IXMLDOMDocument_selectNodes(doc, _bstr_("root"), &list));
1813 ole_check(IXMLDOMNodeList_get_item(list, 0, &rootNode));
1814 ole_check(IXMLDOMNodeList_reset(list));
1815 expect_list_and_release(list, "E2.D1");
1816 if (rootNode == NULL)
1819 ole_check(IXMLDOMDocument_selectNodes(doc, _bstr_("root//c"), &list));
1820 expect_list_and_release(list, "E3.E1.E2.D1 E3.E2.E2.D1");
1822 ole_check(IXMLDOMDocument_selectNodes(doc, _bstr_("//c[@type]"), &list));
1823 expect_list_and_release(list, "E3.E2.E2.D1");
1825 ole_check(IXMLDOMNode_selectNodes(rootNode, _bstr_("elem"), &list));
1826 /* using get_item for query results advances the position */
1827 ole_check(IXMLDOMNodeList_get_item(list, 1, &node));
1828 expect_node(node, "E2.E2.D1");
1829 IXMLDOMNode_Release(node);
1830 ole_check(IXMLDOMNodeList_nextNode(list, &node));
1831 expect_node(node, "E4.E2.D1");
1832 IXMLDOMNode_Release(node);
1833 ole_check(IXMLDOMNodeList_reset(list));
1834 expect_list_and_release(list, "E1.E2.D1 E2.E2.D1 E4.E2.D1");
1836 ole_check(IXMLDOMNode_selectNodes(rootNode, _bstr_("."), &list));
1837 expect_list_and_release(list, "E2.D1");
1839 ole_check(IXMLDOMNode_selectNodes(rootNode, _bstr_("elem[3]/preceding-sibling::*"), &list));
1840 ole_check(IXMLDOMNodeList_get_item(list, 0, &elem1Node));
1841 ole_check(IXMLDOMNodeList_reset(list));
1842 expect_list_and_release(list, "E1.E2.D1 E2.E2.D1 E3.E2.D1");
1844 /* select an attribute */
1845 ole_check(IXMLDOMNode_selectNodes(rootNode, _bstr_(".//@type"), &list));
1846 expect_list_and_release(list, "A'type'.E3.E2.E2.D1");
1848 /* would evaluate to a number */
1849 ole_expect(IXMLDOMNode_selectNodes(rootNode, _bstr_("count(*)"), &list), E_FAIL);
1850 /* would evaluate to a boolean */
1851 ole_expect(IXMLDOMNode_selectNodes(rootNode, _bstr_("position()>0"), &list), E_FAIL);
1852 /* would evaluate to a string */
1853 ole_expect(IXMLDOMNode_selectNodes(rootNode, _bstr_("name()"), &list), E_FAIL);
1856 ole_check(IXMLDOMNode_selectNodes(rootNode, _bstr_("c"), &list));
1857 expect_list_and_release(list, "");
1858 ole_check(IXMLDOMDocument_selectNodes(doc, _bstr_("elem//c"), &list));
1859 expect_list_and_release(list, "");
1860 ole_check(IXMLDOMDocument_selectNodes(doc, _bstr_("//elem[4]"), &list));
1861 expect_list_and_release(list, "");
1863 /* foo undeclared in document node */
1864 ole_expect(IXMLDOMDocument_selectNodes(doc, _bstr_("root//foo:c"), &list), E_FAIL);
1865 /* undeclared in <root> node */
1866 ole_expect(IXMLDOMNode_selectNodes(rootNode, _bstr_(".//foo:c"), &list), E_FAIL);
1867 /* undeclared in <elem> node */
1868 ole_expect(IXMLDOMNode_selectNodes(elem1Node, _bstr_("//foo:c"), &list), E_FAIL);
1869 /* but this trick can be used */
1870 ole_check(IXMLDOMNode_selectNodes(elem1Node, _bstr_("//*[name()='foo:c']"), &list));
1871 expect_list_and_release(list, "E3.E4.E2.D1");
1873 /* it has to be declared in SelectionNamespaces */
1874 todo_wine ole_check(IXMLDOMDocument2_setProperty(doc, _bstr_("SelectionNamespaces"),
1875 _variantbstr_("xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'")));
1877 /* now the namespace can be used */
1878 todo_wine ole_check(IXMLDOMDocument_selectNodes(doc, _bstr_("root//test:c"), &list));
1879 todo_wine expect_list_and_release(list, "E3.E3.E2.D1 E3.E4.E2.D1");
1880 todo_wine ole_check(IXMLDOMNode_selectNodes(rootNode, _bstr_(".//test:c"), &list));
1881 todo_wine expect_list_and_release(list, "E3.E3.E2.D1 E3.E4.E2.D1");
1882 todo_wine ole_check(IXMLDOMNode_selectNodes(elem1Node, _bstr_("//test:c"), &list));
1883 todo_wine expect_list_and_release(list, "E3.E3.E2.D1 E3.E4.E2.D1");
1884 todo_wine ole_check(IXMLDOMNode_selectNodes(elem1Node, _bstr_(".//test:x"), &list));
1885 todo_wine expect_list_and_release(list, "E5.E1.E4.E1.E2.D1");
1887 /* SelectionNamespaces syntax error - the namespaces doesn't work anymore but the value is stored */
1888 ole_expect(IXMLDOMDocument2_setProperty(doc, _bstr_("SelectionNamespaces"),
1889 _variantbstr_("xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29' xmlns:foo=###")), E_FAIL);
1891 ole_expect(IXMLDOMDocument_selectNodes(doc, _bstr_("root//foo:c"), &list), E_FAIL);
1894 todo_wine ole_check(IXMLDOMDocument2_getProperty(doc, _bstr_("SelectionNamespaces"), &var));
1895 todo_wine expect_eq(V_VT(&var), VT_BSTR, int, "%x");
1896 if (V_VT(&var) == VT_BSTR)
1897 expect_bstr_eq_and_free(V_BSTR(&var), "xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29' xmlns:foo=###");
1899 /* extra attributes - same thing*/
1900 ole_expect(IXMLDOMDocument2_setProperty(doc, _bstr_("SelectionNamespaces"),
1901 _variantbstr_("xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29' param='test'")), E_FAIL);
1902 ole_expect(IXMLDOMDocument_selectNodes(doc, _bstr_("root//foo:c"), &list), E_FAIL);
1904 IXMLDOMNode_Release(rootNode);
1905 IXMLDOMNode_Release(elem1Node);
1906 IXMLDOMDocument_Release(doc);
1910 static void test_cloneNode(void )
1912 IXMLDOMDocument *doc = NULL;
1914 IXMLDOMNodeList *pList;
1915 IXMLDOMNamedNodeMap *mapAttr;
1916 long nLength = 0, nLength1 = 0;
1917 long nAttrCnt = 0, nAttrCnt1 = 0;
1919 IXMLDOMNode *node_clone;
1922 static const WCHAR szSearch[] = { 'l', 'c', '/', 'p', 'r', 0 };
1924 r = CoCreateInstance( &CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (LPVOID*)&doc );
1928 str = SysAllocString( szComplete4 );
1929 ole_check(IXMLDOMDocument_loadXML(doc, str, &b));
1930 ok(b == VARIANT_TRUE, "failed to load XML string\n");
1936 str = SysAllocString( szSearch);
1937 r = IXMLDOMNode_selectSingleNode(doc, str, &node);
1938 ok( r == S_OK, "ret %08x\n", r );
1939 ok( node != NULL, "node %p\n", node );
1944 IXMLDOMDocument_Release(doc);
1948 /* Check invalid parameter */
1949 r = IXMLDOMNode_cloneNode(node, VARIANT_TRUE, NULL);
1950 ok( r == E_INVALIDARG, "ret %08x\n", r );
1953 r = IXMLDOMNode_cloneNode(node, VARIANT_TRUE, &node_clone);
1954 ok( r == S_OK, "ret %08x\n", r );
1955 ok( node_clone != NULL, "node %p\n", node );
1959 IXMLDOMDocument_Release(doc);
1960 IXMLDOMNode_Release(node);
1964 r = IXMLDOMNode_get_childNodes(node, &pList);
1965 ok( r == S_OK, "ret %08x\n", r );
1968 IXMLDOMNodeList_get_length(pList, &nLength);
1969 IXMLDOMNodeList_Release(pList);
1972 r = IXMLDOMNode_get_attributes(node, &mapAttr);
1973 ok( r == S_OK, "ret %08x\n", r );
1976 IXMLDOMNamedNodeMap_get_length(mapAttr, &nAttrCnt);
1977 IXMLDOMNamedNodeMap_Release(mapAttr);
1980 r = IXMLDOMNode_get_childNodes(node_clone, &pList);
1981 ok( r == S_OK, "ret %08x\n", r );
1984 IXMLDOMNodeList_get_length(pList, &nLength1);
1985 IXMLDOMNodeList_Release(pList);
1988 r = IXMLDOMNode_get_attributes(node_clone, &mapAttr);
1989 ok( r == S_OK, "ret %08x\n", r );
1992 IXMLDOMNamedNodeMap_get_length(mapAttr, &nAttrCnt1);
1993 IXMLDOMNamedNodeMap_Release(mapAttr);
1996 ok(nLength == nLength1, "wrong Child count (%ld, %ld)\n", nLength, nLength1);
1997 ok(nAttrCnt == nAttrCnt1, "wrong Attribute count (%ld, %ld)\n", nAttrCnt, nAttrCnt1);
1998 IXMLDOMNode_Release(node_clone);
2001 r = IXMLDOMNode_cloneNode(node, VARIANT_FALSE, &node_clone);
2002 ok( r == S_OK, "ret %08x\n", r );
2003 ok( node_clone != NULL, "node %p\n", node );
2007 IXMLDOMDocument_Release(doc);
2008 IXMLDOMNode_Release(node);
2012 r = IXMLDOMNode_get_childNodes(node_clone, &pList);
2013 ok( r == S_OK, "ret %08x\n", r );
2016 IXMLDOMNodeList_get_length(pList, &nLength1);
2017 ok( nLength1 == 0, "Length should be 0 (%ld)\n", nLength1);
2018 IXMLDOMNodeList_Release(pList);
2021 r = IXMLDOMNode_get_attributes(node_clone, &mapAttr);
2022 ok( r == S_OK, "ret %08x\n", r );
2025 IXMLDOMNamedNodeMap_get_length(mapAttr, &nAttrCnt1);
2026 ok( nAttrCnt1 == 3, "Attribute count should be 3 (%ld)\n", nAttrCnt1);
2027 IXMLDOMNamedNodeMap_Release(mapAttr);
2030 ok(nLength != nLength1, "wrong Child count (%ld, %ld)\n", nLength, nLength1);
2031 ok(nAttrCnt == nAttrCnt1, "wrong Attribute count (%ld, %ld)\n", nAttrCnt, nAttrCnt1);
2032 IXMLDOMNode_Release(node_clone);
2035 IXMLDOMNode_Release(node);
2036 IXMLDOMDocument_Release(doc);
2039 static void test_xmlTypes(void)
2041 IXMLDOMDocument *doc = NULL;
2042 IXMLDOMElement *pRoot;
2044 IXMLDOMComment *pComment;
2045 IXMLDOMElement *pElement;
2046 IXMLDOMAttribute *pAttrubute;
2047 IXMLDOMNamedNodeMap *pAttribs;
2048 IXMLDOMCDATASection *pCDataSec;
2049 IXMLDOMImplementation *pIXMLDOMImplementation = NULL;
2050 IXMLDOMDocumentFragment *pDocFrag = NULL;
2051 IXMLDOMEntityReference *pEntityRef = NULL;
2053 IXMLDOMNode *pNextChild = (IXMLDOMNode *)0x1; /* Used for testing Siblings */
2057 hr = CoCreateInstance( &CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (LPVOID*)&doc );
2061 hr = IXMLDOMDocument_get_nextSibling(doc, NULL);
2062 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2064 hr = IXMLDOMDocument_get_nextSibling(doc, &pNextChild);
2065 ok(hr == S_FALSE, "ret %08x\n", hr );
2066 ok(pNextChild == NULL, "pDocChild not NULL\n");
2068 /* test previous Sibling */
2069 hr = IXMLDOMDocument_get_previousSibling(doc, NULL);
2070 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2072 pNextChild = (IXMLDOMNode *)0x1;
2073 hr = IXMLDOMDocument_get_previousSibling(doc, &pNextChild);
2074 ok(hr == S_FALSE, "ret %08x\n", hr );
2075 ok(pNextChild == NULL, "pNextChild not NULL\n");
2077 /* test get_attributes */
2078 hr = IXMLDOMDocument_get_attributes( doc, NULL );
2079 ok( hr == E_INVALIDARG, "get_attributes returned wrong code\n");
2081 pAttribs = (IXMLDOMNamedNodeMap*)0x1;
2082 hr = IXMLDOMDocument_get_attributes( doc, &pAttribs);
2083 ok(hr == S_FALSE, "ret %08x\n", hr );
2084 ok( pAttribs == NULL, "pAttribs not NULL\n");
2086 /* test get_dataType */
2087 hr = IXMLDOMDocument_get_dataType(doc, &v);
2088 ok(hr == S_FALSE, "ret %08x\n", hr );
2089 ok( V_VT(&v) == VT_NULL, "incorrect dataType type\n");
2092 /* test nodeTypeString */
2093 hr = IXMLDOMDocument_get_nodeTypeString(doc, &str);
2094 ok(hr == S_OK, "ret %08x\n", hr );
2095 ok( !lstrcmpW( str, _bstr_("document") ), "incorrect nodeTypeString string\n");
2098 /* test implementation */
2099 hr = IXMLDOMDocument_get_implementation(doc, NULL);
2100 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2102 hr = IXMLDOMDocument_get_implementation(doc, &pIXMLDOMImplementation);
2103 ok(hr == S_OK, "ret %08x\n", hr );
2106 VARIANT_BOOL hasFeature = VARIANT_TRUE;
2107 BSTR sEmpty = SysAllocStringLen(NULL, 0);
2109 hr = IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation, NULL, sEmpty, &hasFeature);
2110 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2112 hr = IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation, sEmpty, sEmpty, NULL);
2113 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2115 hr = IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation, _bstr_("DOM"), sEmpty, &hasFeature);
2116 ok(hr == S_OK, "ret %08x\n", hr );
2117 ok(hasFeature == VARIANT_FALSE, "hasFeature returned false\n");
2119 hr = IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation, sEmpty, sEmpty, &hasFeature);
2120 ok(hr == S_OK, "ret %08x\n", hr );
2121 ok(hasFeature == VARIANT_FALSE, "hasFeature returned true\n");
2123 hr = IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation, _bstr_("DOM"), NULL, &hasFeature);
2124 ok(hr == S_OK, "ret %08x\n", hr );
2125 ok(hasFeature == VARIANT_TRUE, "hasFeature returned false\n");
2127 hr = IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation, _bstr_("DOM"), sEmpty, &hasFeature);
2128 ok(hr == S_OK, "ret %08x\n", hr );
2129 ok(hasFeature == VARIANT_FALSE, "hasFeature returned false\n");
2131 hr = IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation, _bstr_("DOM"), _bstr_("1.0"), &hasFeature);
2132 ok(hr == S_OK, "ret %08x\n", hr );
2133 ok(hasFeature == VARIANT_TRUE, "hasFeature returned true\n");
2135 hr = IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation, _bstr_("XML"), _bstr_("1.0"), &hasFeature);
2136 ok(hr == S_OK, "ret %08x\n", hr );
2137 ok(hasFeature == VARIANT_TRUE, "hasFeature returned true\n");
2139 hr = IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation, _bstr_("MS-DOM"), _bstr_("1.0"), &hasFeature);
2140 ok(hr == S_OK, "ret %08x\n", hr );
2141 ok(hasFeature == VARIANT_TRUE, "hasFeature returned true\n");
2143 hr = IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation, _bstr_("SSS"), NULL, &hasFeature);
2144 ok(hr == S_OK, "ret %08x\n", hr );
2145 ok(hasFeature == VARIANT_FALSE, "hasFeature returned false\n");
2147 SysFreeString(sEmpty);
2148 IXMLDOMImplementation_Release(pIXMLDOMImplementation);
2153 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing"), &pRoot);
2154 ok(hr == S_OK, "ret %08x\n", hr );
2157 hr = IXMLDOMDocument_appendChild(doc, (IXMLDOMNode*)pRoot, NULL);
2158 ok(hr == S_OK, "ret %08x\n", hr );
2162 hr = IXMLDOMDocument_createComment(doc, szComment, &pComment);
2163 ok(hr == S_OK, "ret %08x\n", hr );
2166 /* test get_attributes */
2167 hr = IXMLDOMComment_get_attributes( pComment, NULL );
2168 ok( hr == E_INVALIDARG, "get_attributes returned wrong code\n");
2170 pAttribs = (IXMLDOMNamedNodeMap*)0x1;
2171 hr = IXMLDOMComment_get_attributes( pComment, &pAttribs);
2172 ok(hr == S_FALSE, "ret %08x\n", hr );
2173 ok( pAttribs == NULL, "pAttribs not NULL\n");
2175 /* test nodeTypeString */
2176 hr = IXMLDOMComment_get_nodeTypeString(pComment, &str);
2177 ok(hr == S_OK, "ret %08x\n", hr );
2178 ok( !lstrcmpW( str, _bstr_("comment") ), "incorrect nodeTypeString string\n");
2181 hr = IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pComment, NULL);
2182 ok(hr == S_OK, "ret %08x\n", hr );
2184 hr = IXMLDOMComment_get_nodeName(pComment, &str);
2185 ok(hr == S_OK, "ret %08x\n", hr );
2186 ok( !lstrcmpW( str, szCommentNodeText ), "incorrect comment node Name\n");
2189 hr = IXMLDOMComment_get_xml(pComment, &str);
2190 ok(hr == S_OK, "ret %08x\n", hr );
2191 ok( !lstrcmpW( str, szCommentXML ), "incorrect comment xml\n");
2194 hr = IXMLDOMComment_get_dataType(pComment, &v);
2195 ok(hr == S_FALSE, "ret %08x\n", hr );
2196 ok( V_VT(&v) == VT_NULL, "incorrect dataType type\n");
2199 /* put data Tests */
2200 hr = IXMLDOMComment_put_data(pComment, _bstr_("This &is a ; test <>\\"));
2201 ok(hr == S_OK, "ret %08x\n", hr );
2203 /* get data Tests */
2204 hr = IXMLDOMComment_get_data(pComment, &str);
2205 ok(hr == S_OK, "ret %08x\n", hr );
2206 ok( !lstrcmpW( str, _bstr_("This &is a ; test <>\\") ), "incorrect get_data string\n");
2209 /* get data Tests */
2210 hr = IXMLDOMComment_get_nodeValue(pComment, &v);
2211 ok(hr == S_OK, "ret %08x\n", hr );
2212 ok( V_VT(&v) == VT_BSTR, "incorrect dataType type\n");
2213 ok( !lstrcmpW( V_BSTR(&v), _bstr_("This &is a ; test <>\\") ), "incorrect get_nodeValue string\n");
2216 /* Confirm XML text is good */
2217 hr = IXMLDOMComment_get_xml(pComment, &str);
2218 ok(hr == S_OK, "ret %08x\n", hr );
2219 ok( !lstrcmpW( str, _bstr_("<!--This &is a ; test <>\\-->") ), "incorrect xml string\n");
2222 /* Confirm we get the put_data Text back */
2223 hr = IXMLDOMComment_get_text(pComment, &str);
2224 ok(hr == S_OK, "ret %08x\n", hr );
2225 ok( !lstrcmpW( str, _bstr_("This &is a ; test <>\\") ), "incorrect xml string\n");
2228 /* test length property */
2229 hr = IXMLDOMComment_get_length(pComment, &len);
2230 ok(hr == S_OK, "ret %08x\n", hr );
2231 ok(len == 21, "expected 21 got %ld\n", len);
2233 /* test substringData */
2234 hr = IXMLDOMComment_substringData(pComment, 0, 4, NULL);
2235 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2237 /* test substringData - Invalid offset */
2238 str = (BSTR)&szElement;
2239 hr = IXMLDOMComment_substringData(pComment, -1, 4, &str);
2240 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2241 ok( str == NULL, "incorrect string\n");
2243 /* test substringData - Invalid offset */
2244 str = (BSTR)&szElement;
2245 hr = IXMLDOMComment_substringData(pComment, 30, 0, &str);
2246 ok(hr == S_FALSE, "ret %08x\n", hr );
2247 ok( str == NULL, "incorrect string\n");
2249 /* test substringData - Invalid size */
2250 str = (BSTR)&szElement;
2251 hr = IXMLDOMComment_substringData(pComment, 0, -1, &str);
2252 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2253 ok( str == NULL, "incorrect string\n");
2255 /* test substringData - Invalid size */
2256 str = (BSTR)&szElement;
2257 hr = IXMLDOMComment_substringData(pComment, 2, 0, &str);
2258 ok(hr == S_FALSE, "ret %08x\n", hr );
2259 ok( str == NULL, "incorrect string\n");
2261 /* test substringData - Start of string */
2262 hr = IXMLDOMComment_substringData(pComment, 0, 4, &str);
2263 ok(hr == S_OK, "ret %08x\n", hr );
2264 ok( !lstrcmpW( str, _bstr_("This") ), "incorrect substringData string\n");
2267 /* test substringData - Middle of string */
2268 hr = IXMLDOMComment_substringData(pComment, 13, 4, &str);
2269 ok(hr == S_OK, "ret %08x\n", hr );
2270 ok( !lstrcmpW( str, _bstr_("test") ), "incorrect substringData string\n");
2273 /* test substringData - End of string */
2274 hr = IXMLDOMComment_substringData(pComment, 20, 4, &str);
2275 ok(hr == S_OK, "ret %08x\n", hr );
2276 ok( !lstrcmpW( str, _bstr_("\\") ), "incorrect substringData string\n");
2279 IXMLDOMComment_Release(pComment);
2283 hr = IXMLDOMDocument_createElement(doc, szElement, &pElement);
2284 ok(hr == S_OK, "ret %08x\n", hr );
2287 hr = IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
2288 ok(hr == S_OK, "ret %08x\n", hr );
2290 /* test nodeTypeString */
2291 hr = IXMLDOMDocument_get_nodeTypeString(pElement, &str);
2292 ok(hr == S_OK, "ret %08x\n", hr );
2293 ok( !lstrcmpW( str, _bstr_("element") ), "incorrect nodeTypeString string\n");
2296 hr = IXMLDOMElement_get_nodeName(pElement, &str);
2297 ok(hr == S_OK, "ret %08x\n", hr );
2298 ok( !lstrcmpW( str, szElement ), "incorrect element node Name\n");
2301 hr = IXMLDOMElement_get_xml(pElement, &str);
2302 ok(hr == S_OK, "ret %08x\n", hr );
2303 ok( !lstrcmpW( str, szElementXML ), "incorrect element xml\n");
2306 hr = IXMLDOMElement_get_dataType(pElement, &v);
2307 ok(hr == S_FALSE, "ret %08x\n", hr );
2308 ok( V_VT(&v) == VT_NULL, "incorrect dataType type\n");
2312 hr = IXMLDOMDocument_createAttribute(doc, szAttribute, &pAttrubute);
2313 ok(hr == S_OK, "ret %08x\n", hr );
2316 IXMLDOMNode *pNewChild = (IXMLDOMNode *)0x1;
2318 hr = IXMLDOMAttribute_get_nextSibling(pAttrubute, NULL);
2319 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2321 pNextChild = (IXMLDOMNode *)0x1;
2322 hr = IXMLDOMAttribute_get_nextSibling(pAttrubute, &pNextChild);
2323 ok(hr == S_FALSE, "ret %08x\n", hr );
2324 ok(pNextChild == NULL, "pNextChild not NULL\n");
2326 /* test Previous Sibling*/
2327 hr = IXMLDOMAttribute_get_previousSibling(pAttrubute, NULL);
2328 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2330 pNextChild = (IXMLDOMNode *)0x1;
2331 hr = IXMLDOMAttribute_get_previousSibling(pAttrubute, &pNextChild);
2332 ok(hr == S_FALSE, "ret %08x\n", hr );
2333 ok(pNextChild == NULL, "pNextChild not NULL\n");
2335 /* test get_attributes */
2336 hr = IXMLDOMAttribute_get_attributes( pAttrubute, NULL );
2337 ok( hr == E_INVALIDARG, "get_attributes returned wrong code\n");
2339 pAttribs = (IXMLDOMNamedNodeMap*)0x1;
2340 hr = IXMLDOMAttribute_get_attributes( pAttrubute, &pAttribs);
2341 ok(hr == S_FALSE, "ret %08x\n", hr );
2342 ok( pAttribs == NULL, "pAttribs not NULL\n");
2344 hr = IXMLDOMElement_appendChild(pElement, (IXMLDOMNode*)pAttrubute, &pNewChild);
2345 ok(hr == E_FAIL, "ret %08x\n", hr );
2346 ok(pNewChild == NULL, "pNewChild not NULL\n");
2348 hr = IXMLDOMElement_get_attributes(pElement, &pAttribs);
2349 ok(hr == S_OK, "ret %08x\n", hr );
2352 hr = IXMLDOMNamedNodeMap_setNamedItem(pAttribs, (IXMLDOMNode*)pAttrubute, NULL );
2353 ok(hr == S_OK, "ret %08x\n", hr );
2355 IXMLDOMNamedNodeMap_Release(pAttribs);
2358 hr = IXMLDOMAttribute_get_nodeName(pAttrubute, &str);
2359 ok(hr == S_OK, "ret %08x\n", hr );
2360 ok( !lstrcmpW( str, szAttribute ), "incorrect attribute node Name\n");
2363 /* test nodeTypeString */
2364 hr = IXMLDOMAttribute_get_nodeTypeString(pAttrubute, &str);
2365 ok(hr == S_OK, "ret %08x\n", hr );
2366 ok( !lstrcmpW( str, _bstr_("attribute") ), "incorrect nodeTypeString string\n");
2370 hr = IXMLDOMAttribute_get_nodeName(pAttrubute, &str);
2371 ok(hr == S_OK, "ret %08x\n", hr );
2372 ok( !lstrcmpW( str, szAttribute ), "incorrect nodeName string\n");
2375 /* test name property */
2376 hr = IXMLDOMAttribute_get_name(pAttrubute, &str);
2377 ok(hr == S_OK, "ret %08x\n", hr );
2378 ok( !lstrcmpW( str, szAttribute ), "incorrect name string\n");
2381 hr = IXMLDOMAttribute_get_xml(pAttrubute, &str);
2382 ok(hr == S_OK, "ret %08x\n", hr );
2383 ok( !lstrcmpW( str, szAttributeXML ), "incorrect attribute xml\n");
2386 hr = IXMLDOMAttribute_get_dataType(pAttrubute, &v);
2387 ok(hr == S_FALSE, "ret %08x\n", hr );
2388 ok( V_VT(&v) == VT_NULL, "incorrect dataType type\n");
2391 IXMLDOMAttribute_Release(pAttrubute);
2393 /* Check Element again with the Add Attribute*/
2394 hr = IXMLDOMElement_get_xml(pElement, &str);
2395 ok(hr == S_OK, "ret %08x\n", hr );
2396 ok( !lstrcmpW( str, szElementXML2 ), "incorrect element xml\n");
2400 hr = IXMLDOMElement_put_text(pElement, _bstr_("TestingNode"));
2401 ok(hr == S_OK, "ret %08x\n", hr );
2403 hr = IXMLDOMElement_get_xml(pElement, &str);
2404 ok(hr == S_OK, "ret %08x\n", hr );
2405 ok( !lstrcmpW( str, szElementXML3 ), "incorrect element xml\n");
2408 IXMLDOMElement_Release(pElement);
2412 hr = IXMLDOMDocument_createCDATASection(doc, szCData, NULL);
2413 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2415 hr = IXMLDOMDocument_createCDATASection(doc, szCData, &pCDataSec);
2416 ok(hr == S_OK, "ret %08x\n", hr );
2419 IXMLDOMNode *pNextChild = (IXMLDOMNode *)0x1;
2422 hr = IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pCDataSec, NULL);
2423 ok(hr == S_OK, "ret %08x\n", hr );
2425 /* get Attribute Tests */
2426 hr = IXMLDOMCDATASection_get_attributes(pCDataSec, NULL);
2427 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2429 pAttribs = (IXMLDOMNamedNodeMap*)0x1;
2430 hr = IXMLDOMCDATASection_get_attributes(pCDataSec, &pAttribs);
2431 ok(hr == S_FALSE, "ret %08x\n", hr );
2432 ok(pAttribs == NULL, "pAttribs != NULL\n");
2434 hr = IXMLDOMCDATASection_get_nodeName(pCDataSec, &str);
2435 ok(hr == S_OK, "ret %08x\n", hr );
2436 ok( !lstrcmpW( str, szCDataNodeText ), "incorrect cdata node Name\n");
2439 hr = IXMLDOMCDATASection_get_xml(pCDataSec, &str);
2440 ok(hr == S_OK, "ret %08x\n", hr );
2441 ok( !lstrcmpW( str, szCDataXML ), "incorrect cdata xml\n");
2444 /* test lastChild */
2445 pNextChild = (IXMLDOMNode*)0x1;
2446 hr = IXMLDOMCDATASection_get_lastChild(pCDataSec, &pNextChild);
2447 ok(hr == S_FALSE, "ret %08x\n", hr );
2448 ok(pNextChild == NULL, "pNextChild not NULL\n");
2450 /* test get_dataType */
2451 hr = IXMLDOMCDATASection_get_dataType(pCDataSec, NULL);
2452 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2454 hr = IXMLDOMCDATASection_get_dataType(pCDataSec, &v);
2455 ok(hr == S_FALSE, "ret %08x\n", hr );
2456 ok( V_VT(&v) == VT_NULL, "incorrect dataType type\n");
2459 /* test nodeTypeString */
2460 hr = IXMLDOMCDATASection_get_nodeTypeString(pCDataSec, &str);
2461 ok(hr == S_OK, "ret %08x\n", hr );
2462 ok( !lstrcmpW( str, _bstr_("cdatasection") ), "incorrect nodeTypeString string\n");
2465 /* put data Tests */
2466 hr = IXMLDOMCDATASection_put_data(pCDataSec, _bstr_("This &is a ; test <>\\"));
2467 ok(hr == S_OK, "ret %08x\n", hr );
2469 /* Confirm XML text is good */
2470 hr = IXMLDOMCDATASection_get_xml(pCDataSec, &str);
2471 ok(hr == S_OK, "ret %08x\n", hr );
2472 ok( !lstrcmpW( str, _bstr_("<![CDATA[This &is a ; test <>\\]]>") ), "incorrect xml string\n");
2475 /* Confirm we get the put_data Text back */
2476 hr = IXMLDOMCDATASection_get_text(pCDataSec, &str);
2477 ok(hr == S_OK, "ret %08x\n", hr );
2478 ok( !lstrcmpW( str, _bstr_("This &is a ; test <>\\") ), "incorrect text string\n");
2481 /* test length property */
2482 hr = IXMLDOMCDATASection_get_length(pCDataSec, &len);
2483 ok(hr == S_OK, "ret %08x\n", hr );
2484 ok(len == 21, "expected 21 got %ld\n", len);
2486 /* test get nodeValue */
2487 hr = IXMLDOMCDATASection_get_nodeValue(pCDataSec, &var);
2488 ok(hr == S_OK, "ret %08x\n", hr );
2489 ok( !lstrcmpW( str, _bstr_("This &is a ; test <>\\") ), "incorrect text string\n");
2493 hr = IXMLDOMCDATASection_get_data(pCDataSec, &str);
2494 ok(hr == S_OK, "ret %08x\n", hr );
2495 ok( !lstrcmpW( str, _bstr_("This &is a ; test <>\\") ), "incorrect text string\n");
2498 /* test substringData */
2499 hr = IXMLDOMCDATASection_substringData(pCDataSec, 0, 4, NULL);
2500 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2502 /* test substringData - Invalid offset */
2503 str = (BSTR)&szElement;
2504 hr = IXMLDOMCDATASection_substringData(pCDataSec, -1, 4, &str);
2505 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2506 ok( str == NULL, "incorrect string\n");
2508 /* test substringData - Invalid offset */
2509 str = (BSTR)&szElement;
2510 hr = IXMLDOMCDATASection_substringData(pCDataSec, 30, 0, &str);
2511 ok(hr == S_FALSE, "ret %08x\n", hr );
2512 ok( str == NULL, "incorrect string\n");
2514 /* test substringData - Invalid size */
2515 str = (BSTR)&szElement;
2516 hr = IXMLDOMCDATASection_substringData(pCDataSec, 0, -1, &str);
2517 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2518 ok( str == NULL, "incorrect string\n");
2520 /* test substringData - Invalid size */
2521 str = (BSTR)&szElement;
2522 hr = IXMLDOMCDATASection_substringData(pCDataSec, 2, 0, &str);
2523 ok(hr == S_FALSE, "ret %08x\n", hr );
2524 ok( str == NULL, "incorrect string\n");
2526 /* test substringData - Start of string */
2527 hr = IXMLDOMCDATASection_substringData(pCDataSec, 0, 4, &str);
2528 ok(hr == S_OK, "ret %08x\n", hr );
2529 ok( !lstrcmpW( str, _bstr_("This") ), "incorrect substringData string\n");
2532 /* test substringData - Middle of string */
2533 hr = IXMLDOMCDATASection_substringData(pCDataSec, 13, 4, &str);
2534 ok(hr == S_OK, "ret %08x\n", hr );
2535 ok( !lstrcmpW( str, _bstr_("test") ), "incorrect substringData string\n");
2538 /* test substringData - End of string */
2539 hr = IXMLDOMCDATASection_substringData(pCDataSec, 20, 4, &str);
2540 ok(hr == S_OK, "ret %08x\n", hr );
2541 ok( !lstrcmpW( str, _bstr_("\\") ), "incorrect substringData string\n");
2544 /* test appendData */
2545 hr = IXMLDOMCDATASection_appendData(pCDataSec, NULL);
2546 ok(hr == S_OK, "ret %08x\n", hr );
2548 hr = IXMLDOMCDATASection_appendData(pCDataSec, _bstr_(""));
2549 ok(hr == S_OK, "ret %08x\n", hr );
2551 hr = IXMLDOMCDATASection_appendData(pCDataSec, _bstr_("Append"));
2552 ok(hr == S_OK, "ret %08x\n", hr );
2554 hr = IXMLDOMCDATASection_get_text(pCDataSec, &str);
2555 ok(hr == S_OK, "ret %08x\n", hr );
2556 ok( !lstrcmpW( str, _bstr_("This &is a ; test <>\\Append") ), "incorrect get_text string\n");
2559 IXMLDOMCDATASection_Release(pCDataSec);
2562 /* Document Fragments */
2563 hr = IXMLDOMDocument_createDocumentFragment(doc, NULL);
2564 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2566 hr = IXMLDOMDocument_createDocumentFragment(doc, &pDocFrag);
2567 ok(hr == S_OK, "ret %08x\n", hr );
2570 IXMLDOMNode *pNextChild = (IXMLDOMNode *)0x1;
2572 hr = IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pDocFrag, NULL);
2573 ok(hr == S_OK, "ret %08x\n", hr );
2575 /* get Attribute Tests */
2576 hr = IXMLDOMDocumentFragment_get_attributes(pDocFrag, NULL);
2577 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2579 pAttribs = (IXMLDOMNamedNodeMap*)0x1;
2580 hr = IXMLDOMDocumentFragment_get_attributes(pDocFrag, &pAttribs);
2581 ok(hr == S_FALSE, "ret %08x\n", hr );
2582 ok(pAttribs == NULL, "pAttribs != NULL\n");
2584 hr = IXMLDOMDocumentFragment_get_nodeName(pDocFrag, &str);
2585 ok(hr == S_OK, "ret %08x\n", hr );
2586 ok( !lstrcmpW( str, szDocFragmentText ), "incorrect docfragment node Name\n");
2589 /* test next Sibling*/
2590 hr = IXMLDOMDocumentFragment_get_nextSibling(pDocFrag, NULL);
2591 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2593 pNextChild = (IXMLDOMNode *)0x1;
2594 hr = IXMLDOMDocumentFragment_get_nextSibling(pDocFrag, &pNextChild);
2595 ok(hr == S_FALSE, "ret %08x\n", hr );
2596 ok(pNextChild == NULL, "pNextChild not NULL\n");
2598 /* test Previous Sibling*/
2599 hr = IXMLDOMDocumentFragment_get_previousSibling(pDocFrag, NULL);
2600 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2602 pNextChild = (IXMLDOMNode *)0x1;
2603 hr = IXMLDOMDocumentFragment_get_previousSibling(pDocFrag, &pNextChild);
2604 ok(hr == S_FALSE, "ret %08x\n", hr );
2605 ok(pNextChild == NULL, "pNextChild not NULL\n");
2607 /* test get_dataType */
2608 hr = IXMLDOMDocumentFragment_get_dataType(pDocFrag, NULL);
2609 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2611 hr = IXMLDOMDocumentFragment_get_dataType(pDocFrag, &v);
2612 ok(hr == S_FALSE, "ret %08x\n", hr );
2613 ok( V_VT(&v) == VT_NULL, "incorrect dataType type\n");
2616 /* test nodeTypeString */
2617 hr = IXMLDOMDocumentFragment_get_nodeTypeString(pDocFrag, &str);
2618 ok(hr == S_OK, "ret %08x\n", hr );
2619 ok( !lstrcmpW( str, _bstr_("documentfragment") ), "incorrect nodeTypeString string\n");
2622 IXMLDOMDocumentFragment_Release(pDocFrag);
2625 /* Entity References */
2626 hr = IXMLDOMDocument_createEntityReference(doc, szEntityRef, NULL);
2627 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2629 hr = IXMLDOMDocument_createEntityReference(doc, szEntityRef, &pEntityRef);
2630 ok(hr == S_OK, "ret %08x\n", hr );
2633 hr = IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pEntityRef, NULL);
2634 ok(hr == S_OK, "ret %08x\n", hr );
2636 /* get Attribute Tests */
2637 hr = IXMLDOMEntityReference_get_attributes(pEntityRef, NULL);
2638 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2640 pAttribs = (IXMLDOMNamedNodeMap*)0x1;
2641 hr = IXMLDOMEntityReference_get_attributes(pEntityRef, &pAttribs);
2642 ok(hr == S_FALSE, "ret %08x\n", hr );
2643 ok(pAttribs == NULL, "pAttribs != NULL\n");
2646 hr = IXMLDOMEntityReference_get_dataType(pEntityRef, &v);
2647 ok(hr == S_FALSE, "ret %08x\n", hr );
2648 ok( V_VT(&v) == VT_NULL, "incorrect dataType type\n");
2651 /* test nodeTypeString */
2652 hr = IXMLDOMEntityReference_get_nodeTypeString(pEntityRef, &str);
2653 ok(hr == S_OK, "ret %08x\n", hr );
2654 ok( !lstrcmpW( str, _bstr_("entityreference") ), "incorrect nodeTypeString string\n");
2658 hr = IXMLDOMEntityReference_get_xml(pEntityRef, &str);
2659 ok(hr == S_OK, "ret %08x\n", hr );
2660 ok( !lstrcmpW( str, szEntityRefXML ), "incorrect xml string\n");
2663 IXMLDOMEntityReference_Release(pEntityRef);
2666 IXMLDOMElement_Release( pRoot );
2670 IXMLDOMDocument_Release(doc);
2675 static void test_nodeTypeTests( void )
2677 IXMLDOMDocument *doc = NULL;
2678 IXMLDOMElement *pRoot;
2679 IXMLDOMElement *pElement;
2682 hr = CoCreateInstance( &CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (LPVOID*)&doc );
2686 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing"), &pRoot);
2687 ok(hr == S_OK, "ret %08x\n", hr );
2690 hr = IXMLDOMDocument_appendChild(doc, (IXMLDOMNode*)pRoot, NULL);
2691 ok(hr == S_OK, "ret %08x\n", hr );
2694 hr = IXMLDOMElement_put_dataType(pRoot, NULL);
2695 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2698 hr = IXMLDOMElement_put_dataType(pRoot, _bstr_("abcdefg") );
2699 ok(hr == E_FAIL, "ret %08x\n", hr );
2702 * The name passed into put_dataType is case-insensitive. So many of the names
2703 * have been changed to reflect this.
2706 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_Boolean"), &pElement);
2707 ok(hr == S_OK, "ret %08x\n", hr );
2710 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
2712 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("Boolean") );
2713 ok(hr == S_OK, "ret %08x\n", hr );
2715 IXMLDOMElement_Release(pElement);
2719 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_String"), &pElement);
2720 ok(hr == S_OK, "ret %08x\n", hr );
2723 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
2725 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("String") );
2726 ok(hr == S_OK, "ret %08x\n", hr );
2728 IXMLDOMElement_Release(pElement);
2732 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_Number"), &pElement);
2733 ok(hr == S_OK, "ret %08x\n", hr );
2736 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
2738 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("number") );
2739 ok(hr == S_OK, "ret %08x\n", hr );
2741 IXMLDOMElement_Release(pElement);
2745 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_Int"), &pElement);
2746 ok(hr == S_OK, "ret %08x\n", hr );
2749 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
2751 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("InT") );
2752 ok(hr == S_OK, "ret %08x\n", hr );
2754 IXMLDOMElement_Release(pElement);
2758 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_Fixed"), &pElement);
2759 ok(hr == S_OK, "ret %08x\n", hr );
2762 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
2764 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("fixed.14.4") );
2765 ok(hr == S_OK, "ret %08x\n", hr );
2767 IXMLDOMElement_Release(pElement);
2771 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_DateTime"), &pElement);
2772 ok(hr == S_OK, "ret %08x\n", hr );
2775 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
2777 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("DateTime") );
2778 ok(hr == S_OK, "ret %08x\n", hr );
2780 IXMLDOMElement_Release(pElement);
2784 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_DateTime_tz"), &pElement);
2785 ok(hr == S_OK, "ret %08x\n", hr );
2788 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
2790 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("DateTime.tz") );
2791 ok(hr == S_OK, "ret %08x\n", hr );
2793 IXMLDOMElement_Release(pElement);
2797 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_Date"), &pElement);
2798 ok(hr == S_OK, "ret %08x\n", hr );
2801 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
2803 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("Date") );
2804 ok(hr == S_OK, "ret %08x\n", hr );
2806 IXMLDOMElement_Release(pElement);
2810 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_Time"), &pElement);
2811 ok(hr == S_OK, "ret %08x\n", hr );
2814 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
2816 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("Time") );
2817 ok(hr == S_OK, "ret %08x\n", hr );
2819 IXMLDOMElement_Release(pElement);
2823 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_Time_TZ"), &pElement);
2824 ok(hr == S_OK, "ret %08x\n", hr );
2827 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
2829 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("Time.tz") );
2830 ok(hr == S_OK, "ret %08x\n", hr );
2832 IXMLDOMElement_Release(pElement);
2836 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_I1"), &pElement);
2837 ok(hr == S_OK, "ret %08x\n", hr );
2840 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
2842 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("I1") );
2843 ok(hr == S_OK, "ret %08x\n", hr );
2845 IXMLDOMElement_Release(pElement);
2849 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_I2"), &pElement);
2850 ok(hr == S_OK, "ret %08x\n", hr );
2853 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
2855 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("I2") );
2856 ok(hr == S_OK, "ret %08x\n", hr );
2858 IXMLDOMElement_Release(pElement);
2862 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_I4"), &pElement);
2863 ok(hr == S_OK, "ret %08x\n", hr );
2866 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
2868 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("I4") );
2869 ok(hr == S_OK, "ret %08x\n", hr );
2871 IXMLDOMElement_Release(pElement);
2875 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_UI1"), &pElement);
2876 ok(hr == S_OK, "ret %08x\n", hr );
2879 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
2881 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("UI1") );
2882 ok(hr == S_OK, "ret %08x\n", hr );
2884 IXMLDOMElement_Release(pElement);
2888 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_UI2"), &pElement);
2889 ok(hr == S_OK, "ret %08x\n", hr );
2892 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
2894 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("UI2") );
2895 ok(hr == S_OK, "ret %08x\n", hr );
2897 IXMLDOMElement_Release(pElement);
2901 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_UI4"), &pElement);
2902 ok(hr == S_OK, "ret %08x\n", hr );
2905 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
2907 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("UI4") );
2908 ok(hr == S_OK, "ret %08x\n", hr );
2910 IXMLDOMElement_Release(pElement);
2914 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_r4"), &pElement);
2915 ok(hr == S_OK, "ret %08x\n", hr );
2918 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
2920 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("r4") );
2921 ok(hr == S_OK, "ret %08x\n", hr );
2923 IXMLDOMElement_Release(pElement);
2927 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_r8"), &pElement);
2928 ok(hr == S_OK, "ret %08x\n", hr );
2931 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
2933 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("r8") );
2934 ok(hr == S_OK, "ret %08x\n", hr );
2936 IXMLDOMElement_Release(pElement);
2940 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_float"), &pElement);
2941 ok(hr == S_OK, "ret %08x\n", hr );
2944 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
2946 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("float") );
2947 ok(hr == S_OK, "ret %08x\n", hr );
2949 IXMLDOMElement_Release(pElement);
2953 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_uuid"), &pElement);
2954 ok(hr == S_OK, "ret %08x\n", hr );
2957 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
2959 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("UuId") );
2960 ok(hr == S_OK, "ret %08x\n", hr );
2962 IXMLDOMElement_Release(pElement);
2966 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_bin_hex"), &pElement);
2967 ok(hr == S_OK, "ret %08x\n", hr );
2970 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
2972 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("bin.hex") );
2973 ok(hr == S_OK, "ret %08x\n", hr );
2975 IXMLDOMElement_Release(pElement);
2979 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_bin_base64"), &pElement);
2980 ok(hr == S_OK, "ret %08x\n", hr );
2983 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
2985 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("bin.base64") );
2986 ok(hr == S_OK, "ret %08x\n", hr );
2988 IXMLDOMElement_Release(pElement);
2991 /* Check changing types */
2992 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_Change"), &pElement);
2993 ok(hr == S_OK, "ret %08x\n", hr );
2996 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
2998 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("DateTime.tz") );
2999 ok(hr == S_OK, "ret %08x\n", hr );
3001 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("string") );
3002 ok(hr == S_OK, "ret %08x\n", hr );
3004 IXMLDOMElement_Release(pElement);
3007 IXMLDOMElement_Release(pRoot);
3011 IXMLDOMDocument_Release(doc);
3020 r = CoInitialize( NULL );
3021 ok( r == S_OK, "failed to init com\n");
3027 test_getElementsByTagName();
3029 test_get_childNodes();
3032 test_IXMLDOMDocument2();
3036 test_nodeTypeTests();