pop fafc973c8c92ea6fa823adc8f5a7f591f01396fd
[wine/hacks.git] / dlls / msxml3 / xmlelem.c
bloba71b18b1167914988faddb9f8e5523e4e28f47f4
1 /*
2 * XML Element implementation
4 * Copyright 2007 James Hawkins
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 #define COBJMACROS
23 #include "config.h"
25 #include <stdarg.h>
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winuser.h"
29 #include "ole2.h"
30 #include "msxml2.h"
31 #include "ocidl.h"
33 #include "wine/debug.h"
35 #include "msxml_private.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
39 #ifdef HAVE_LIBXML2
41 static HRESULT XMLElementCollection_create( IUnknown *pUnkOuter, xmlNodePtr node, LPVOID *ppObj );
43 /**********************************************************************
44 * IXMLElement
46 typedef struct _xmlelem
48 const IXMLElementVtbl *lpVtbl;
49 LONG ref;
50 xmlNodePtr node;
51 BOOL own;
52 } xmlelem;
54 static inline xmlelem *impl_from_IXMLElement(IXMLElement *iface)
56 return (xmlelem *)((char*)iface - FIELD_OFFSET(xmlelem, lpVtbl));
59 static HRESULT WINAPI xmlelem_QueryInterface(IXMLElement *iface, REFIID riid, void** ppvObject)
61 xmlelem *This = impl_from_IXMLElement(iface);
63 TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject);
65 if (IsEqualGUID(riid, &IID_IUnknown) ||
66 IsEqualGUID(riid, &IID_IXMLElement))
68 *ppvObject = iface;
70 else
72 FIXME("interface %s not implemented\n", debugstr_guid(riid));
73 return E_NOINTERFACE;
76 IXMLElement_AddRef(iface);
78 return S_OK;
81 static ULONG WINAPI xmlelem_AddRef(IXMLElement *iface)
83 xmlelem *This = impl_from_IXMLElement(iface);
84 TRACE("%p\n", This);
85 return InterlockedIncrement(&This->ref);
88 static ULONG WINAPI xmlelem_Release(IXMLElement *iface)
90 xmlelem *This = impl_from_IXMLElement(iface);
91 LONG ref;
93 TRACE("%p\n", This);
95 ref = InterlockedDecrement(&This->ref);
96 if (ref == 0)
98 if (This->own) xmlFreeNode(This->node);
99 heap_free(This);
102 return ref;
105 static HRESULT WINAPI xmlelem_GetTypeInfoCount(IXMLElement *iface, UINT* pctinfo)
107 xmlelem *This = impl_from_IXMLElement(iface);
109 TRACE("(%p)->(%p)\n", This, pctinfo);
111 *pctinfo = 1;
113 return S_OK;
116 static HRESULT WINAPI xmlelem_GetTypeInfo(IXMLElement *iface, UINT iTInfo,
117 LCID lcid, ITypeInfo** ppTInfo)
119 xmlelem *This = impl_from_IXMLElement(iface);
120 HRESULT hr;
122 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
124 hr = get_typeinfo(IXMLElement_tid, ppTInfo);
126 return hr;
129 static HRESULT WINAPI xmlelem_GetIDsOfNames(IXMLElement *iface, REFIID riid,
130 LPOLESTR* rgszNames, UINT cNames,
131 LCID lcid, DISPID* rgDispId)
133 xmlelem *This = impl_from_IXMLElement(iface);
134 ITypeInfo *typeinfo;
135 HRESULT hr;
137 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
138 lcid, rgDispId);
140 if(!rgszNames || cNames == 0 || !rgDispId)
141 return E_INVALIDARG;
143 hr = get_typeinfo(IXMLElement_tid, &typeinfo);
144 if(SUCCEEDED(hr))
146 hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
147 ITypeInfo_Release(typeinfo);
150 return hr;
153 static HRESULT WINAPI xmlelem_Invoke(IXMLElement *iface, DISPID dispIdMember,
154 REFIID riid, LCID lcid, WORD wFlags,
155 DISPPARAMS* pDispParams, VARIANT* pVarResult,
156 EXCEPINFO* pExcepInfo, UINT* puArgErr)
158 xmlelem *This = impl_from_IXMLElement(iface);
159 ITypeInfo *typeinfo;
160 HRESULT hr;
162 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
163 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
165 hr = get_typeinfo(IXMLElement_tid, &typeinfo);
166 if(SUCCEEDED(hr))
168 hr = ITypeInfo_Invoke(typeinfo, &(This->lpVtbl), dispIdMember, wFlags, pDispParams,
169 pVarResult, pExcepInfo, puArgErr);
170 ITypeInfo_Release(typeinfo);
173 return hr;
176 static HRESULT WINAPI xmlelem_get_tagName(IXMLElement *iface, BSTR *p)
178 xmlelem *This = impl_from_IXMLElement(iface);
180 TRACE("(%p, %p)\n", iface, p);
182 if (!p)
183 return E_INVALIDARG;
185 *p = bstr_from_xmlChar(This->node->name);
186 CharUpperBuffW(*p, SysStringLen(*p));
188 TRACE("returning %s\n", debugstr_w(*p));
190 return S_OK;
193 static HRESULT WINAPI xmlelem_put_tagName(IXMLElement *iface, BSTR p)
195 FIXME("(%p, %p): stub\n", iface, p);
197 if (!p)
198 return E_INVALIDARG;
200 return E_NOTIMPL;
203 static HRESULT WINAPI xmlelem_get_parent(IXMLElement *iface, IXMLElement **parent)
205 xmlelem *This = impl_from_IXMLElement(iface);
207 TRACE("(%p, %p)\n", iface, parent);
209 if (!parent)
210 return E_INVALIDARG;
212 *parent = NULL;
214 if (!This->node->parent)
215 return S_FALSE;
217 return XMLElement_create((IUnknown *)iface, This->node->parent, (LPVOID *)parent, FALSE);
220 static HRESULT WINAPI xmlelem_setAttribute(IXMLElement *iface, BSTR strPropertyName,
221 VARIANT PropertyValue)
223 xmlelem *This = impl_from_IXMLElement(iface);
224 xmlChar *name, *value;
225 xmlAttrPtr attr;
227 TRACE("(%p, %s)\n", iface, debugstr_w(strPropertyName));
229 if (!strPropertyName || V_VT(&PropertyValue) != VT_BSTR)
230 return E_INVALIDARG;
232 name = xmlChar_from_wchar(strPropertyName);
233 value = xmlChar_from_wchar(V_BSTR(&PropertyValue));
234 attr = xmlSetProp(This->node, name, value);
236 heap_free(name);
237 heap_free(value);
238 return (attr) ? S_OK : S_FALSE;
241 static HRESULT WINAPI xmlelem_getAttribute(IXMLElement *iface, BSTR name,
242 VARIANT *value)
244 static const WCHAR xmllangW[] = { 'x','m','l',':','l','a','n','g',0 };
245 xmlelem *This = impl_from_IXMLElement(iface);
246 xmlChar *val = NULL;
248 TRACE("(%p, %s, %p)\n", iface, debugstr_w(name), value);
250 if (!value)
251 return E_INVALIDARG;
253 VariantInit(value);
254 V_BSTR(value) = NULL;
256 if (!name)
257 return E_INVALIDARG;
259 /* case for xml:lang attribute */
260 if (!lstrcmpiW(name, xmllangW))
262 xmlNsPtr ns;
263 ns = xmlSearchNs(This->node->doc, This->node, (xmlChar*)"xml");
264 val = xmlGetNsProp(This->node, (xmlChar*)"lang", ns->href);
266 else
268 xmlAttrPtr attr;
269 xmlChar *xml_name;
271 xml_name = xmlChar_from_wchar(name);
272 attr = This->node->properties;
273 while (attr)
275 BSTR attr_name;
277 attr_name = bstr_from_xmlChar(attr->name);
278 if (!lstrcmpiW(name, attr_name))
280 val = xmlNodeListGetString(attr->doc, attr->children, 1);
281 SysFreeString(attr_name);
282 break;
285 attr = attr->next;
286 SysFreeString(attr_name);
289 heap_free(xml_name);
292 if (val)
294 V_VT(value) = VT_BSTR;
295 V_BSTR(value) = bstr_from_xmlChar(val);
298 xmlFree(val);
299 TRACE("returning %s\n", debugstr_w(V_BSTR(value)));
300 return (val) ? S_OK : S_FALSE;
303 static HRESULT WINAPI xmlelem_removeAttribute(IXMLElement *iface, BSTR strPropertyName)
305 xmlelem *This = impl_from_IXMLElement(iface);
306 xmlChar *name;
307 xmlAttrPtr attr;
308 int res;
309 HRESULT hr = S_FALSE;
311 TRACE("(%p, %s)\n", iface, debugstr_w(strPropertyName));
313 if (!strPropertyName)
314 return E_INVALIDARG;
316 name = xmlChar_from_wchar(strPropertyName);
317 attr = xmlHasProp(This->node, name);
318 if (!attr)
319 goto done;
321 res = xmlRemoveProp(attr);
323 if (res == 0)
324 hr = S_OK;
326 done:
327 heap_free(name);
328 return hr;
331 static HRESULT WINAPI xmlelem_get_children(IXMLElement *iface, IXMLElementCollection **p)
333 xmlelem *This = impl_from_IXMLElement(iface);
335 TRACE("(%p, %p)\n", iface, p);
337 if (!p)
338 return E_INVALIDARG;
340 return XMLElementCollection_create((IUnknown *)iface, This->node, (LPVOID *)p);
343 static LONG type_libxml_to_msxml(xmlElementType type)
345 switch (type)
347 case XML_ELEMENT_NODE:
348 return XMLELEMTYPE_ELEMENT;
349 case XML_TEXT_NODE:
350 return XMLELEMTYPE_TEXT;
351 case XML_COMMENT_NODE:
352 return XMLELEMTYPE_COMMENT;
353 case XML_DOCUMENT_NODE:
354 return XMLELEMTYPE_DOCUMENT;
355 case XML_DTD_NODE:
356 return XMLELEMTYPE_DTD;
357 case XML_PI_NODE:
358 return XMLELEMTYPE_PI;
359 default:
360 break;
363 return XMLELEMTYPE_OTHER;
366 static HRESULT WINAPI xmlelem_get_type(IXMLElement *iface, LONG *p)
368 xmlelem *This = impl_from_IXMLElement(iface);
370 TRACE("(%p, %p)\n", This, p);
372 if (!p)
373 return E_INVALIDARG;
375 *p = type_libxml_to_msxml(This->node->type);
376 TRACE("returning %d\n", *p);
377 return S_OK;
380 static HRESULT WINAPI xmlelem_get_text(IXMLElement *iface, BSTR *p)
382 xmlelem *This = impl_from_IXMLElement(iface);
383 xmlChar *content;
385 TRACE("(%p, %p)\n", iface, p);
387 if (!p)
388 return E_INVALIDARG;
390 content = xmlNodeGetContent(This->node);
391 *p = bstr_from_xmlChar(content);
392 TRACE("returning %s\n", debugstr_w(*p));
394 xmlFree(content);
395 return S_OK;
398 static HRESULT WINAPI xmlelem_put_text(IXMLElement *iface, BSTR p)
400 xmlelem *This = impl_from_IXMLElement(iface);
401 xmlChar *content;
403 TRACE("(%p, %s)\n", iface, debugstr_w(p));
405 /* FIXME: test which types can be used */
406 if (This->node->type == XML_ELEMENT_NODE)
407 return E_NOTIMPL;
409 content = xmlChar_from_wchar(p);
410 xmlNodeSetContent(This->node, content);
412 heap_free(content);
414 return S_OK;
417 static HRESULT WINAPI xmlelem_addChild(IXMLElement *iface, IXMLElement *pChildElem,
418 LONG lIndex, LONG lreserved)
420 xmlelem *This = impl_from_IXMLElement(iface);
421 xmlelem *childElem = impl_from_IXMLElement(pChildElem);
422 xmlNodePtr child;
424 TRACE("(%p, %p, %d, %d)\n", iface, pChildElem, lIndex, lreserved);
426 if (lIndex == 0)
427 child = xmlAddChild(This->node, childElem->node);
428 else
429 child = xmlAddNextSibling(This->node, childElem->node->last);
431 /* parent is responsible for child data */
432 if (child) childElem->own = FALSE;
434 return (child) ? S_OK : S_FALSE;
437 static HRESULT WINAPI xmlelem_removeChild(IXMLElement *iface, IXMLElement *pChildElem)
439 xmlelem *This = impl_from_IXMLElement(iface);
440 xmlelem *childElem = impl_from_IXMLElement(pChildElem);
442 TRACE("(%p, %p)\n", This, childElem);
444 if (!pChildElem)
445 return E_INVALIDARG;
447 /* only supported for This is childElem parent case */
448 if (This->node != childElem->node->parent)
449 return E_INVALIDARG;
451 xmlUnlinkNode(childElem->node);
452 /* standalone element now */
453 childElem->own = TRUE;
455 return S_OK;
458 static const struct IXMLElementVtbl xmlelem_vtbl =
460 xmlelem_QueryInterface,
461 xmlelem_AddRef,
462 xmlelem_Release,
463 xmlelem_GetTypeInfoCount,
464 xmlelem_GetTypeInfo,
465 xmlelem_GetIDsOfNames,
466 xmlelem_Invoke,
467 xmlelem_get_tagName,
468 xmlelem_put_tagName,
469 xmlelem_get_parent,
470 xmlelem_setAttribute,
471 xmlelem_getAttribute,
472 xmlelem_removeAttribute,
473 xmlelem_get_children,
474 xmlelem_get_type,
475 xmlelem_get_text,
476 xmlelem_put_text,
477 xmlelem_addChild,
478 xmlelem_removeChild
481 HRESULT XMLElement_create(IUnknown *pUnkOuter, xmlNodePtr node, LPVOID *ppObj, BOOL own)
483 xmlelem *elem;
485 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
487 if (!ppObj)
488 return E_INVALIDARG;
490 *ppObj = NULL;
492 elem = heap_alloc(sizeof (*elem));
493 if(!elem)
494 return E_OUTOFMEMORY;
496 elem->lpVtbl = &xmlelem_vtbl;
497 elem->ref = 1;
498 elem->node = node;
499 elem->own = own;
501 *ppObj = &elem->lpVtbl;
503 TRACE("returning iface %p\n", *ppObj);
504 return S_OK;
507 /************************************************************************
508 * IXMLElementCollection
510 typedef struct _xmlelem_collection
512 const IXMLElementCollectionVtbl *lpVtbl;
513 const IEnumVARIANTVtbl *lpvtblIEnumVARIANT;
514 LONG ref;
515 LONG length;
516 xmlNodePtr node;
518 /* IEnumVARIANT members */
519 xmlNodePtr current;
520 } xmlelem_collection;
522 static inline LONG xmlelem_collection_updatelength(xmlelem_collection *collection)
524 xmlNodePtr ptr = collection->node->children;
526 collection->length = 0;
527 while (ptr)
529 collection->length++;
530 ptr = ptr->next;
532 return collection->length;
535 static inline xmlelem_collection *impl_from_IXMLElementCollection(IXMLElementCollection *iface)
537 return (xmlelem_collection *)((char*)iface - FIELD_OFFSET(xmlelem_collection, lpVtbl));
540 static inline xmlelem_collection *impl_from_IEnumVARIANT(IEnumVARIANT *iface)
542 return (xmlelem_collection *)((char*)iface - FIELD_OFFSET(xmlelem_collection, lpvtblIEnumVARIANT));
545 static HRESULT WINAPI xmlelem_collection_QueryInterface(IXMLElementCollection *iface, REFIID riid, void** ppvObject)
547 xmlelem_collection *This = impl_from_IXMLElementCollection(iface);
549 TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject);
551 if (IsEqualGUID(riid, &IID_IUnknown) ||
552 IsEqualGUID(riid, &IID_IXMLElementCollection))
554 *ppvObject = iface;
556 else if (IsEqualGUID(riid, &IID_IEnumVARIANT))
558 *ppvObject = &(This->lpvtblIEnumVARIANT);
560 else
562 FIXME("interface %s not implemented\n", debugstr_guid(riid));
563 return E_NOINTERFACE;
566 IXMLElementCollection_AddRef(iface);
568 return S_OK;
571 static ULONG WINAPI xmlelem_collection_AddRef(IXMLElementCollection *iface)
573 xmlelem_collection *This = impl_from_IXMLElementCollection(iface);
574 TRACE("%p\n", This);
575 return InterlockedIncrement(&This->ref);
578 static ULONG WINAPI xmlelem_collection_Release(IXMLElementCollection *iface)
580 xmlelem_collection *This = impl_from_IXMLElementCollection(iface);
581 LONG ref;
583 TRACE("%p\n", This);
585 ref = InterlockedDecrement(&This->ref);
586 if (ref == 0)
588 heap_free(This);
591 return ref;
594 static HRESULT WINAPI xmlelem_collection_GetTypeInfoCount(IXMLElementCollection *iface, UINT* pctinfo)
596 FIXME("\n");
597 return E_NOTIMPL;
600 static HRESULT WINAPI xmlelem_collection_GetTypeInfo(IXMLElementCollection *iface, UINT iTInfo,
601 LCID lcid, ITypeInfo** ppTInfo)
603 FIXME("\n");
604 return E_NOTIMPL;
607 static HRESULT WINAPI xmlelem_collection_GetIDsOfNames(IXMLElementCollection *iface, REFIID riid,
608 LPOLESTR* rgszNames, UINT cNames,
609 LCID lcid, DISPID* rgDispId)
611 FIXME("\n");
612 return E_NOTIMPL;
615 static HRESULT WINAPI xmlelem_collection_Invoke(IXMLElementCollection *iface, DISPID dispIdMember,
616 REFIID riid, LCID lcid, WORD wFlags,
617 DISPPARAMS* pDispParams, VARIANT* pVarResult,
618 EXCEPINFO* pExcepInfo, UINT* puArgErr)
620 FIXME("\n");
621 return E_NOTIMPL;
624 static HRESULT WINAPI xmlelem_collection_put_length(IXMLElementCollection *iface, LONG v)
626 TRACE("(%p, %d)\n", iface, v);
627 return E_FAIL;
630 static HRESULT WINAPI xmlelem_collection_get_length(IXMLElementCollection *iface, LONG *p)
632 xmlelem_collection *This = impl_from_IXMLElementCollection(iface);
634 TRACE("(%p, %p)\n", iface, p);
636 if (!p)
637 return E_INVALIDARG;
639 *p = xmlelem_collection_updatelength(This);
640 return S_OK;
643 static HRESULT WINAPI xmlelem_collection_get__newEnum(IXMLElementCollection *iface, IUnknown **ppUnk)
645 xmlelem_collection *This = impl_from_IXMLElementCollection(iface);
647 TRACE("(%p, %p)\n", iface, ppUnk);
649 if (!ppUnk)
650 return E_INVALIDARG;
652 *ppUnk = (IUnknown *)This;
653 IUnknown_AddRef(*ppUnk);
654 return S_OK;
657 static HRESULT WINAPI xmlelem_collection_item(IXMLElementCollection *iface, VARIANT var1,
658 VARIANT var2, IDispatch **ppDisp)
660 xmlelem_collection *This = impl_from_IXMLElementCollection(iface);
661 xmlNodePtr ptr = This->node->children;
662 int index, i;
664 TRACE("(%p, %p)\n", iface, ppDisp);
666 if (!ppDisp)
667 return E_INVALIDARG;
669 *ppDisp = NULL;
671 index = V_I4(&var1);
672 if (index < 0)
673 return E_INVALIDARG;
675 xmlelem_collection_updatelength(This);
676 if (index >= This->length)
677 return E_FAIL;
679 for (i = 0; i < index; i++)
680 ptr = ptr->next;
682 return XMLElement_create((IUnknown *)iface, ptr, (LPVOID *)ppDisp, FALSE);
685 static const struct IXMLElementCollectionVtbl xmlelem_collection_vtbl =
687 xmlelem_collection_QueryInterface,
688 xmlelem_collection_AddRef,
689 xmlelem_collection_Release,
690 xmlelem_collection_GetTypeInfoCount,
691 xmlelem_collection_GetTypeInfo,
692 xmlelem_collection_GetIDsOfNames,
693 xmlelem_collection_Invoke,
694 xmlelem_collection_put_length,
695 xmlelem_collection_get_length,
696 xmlelem_collection_get__newEnum,
697 xmlelem_collection_item
700 /************************************************************************
701 * xmlelem_collection implementation of IEnumVARIANT.
703 static HRESULT WINAPI xmlelem_collection_IEnumVARIANT_QueryInterface(
704 IEnumVARIANT *iface, REFIID riid, LPVOID *ppvObj)
706 xmlelem_collection *this = impl_from_IEnumVARIANT(iface);
707 return IXMLDocument_QueryInterface((IXMLDocument *)this, riid, ppvObj);
710 static ULONG WINAPI xmlelem_collection_IEnumVARIANT_AddRef(
711 IEnumVARIANT *iface)
713 xmlelem_collection *this = impl_from_IEnumVARIANT(iface);
714 return IXMLDocument_AddRef((IXMLDocument *)this);
717 static ULONG WINAPI xmlelem_collection_IEnumVARIANT_Release(
718 IEnumVARIANT *iface)
720 xmlelem_collection *this = impl_from_IEnumVARIANT(iface);
721 return IXMLDocument_Release((IXMLDocument *)this);
724 static HRESULT WINAPI xmlelem_collection_IEnumVARIANT_Next(
725 IEnumVARIANT *iface, ULONG celt, VARIANT *rgVar, ULONG *fetched)
727 xmlelem_collection *This = impl_from_IEnumVARIANT(iface);
728 xmlNodePtr ptr = This->current;
730 TRACE("(%p, %d, %p, %p)\n", iface, celt, rgVar, fetched);
732 if (!rgVar)
733 return E_INVALIDARG;
735 /* FIXME: handle celt */
736 if (fetched)
737 *fetched = 1;
739 if (This->current)
740 This->current = This->current->next;
741 else
743 V_VT(rgVar) = VT_EMPTY;
744 if (fetched) *fetched = 0;
745 return S_FALSE;
748 V_VT(rgVar) = VT_DISPATCH;
749 return XMLElement_create((IUnknown *)iface, ptr, (LPVOID *)&V_DISPATCH(rgVar), FALSE);
752 static HRESULT WINAPI xmlelem_collection_IEnumVARIANT_Skip(
753 IEnumVARIANT *iface, ULONG celt)
755 FIXME("(%p, %d): stub\n", iface, celt);
756 return E_NOTIMPL;
759 static HRESULT WINAPI xmlelem_collection_IEnumVARIANT_Reset(
760 IEnumVARIANT *iface)
762 xmlelem_collection *This = impl_from_IEnumVARIANT(iface);
763 This->current = This->node->children;
764 return S_OK;
767 static HRESULT WINAPI xmlelem_collection_IEnumVARIANT_Clone(
768 IEnumVARIANT *iface, IEnumVARIANT **ppEnum)
770 FIXME("(%p, %p): stub\n", iface, ppEnum);
771 return E_NOTIMPL;
774 static const struct IEnumVARIANTVtbl xmlelem_collection_IEnumVARIANTvtbl =
776 xmlelem_collection_IEnumVARIANT_QueryInterface,
777 xmlelem_collection_IEnumVARIANT_AddRef,
778 xmlelem_collection_IEnumVARIANT_Release,
779 xmlelem_collection_IEnumVARIANT_Next,
780 xmlelem_collection_IEnumVARIANT_Skip,
781 xmlelem_collection_IEnumVARIANT_Reset,
782 xmlelem_collection_IEnumVARIANT_Clone
785 static HRESULT XMLElementCollection_create(IUnknown *pUnkOuter, xmlNodePtr node, LPVOID *ppObj)
787 xmlelem_collection *collection;
789 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
791 *ppObj = NULL;
793 if (!node->children)
794 return S_FALSE;
796 collection = heap_alloc(sizeof (*collection));
797 if(!collection)
798 return E_OUTOFMEMORY;
800 collection->lpVtbl = &xmlelem_collection_vtbl;
801 collection->lpvtblIEnumVARIANT = &xmlelem_collection_IEnumVARIANTvtbl;
802 collection->ref = 1;
803 collection->length = 0;
804 collection->node = node;
805 collection->current = node->children;
806 xmlelem_collection_updatelength(collection);
808 *ppObj = &collection->lpVtbl;
810 TRACE("returning iface %p\n", *ppObj);
811 return S_OK;
814 #endif