po: Remove English strings from the Finnish translation.
[wine.git] / dlls / msxml3 / node.c
blobadc38cbd6d5ce8489d2bdfac1bba7ee4effc0368
1 /*
2 * Node implementation
4 * Copyright 2005 Mike McCormack
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "config.h"
23 #define COBJMACROS
25 #include <stdarg.h>
27 #ifdef HAVE_LIBXML2
28 # include <libxml/parser.h>
29 # include <libxml/xmlerror.h>
30 # include <libxml/HTMLtree.h>
31 # ifdef SONAME_LIBXSLT
32 # ifdef HAVE_LIBXSLT_PATTERN_H
33 # include <libxslt/pattern.h>
34 # endif
35 # ifdef HAVE_LIBXSLT_TRANSFORM_H
36 # include <libxslt/transform.h>
37 # endif
38 # include <libxslt/xsltutils.h>
39 # include <libxslt/xsltInternals.h>
40 # endif
41 #endif
43 #include "windef.h"
44 #include "winbase.h"
45 #include "winuser.h"
46 #include "winnls.h"
47 #include "ole2.h"
48 #include "msxml6.h"
50 #include "msxml_private.h"
52 #include "wine/debug.h"
54 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
56 #ifdef HAVE_LIBXML2
58 #ifdef SONAME_LIBXSLT
59 extern void* libxslt_handle;
60 # define MAKE_FUNCPTR(f) extern typeof(f) * p##f
61 MAKE_FUNCPTR(xsltApplyStylesheet);
62 MAKE_FUNCPTR(xsltCleanupGlobals);
63 MAKE_FUNCPTR(xsltFreeStylesheet);
64 MAKE_FUNCPTR(xsltParseStylesheetDoc);
65 # undef MAKE_FUNCPTR
66 #endif
68 static const IID IID_xmlnode = {0x4f2f4ba2,0xb822,0x11df,{0x8b,0x8a,0x68,0x50,0xdf,0xd7,0x20,0x85}};
70 xmlNodePtr xmlNodePtr_from_domnode( IXMLDOMNode *iface, xmlElementType type )
72 xmlnode *This;
74 if ( !iface )
75 return NULL;
76 This = get_node_obj( iface );
77 if ( !This || !This->node )
78 return NULL;
79 if ( type && This->node->type != type )
80 return NULL;
81 return This->node;
84 BOOL node_query_interface(xmlnode *This, REFIID riid, void **ppv)
86 if(IsEqualGUID(&IID_xmlnode, riid)) {
87 TRACE("(%p)->(IID_xmlnode %p)\n", This, ppv);
88 *ppv = This;
89 return TRUE;
92 return dispex_query_interface(&This->dispex, riid, ppv);
95 /* common ISupportErrorInfo implementation */
96 typedef struct {
97 ISupportErrorInfo ISupportErrorInfo_iface;
98 LONG ref;
100 const tid_t* iids;
101 } SupportErrorInfo;
103 static inline SupportErrorInfo *impl_from_ISupportErrorInfo(ISupportErrorInfo *iface)
105 return CONTAINING_RECORD(iface, SupportErrorInfo, ISupportErrorInfo_iface);
108 static HRESULT WINAPI SupportErrorInfo_QueryInterface(ISupportErrorInfo *iface, REFIID riid, void **obj)
110 SupportErrorInfo *This = impl_from_ISupportErrorInfo(iface);
111 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), obj);
113 *obj = NULL;
115 if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_ISupportErrorInfo)) {
116 *obj = iface;
117 ISupportErrorInfo_AddRef(iface);
118 return S_OK;
121 return E_NOINTERFACE;
124 static ULONG WINAPI SupportErrorInfo_AddRef(ISupportErrorInfo *iface)
126 SupportErrorInfo *This = impl_from_ISupportErrorInfo(iface);
127 ULONG ref = InterlockedIncrement(&This->ref);
128 TRACE("(%p)->(%d)\n", This, ref );
129 return ref;
132 static ULONG WINAPI SupportErrorInfo_Release(ISupportErrorInfo *iface)
134 SupportErrorInfo *This = impl_from_ISupportErrorInfo(iface);
135 LONG ref = InterlockedDecrement(&This->ref);
137 TRACE("(%p)->(%d)\n", This, ref);
139 if (ref == 0)
140 heap_free(This);
142 return ref;
145 static HRESULT WINAPI SupportErrorInfo_InterfaceSupportsErrorInfo(ISupportErrorInfo *iface, REFIID riid)
147 SupportErrorInfo *This = impl_from_ISupportErrorInfo(iface);
148 enum tid_t const *tid;
150 TRACE("(%p)->(%s)\n", This, debugstr_guid(riid));
152 tid = This->iids;
153 while (*tid)
155 if (IsEqualGUID(riid, get_riid_from_tid(*tid)))
156 return S_OK;
157 tid++;
160 return S_FALSE;
163 static const struct ISupportErrorInfoVtbl SupportErrorInfoVtbl = {
164 SupportErrorInfo_QueryInterface,
165 SupportErrorInfo_AddRef,
166 SupportErrorInfo_Release,
167 SupportErrorInfo_InterfaceSupportsErrorInfo
170 HRESULT node_create_supporterrorinfo(enum tid_t const *iids, void **obj)
172 SupportErrorInfo *This;
174 This = heap_alloc(sizeof(*This));
175 if (!This) return E_OUTOFMEMORY;
177 This->ISupportErrorInfo_iface.lpVtbl = &SupportErrorInfoVtbl;
178 This->ref = 1;
179 This->iids = iids;
181 *obj = &This->ISupportErrorInfo_iface;
183 return S_OK;
186 xmlnode *get_node_obj(IXMLDOMNode *node)
188 xmlnode *obj = NULL;
189 HRESULT hres;
191 hres = IXMLDOMNode_QueryInterface(node, &IID_xmlnode, (void**)&obj);
192 if (!obj) WARN("node is not our IXMLDOMNode implementation\n");
193 return SUCCEEDED(hres) ? obj : NULL;
196 HRESULT node_get_nodeName(xmlnode *This, BSTR *name)
198 BSTR prefix, base;
199 HRESULT hr;
201 if (!name)
202 return E_INVALIDARG;
204 hr = node_get_base_name(This, &base);
205 if (hr != S_OK) return hr;
207 hr = node_get_prefix(This, &prefix);
208 if (hr == S_OK)
210 static const WCHAR colW = ':';
211 WCHAR *ptr;
213 /* +1 for ':' */
214 ptr = *name = SysAllocStringLen(NULL, SysStringLen(base) + SysStringLen(prefix) + 1);
215 memcpy(ptr, prefix, SysStringByteLen(prefix));
216 ptr += SysStringLen(prefix);
217 memcpy(ptr++, &colW, sizeof(WCHAR));
218 memcpy(ptr, base, SysStringByteLen(base));
220 SysFreeString(base);
221 SysFreeString(prefix);
223 else
224 *name = base;
226 return S_OK;
229 HRESULT node_get_content(xmlnode *This, VARIANT *value)
231 xmlChar *content;
233 if(!value)
234 return E_INVALIDARG;
236 content = xmlNodeGetContent(This->node);
237 V_VT(value) = VT_BSTR;
238 V_BSTR(value) = bstr_from_xmlChar( content );
239 xmlFree(content);
241 TRACE("%p returned %s\n", This, debugstr_w(V_BSTR(value)));
242 return S_OK;
245 HRESULT node_set_content(xmlnode *This, LPCWSTR value)
247 xmlChar *str;
249 TRACE("(%p)->(%s)\n", This, debugstr_w(value));
250 str = xmlchar_from_wchar(value);
251 if(!str)
252 return E_OUTOFMEMORY;
254 xmlNodeSetContent(This->node, str);
255 heap_free(str);
256 return S_OK;
259 static HRESULT node_set_content_escaped(xmlnode *This, LPCWSTR value)
261 xmlChar *str, *escaped;
263 TRACE("(%p)->(%s)\n", This, debugstr_w(value));
264 str = xmlchar_from_wchar(value);
265 if(!str)
266 return E_OUTOFMEMORY;
268 escaped = xmlEncodeSpecialChars(NULL, str);
269 if(!escaped)
271 heap_free(str);
272 return E_OUTOFMEMORY;
275 xmlNodeSetContent(This->node, escaped);
277 heap_free(str);
278 xmlFree(escaped);
280 return S_OK;
283 HRESULT node_put_value(xmlnode *This, VARIANT *value)
285 VARIANT string_value;
286 HRESULT hr;
288 VariantInit(&string_value);
289 hr = VariantChangeType(&string_value, value, 0, VT_BSTR);
290 if(FAILED(hr)) {
291 WARN("Couldn't convert to VT_BSTR\n");
292 return hr;
295 hr = node_set_content(This, V_BSTR(&string_value));
296 VariantClear(&string_value);
298 return hr;
301 HRESULT node_put_value_escaped(xmlnode *This, VARIANT *value)
303 VARIANT string_value;
304 HRESULT hr;
306 VariantInit(&string_value);
307 hr = VariantChangeType(&string_value, value, 0, VT_BSTR);
308 if(FAILED(hr)) {
309 WARN("Couldn't convert to VT_BSTR\n");
310 return hr;
313 hr = node_set_content_escaped(This, V_BSTR(&string_value));
314 VariantClear(&string_value);
316 return hr;
319 static HRESULT get_node(
320 xmlnode *This,
321 const char *name,
322 xmlNodePtr node,
323 IXMLDOMNode **out )
325 TRACE("(%p)->(%s %p %p)\n", This, name, node, out );
327 if ( !out )
328 return E_INVALIDARG;
330 /* if we don't have a doc, use our parent. */
331 if(node && !node->doc && node->parent)
332 node->doc = node->parent->doc;
334 *out = create_node( node );
335 if (!*out)
336 return S_FALSE;
337 return S_OK;
340 HRESULT node_get_parent(xmlnode *This, IXMLDOMNode **parent)
342 return get_node( This, "parent", This->node->parent, parent );
345 HRESULT node_get_child_nodes(xmlnode *This, IXMLDOMNodeList **ret)
347 if(!ret)
348 return E_INVALIDARG;
350 *ret = create_children_nodelist(This->node);
351 if(!*ret)
352 return E_OUTOFMEMORY;
354 return S_OK;
357 HRESULT node_get_first_child(xmlnode *This, IXMLDOMNode **ret)
359 return get_node(This, "firstChild", This->node->children, ret);
362 HRESULT node_get_last_child(xmlnode *This, IXMLDOMNode **ret)
364 return get_node(This, "lastChild", This->node->last, ret);
367 HRESULT node_get_previous_sibling(xmlnode *This, IXMLDOMNode **ret)
369 return get_node(This, "previous", This->node->prev, ret);
372 HRESULT node_get_next_sibling(xmlnode *This, IXMLDOMNode **ret)
374 return get_node(This, "next", This->node->next, ret);
377 HRESULT node_insert_before(xmlnode *This, IXMLDOMNode *new_child, const VARIANT *ref_child,
378 IXMLDOMNode **ret)
380 IXMLDOMNode *before = NULL;
381 xmlnode *node_obj;
382 xmlDocPtr doc;
383 HRESULT hr;
385 if(!new_child)
386 return E_INVALIDARG;
388 node_obj = get_node_obj(new_child);
389 if(!node_obj) return E_FAIL;
391 switch(V_VT(ref_child))
393 case VT_EMPTY:
394 case VT_NULL:
395 break;
397 case VT_UNKNOWN:
398 case VT_DISPATCH:
399 if (V_UNKNOWN(ref_child))
401 hr = IUnknown_QueryInterface(V_UNKNOWN(ref_child), &IID_IXMLDOMNode, (void**)&before);
402 if(FAILED(hr)) return hr;
404 break;
406 default:
407 FIXME("refChild var type %x\n", V_VT(ref_child));
408 return E_FAIL;
411 TRACE("new child %p, This->node %p\n", node_obj->node, This->node);
413 if(!node_obj->node->parent)
414 if(xmldoc_remove_orphan(node_obj->node->doc, node_obj->node) != S_OK)
415 WARN("%p is not an orphan of %p\n", node_obj->node, node_obj->node->doc);
417 if(before)
419 xmlnode *before_node_obj = get_node_obj(before);
420 IXMLDOMNode_Release(before);
421 if(!before_node_obj) return E_FAIL;
423 /* unlink from current parent first */
424 if(node_obj->parent)
426 hr = IXMLDOMNode_removeChild(node_obj->parent, node_obj->iface, NULL);
427 if (hr == S_OK) xmldoc_remove_orphan(node_obj->node->doc, node_obj->node);
429 doc = node_obj->node->doc;
430 xmldoc_add_ref(before_node_obj->node->doc);
431 xmlAddPrevSibling(before_node_obj->node, node_obj->node);
432 xmldoc_release(doc);
433 node_obj->parent = This->parent;
435 else
437 /* unlink from current parent first */
438 if(node_obj->parent)
440 hr = IXMLDOMNode_removeChild(node_obj->parent, node_obj->iface, NULL);
441 if (hr == S_OK) xmldoc_remove_orphan(node_obj->node->doc, node_obj->node);
443 doc = node_obj->node->doc;
444 xmldoc_add_ref(This->node->doc);
445 /* xmlAddChild doesn't unlink node from previous parent */
446 xmlUnlinkNode(node_obj->node);
447 xmlAddChild(This->node, node_obj->node);
448 xmldoc_release(doc);
449 node_obj->parent = This->iface;
452 if(ret)
454 IXMLDOMNode_AddRef(new_child);
455 *ret = new_child;
458 TRACE("ret S_OK\n");
459 return S_OK;
462 HRESULT node_replace_child(xmlnode *This, IXMLDOMNode *newChild, IXMLDOMNode *oldChild,
463 IXMLDOMNode **ret)
465 xmlnode *old_child, *new_child;
466 xmlDocPtr leaving_doc;
467 xmlNode *my_ancestor;
469 /* Do not believe any documentation telling that newChild == NULL
470 means removal. It does certainly *not* apply to msxml3! */
471 if(!newChild || !oldChild)
472 return E_INVALIDARG;
474 if(ret)
475 *ret = NULL;
477 old_child = get_node_obj(oldChild);
478 if(!old_child) return E_FAIL;
480 if(old_child->node->parent != This->node)
482 WARN("childNode %p is not a child of %p\n", oldChild, This);
483 return E_INVALIDARG;
486 new_child = get_node_obj(newChild);
487 if(!new_child) return E_FAIL;
489 my_ancestor = This->node;
490 while(my_ancestor)
492 if(my_ancestor == new_child->node)
494 WARN("tried to create loop\n");
495 return E_FAIL;
497 my_ancestor = my_ancestor->parent;
500 if(!new_child->node->parent)
501 if(xmldoc_remove_orphan(new_child->node->doc, new_child->node) != S_OK)
502 WARN("%p is not an orphan of %p\n", new_child->node, new_child->node->doc);
504 leaving_doc = new_child->node->doc;
505 xmldoc_add_ref(old_child->node->doc);
506 xmlReplaceNode(old_child->node, new_child->node);
507 xmldoc_release(leaving_doc);
508 new_child->parent = old_child->parent;
509 old_child->parent = NULL;
511 xmldoc_add_orphan(old_child->node->doc, old_child->node);
513 if(ret)
515 IXMLDOMNode_AddRef(oldChild);
516 *ret = oldChild;
519 return S_OK;
522 HRESULT node_remove_child(xmlnode *This, IXMLDOMNode* child, IXMLDOMNode** oldChild)
524 xmlnode *child_node;
526 if(!child) return E_INVALIDARG;
528 if(oldChild)
529 *oldChild = NULL;
531 child_node = get_node_obj(child);
532 if(!child_node) return E_FAIL;
534 if(child_node->node->parent != This->node)
536 WARN("childNode %p is not a child of %p\n", child, This);
537 return E_INVALIDARG;
540 xmlUnlinkNode(child_node->node);
541 child_node->parent = NULL;
542 xmldoc_add_orphan(child_node->node->doc, child_node->node);
544 if(oldChild)
546 IXMLDOMNode_AddRef(child);
547 *oldChild = child;
550 return S_OK;
553 HRESULT node_append_child(xmlnode *This, IXMLDOMNode *child, IXMLDOMNode **outChild)
555 DOMNodeType type;
556 VARIANT var;
557 HRESULT hr;
559 hr = IXMLDOMNode_get_nodeType(child, &type);
560 if(FAILED(hr) || type == NODE_ATTRIBUTE) {
561 if (outChild) *outChild = NULL;
562 return E_FAIL;
565 VariantInit(&var);
566 return IXMLDOMNode_insertBefore(This->iface, child, var, outChild);
569 HRESULT node_has_childnodes(const xmlnode *This, VARIANT_BOOL *ret)
571 if (!ret) return E_INVALIDARG;
573 if (!This->node->children)
575 *ret = VARIANT_FALSE;
576 return S_FALSE;
579 *ret = VARIANT_TRUE;
580 return S_OK;
583 HRESULT node_get_owner_doc(const xmlnode *This, IXMLDOMDocument **doc)
585 return get_domdoc_from_xmldoc(This->node->doc, (IXMLDOMDocument3**)doc);
588 HRESULT node_clone(xmlnode *This, VARIANT_BOOL deep, IXMLDOMNode **cloneNode)
590 IXMLDOMNode *node;
591 xmlNodePtr clone;
593 if(!cloneNode) return E_INVALIDARG;
595 clone = xmlCopyNode(This->node, deep ? 1 : 2);
596 if (clone)
598 clone->doc = This->node->doc;
599 xmldoc_add_orphan(clone->doc, clone);
601 node = create_node(clone);
602 if (!node)
604 ERR("Copy failed\n");
605 xmldoc_remove_orphan(clone->doc, clone);
606 xmlFreeNode(clone);
607 return E_FAIL;
610 *cloneNode = node;
612 else
614 ERR("Copy failed\n");
615 return E_FAIL;
618 return S_OK;
621 static inline xmlChar* trim_whitespace(xmlChar* str)
623 xmlChar* ret = str;
624 int len;
626 if (!str)
627 return NULL;
629 while (*ret && isspace(*ret))
630 ++ret;
631 len = xmlStrlen(ret);
632 if (len)
633 while (isspace(ret[len-1])) --len;
635 ret = xmlStrndup(ret, len);
636 xmlFree(str);
637 return ret;
640 static xmlChar* do_get_text(xmlNodePtr node)
642 xmlNodePtr child;
643 xmlChar* str;
644 BOOL preserving = is_preserving_whitespace(node);
646 if (!node->children)
648 str = xmlNodeGetContent(node);
650 else
652 xmlElementType prev_type = XML_TEXT_NODE;
653 xmlChar* tmp;
654 str = xmlStrdup(BAD_CAST "");
655 for (child = node->children; child != NULL; child = child->next)
657 switch (child->type)
659 case XML_ELEMENT_NODE:
660 tmp = do_get_text(child);
661 break;
662 case XML_TEXT_NODE:
663 case XML_CDATA_SECTION_NODE:
664 case XML_ENTITY_REF_NODE:
665 case XML_ENTITY_NODE:
666 tmp = xmlNodeGetContent(child);
667 break;
668 default:
669 tmp = NULL;
670 break;
673 if (tmp)
675 if (*tmp)
677 if (prev_type == XML_ELEMENT_NODE && child->type == XML_ELEMENT_NODE)
678 str = xmlStrcat(str, BAD_CAST " ");
679 str = xmlStrcat(str, tmp);
680 prev_type = child->type;
682 xmlFree(tmp);
687 switch (node->type)
689 case XML_ELEMENT_NODE:
690 case XML_TEXT_NODE:
691 case XML_ENTITY_REF_NODE:
692 case XML_ENTITY_NODE:
693 case XML_DOCUMENT_NODE:
694 case XML_DOCUMENT_FRAG_NODE:
695 if (!preserving)
696 str = trim_whitespace(str);
697 break;
698 default:
699 break;
702 return str;
705 HRESULT node_get_text(const xmlnode *This, BSTR *text)
707 BSTR str = NULL;
708 xmlChar *content;
710 if (!text) return E_INVALIDARG;
712 content = do_get_text(This->node);
713 if (content)
715 str = bstr_from_xmlChar(content);
716 xmlFree(content);
719 /* Always return a string. */
720 if (!str) str = SysAllocStringLen( NULL, 0 );
722 TRACE("%p %s\n", This, debugstr_w(str) );
723 *text = str;
725 return S_OK;
728 HRESULT node_put_text(xmlnode *This, BSTR text)
730 xmlChar *str, *str2;
732 TRACE("(%p)->(%s)\n", This, debugstr_w(text));
734 str = xmlchar_from_wchar(text);
736 /* Escape the string. */
737 str2 = xmlEncodeEntitiesReentrant(This->node->doc, str);
738 heap_free(str);
740 xmlNodeSetContent(This->node, str2);
741 xmlFree(str2);
743 return S_OK;
746 BSTR EnsureCorrectEOL(BSTR sInput)
748 int nNum = 0;
749 BSTR sNew;
750 int nLen;
751 int i;
753 nLen = SysStringLen(sInput);
754 /* Count line endings */
755 for(i=0; i < nLen; i++)
757 if(sInput[i] == '\n')
758 nNum++;
761 TRACE("len=%d, num=%d\n", nLen, nNum);
763 /* Add linefeed as needed */
764 if(nNum > 0)
766 int nPlace = 0;
767 sNew = SysAllocStringLen(NULL, nLen + nNum);
768 for(i=0; i < nLen; i++)
770 if(sInput[i] == '\n')
772 sNew[i+nPlace] = '\r';
773 nPlace++;
775 sNew[i+nPlace] = sInput[i];
778 SysFreeString(sInput);
780 else
782 sNew = sInput;
785 TRACE("len %d\n", SysStringLen(sNew));
787 return sNew;
790 /* Removes encoding information and last character (nullbyte) */
791 static BSTR EnsureNoEncoding(BSTR sInput)
793 static const WCHAR wszEncoding[] = {'e','n','c','o','d','i','n','g','='};
794 BSTR sNew;
795 WCHAR *pBeg, *pEnd;
797 pBeg = sInput;
798 while(*pBeg != '\n' && memcmp(pBeg, wszEncoding, sizeof(wszEncoding)))
799 pBeg++;
801 if(*pBeg == '\n')
803 SysReAllocStringLen(&sInput, sInput, SysStringLen(sInput)-1);
804 return sInput;
806 pBeg--;
808 pEnd = pBeg + sizeof(wszEncoding)/sizeof(WCHAR) + 2;
809 while(*pEnd != '\"') pEnd++;
810 pEnd++;
812 sNew = SysAllocStringLen(NULL,
813 pBeg-sInput + SysStringLen(sInput)-(pEnd-sInput)-1);
814 memcpy(sNew, sInput, (pBeg-sInput)*sizeof(WCHAR));
815 memcpy(&sNew[pBeg-sInput], pEnd, (SysStringLen(sInput)-(pEnd-sInput)-1)*sizeof(WCHAR));
817 SysFreeString(sInput);
818 return sNew;
822 * We are trying to replicate the same behaviour as msxml by converting
823 * line endings to \r\n and using indents as \t. The problem is that msxml
824 * only formats nodes that have a line ending. Using libxml we cannot
825 * reproduce behaviour exactly.
828 HRESULT node_get_xml(xmlnode *This, BOOL ensure_eol, BOOL ensure_no_encoding, BSTR *ret)
830 xmlBufferPtr xml_buf;
831 xmlNodePtr xmldecl;
832 int size;
834 if(!ret)
835 return E_INVALIDARG;
837 *ret = NULL;
839 xml_buf = xmlBufferCreate();
840 if(!xml_buf)
841 return E_OUTOFMEMORY;
843 xmldecl = xmldoc_unlink_xmldecl( This->node->doc );
845 size = xmlNodeDump(xml_buf, This->node->doc, This->node, 0, 1);
846 if(size > 0) {
847 const xmlChar *buf_content;
848 BSTR content;
850 /* Attribute Nodes return a space in front of their name */
851 buf_content = xmlBufferContent(xml_buf);
853 content = bstr_from_xmlChar(buf_content + (buf_content[0] == ' ' ? 1 : 0));
854 if(ensure_eol)
855 content = EnsureCorrectEOL(content);
856 if(ensure_no_encoding)
857 content = EnsureNoEncoding(content);
859 *ret = content;
860 }else {
861 *ret = SysAllocStringLen(NULL, 0);
864 xmlBufferFree(xml_buf);
865 xmldoc_link_xmldecl( This->node->doc, xmldecl );
866 return *ret ? S_OK : E_OUTOFMEMORY;
869 HRESULT node_transform_node(const xmlnode *This, IXMLDOMNode *stylesheet, BSTR *p)
871 #ifdef SONAME_LIBXSLT
872 xsltStylesheetPtr xsltSS;
873 xmlnode *sheet;
875 if (!libxslt_handle) return E_NOTIMPL;
876 if (!stylesheet || !p) return E_INVALIDARG;
878 *p = NULL;
880 sheet = get_node_obj(stylesheet);
881 if(!sheet) return E_FAIL;
883 xsltSS = pxsltParseStylesheetDoc(sheet->node->doc);
884 if(xsltSS)
886 xmlDocPtr result = pxsltApplyStylesheet(xsltSS, This->node->doc, NULL);
887 if(result)
889 const xmlChar *content;
891 if(result->type == XML_HTML_DOCUMENT_NODE)
893 xmlOutputBufferPtr output = xmlAllocOutputBuffer(NULL);
894 if (output)
896 htmlDocContentDumpOutput(output, result->doc, NULL);
897 content = xmlBufferContent(output->buffer);
898 *p = bstr_from_xmlChar(content);
899 xmlOutputBufferClose(output);
902 else
904 xmlBufferPtr buf = xmlBufferCreate();
905 if (buf)
907 int size = xmlNodeDump(buf, NULL, (xmlNodePtr)result, 0, 0);
908 if(size > 0)
910 content = xmlBufferContent(buf);
911 *p = bstr_from_xmlChar(content);
913 xmlBufferFree(buf);
916 xmlFreeDoc(result);
918 /* libxslt "helpfully" frees the XML document the stylesheet was
919 generated from, too */
920 xsltSS->doc = NULL;
921 pxsltFreeStylesheet(xsltSS);
924 if(!*p) *p = SysAllocStringLen(NULL, 0);
926 return S_OK;
927 #else
928 FIXME("libxslt headers were not found at compile time\n");
929 return E_NOTIMPL;
930 #endif
933 HRESULT node_select_nodes(const xmlnode *This, BSTR query, IXMLDOMNodeList **nodes)
935 xmlChar* str;
936 HRESULT hr;
938 if (!query || !nodes) return E_INVALIDARG;
940 str = xmlchar_from_wchar(query);
941 hr = create_selection(This->node, str, nodes);
942 heap_free(str);
944 return hr;
947 HRESULT node_select_singlenode(const xmlnode *This, BSTR query, IXMLDOMNode **node)
949 IXMLDOMNodeList *list;
950 HRESULT hr;
952 hr = node_select_nodes(This, query, &list);
953 if (hr == S_OK)
955 hr = IXMLDOMNodeList_nextNode(list, node);
956 IXMLDOMNodeList_Release(list);
958 return hr;
961 HRESULT node_get_namespaceURI(xmlnode *This, BSTR *namespaceURI)
963 xmlNsPtr ns = This->node->ns;
965 if(!namespaceURI)
966 return E_INVALIDARG;
968 *namespaceURI = NULL;
970 if (ns && ns->href)
971 *namespaceURI = bstr_from_xmlChar(ns->href);
973 TRACE("uri: %s\n", debugstr_w(*namespaceURI));
975 return *namespaceURI ? S_OK : S_FALSE;
978 HRESULT node_get_prefix(xmlnode *This, BSTR *prefix)
980 xmlNsPtr ns = This->node->ns;
982 if (!prefix) return E_INVALIDARG;
984 *prefix = NULL;
986 if (ns && ns->prefix)
987 *prefix = bstr_from_xmlChar(ns->prefix);
989 TRACE("prefix: %s\n", debugstr_w(*prefix));
991 return *prefix ? S_OK : S_FALSE;
994 HRESULT node_get_base_name(xmlnode *This, BSTR *name)
996 if (!name) return E_INVALIDARG;
998 *name = bstr_from_xmlChar(This->node->name);
999 if (!*name) return E_OUTOFMEMORY;
1001 TRACE("returning %s\n", debugstr_w(*name));
1003 return S_OK;
1006 void destroy_xmlnode(xmlnode *This)
1008 if(This->node)
1009 xmldoc_release(This->node->doc);
1010 release_dispex(&This->dispex);
1013 void init_xmlnode(xmlnode *This, xmlNodePtr node, IXMLDOMNode *node_iface, dispex_static_data_t *dispex_data)
1015 if(node)
1016 xmldoc_add_ref( node->doc );
1018 This->node = node;
1019 This->iface = node_iface;
1020 This->parent = NULL;
1022 init_dispex(&This->dispex, (IUnknown*)This->iface, dispex_data);
1025 typedef struct {
1026 xmlnode node;
1027 IXMLDOMNode IXMLDOMNode_iface;
1028 LONG ref;
1029 } unknode;
1031 static inline unknode *unknode_from_IXMLDOMNode(IXMLDOMNode *iface)
1033 return CONTAINING_RECORD(iface, unknode, IXMLDOMNode_iface);
1036 static HRESULT WINAPI unknode_QueryInterface(
1037 IXMLDOMNode *iface,
1038 REFIID riid,
1039 void** ppvObject )
1041 unknode *This = unknode_from_IXMLDOMNode( iface );
1043 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject);
1045 if (IsEqualGUID(riid, &IID_IUnknown)) {
1046 *ppvObject = iface;
1047 }else if (IsEqualGUID( riid, &IID_IDispatch) ||
1048 IsEqualGUID( riid, &IID_IXMLDOMNode)) {
1049 *ppvObject = &This->IXMLDOMNode_iface;
1050 }else if(node_query_interface(&This->node, riid, ppvObject)) {
1051 return *ppvObject ? S_OK : E_NOINTERFACE;
1052 }else {
1053 FIXME("interface %s not implemented\n", debugstr_guid(riid));
1054 *ppvObject = NULL;
1055 return E_NOINTERFACE;
1058 IUnknown_AddRef((IUnknown*)*ppvObject);
1059 return S_OK;
1062 static ULONG WINAPI unknode_AddRef(
1063 IXMLDOMNode *iface )
1065 unknode *This = unknode_from_IXMLDOMNode( iface );
1067 return InterlockedIncrement(&This->ref);
1070 static ULONG WINAPI unknode_Release(
1071 IXMLDOMNode *iface )
1073 unknode *This = unknode_from_IXMLDOMNode( iface );
1074 LONG ref;
1076 ref = InterlockedDecrement( &This->ref );
1077 if(!ref) {
1078 destroy_xmlnode(&This->node);
1079 heap_free(This);
1082 return ref;
1085 static HRESULT WINAPI unknode_GetTypeInfoCount(
1086 IXMLDOMNode *iface,
1087 UINT* pctinfo )
1089 unknode *This = unknode_from_IXMLDOMNode( iface );
1091 TRACE("(%p)->(%p)\n", This, pctinfo);
1093 *pctinfo = 1;
1095 return S_OK;
1098 static HRESULT WINAPI unknode_GetTypeInfo(
1099 IXMLDOMNode *iface,
1100 UINT iTInfo,
1101 LCID lcid,
1102 ITypeInfo** ppTInfo )
1104 unknode *This = unknode_from_IXMLDOMNode( iface );
1105 HRESULT hr;
1107 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
1109 hr = get_typeinfo(IXMLDOMNode_tid, ppTInfo);
1111 return hr;
1114 static HRESULT WINAPI unknode_GetIDsOfNames(
1115 IXMLDOMNode *iface,
1116 REFIID riid,
1117 LPOLESTR* rgszNames,
1118 UINT cNames,
1119 LCID lcid,
1120 DISPID* rgDispId )
1122 unknode *This = unknode_from_IXMLDOMNode( iface );
1124 ITypeInfo *typeinfo;
1125 HRESULT hr;
1127 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
1128 lcid, rgDispId);
1130 if(!rgszNames || cNames == 0 || !rgDispId)
1131 return E_INVALIDARG;
1133 hr = get_typeinfo(IXMLDOMNode_tid, &typeinfo);
1134 if(SUCCEEDED(hr))
1136 hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
1137 ITypeInfo_Release(typeinfo);
1140 return hr;
1143 static HRESULT WINAPI unknode_Invoke(
1144 IXMLDOMNode *iface,
1145 DISPID dispIdMember,
1146 REFIID riid,
1147 LCID lcid,
1148 WORD wFlags,
1149 DISPPARAMS* pDispParams,
1150 VARIANT* pVarResult,
1151 EXCEPINFO* pExcepInfo,
1152 UINT* puArgErr )
1154 unknode *This = unknode_from_IXMLDOMNode( iface );
1155 ITypeInfo *typeinfo;
1156 HRESULT hr;
1158 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
1159 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1161 hr = get_typeinfo(IXMLDOMNode_tid, &typeinfo);
1162 if(SUCCEEDED(hr))
1164 hr = ITypeInfo_Invoke(typeinfo, &This->IXMLDOMNode_iface, dispIdMember, wFlags, pDispParams,
1165 pVarResult, pExcepInfo, puArgErr);
1166 ITypeInfo_Release(typeinfo);
1169 return hr;
1172 static HRESULT WINAPI unknode_get_nodeName(
1173 IXMLDOMNode *iface,
1174 BSTR* p )
1176 unknode *This = unknode_from_IXMLDOMNode( iface );
1178 FIXME("(%p)->(%p)\n", This, p);
1180 return node_get_nodeName(&This->node, p);
1183 static HRESULT WINAPI unknode_get_nodeValue(
1184 IXMLDOMNode *iface,
1185 VARIANT* value)
1187 unknode *This = unknode_from_IXMLDOMNode( iface );
1189 FIXME("(%p)->(%p)\n", This, value);
1191 if(!value)
1192 return E_INVALIDARG;
1194 V_VT(value) = VT_NULL;
1195 return S_FALSE;
1198 static HRESULT WINAPI unknode_put_nodeValue(
1199 IXMLDOMNode *iface,
1200 VARIANT value)
1202 unknode *This = unknode_from_IXMLDOMNode( iface );
1203 FIXME("(%p)->(v%d)\n", This, V_VT(&value));
1204 return E_FAIL;
1207 static HRESULT WINAPI unknode_get_nodeType(
1208 IXMLDOMNode *iface,
1209 DOMNodeType* domNodeType )
1211 unknode *This = unknode_from_IXMLDOMNode( iface );
1213 FIXME("(%p)->(%p)\n", This, domNodeType);
1215 *domNodeType = This->node.node->type;
1216 return S_OK;
1219 static HRESULT WINAPI unknode_get_parentNode(
1220 IXMLDOMNode *iface,
1221 IXMLDOMNode** parent )
1223 unknode *This = unknode_from_IXMLDOMNode( iface );
1224 FIXME("(%p)->(%p)\n", This, parent);
1225 if (!parent) return E_INVALIDARG;
1226 *parent = NULL;
1227 return S_FALSE;
1230 static HRESULT WINAPI unknode_get_childNodes(
1231 IXMLDOMNode *iface,
1232 IXMLDOMNodeList** outList)
1234 unknode *This = unknode_from_IXMLDOMNode( iface );
1236 TRACE("(%p)->(%p)\n", This, outList);
1238 return node_get_child_nodes(&This->node, outList);
1241 static HRESULT WINAPI unknode_get_firstChild(
1242 IXMLDOMNode *iface,
1243 IXMLDOMNode** domNode)
1245 unknode *This = unknode_from_IXMLDOMNode( iface );
1247 TRACE("(%p)->(%p)\n", This, domNode);
1249 return node_get_first_child(&This->node, domNode);
1252 static HRESULT WINAPI unknode_get_lastChild(
1253 IXMLDOMNode *iface,
1254 IXMLDOMNode** domNode)
1256 unknode *This = unknode_from_IXMLDOMNode( iface );
1258 TRACE("(%p)->(%p)\n", This, domNode);
1260 return node_get_last_child(&This->node, domNode);
1263 static HRESULT WINAPI unknode_get_previousSibling(
1264 IXMLDOMNode *iface,
1265 IXMLDOMNode** domNode)
1267 unknode *This = unknode_from_IXMLDOMNode( iface );
1269 TRACE("(%p)->(%p)\n", This, domNode);
1271 return node_get_previous_sibling(&This->node, domNode);
1274 static HRESULT WINAPI unknode_get_nextSibling(
1275 IXMLDOMNode *iface,
1276 IXMLDOMNode** domNode)
1278 unknode *This = unknode_from_IXMLDOMNode( iface );
1280 TRACE("(%p)->(%p)\n", This, domNode);
1282 return node_get_next_sibling(&This->node, domNode);
1285 static HRESULT WINAPI unknode_get_attributes(
1286 IXMLDOMNode *iface,
1287 IXMLDOMNamedNodeMap** attributeMap)
1289 unknode *This = unknode_from_IXMLDOMNode( iface );
1291 FIXME("(%p)->(%p)\n", This, attributeMap);
1293 return return_null_ptr((void**)attributeMap);
1296 static HRESULT WINAPI unknode_insertBefore(
1297 IXMLDOMNode *iface,
1298 IXMLDOMNode* newNode, VARIANT refChild,
1299 IXMLDOMNode** outOldNode)
1301 unknode *This = unknode_from_IXMLDOMNode( iface );
1303 FIXME("(%p)->(%p x%d %p)\n", This, newNode, V_VT(&refChild), outOldNode);
1305 return node_insert_before(&This->node, newNode, &refChild, outOldNode);
1308 static HRESULT WINAPI unknode_replaceChild(
1309 IXMLDOMNode *iface,
1310 IXMLDOMNode* newNode,
1311 IXMLDOMNode* oldNode,
1312 IXMLDOMNode** outOldNode)
1314 unknode *This = unknode_from_IXMLDOMNode( iface );
1316 FIXME("(%p)->(%p %p %p)\n", This, newNode, oldNode, outOldNode);
1318 return node_replace_child(&This->node, newNode, oldNode, outOldNode);
1321 static HRESULT WINAPI unknode_removeChild(
1322 IXMLDOMNode *iface,
1323 IXMLDOMNode* domNode, IXMLDOMNode** oldNode)
1325 unknode *This = unknode_from_IXMLDOMNode( iface );
1326 return node_remove_child(&This->node, domNode, oldNode);
1329 static HRESULT WINAPI unknode_appendChild(
1330 IXMLDOMNode *iface,
1331 IXMLDOMNode* newNode, IXMLDOMNode** outNewNode)
1333 unknode *This = unknode_from_IXMLDOMNode( iface );
1334 return node_append_child(&This->node, newNode, outNewNode);
1337 static HRESULT WINAPI unknode_hasChildNodes(
1338 IXMLDOMNode *iface,
1339 VARIANT_BOOL* pbool)
1341 unknode *This = unknode_from_IXMLDOMNode( iface );
1342 return node_has_childnodes(&This->node, pbool);
1345 static HRESULT WINAPI unknode_get_ownerDocument(
1346 IXMLDOMNode *iface,
1347 IXMLDOMDocument** domDocument)
1349 unknode *This = unknode_from_IXMLDOMNode( iface );
1350 return node_get_owner_doc(&This->node, domDocument);
1353 static HRESULT WINAPI unknode_cloneNode(
1354 IXMLDOMNode *iface,
1355 VARIANT_BOOL pbool, IXMLDOMNode** outNode)
1357 unknode *This = unknode_from_IXMLDOMNode( iface );
1358 return node_clone(&This->node, pbool, outNode );
1361 static HRESULT WINAPI unknode_get_nodeTypeString(
1362 IXMLDOMNode *iface,
1363 BSTR* p)
1365 unknode *This = unknode_from_IXMLDOMNode( iface );
1367 FIXME("(%p)->(%p)\n", This, p);
1369 return node_get_nodeName(&This->node, p);
1372 static HRESULT WINAPI unknode_get_text(
1373 IXMLDOMNode *iface,
1374 BSTR* p)
1376 unknode *This = unknode_from_IXMLDOMNode( iface );
1377 return node_get_text(&This->node, p);
1380 static HRESULT WINAPI unknode_put_text(
1381 IXMLDOMNode *iface,
1382 BSTR p)
1384 unknode *This = unknode_from_IXMLDOMNode( iface );
1385 return node_put_text(&This->node, p);
1388 static HRESULT WINAPI unknode_get_specified(
1389 IXMLDOMNode *iface,
1390 VARIANT_BOOL* isSpecified)
1392 unknode *This = unknode_from_IXMLDOMNode( iface );
1393 FIXME("(%p)->(%p) stub!\n", This, isSpecified);
1394 *isSpecified = VARIANT_TRUE;
1395 return S_OK;
1398 static HRESULT WINAPI unknode_get_definition(
1399 IXMLDOMNode *iface,
1400 IXMLDOMNode** definitionNode)
1402 unknode *This = unknode_from_IXMLDOMNode( iface );
1403 FIXME("(%p)->(%p)\n", This, definitionNode);
1404 return E_NOTIMPL;
1407 static HRESULT WINAPI unknode_get_nodeTypedValue(
1408 IXMLDOMNode *iface,
1409 VARIANT* var1)
1411 unknode *This = unknode_from_IXMLDOMNode( iface );
1412 FIXME("(%p)->(%p)\n", This, var1);
1413 return return_null_var(var1);
1416 static HRESULT WINAPI unknode_put_nodeTypedValue(
1417 IXMLDOMNode *iface,
1418 VARIANT typedValue)
1420 unknode *This = unknode_from_IXMLDOMNode( iface );
1421 FIXME("(%p)->(%s)\n", This, debugstr_variant(&typedValue));
1422 return E_NOTIMPL;
1425 static HRESULT WINAPI unknode_get_dataType(
1426 IXMLDOMNode *iface,
1427 VARIANT* var1)
1429 unknode *This = unknode_from_IXMLDOMNode( iface );
1430 TRACE("(%p)->(%p)\n", This, var1);
1431 return return_null_var(var1);
1434 static HRESULT WINAPI unknode_put_dataType(
1435 IXMLDOMNode *iface,
1436 BSTR p)
1438 unknode *This = unknode_from_IXMLDOMNode( iface );
1440 FIXME("(%p)->(%s)\n", This, debugstr_w(p));
1442 if(!p)
1443 return E_INVALIDARG;
1445 return E_FAIL;
1448 static HRESULT WINAPI unknode_get_xml(
1449 IXMLDOMNode *iface,
1450 BSTR* p)
1452 unknode *This = unknode_from_IXMLDOMNode( iface );
1454 FIXME("(%p)->(%p)\n", This, p);
1456 return node_get_xml(&This->node, FALSE, FALSE, p);
1459 static HRESULT WINAPI unknode_transformNode(
1460 IXMLDOMNode *iface,
1461 IXMLDOMNode* domNode, BSTR* p)
1463 unknode *This = unknode_from_IXMLDOMNode( iface );
1464 return node_transform_node(&This->node, domNode, p);
1467 static HRESULT WINAPI unknode_selectNodes(
1468 IXMLDOMNode *iface,
1469 BSTR p, IXMLDOMNodeList** outList)
1471 unknode *This = unknode_from_IXMLDOMNode( iface );
1472 return node_select_nodes(&This->node, p, outList);
1475 static HRESULT WINAPI unknode_selectSingleNode(
1476 IXMLDOMNode *iface,
1477 BSTR p, IXMLDOMNode** outNode)
1479 unknode *This = unknode_from_IXMLDOMNode( iface );
1480 return node_select_singlenode(&This->node, p, outNode);
1483 static HRESULT WINAPI unknode_get_parsed(
1484 IXMLDOMNode *iface,
1485 VARIANT_BOOL* isParsed)
1487 unknode *This = unknode_from_IXMLDOMNode( iface );
1488 FIXME("(%p)->(%p) stub!\n", This, isParsed);
1489 *isParsed = VARIANT_TRUE;
1490 return S_OK;
1493 static HRESULT WINAPI unknode_get_namespaceURI(
1494 IXMLDOMNode *iface,
1495 BSTR* p)
1497 unknode *This = unknode_from_IXMLDOMNode( iface );
1498 TRACE("(%p)->(%p)\n", This, p);
1499 return node_get_namespaceURI(&This->node, p);
1502 static HRESULT WINAPI unknode_get_prefix(
1503 IXMLDOMNode *iface,
1504 BSTR* p)
1506 unknode *This = unknode_from_IXMLDOMNode( iface );
1507 return node_get_prefix(&This->node, p);
1510 static HRESULT WINAPI unknode_get_baseName(
1511 IXMLDOMNode *iface,
1512 BSTR* p)
1514 unknode *This = unknode_from_IXMLDOMNode( iface );
1515 return node_get_base_name(&This->node, p);
1518 static HRESULT WINAPI unknode_transformNodeToObject(
1519 IXMLDOMNode *iface,
1520 IXMLDOMNode* domNode, VARIANT var1)
1522 unknode *This = unknode_from_IXMLDOMNode( iface );
1523 FIXME("(%p)->(%p %s)\n", This, domNode, debugstr_variant(&var1));
1524 return E_NOTIMPL;
1527 static const struct IXMLDOMNodeVtbl unknode_vtbl =
1529 unknode_QueryInterface,
1530 unknode_AddRef,
1531 unknode_Release,
1532 unknode_GetTypeInfoCount,
1533 unknode_GetTypeInfo,
1534 unknode_GetIDsOfNames,
1535 unknode_Invoke,
1536 unknode_get_nodeName,
1537 unknode_get_nodeValue,
1538 unknode_put_nodeValue,
1539 unknode_get_nodeType,
1540 unknode_get_parentNode,
1541 unknode_get_childNodes,
1542 unknode_get_firstChild,
1543 unknode_get_lastChild,
1544 unknode_get_previousSibling,
1545 unknode_get_nextSibling,
1546 unknode_get_attributes,
1547 unknode_insertBefore,
1548 unknode_replaceChild,
1549 unknode_removeChild,
1550 unknode_appendChild,
1551 unknode_hasChildNodes,
1552 unknode_get_ownerDocument,
1553 unknode_cloneNode,
1554 unknode_get_nodeTypeString,
1555 unknode_get_text,
1556 unknode_put_text,
1557 unknode_get_specified,
1558 unknode_get_definition,
1559 unknode_get_nodeTypedValue,
1560 unknode_put_nodeTypedValue,
1561 unknode_get_dataType,
1562 unknode_put_dataType,
1563 unknode_get_xml,
1564 unknode_transformNode,
1565 unknode_selectNodes,
1566 unknode_selectSingleNode,
1567 unknode_get_parsed,
1568 unknode_get_namespaceURI,
1569 unknode_get_prefix,
1570 unknode_get_baseName,
1571 unknode_transformNodeToObject
1574 IXMLDOMNode *create_node( xmlNodePtr node )
1576 IUnknown *pUnk;
1577 IXMLDOMNode *ret;
1578 HRESULT hr;
1580 if ( !node )
1581 return NULL;
1583 TRACE("type %d\n", node->type);
1584 switch(node->type)
1586 case XML_ELEMENT_NODE:
1587 pUnk = create_element( node );
1588 break;
1589 case XML_ATTRIBUTE_NODE:
1590 pUnk = create_attribute( node );
1591 break;
1592 case XML_TEXT_NODE:
1593 pUnk = create_text( node );
1594 break;
1595 case XML_CDATA_SECTION_NODE:
1596 pUnk = create_cdata( node );
1597 break;
1598 case XML_ENTITY_REF_NODE:
1599 pUnk = create_doc_entity_ref( node );
1600 break;
1601 case XML_PI_NODE:
1602 pUnk = create_pi( node );
1603 break;
1604 case XML_COMMENT_NODE:
1605 pUnk = create_comment( node );
1606 break;
1607 case XML_DOCUMENT_NODE:
1608 pUnk = create_domdoc( node );
1609 break;
1610 case XML_DOCUMENT_FRAG_NODE:
1611 pUnk = create_doc_fragment( node );
1612 break;
1613 case XML_DTD_NODE:
1614 pUnk = create_doc_type( node );
1615 break;
1616 default: {
1617 unknode *new_node;
1619 FIXME("only creating basic node for type %d\n", node->type);
1621 new_node = heap_alloc(sizeof(unknode));
1622 if(!new_node)
1623 return NULL;
1625 new_node->IXMLDOMNode_iface.lpVtbl = &unknode_vtbl;
1626 new_node->ref = 1;
1627 init_xmlnode(&new_node->node, node, &new_node->IXMLDOMNode_iface, NULL);
1628 pUnk = (IUnknown*)&new_node->IXMLDOMNode_iface;
1632 hr = IUnknown_QueryInterface(pUnk, &IID_IXMLDOMNode, (LPVOID*)&ret);
1633 IUnknown_Release(pUnk);
1634 if(FAILED(hr)) return NULL;
1635 return ret;
1637 #endif