2 * DOM Document 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
22 #define NONAMELESSUNION
41 #include "wine/debug.h"
42 #include "wine/list.h"
44 #include "msxml_private.h"
46 WINE_DEFAULT_DEBUG_CHANNEL(msxml
);
50 #include <libxml/xmlsave.h>
52 /* not defined in older versions */
53 #define XML_SAVE_FORMAT 1
54 #define XML_SAVE_NO_DECL 2
55 #define XML_SAVE_NO_EMPTY 4
56 #define XML_SAVE_NO_XHTML 8
57 #define XML_SAVE_XHTML 16
58 #define XML_SAVE_AS_XML 32
59 #define XML_SAVE_AS_HTML 64
61 static const WCHAR PropertySelectionLanguageW
[] = {'S','e','l','e','c','t','i','o','n','L','a','n','g','u','a','g','e',0};
62 static const WCHAR PropertySelectionNamespacesW
[] = {'S','e','l','e','c','t','i','o','n','N','a','m','e','s','p','a','c','e','s',0};
63 static const WCHAR PropertyProhibitDTDW
[] = {'P','r','o','h','i','b','i','t','D','T','D',0};
64 static const WCHAR PropValueXPathW
[] = {'X','P','a','t','h',0};
65 static const WCHAR PropValueXSLPatternW
[] = {'X','S','L','P','a','t','t','e','r','n',0};
67 typedef struct _domdoc
70 const struct IXMLDOMDocument3Vtbl
*lpVtbl
;
71 const struct IPersistStreamInitVtbl
*lpvtblIPersistStreamInit
;
72 const struct IObjectWithSiteVtbl
*lpvtblIObjectWithSite
;
73 const struct IObjectSafetyVtbl
*lpvtblIObjectSafety
;
74 const struct ISupportErrorInfoVtbl
*lpvtblISupportErrorInfo
;
77 VARIANT_BOOL validating
;
78 VARIANT_BOOL resolving
;
79 VARIANT_BOOL preserving
;
80 IXMLDOMSchemaCollection
*schema
;
95 In native windows, the whole lifetime management of XMLDOMNodes is
96 managed automatically using reference counts. Wine emulates that by
97 maintaining a reference count to the document that is increased for
98 each IXMLDOMNode pointer passed out for this document. If all these
99 pointers are gone, the document is unreachable and gets freed, that
100 is, all nodes in the tree of the document get freed.
102 You are able to create nodes that are associated to a document (in
103 fact, in msxml's XMLDOM model, all nodes are associated to a document),
104 but not in the tree of that document, for example using the createFoo
105 functions from IXMLDOMDocument. These nodes do not get cleaned up
106 by libxml, so we have to do it ourselves.
108 To catch these nodes, a list of "orphan nodes" is introduced.
109 It contains pointers to all roots of node trees that are
110 associated with the document without being part of the document
111 tree. All nodes with parent==NULL (except for the document root nodes)
112 should be in the orphan node list of their document. All orphan nodes
113 get freed together with the document itself.
116 typedef struct _xmldoc_priv
{
122 typedef struct _orphan_entry
{
127 static inline xmldoc_priv
* priv_from_xmlDocPtr(const xmlDocPtr doc
)
129 return doc
->_private
;
132 static inline BOOL
is_xpathmode(const xmlDocPtr doc
)
134 return priv_from_xmlDocPtr(doc
)->XPath
;
137 static inline void set_xpathmode(const xmlDocPtr doc
)
139 priv_from_xmlDocPtr(doc
)->XPath
= TRUE
;
142 static inline void reset_xpathmode(const xmlDocPtr doc
)
144 priv_from_xmlDocPtr(doc
)->XPath
= FALSE
;
147 static xmldoc_priv
* create_priv(void)
150 priv
= heap_alloc( sizeof (*priv
) );
156 list_init( &priv
->orphans
);
162 /* links a "<?xml" node as a first child */
163 void xmldoc_link_xmldecl(xmlDocPtr doc
, xmlNodePtr node
)
166 if (doc
->standalone
!= -1) xmlAddPrevSibling( doc
->children
, node
);
169 /* unlinks a first "<?xml" child if it was created */
170 xmlNodePtr
xmldoc_unlink_xmldecl(xmlDocPtr doc
)
176 if (doc
->standalone
!= -1)
178 node
= doc
->children
;
179 xmlUnlinkNode( node
);
187 static xmlDocPtr
doparse( char *ptr
, int len
, const char *encoding
)
191 #ifdef HAVE_XMLREADMEMORY
193 * use xmlReadMemory if possible so we can suppress
194 * writing errors to stderr
196 doc
= xmlReadMemory( ptr
, len
, NULL
, encoding
,
197 XML_PARSE_NOERROR
| XML_PARSE_NOWARNING
| XML_PARSE_NOBLANKS
);
199 doc
= xmlParseMemory( ptr
, len
);
202 /* create first child as a <?xml...?> */
203 if (doc
&& doc
->standalone
!= -1)
207 xmlChar
*xmlbuff
= (xmlChar
*)buff
;
209 node
= xmlNewDocPI( doc
, (xmlChar
*)"xml", NULL
);
211 /* version attribute can't be omitted */
212 sprintf(buff
, "version=\"%s\"", doc
->version
? (char*)doc
->version
: "1.0");
213 xmlNodeAddContent( node
, xmlbuff
);
217 sprintf(buff
, " encoding=\"%s\"", doc
->encoding
);
218 xmlNodeAddContent( node
, xmlbuff
);
221 if (doc
->standalone
!= -2)
223 sprintf(buff
, " standalone=\"%s\"", doc
->standalone
== 0 ? "no" : "yes");
224 xmlNodeAddContent( node
, xmlbuff
);
227 xmldoc_link_xmldecl( doc
, node
);
233 LONG
xmldoc_add_ref(xmlDocPtr doc
)
235 LONG ref
= InterlockedIncrement(&priv_from_xmlDocPtr(doc
)->refs
);
236 TRACE("(%p)->(%d)\n", doc
, ref
);
240 LONG
xmldoc_release(xmlDocPtr doc
)
242 xmldoc_priv
*priv
= priv_from_xmlDocPtr(doc
);
243 LONG ref
= InterlockedDecrement(&priv
->refs
);
244 TRACE("(%p)->(%d)\n", doc
, ref
);
247 orphan_entry
*orphan
, *orphan2
;
248 TRACE("freeing docptr %p\n", doc
);
250 LIST_FOR_EACH_ENTRY_SAFE( orphan
, orphan2
, &priv
->orphans
, orphan_entry
, entry
)
252 xmlFreeNode( orphan
->node
);
255 heap_free(doc
->_private
);
263 HRESULT
xmldoc_add_orphan(xmlDocPtr doc
, xmlNodePtr node
)
265 xmldoc_priv
*priv
= priv_from_xmlDocPtr(doc
);
268 entry
= heap_alloc( sizeof (*entry
) );
270 return E_OUTOFMEMORY
;
273 list_add_head( &priv
->orphans
, &entry
->entry
);
277 HRESULT
xmldoc_remove_orphan(xmlDocPtr doc
, xmlNodePtr node
)
279 xmldoc_priv
*priv
= priv_from_xmlDocPtr(doc
);
280 orphan_entry
*entry
, *entry2
;
282 LIST_FOR_EACH_ENTRY_SAFE( entry
, entry2
, &priv
->orphans
, orphan_entry
, entry
)
284 if( entry
->node
== node
)
286 list_remove( &entry
->entry
);
295 static HRESULT
attach_xmldoc( xmlnode
*node
, xmlDocPtr xml
)
298 xmldoc_release(node
->node
->doc
);
300 node
->node
= (xmlNodePtr
) xml
;
302 xmldoc_add_ref(node
->node
->doc
);
307 static inline domdoc
*impl_from_IXMLDOMDocument3( IXMLDOMDocument3
*iface
)
309 return (domdoc
*)((char*)iface
- FIELD_OFFSET(domdoc
, lpVtbl
));
312 static inline xmlDocPtr
get_doc( domdoc
*This
)
314 return (xmlDocPtr
)This
->node
.node
;
317 static inline domdoc
*impl_from_IPersistStreamInit(IPersistStreamInit
*iface
)
319 return (domdoc
*)((char*)iface
- FIELD_OFFSET(domdoc
, lpvtblIPersistStreamInit
));
322 static inline domdoc
*impl_from_IObjectWithSite(IObjectWithSite
*iface
)
324 return (domdoc
*)((char*)iface
- FIELD_OFFSET(domdoc
, lpvtblIObjectWithSite
));
327 static inline domdoc
*impl_from_IObjectSafety(IObjectSafety
*iface
)
329 return (domdoc
*)((char*)iface
- FIELD_OFFSET(domdoc
, lpvtblIObjectSafety
));
332 static inline domdoc
*impl_from_ISupportErrorInfo(ISupportErrorInfo
*iface
)
334 return (domdoc
*)((char*)iface
- FIELD_OFFSET(domdoc
, lpvtblISupportErrorInfo
));
337 /************************************************************************
338 * domdoc implementation of IPersistStream.
340 static HRESULT WINAPI
domdoc_IPersistStreamInit_QueryInterface(
341 IPersistStreamInit
*iface
, REFIID riid
, void **ppvObj
)
343 domdoc
*this = impl_from_IPersistStreamInit(iface
);
344 return IXMLDOMDocument2_QueryInterface((IXMLDOMDocument2
*)this, riid
, ppvObj
);
347 static ULONG WINAPI
domdoc_IPersistStreamInit_AddRef(
348 IPersistStreamInit
*iface
)
350 domdoc
*this = impl_from_IPersistStreamInit(iface
);
351 return IXMLDOMDocument2_AddRef((IXMLDOMDocument2
*)this);
354 static ULONG WINAPI
domdoc_IPersistStreamInit_Release(
355 IPersistStreamInit
*iface
)
357 domdoc
*this = impl_from_IPersistStreamInit(iface
);
358 return IXMLDOMDocument2_Release((IXMLDOMDocument2
*)this);
361 static HRESULT WINAPI
domdoc_IPersistStreamInit_GetClassID(
362 IPersistStreamInit
*iface
, CLSID
*classid
)
364 TRACE("(%p,%p): stub!\n", iface
, classid
);
369 *classid
= CLSID_DOMDocument2
;
374 static HRESULT WINAPI
domdoc_IPersistStreamInit_IsDirty(
375 IPersistStreamInit
*iface
)
377 domdoc
*This
= impl_from_IPersistStreamInit(iface
);
378 FIXME("(%p): stub!\n", This
);
382 static HRESULT WINAPI
domdoc_IPersistStreamInit_Load(
383 IPersistStreamInit
*iface
, LPSTREAM pStm
)
385 domdoc
*This
= impl_from_IPersistStreamInit(iface
);
388 DWORD read
, written
, len
;
391 xmlDocPtr xmldoc
= NULL
;
393 TRACE("(%p)->(%p)\n", This
, pStm
);
398 hr
= CreateStreamOnHGlobal(NULL
, TRUE
, &This
->stream
);
404 IStream_Read(pStm
, buf
, sizeof(buf
), &read
);
405 hr
= IStream_Write(This
->stream
, buf
, read
, &written
);
406 } while(SUCCEEDED(hr
) && written
!= 0 && read
!= 0);
410 ERR("Failed to copy stream\n");
414 hr
= GetHGlobalFromStream(This
->stream
, &hglobal
);
418 len
= GlobalSize(hglobal
);
419 ptr
= GlobalLock(hglobal
);
421 xmldoc
= doparse(ptr
, len
, NULL
);
422 GlobalUnlock(hglobal
);
426 ERR("Failed to parse xml\n");
430 xmldoc
->_private
= create_priv();
432 return attach_xmldoc( &This
->node
, xmldoc
);
435 static HRESULT WINAPI
domdoc_IPersistStreamInit_Save(
436 IPersistStreamInit
*iface
, IStream
*stream
, BOOL clr_dirty
)
438 domdoc
*This
= impl_from_IPersistStreamInit(iface
);
442 TRACE("(%p)->(%p %d)\n", This
, stream
, clr_dirty
);
444 hr
= IXMLDOMDocument3_get_xml( (IXMLDOMDocument3
*)&This
->lpVtbl
, &xmlString
);
447 DWORD len
= SysStringLen(xmlString
) * sizeof(WCHAR
);
449 hr
= IStream_Write( stream
, xmlString
, len
, NULL
);
450 SysFreeString(xmlString
);
453 TRACE("ret 0x%08x\n", hr
);
458 static HRESULT WINAPI
domdoc_IPersistStreamInit_GetSizeMax(
459 IPersistStreamInit
*iface
, ULARGE_INTEGER
*pcbSize
)
461 domdoc
*This
= impl_from_IPersistStreamInit(iface
);
462 TRACE("(%p)->(%p): stub!\n", This
, pcbSize
);
466 static HRESULT WINAPI
domdoc_IPersistStreamInit_InitNew(
467 IPersistStreamInit
*iface
)
469 domdoc
*This
= impl_from_IPersistStreamInit(iface
);
470 TRACE("(%p)\n", This
);
474 static const IPersistStreamInitVtbl xmldoc_IPersistStreamInit_VTable
=
476 domdoc_IPersistStreamInit_QueryInterface
,
477 domdoc_IPersistStreamInit_AddRef
,
478 domdoc_IPersistStreamInit_Release
,
479 domdoc_IPersistStreamInit_GetClassID
,
480 domdoc_IPersistStreamInit_IsDirty
,
481 domdoc_IPersistStreamInit_Load
,
482 domdoc_IPersistStreamInit_Save
,
483 domdoc_IPersistStreamInit_GetSizeMax
,
484 domdoc_IPersistStreamInit_InitNew
487 /* ISupportErrorInfo interface */
488 static HRESULT WINAPI
support_error_QueryInterface(
489 ISupportErrorInfo
*iface
,
490 REFIID riid
, void** ppvObj
)
492 domdoc
*This
= impl_from_ISupportErrorInfo(iface
);
493 return IXMLDOMDocument3_QueryInterface((IXMLDOMDocument3
*)This
, riid
, ppvObj
);
496 static ULONG WINAPI
support_error_AddRef(
497 ISupportErrorInfo
*iface
)
499 domdoc
*This
= impl_from_ISupportErrorInfo(iface
);
500 return IXMLDOMDocument3_AddRef((IXMLDOMDocument3
*)This
);
503 static ULONG WINAPI
support_error_Release(
504 ISupportErrorInfo
*iface
)
506 domdoc
*This
= impl_from_ISupportErrorInfo(iface
);
507 return IXMLDOMDocument3_Release((IXMLDOMDocument3
*)This
);
510 static HRESULT WINAPI
support_error_InterfaceSupportsErrorInfo(
511 ISupportErrorInfo
*iface
,
514 FIXME("(%p)->(%s)\n", iface
, debugstr_guid(riid
));
518 static const struct ISupportErrorInfoVtbl support_error_vtbl
=
520 support_error_QueryInterface
,
521 support_error_AddRef
,
522 support_error_Release
,
523 support_error_InterfaceSupportsErrorInfo
526 /* IXMLDOMDocument2 interface */
527 static HRESULT WINAPI
domdoc_QueryInterface( IXMLDOMDocument3
*iface
, REFIID riid
, void** ppvObject
)
529 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
531 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid( riid
), ppvObject
);
535 if ( IsEqualGUID( riid
, &IID_IUnknown
) ||
536 IsEqualGUID( riid
, &IID_IDispatch
) ||
537 IsEqualGUID( riid
, &IID_IXMLDOMNode
) ||
538 IsEqualGUID( riid
, &IID_IXMLDOMDocument
) ||
539 IsEqualGUID( riid
, &IID_IXMLDOMDocument2
)||
540 IsEqualGUID( riid
, &IID_IXMLDOMDocument3
))
544 else if (IsEqualGUID(&IID_IPersistStream
, riid
) ||
545 IsEqualGUID(&IID_IPersistStreamInit
, riid
))
547 *ppvObject
= &(This
->lpvtblIPersistStreamInit
);
549 else if (IsEqualGUID(&IID_IObjectWithSite
, riid
))
551 *ppvObject
= &(This
->lpvtblIObjectWithSite
);
553 else if (IsEqualGUID(&IID_IObjectSafety
, riid
))
555 *ppvObject
= &(This
->lpvtblIObjectSafety
);
557 else if( IsEqualGUID( riid
, &IID_ISupportErrorInfo
))
559 *ppvObject
= &This
->lpvtblISupportErrorInfo
;
561 else if(node_query_interface(&This
->node
, riid
, ppvObject
))
563 return *ppvObject
? S_OK
: E_NOINTERFACE
;
565 else if(IsEqualGUID(&IID_IRunnableObject
, riid
))
567 TRACE("IID_IRunnableObject not supported returning NULL\n");
568 return E_NOINTERFACE
;
572 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
573 return E_NOINTERFACE
;
576 IUnknown_AddRef((IUnknown
*)*ppvObject
);
582 static ULONG WINAPI
domdoc_AddRef(
583 IXMLDOMDocument3
*iface
)
585 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
586 TRACE("%p\n", This
);
587 return InterlockedIncrement( &This
->ref
);
591 static ULONG WINAPI
domdoc_Release(
592 IXMLDOMDocument3
*iface
)
594 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
597 TRACE("%p\n", This
);
599 ref
= InterlockedDecrement( &This
->ref
);
603 detach_bsc(This
->bsc
);
606 IUnknown_Release( This
->site
);
607 destroy_xmlnode(&This
->node
);
608 if(This
->schema
) IXMLDOMSchemaCollection_Release( This
->schema
);
609 if (This
->stream
) IStream_Release(This
->stream
);
610 HeapFree( GetProcessHeap(), 0, This
);
616 static HRESULT WINAPI
domdoc_GetTypeInfoCount( IXMLDOMDocument3
*iface
, UINT
* pctinfo
)
618 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
620 TRACE("(%p)->(%p)\n", This
, pctinfo
);
627 static HRESULT WINAPI
domdoc_GetTypeInfo(
628 IXMLDOMDocument3
*iface
,
629 UINT iTInfo
, LCID lcid
, ITypeInfo
** ppTInfo
)
631 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
634 TRACE("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
636 hr
= get_typeinfo(IXMLDOMDocument2_tid
, ppTInfo
);
641 static HRESULT WINAPI
domdoc_GetIDsOfNames(
642 IXMLDOMDocument3
*iface
,
649 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
653 TRACE("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
656 if(!rgszNames
|| cNames
== 0 || !rgDispId
)
659 hr
= get_typeinfo(IXMLDOMDocument2_tid
, &typeinfo
);
662 hr
= ITypeInfo_GetIDsOfNames(typeinfo
, rgszNames
, cNames
, rgDispId
);
663 ITypeInfo_Release(typeinfo
);
670 static HRESULT WINAPI
domdoc_Invoke(
671 IXMLDOMDocument3
*iface
,
676 DISPPARAMS
* pDispParams
,
678 EXCEPINFO
* pExcepInfo
,
681 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
685 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
686 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
688 hr
= get_typeinfo(IXMLDOMDocument2_tid
, &typeinfo
);
691 hr
= ITypeInfo_Invoke(typeinfo
, &(This
->lpVtbl
), dispIdMember
, wFlags
, pDispParams
,
692 pVarResult
, pExcepInfo
, puArgErr
);
693 ITypeInfo_Release(typeinfo
);
700 static HRESULT WINAPI
domdoc_get_nodeName(
701 IXMLDOMDocument3
*iface
,
704 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
706 static const WCHAR documentW
[] = {'#','d','o','c','u','m','e','n','t',0};
708 TRACE("(%p)->(%p)\n", This
, name
);
710 return return_bstr(documentW
, name
);
714 static HRESULT WINAPI
domdoc_get_nodeValue(
715 IXMLDOMDocument3
*iface
,
718 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
720 TRACE("(%p)->(%p)\n", This
, value
);
725 V_VT(value
) = VT_NULL
;
726 V_BSTR(value
) = NULL
; /* tests show that we should do this */
731 static HRESULT WINAPI
domdoc_put_nodeValue(
732 IXMLDOMDocument3
*iface
,
735 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
736 FIXME("(%p)->(v%d)\n", This
, V_VT(&value
));
741 static HRESULT WINAPI
domdoc_get_nodeType(
742 IXMLDOMDocument3
*iface
,
745 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
747 TRACE("(%p)->(%p)\n", This
, type
);
749 *type
= NODE_DOCUMENT
;
754 static HRESULT WINAPI
domdoc_get_parentNode(
755 IXMLDOMDocument3
*iface
,
756 IXMLDOMNode
** parent
)
758 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
760 TRACE("(%p)->(%p)\n", This
, parent
);
762 return node_get_parent(&This
->node
, parent
);
766 static HRESULT WINAPI
domdoc_get_childNodes(
767 IXMLDOMDocument3
*iface
,
768 IXMLDOMNodeList
** childList
)
770 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
772 TRACE("(%p)->(%p)\n", This
, childList
);
774 return node_get_child_nodes(&This
->node
, childList
);
778 static HRESULT WINAPI
domdoc_get_firstChild(
779 IXMLDOMDocument3
*iface
,
780 IXMLDOMNode
** firstChild
)
782 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
784 TRACE("(%p)->(%p)\n", This
, firstChild
);
786 return node_get_first_child(&This
->node
, firstChild
);
790 static HRESULT WINAPI
domdoc_get_lastChild(
791 IXMLDOMDocument3
*iface
,
792 IXMLDOMNode
** lastChild
)
794 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
796 TRACE("(%p)->(%p)\n", This
, lastChild
);
798 return node_get_last_child(&This
->node
, lastChild
);
802 static HRESULT WINAPI
domdoc_get_previousSibling(
803 IXMLDOMDocument3
*iface
,
804 IXMLDOMNode
** previousSibling
)
806 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
808 TRACE("(%p)->(%p)\n", This
, previousSibling
);
810 return return_null_node(previousSibling
);
814 static HRESULT WINAPI
domdoc_get_nextSibling(
815 IXMLDOMDocument3
*iface
,
816 IXMLDOMNode
** nextSibling
)
818 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
820 TRACE("(%p)->(%p)\n", This
, nextSibling
);
822 return return_null_node(nextSibling
);
826 static HRESULT WINAPI
domdoc_get_attributes(
827 IXMLDOMDocument3
*iface
,
828 IXMLDOMNamedNodeMap
** attributeMap
)
830 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
832 TRACE("(%p)->(%p)\n", This
, attributeMap
);
834 return return_null_ptr((void**)attributeMap
);
838 static HRESULT WINAPI
domdoc_insertBefore(
839 IXMLDOMDocument3
*iface
,
840 IXMLDOMNode
* newChild
,
842 IXMLDOMNode
** outNewChild
)
844 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
846 TRACE("(%p)->(%p x%d %p)\n", This
, newChild
, V_VT(&refChild
), outNewChild
);
848 return node_insert_before(&This
->node
, newChild
, &refChild
, outNewChild
);
852 static HRESULT WINAPI
domdoc_replaceChild(
853 IXMLDOMDocument3
*iface
,
854 IXMLDOMNode
* newChild
,
855 IXMLDOMNode
* oldChild
,
856 IXMLDOMNode
** outOldChild
)
858 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
859 return IXMLDOMNode_replaceChild( IXMLDOMNode_from_impl(&This
->node
), newChild
, oldChild
, outOldChild
);
863 static HRESULT WINAPI
domdoc_removeChild(
864 IXMLDOMDocument3
*iface
,
865 IXMLDOMNode
* childNode
,
866 IXMLDOMNode
** oldChild
)
868 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
869 return IXMLDOMNode_removeChild( IXMLDOMNode_from_impl(&This
->node
), childNode
, oldChild
);
873 static HRESULT WINAPI
domdoc_appendChild(
874 IXMLDOMDocument3
*iface
,
875 IXMLDOMNode
* newChild
,
876 IXMLDOMNode
** outNewChild
)
878 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
879 return IXMLDOMNode_appendChild( IXMLDOMNode_from_impl(&This
->node
), newChild
, outNewChild
);
883 static HRESULT WINAPI
domdoc_hasChildNodes(
884 IXMLDOMDocument3
*iface
,
885 VARIANT_BOOL
* hasChild
)
887 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
888 return IXMLDOMNode_hasChildNodes( IXMLDOMNode_from_impl(&This
->node
), hasChild
);
892 static HRESULT WINAPI
domdoc_get_ownerDocument(
893 IXMLDOMDocument3
*iface
,
894 IXMLDOMDocument
** DOMDocument
)
896 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
897 return IXMLDOMNode_get_ownerDocument( IXMLDOMNode_from_impl(&This
->node
), DOMDocument
);
901 static HRESULT WINAPI
domdoc_cloneNode(
902 IXMLDOMDocument3
*iface
,
904 IXMLDOMNode
** cloneRoot
)
906 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
907 return IXMLDOMNode_cloneNode( IXMLDOMNode_from_impl(&This
->node
), deep
, cloneRoot
);
911 static HRESULT WINAPI
domdoc_get_nodeTypeString(
912 IXMLDOMDocument3
*iface
,
915 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
916 return IXMLDOMNode_get_nodeTypeString( IXMLDOMNode_from_impl(&This
->node
), nodeType
);
920 static HRESULT WINAPI
domdoc_get_text(
921 IXMLDOMDocument3
*iface
,
924 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
925 return IXMLDOMNode_get_text( IXMLDOMNode_from_impl(&This
->node
), text
);
929 static HRESULT WINAPI
domdoc_put_text(
930 IXMLDOMDocument3
*iface
,
933 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
934 return IXMLDOMNode_put_text( IXMLDOMNode_from_impl(&This
->node
), text
);
938 static HRESULT WINAPI
domdoc_get_specified(
939 IXMLDOMDocument3
*iface
,
940 VARIANT_BOOL
* isSpecified
)
942 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
943 return IXMLDOMNode_get_specified( IXMLDOMNode_from_impl(&This
->node
), isSpecified
);
947 static HRESULT WINAPI
domdoc_get_definition(
948 IXMLDOMDocument3
*iface
,
949 IXMLDOMNode
** definitionNode
)
951 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
952 return IXMLDOMNode_get_definition( IXMLDOMNode_from_impl(&This
->node
), definitionNode
);
956 static HRESULT WINAPI
domdoc_get_nodeTypedValue(
957 IXMLDOMDocument3
*iface
,
958 VARIANT
* typedValue
)
960 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
961 return IXMLDOMNode_get_nodeTypedValue( IXMLDOMNode_from_impl(&This
->node
), typedValue
);
964 static HRESULT WINAPI
domdoc_put_nodeTypedValue(
965 IXMLDOMDocument3
*iface
,
968 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
969 return IXMLDOMNode_put_nodeTypedValue( IXMLDOMNode_from_impl(&This
->node
), typedValue
);
973 static HRESULT WINAPI
domdoc_get_dataType(
974 IXMLDOMDocument3
*iface
,
975 VARIANT
* dataTypeName
)
977 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
978 return IXMLDOMNode_get_dataType( IXMLDOMNode_from_impl(&This
->node
), dataTypeName
);
982 static HRESULT WINAPI
domdoc_put_dataType(
983 IXMLDOMDocument3
*iface
,
986 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
987 return IXMLDOMNode_put_dataType( IXMLDOMNode_from_impl(&This
->node
), dataTypeName
);
991 static HRESULT WINAPI
domdoc_get_xml(
992 IXMLDOMDocument3
*iface
,
995 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
996 return IXMLDOMNode_get_xml( IXMLDOMNode_from_impl(&This
->node
), xmlString
);
1000 static HRESULT WINAPI
domdoc_transformNode(
1001 IXMLDOMDocument3
*iface
,
1002 IXMLDOMNode
* styleSheet
,
1005 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
1006 return IXMLDOMNode_transformNode( IXMLDOMNode_from_impl(&This
->node
), styleSheet
, xmlString
);
1010 static HRESULT WINAPI
domdoc_selectNodes(
1011 IXMLDOMDocument3
*iface
,
1013 IXMLDOMNodeList
** resultList
)
1015 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
1016 return IXMLDOMNode_selectNodes( IXMLDOMNode_from_impl(&This
->node
), queryString
, resultList
);
1020 static HRESULT WINAPI
domdoc_selectSingleNode(
1021 IXMLDOMDocument3
*iface
,
1023 IXMLDOMNode
** resultNode
)
1025 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
1026 return IXMLDOMNode_selectSingleNode( IXMLDOMNode_from_impl(&This
->node
), queryString
, resultNode
);
1030 static HRESULT WINAPI
domdoc_get_parsed(
1031 IXMLDOMDocument3
*iface
,
1032 VARIANT_BOOL
* isParsed
)
1034 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
1035 return IXMLDOMNode_get_parsed( IXMLDOMNode_from_impl(&This
->node
), isParsed
);
1039 static HRESULT WINAPI
domdoc_get_namespaceURI(
1040 IXMLDOMDocument3
*iface
,
1041 BSTR
* namespaceURI
)
1043 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
1044 return IXMLDOMNode_get_namespaceURI( IXMLDOMNode_from_impl(&This
->node
), namespaceURI
);
1048 static HRESULT WINAPI
domdoc_get_prefix(
1049 IXMLDOMDocument3
*iface
,
1050 BSTR
* prefixString
)
1052 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
1053 return IXMLDOMNode_get_prefix( IXMLDOMNode_from_impl(&This
->node
), prefixString
);
1057 static HRESULT WINAPI
domdoc_get_baseName(
1058 IXMLDOMDocument3
*iface
,
1061 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
1062 return IXMLDOMNode_get_baseName( IXMLDOMNode_from_impl(&This
->node
), nameString
);
1066 static HRESULT WINAPI
domdoc_transformNodeToObject(
1067 IXMLDOMDocument3
*iface
,
1068 IXMLDOMNode
* stylesheet
,
1069 VARIANT outputObject
)
1071 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
1072 return IXMLDOMNode_transformNodeToObject( IXMLDOMNode_from_impl(&This
->node
), stylesheet
, outputObject
);
1076 static HRESULT WINAPI
domdoc_get_doctype(
1077 IXMLDOMDocument3
*iface
,
1078 IXMLDOMDocumentType
** documentType
)
1080 domdoc
*This
= impl_from_IXMLDOMDocument3(iface
);
1081 FIXME("(%p)\n", This
);
1086 static HRESULT WINAPI
domdoc_get_implementation(
1087 IXMLDOMDocument3
*iface
,
1088 IXMLDOMImplementation
** impl
)
1090 domdoc
*This
= impl_from_IXMLDOMDocument3(iface
);
1092 TRACE("(%p)->(%p)\n", This
, impl
);
1095 return E_INVALIDARG
;
1097 *impl
= (IXMLDOMImplementation
*)create_doc_Implementation();
1102 static HRESULT WINAPI
domdoc_get_documentElement(
1103 IXMLDOMDocument3
*iface
,
1104 IXMLDOMElement
** DOMElement
)
1106 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
1107 IXMLDOMNode
*element_node
;
1111 TRACE("(%p)->(%p)\n", This
, DOMElement
);
1114 return E_INVALIDARG
;
1118 root
= xmlDocGetRootElement( get_doc(This
) );
1122 element_node
= create_node( root
);
1123 if(!element_node
) return S_FALSE
;
1125 hr
= IXMLDOMNode_QueryInterface(element_node
, &IID_IXMLDOMElement
, (void**)DOMElement
);
1126 IXMLDOMNode_Release(element_node
);
1132 static HRESULT WINAPI
domdoc_put_documentElement(
1133 IXMLDOMDocument3
*iface
,
1134 IXMLDOMElement
* DOMElement
)
1136 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
1137 IXMLDOMNode
*elementNode
;
1142 TRACE("(%p)->(%p)\n", This
, DOMElement
);
1144 hr
= IXMLDOMElement_QueryInterface( DOMElement
, &IID_IXMLDOMNode
, (void**)&elementNode
);
1148 xmlNode
= get_node_obj( elementNode
);
1150 FIXME("elementNode is not our object\n");
1154 if(!xmlNode
->node
->parent
)
1155 if(xmldoc_remove_orphan(xmlNode
->node
->doc
, xmlNode
->node
) != S_OK
)
1156 WARN("%p is not an orphan of %p\n", xmlNode
->node
->doc
, xmlNode
->node
);
1158 oldRoot
= xmlDocSetRootElement( get_doc(This
), xmlNode
->node
);
1159 IXMLDOMNode_Release( elementNode
);
1162 xmldoc_add_orphan(oldRoot
->doc
, oldRoot
);
1168 static HRESULT WINAPI
domdoc_createElement(
1169 IXMLDOMDocument3
*iface
,
1171 IXMLDOMElement
** element
)
1173 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
1178 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(tagname
), element
);
1180 if (!element
|| !tagname
) return E_INVALIDARG
;
1182 V_VT(&type
) = VT_I1
;
1183 V_I1(&type
) = NODE_ELEMENT
;
1185 hr
= IXMLDOMDocument3_createNode(iface
, type
, tagname
, NULL
, &node
);
1188 IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMElement
, (void**)element
);
1189 IXMLDOMNode_Release(node
);
1196 static HRESULT WINAPI
domdoc_createDocumentFragment(
1197 IXMLDOMDocument3
*iface
,
1198 IXMLDOMDocumentFragment
** frag
)
1200 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
1205 TRACE("(%p)->(%p)\n", This
, frag
);
1207 if (!frag
) return E_INVALIDARG
;
1211 V_VT(&type
) = VT_I1
;
1212 V_I1(&type
) = NODE_DOCUMENT_FRAGMENT
;
1214 hr
= IXMLDOMDocument3_createNode(iface
, type
, NULL
, NULL
, &node
);
1217 IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMDocumentFragment
, (void**)frag
);
1218 IXMLDOMNode_Release(node
);
1225 static HRESULT WINAPI
domdoc_createTextNode(
1226 IXMLDOMDocument3
*iface
,
1228 IXMLDOMText
** text
)
1230 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
1235 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(data
), text
);
1237 if (!text
) return E_INVALIDARG
;
1241 V_VT(&type
) = VT_I1
;
1242 V_I1(&type
) = NODE_TEXT
;
1244 hr
= IXMLDOMDocument3_createNode(iface
, type
, NULL
, NULL
, &node
);
1247 IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMText
, (void**)text
);
1248 IXMLDOMNode_Release(node
);
1249 hr
= IXMLDOMText_put_data(*text
, data
);
1256 static HRESULT WINAPI
domdoc_createComment(
1257 IXMLDOMDocument3
*iface
,
1259 IXMLDOMComment
** comment
)
1261 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
1266 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(data
), comment
);
1268 if (!comment
) return E_INVALIDARG
;
1272 V_VT(&type
) = VT_I1
;
1273 V_I1(&type
) = NODE_COMMENT
;
1275 hr
= IXMLDOMDocument3_createNode(iface
, type
, NULL
, NULL
, &node
);
1278 IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMComment
, (void**)comment
);
1279 IXMLDOMNode_Release(node
);
1280 hr
= IXMLDOMComment_put_data(*comment
, data
);
1287 static HRESULT WINAPI
domdoc_createCDATASection(
1288 IXMLDOMDocument3
*iface
,
1290 IXMLDOMCDATASection
** cdata
)
1292 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
1297 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(data
), cdata
);
1299 if (!cdata
) return E_INVALIDARG
;
1303 V_VT(&type
) = VT_I1
;
1304 V_I1(&type
) = NODE_CDATA_SECTION
;
1306 hr
= IXMLDOMDocument3_createNode(iface
, type
, NULL
, NULL
, &node
);
1309 IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMCDATASection
, (void**)cdata
);
1310 IXMLDOMNode_Release(node
);
1311 hr
= IXMLDOMCDATASection_put_data(*cdata
, data
);
1318 static HRESULT WINAPI
domdoc_createProcessingInstruction(
1319 IXMLDOMDocument3
*iface
,
1322 IXMLDOMProcessingInstruction
** pi
)
1324 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
1329 TRACE("(%p)->(%s %s %p)\n", This
, debugstr_w(target
), debugstr_w(data
), pi
);
1331 if (!pi
) return E_INVALIDARG
;
1335 V_VT(&type
) = VT_I1
;
1336 V_I1(&type
) = NODE_PROCESSING_INSTRUCTION
;
1338 hr
= IXMLDOMDocument3_createNode(iface
, type
, target
, NULL
, &node
);
1344 /* this is to bypass check in ::put_data() that blocks "<?xml" PIs */
1345 node_obj
= get_node_obj(node
);
1346 V_VT(&v_data
) = VT_BSTR
;
1347 V_BSTR(&v_data
) = data
;
1349 hr
= node_put_value(node_obj
, &v_data
);
1351 IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMProcessingInstruction
, (void**)pi
);
1352 IXMLDOMNode_Release(node
);
1359 static HRESULT WINAPI
domdoc_createAttribute(
1360 IXMLDOMDocument3
*iface
,
1362 IXMLDOMAttribute
** attribute
)
1364 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
1369 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(name
), attribute
);
1371 if (!attribute
|| !name
) return E_INVALIDARG
;
1373 V_VT(&type
) = VT_I1
;
1374 V_I1(&type
) = NODE_ATTRIBUTE
;
1376 hr
= IXMLDOMDocument3_createNode(iface
, type
, name
, NULL
, &node
);
1379 IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMAttribute
, (void**)attribute
);
1380 IXMLDOMNode_Release(node
);
1387 static HRESULT WINAPI
domdoc_createEntityReference(
1388 IXMLDOMDocument3
*iface
,
1390 IXMLDOMEntityReference
** entityref
)
1392 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
1397 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(name
), entityref
);
1399 if (!entityref
) return E_INVALIDARG
;
1403 V_VT(&type
) = VT_I1
;
1404 V_I1(&type
) = NODE_ENTITY_REFERENCE
;
1406 hr
= IXMLDOMDocument3_createNode(iface
, type
, name
, NULL
, &node
);
1409 IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMEntityReference
, (void**)entityref
);
1410 IXMLDOMNode_Release(node
);
1417 static HRESULT WINAPI
domdoc_getElementsByTagName(
1418 IXMLDOMDocument3
*iface
,
1420 IXMLDOMNodeList
** resultList
)
1422 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
1425 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(tagName
), resultList
);
1427 if (!tagName
|| !resultList
) return E_INVALIDARG
;
1429 if (tagName
[0] == '*' && tagName
[1] == 0)
1431 static const WCHAR formatallW
[] = {'/','/','*',0};
1432 hr
= queryresult_create((xmlNodePtr
)get_doc(This
), formatallW
, resultList
);
1436 static const WCHAR xpathformat
[] =
1437 { '/','/','*','[','l','o','c','a','l','-','n','a','m','e','(',')','=','\'' };
1438 static const WCHAR closeW
[] = { '\'',']',0 };
1444 length
= lstrlenW(tagName
);
1446 /* without two WCHARs from format specifier */
1447 ptr
= pattern
= heap_alloc(sizeof(xpathformat
) + length
*sizeof(WCHAR
) + sizeof(closeW
));
1449 memcpy(ptr
, xpathformat
, sizeof(xpathformat
));
1450 ptr
+= sizeof(xpathformat
)/sizeof(WCHAR
);
1451 memcpy(ptr
, tagName
, length
*sizeof(WCHAR
));
1453 memcpy(ptr
, closeW
, sizeof(closeW
));
1455 hr
= queryresult_create((xmlNodePtr
)get_doc(This
), pattern
, resultList
);
1462 static HRESULT
get_node_type(VARIANT Type
, DOMNodeType
* type
)
1468 hr
= VariantChangeType(&tmp
, &Type
, 0, VT_I4
);
1470 return E_INVALIDARG
;
1477 static HRESULT WINAPI
domdoc_createNode(
1478 IXMLDOMDocument3
*iface
,
1482 IXMLDOMNode
** node
)
1484 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
1485 DOMNodeType node_type
;
1487 xmlChar
*xml_name
, *href
;
1490 TRACE("(%p)->(%s %s %p)\n", This
, debugstr_w(name
), debugstr_w(namespaceURI
), node
);
1492 if(!node
) return E_INVALIDARG
;
1494 hr
= get_node_type(Type
, &node_type
);
1495 if(FAILED(hr
)) return hr
;
1497 if(namespaceURI
&& namespaceURI
[0] && node_type
!= NODE_ELEMENT
)
1498 FIXME("nodes with namespaces currently not supported.\n");
1500 TRACE("node_type %d\n", node_type
);
1502 /* exit earlier for types that need name */
1506 case NODE_ATTRIBUTE
:
1507 case NODE_ENTITY_REFERENCE
:
1508 case NODE_PROCESSING_INSTRUCTION
:
1509 if (!name
|| *name
== 0) return E_FAIL
;
1514 xml_name
= xmlChar_from_wchar(name
);
1515 /* prevent empty href to be allocated */
1516 href
= namespaceURI
? xmlChar_from_wchar(namespaceURI
) : NULL
;
1522 xmlChar
*local
, *prefix
;
1524 local
= xmlSplitQName2(xml_name
, &prefix
);
1526 xmlnode
= xmlNewDocNode(get_doc(This
), NULL
, local
? local
: xml_name
, NULL
);
1528 /* allow to create default namespace xmlns= */
1529 if (local
|| (href
&& *href
))
1531 xmlNsPtr ns
= xmlNewNs(xmlnode
, href
, prefix
);
1532 xmlSetNs(xmlnode
, ns
);
1540 case NODE_ATTRIBUTE
:
1541 xmlnode
= (xmlNodePtr
)xmlNewDocProp(get_doc(This
), xml_name
, NULL
);
1544 xmlnode
= (xmlNodePtr
)xmlNewDocText(get_doc(This
), NULL
);
1546 case NODE_CDATA_SECTION
:
1547 xmlnode
= xmlNewCDataBlock(get_doc(This
), NULL
, 0);
1549 case NODE_ENTITY_REFERENCE
:
1550 xmlnode
= xmlNewReference(get_doc(This
), xml_name
);
1552 case NODE_PROCESSING_INSTRUCTION
:
1553 #ifdef HAVE_XMLNEWDOCPI
1554 xmlnode
= xmlNewDocPI(get_doc(This
), xml_name
, NULL
);
1556 FIXME("xmlNewDocPI() not supported, use libxml2 2.6.15 or greater\n");
1561 xmlnode
= xmlNewDocComment(get_doc(This
), NULL
);
1563 case NODE_DOCUMENT_FRAGMENT
:
1564 xmlnode
= xmlNewDocFragment(get_doc(This
));
1566 /* unsupported types */
1568 case NODE_DOCUMENT_TYPE
:
1571 heap_free(xml_name
);
1572 return E_INVALIDARG
;
1574 FIXME("unhandled node type %d\n", node_type
);
1579 *node
= create_node(xmlnode
);
1580 heap_free(xml_name
);
1585 TRACE("created node (%d, %p, %p)\n", node_type
, *node
, xmlnode
);
1586 xmldoc_add_orphan(xmlnode
->doc
, xmlnode
);
1593 static HRESULT WINAPI
domdoc_nodeFromID(
1594 IXMLDOMDocument3
*iface
,
1596 IXMLDOMNode
** node
)
1598 domdoc
*This
= impl_from_IXMLDOMDocument3(iface
);
1599 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(idString
), node
);
1603 static HRESULT
domdoc_onDataAvailable(void *obj
, char *ptr
, DWORD len
)
1608 xmldoc
= doparse( ptr
, len
, NULL
);
1610 xmldoc
->_private
= create_priv();
1611 return attach_xmldoc(&This
->node
, xmldoc
);
1617 static HRESULT
doread( domdoc
*This
, LPWSTR filename
)
1622 hr
= bind_url(filename
, domdoc_onDataAvailable
, This
, &bsc
);
1627 detach_bsc(This
->bsc
);
1633 static HRESULT WINAPI
domdoc_load(
1634 IXMLDOMDocument3
*iface
,
1636 VARIANT_BOOL
* isSuccessful
)
1638 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
1639 LPWSTR filename
= NULL
;
1640 HRESULT hr
= S_FALSE
;
1641 IXMLDOMDocument3
*pNewDoc
= NULL
;
1642 IStream
*pStream
= NULL
;
1645 TRACE("(%p)->type %d\n", This
, V_VT(&xmlSource
) );
1647 *isSuccessful
= VARIANT_FALSE
;
1649 assert( &This
->node
);
1651 switch( V_VT(&xmlSource
) )
1654 filename
= V_BSTR(&xmlSource
);
1657 hr
= IUnknown_QueryInterface(V_UNKNOWN(&xmlSource
), &IID_IXMLDOMDocument3
, (void**)&pNewDoc
);
1662 domdoc
*newDoc
= impl_from_IXMLDOMDocument3( pNewDoc
);
1663 xmldoc
= xmlCopyDoc(get_doc(newDoc
), 1);
1664 hr
= attach_xmldoc(&This
->node
, xmldoc
);
1667 *isSuccessful
= VARIANT_TRUE
;
1672 hr
= IUnknown_QueryInterface(V_UNKNOWN(&xmlSource
), &IID_IStream
, (void**)&pStream
);
1675 IPersistStream
*pDocStream
;
1676 hr
= IUnknown_QueryInterface(iface
, &IID_IPersistStream
, (void**)&pDocStream
);
1679 hr
= IPersistStream_Load(pDocStream
, pStream
);
1680 IStream_Release(pStream
);
1683 *isSuccessful
= VARIANT_TRUE
;
1685 TRACE("Using IStream to load Document\n");
1690 ERR("xmldoc_IPersistStream_Load failed (%d)\n", hr
);
1695 ERR("QueryInterface IID_IPersistStream failed (%d)\n", hr
);
1700 /* ISequentialStream */
1701 FIXME("Unknown type not supported (%d) (%p)(%p)\n", hr
, pNewDoc
, V_UNKNOWN(&xmlSource
)->lpVtbl
);
1705 FIXME("VT type not supported (%d)\n", V_VT(&xmlSource
));
1708 TRACE("filename (%s)\n", debugstr_w(filename
));
1712 hr
= doread( This
, filename
);
1715 This
->error
= E_FAIL
;
1718 hr
= This
->error
= S_OK
;
1719 *isSuccessful
= VARIANT_TRUE
;
1723 if(!filename
|| FAILED(hr
)) {
1724 xmldoc
= xmlNewDoc(NULL
);
1725 xmldoc
->_private
= create_priv();
1726 hr
= attach_xmldoc(&This
->node
, xmldoc
);
1731 TRACE("ret (%d)\n", hr
);
1737 static HRESULT WINAPI
domdoc_get_readyState(
1738 IXMLDOMDocument3
*iface
,
1741 domdoc
*This
= impl_from_IXMLDOMDocument3(iface
);
1742 FIXME("(%p)->(%p)\n", This
, value
);
1747 static HRESULT WINAPI
domdoc_get_parseError(
1748 IXMLDOMDocument3
*iface
,
1749 IXMLDOMParseError
** errorObj
)
1751 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
1752 static const WCHAR err
[] = {'e','r','r','o','r',0};
1753 BSTR error_string
= NULL
;
1755 FIXME("(%p)->(%p): creating a dummy parseError\n", iface
, errorObj
);
1758 error_string
= SysAllocString(err
);
1760 *errorObj
= create_parseError(This
->error
, NULL
, error_string
, NULL
, 0, 0, 0);
1761 if(!*errorObj
) return E_OUTOFMEMORY
;
1766 static HRESULT WINAPI
domdoc_get_url(
1767 IXMLDOMDocument3
*iface
,
1770 domdoc
*This
= impl_from_IXMLDOMDocument3(iface
);
1771 FIXME("(%p)->(%p)\n", This
, urlString
);
1776 static HRESULT WINAPI
domdoc_get_async(
1777 IXMLDOMDocument3
*iface
,
1778 VARIANT_BOOL
* isAsync
)
1780 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
1782 TRACE("(%p)->(%p: %d)\n", This
, isAsync
, This
->async
);
1783 *isAsync
= This
->async
;
1788 static HRESULT WINAPI
domdoc_put_async(
1789 IXMLDOMDocument3
*iface
,
1790 VARIANT_BOOL isAsync
)
1792 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
1794 TRACE("(%p)->(%d)\n", This
, isAsync
);
1795 This
->async
= isAsync
;
1800 static HRESULT WINAPI
domdoc_abort(
1801 IXMLDOMDocument3
*iface
)
1803 domdoc
*This
= impl_from_IXMLDOMDocument3(iface
);
1804 FIXME("%p\n", This
);
1809 static BOOL
bstr_to_utf8( BSTR bstr
, char **pstr
, int *plen
)
1814 len
= WideCharToMultiByte( CP_UTF8
, 0, bstr
, -1, NULL
, 0, NULL
, NULL
);
1815 str
= heap_alloc( len
);
1818 WideCharToMultiByte( CP_UTF8
, 0, bstr
, -1, str
, len
, NULL
, NULL
);
1824 /* don't rely on data to be in BSTR format, treat it as WCHAR string */
1825 static HRESULT WINAPI
domdoc_loadXML(
1826 IXMLDOMDocument3
*iface
,
1828 VARIANT_BOOL
* isSuccessful
)
1830 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
1831 xmlDocPtr xmldoc
= NULL
;
1832 HRESULT hr
= S_FALSE
, hr2
;
1836 TRACE("(%p)->(%s %p)\n", This
, debugstr_w( bstrXML
), isSuccessful
);
1838 assert ( &This
->node
);
1842 *isSuccessful
= VARIANT_FALSE
;
1844 if ( bstrXML
&& bstr_to_utf8( bstrXML
, &str
, &len
) )
1846 xmldoc
= doparse( str
, len
, "UTF-8" );
1849 This
->error
= E_FAIL
;
1852 hr
= This
->error
= S_OK
;
1853 *isSuccessful
= VARIANT_TRUE
;
1854 TRACE("parsed document %p\n", xmldoc
);
1859 xmldoc
= xmlNewDoc(NULL
);
1861 xmldoc
->_private
= create_priv();
1862 hr2
= attach_xmldoc( &This
->node
, xmldoc
);
1869 static int XMLCALL
domdoc_save_writecallback(void *ctx
, const char *buffer
,
1874 if(!WriteFile(ctx
, buffer
, len
, &written
, NULL
))
1876 WARN("write error\n");
1883 static int XMLCALL
domdoc_save_closecallback(void *ctx
)
1885 return CloseHandle(ctx
) ? 0 : -1;
1888 static HRESULT WINAPI
domdoc_save(
1889 IXMLDOMDocument3
*iface
,
1890 VARIANT destination
)
1892 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
1898 TRACE("(%p)->(var(vt %d, %s))\n", This
, V_VT(&destination
),
1899 V_VT(&destination
) == VT_BSTR
? debugstr_w(V_BSTR(&destination
)) : NULL
);
1901 if(V_VT(&destination
) != VT_BSTR
&& V_VT(&destination
) != VT_UNKNOWN
)
1903 FIXME("Unhandled vt %d\n", V_VT(&destination
));
1907 if(V_VT(&destination
) == VT_UNKNOWN
)
1909 IUnknown
*pUnk
= V_UNKNOWN(&destination
);
1910 IXMLDOMDocument2
*pDocument
;
1912 ret
= IUnknown_QueryInterface(pUnk
, &IID_IXMLDOMDocument3
, (void**)&pDocument
);
1915 VARIANT_BOOL success
;
1918 ret
= IXMLDOMDocument3_get_xml(iface
, &xml
);
1921 ret
= IXMLDOMDocument3_loadXML(pDocument
, xml
, &success
);
1925 IXMLDOMDocument3_Release(pDocument
);
1928 TRACE("ret %d\n", ret
);
1933 handle
= CreateFileW( V_BSTR(&destination
), GENERIC_WRITE
, 0,
1934 NULL
, CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
1935 if( handle
== INVALID_HANDLE_VALUE
)
1937 WARN("failed to create file\n");
1941 /* disable top XML declaration */
1942 ctx
= xmlSaveToIO(domdoc_save_writecallback
, domdoc_save_closecallback
,
1943 handle
, NULL
, XML_SAVE_NO_DECL
);
1946 CloseHandle(handle
);
1950 xmldecl
= xmldoc_unlink_xmldecl(get_doc(This
));
1951 if (xmlSaveDoc(ctx
, get_doc(This
)) == -1) ret
= S_FALSE
;
1952 xmldoc_link_xmldecl(get_doc(This
), xmldecl
);
1954 /* will close file through close callback */
1960 static HRESULT WINAPI
domdoc_get_validateOnParse(
1961 IXMLDOMDocument3
*iface
,
1962 VARIANT_BOOL
* isValidating
)
1964 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
1965 TRACE("(%p)->(%p: %d)\n", This
, isValidating
, This
->validating
);
1966 *isValidating
= This
->validating
;
1971 static HRESULT WINAPI
domdoc_put_validateOnParse(
1972 IXMLDOMDocument3
*iface
,
1973 VARIANT_BOOL isValidating
)
1975 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
1976 TRACE("(%p)->(%d)\n", This
, isValidating
);
1977 This
->validating
= isValidating
;
1982 static HRESULT WINAPI
domdoc_get_resolveExternals(
1983 IXMLDOMDocument3
*iface
,
1984 VARIANT_BOOL
* isResolving
)
1986 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
1987 TRACE("(%p)->(%p: %d)\n", This
, isResolving
, This
->resolving
);
1988 *isResolving
= This
->resolving
;
1993 static HRESULT WINAPI
domdoc_put_resolveExternals(
1994 IXMLDOMDocument3
*iface
,
1995 VARIANT_BOOL isResolving
)
1997 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
1998 TRACE("(%p)->(%d)\n", This
, isResolving
);
1999 This
->resolving
= isResolving
;
2004 static HRESULT WINAPI
domdoc_get_preserveWhiteSpace(
2005 IXMLDOMDocument3
*iface
,
2006 VARIANT_BOOL
* isPreserving
)
2008 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
2009 TRACE("(%p)->(%p: %d)\n", This
, isPreserving
, This
->preserving
);
2010 *isPreserving
= This
->preserving
;
2015 static HRESULT WINAPI
domdoc_put_preserveWhiteSpace(
2016 IXMLDOMDocument3
*iface
,
2017 VARIANT_BOOL isPreserving
)
2019 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
2020 TRACE("(%p)->(%d)\n", This
, isPreserving
);
2021 This
->preserving
= isPreserving
;
2026 static HRESULT WINAPI
domdoc_put_onReadyStateChange(
2027 IXMLDOMDocument3
*iface
,
2028 VARIANT readyStateChangeSink
)
2030 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
2031 FIXME("%p\n", This
);
2036 static HRESULT WINAPI
domdoc_put_onDataAvailable(
2037 IXMLDOMDocument3
*iface
,
2038 VARIANT onDataAvailableSink
)
2040 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
2041 FIXME("%p\n", This
);
2045 static HRESULT WINAPI
domdoc_put_onTransformNode(
2046 IXMLDOMDocument3
*iface
,
2047 VARIANT onTransformNodeSink
)
2049 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
2050 FIXME("%p\n", This
);
2054 static HRESULT WINAPI
domdoc_get_namespaces(
2055 IXMLDOMDocument3
* iface
,
2056 IXMLDOMSchemaCollection
** schemaCollection
)
2058 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
2059 FIXME("(%p)->(%p)\n", This
, schemaCollection
);
2063 static HRESULT WINAPI
domdoc_get_schemas(
2064 IXMLDOMDocument3
* iface
,
2067 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
2068 HRESULT hr
= S_FALSE
;
2069 IXMLDOMSchemaCollection
*cur_schema
= This
->schema
;
2071 TRACE("(%p)->(%p)\n", This
, var1
);
2073 VariantInit(var1
); /* Test shows we don't call VariantClear here */
2074 V_VT(var1
) = VT_NULL
;
2078 hr
= IXMLDOMSchemaCollection_QueryInterface(cur_schema
, &IID_IDispatch
, (void**)&V_DISPATCH(var1
));
2080 V_VT(var1
) = VT_DISPATCH
;
2085 static HRESULT WINAPI
domdoc_putref_schemas(
2086 IXMLDOMDocument3
* iface
,
2089 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
2090 HRESULT hr
= E_FAIL
;
2091 IXMLDOMSchemaCollection
*new_schema
= NULL
;
2093 FIXME("(%p): semi-stub\n", This
);
2097 hr
= IUnknown_QueryInterface(V_UNKNOWN(&var1
), &IID_IXMLDOMSchemaCollection
, (void**)&new_schema
);
2101 hr
= IDispatch_QueryInterface(V_DISPATCH(&var1
), &IID_IXMLDOMSchemaCollection
, (void**)&new_schema
);
2110 WARN("Can't get schema from vt %x\n", V_VT(&var1
));
2115 IXMLDOMSchemaCollection
*old_schema
= InterlockedExchangePointer((void**)&This
->schema
, new_schema
);
2116 if(old_schema
) IXMLDOMSchemaCollection_Release(old_schema
);
2122 static HRESULT WINAPI
domdoc_validate(
2123 IXMLDOMDocument3
* iface
,
2124 IXMLDOMParseError
** err
)
2126 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
2127 FIXME("(%p)->(%p)\n", This
, err
);
2131 static HRESULT WINAPI
domdoc_setProperty(
2132 IXMLDOMDocument3
* iface
,
2136 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
2138 TRACE("(%p)->(%s)\n", This
, debugstr_w(p
));
2140 if (lstrcmpiW(p
, PropertySelectionLanguageW
) == 0)
2146 V_VT(&varStr
) = VT_EMPTY
;
2147 if (V_VT(&var
) != VT_BSTR
)
2149 if (FAILED(hr
= VariantChangeType(&varStr
, &var
, 0, VT_BSTR
)))
2151 bstr
= V_BSTR(&varStr
);
2154 bstr
= V_BSTR(&var
);
2157 if (lstrcmpiW(bstr
, PropValueXPathW
) == 0)
2158 set_xpathmode(get_doc(This
));
2159 else if (lstrcmpiW(bstr
, PropValueXSLPatternW
) == 0)
2160 reset_xpathmode(get_doc(This
));
2164 VariantClear(&varStr
);
2167 else if (lstrcmpiW(p
, PropertyProhibitDTDW
) == 0)
2170 FIXME("Ignoring property ProhibitDTD, value %d\n", V_BOOL(&var
));
2173 else if (lstrcmpiW(p
, PropertySelectionNamespacesW
) == 0)
2175 if (V_VT(&var
) == VT_BSTR
)
2176 FIXME("Unsupported SelectionNamespaces: %s\n", wine_dbgstr_w(V_BSTR(&var
)));
2180 FIXME("Unknown property %s\n", wine_dbgstr_w(p
));
2184 static HRESULT WINAPI
domdoc_getProperty(
2185 IXMLDOMDocument3
* iface
,
2189 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
2191 TRACE("(%p)->(%p)\n", This
, debugstr_w(p
));
2194 return E_INVALIDARG
;
2196 if (lstrcmpiW(p
, PropertySelectionLanguageW
) == 0)
2198 V_VT(var
) = VT_BSTR
;
2199 V_BSTR(var
) = is_xpathmode(This
->node
.node
->doc
) ?
2200 SysAllocString(PropValueXPathW
) :
2201 SysAllocString(PropValueXSLPatternW
);
2202 return V_BSTR(var
) ? S_OK
: E_OUTOFMEMORY
;
2205 FIXME("Unknown property %s\n", wine_dbgstr_w(p
));
2209 static HRESULT WINAPI
domdoc_validateNode(
2210 IXMLDOMDocument3
* iface
,
2212 IXMLDOMParseError
** error
)
2214 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
2215 FIXME("(%p)->(%p %p): stub\n", This
, node
, error
);
2219 static HRESULT WINAPI
domdoc_importNode(
2220 IXMLDOMDocument3
* iface
,
2223 IXMLDOMNode
** clone
)
2225 domdoc
*This
= impl_from_IXMLDOMDocument3( iface
);
2226 FIXME("(%p)->(%p %d %p): stub\n", This
, node
, deep
, clone
);
2230 static const struct IXMLDOMDocument3Vtbl domdoc_vtbl
=
2232 domdoc_QueryInterface
,
2235 domdoc_GetTypeInfoCount
,
2237 domdoc_GetIDsOfNames
,
2239 domdoc_get_nodeName
,
2240 domdoc_get_nodeValue
,
2241 domdoc_put_nodeValue
,
2242 domdoc_get_nodeType
,
2243 domdoc_get_parentNode
,
2244 domdoc_get_childNodes
,
2245 domdoc_get_firstChild
,
2246 domdoc_get_lastChild
,
2247 domdoc_get_previousSibling
,
2248 domdoc_get_nextSibling
,
2249 domdoc_get_attributes
,
2250 domdoc_insertBefore
,
2251 domdoc_replaceChild
,
2254 domdoc_hasChildNodes
,
2255 domdoc_get_ownerDocument
,
2257 domdoc_get_nodeTypeString
,
2260 domdoc_get_specified
,
2261 domdoc_get_definition
,
2262 domdoc_get_nodeTypedValue
,
2263 domdoc_put_nodeTypedValue
,
2264 domdoc_get_dataType
,
2265 domdoc_put_dataType
,
2267 domdoc_transformNode
,
2269 domdoc_selectSingleNode
,
2271 domdoc_get_namespaceURI
,
2273 domdoc_get_baseName
,
2274 domdoc_transformNodeToObject
,
2276 domdoc_get_implementation
,
2277 domdoc_get_documentElement
,
2278 domdoc_put_documentElement
,
2279 domdoc_createElement
,
2280 domdoc_createDocumentFragment
,
2281 domdoc_createTextNode
,
2282 domdoc_createComment
,
2283 domdoc_createCDATASection
,
2284 domdoc_createProcessingInstruction
,
2285 domdoc_createAttribute
,
2286 domdoc_createEntityReference
,
2287 domdoc_getElementsByTagName
,
2291 domdoc_get_readyState
,
2292 domdoc_get_parseError
,
2299 domdoc_get_validateOnParse
,
2300 domdoc_put_validateOnParse
,
2301 domdoc_get_resolveExternals
,
2302 domdoc_put_resolveExternals
,
2303 domdoc_get_preserveWhiteSpace
,
2304 domdoc_put_preserveWhiteSpace
,
2305 domdoc_put_onReadyStateChange
,
2306 domdoc_put_onDataAvailable
,
2307 domdoc_put_onTransformNode
,
2308 domdoc_get_namespaces
,
2310 domdoc_putref_schemas
,
2314 domdoc_validateNode
,
2318 /* xmldoc implementation of IObjectWithSite */
2319 static HRESULT WINAPI
2320 xmldoc_ObjectWithSite_QueryInterface( IObjectWithSite
* iface
, REFIID riid
, void** ppvObject
)
2322 domdoc
*This
= impl_from_IObjectWithSite(iface
);
2323 return IXMLDocument_QueryInterface( (IXMLDocument
*)This
, riid
, ppvObject
);
2327 xmldoc_ObjectWithSite_AddRef( IObjectWithSite
* iface
)
2329 domdoc
*This
= impl_from_IObjectWithSite(iface
);
2330 return IXMLDocument_AddRef((IXMLDocument
*)This
);
2334 xmldoc_ObjectWithSite_Release( IObjectWithSite
* iface
)
2336 domdoc
*This
= impl_from_IObjectWithSite(iface
);
2337 return IXMLDocument_Release((IXMLDocument
*)This
);
2340 static HRESULT WINAPI
2341 xmldoc_GetSite( IObjectWithSite
*iface
, REFIID iid
, void ** ppvSite
)
2343 domdoc
*This
= impl_from_IObjectWithSite(iface
);
2345 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid( iid
), ppvSite
);
2350 return IUnknown_QueryInterface( This
->site
, iid
, ppvSite
);
2353 static HRESULT WINAPI
2354 xmldoc_SetSite( IObjectWithSite
*iface
, IUnknown
*punk
)
2356 domdoc
*This
= impl_from_IObjectWithSite(iface
);
2358 TRACE("(%p)->(%p)\n", iface
, punk
);
2364 IUnknown_Release( This
->site
);
2371 IUnknown_AddRef( punk
);
2374 IUnknown_Release( This
->site
);
2381 static const IObjectWithSiteVtbl domdocObjectSite
=
2383 xmldoc_ObjectWithSite_QueryInterface
,
2384 xmldoc_ObjectWithSite_AddRef
,
2385 xmldoc_ObjectWithSite_Release
,
2390 static HRESULT WINAPI
xmldoc_Safety_QueryInterface(IObjectSafety
*iface
, REFIID riid
, void **ppv
)
2392 domdoc
*This
= impl_from_IObjectSafety(iface
);
2393 return IXMLDocument_QueryInterface( (IXMLDocument
*)This
, riid
, ppv
);
2396 static ULONG WINAPI
xmldoc_Safety_AddRef(IObjectSafety
*iface
)
2398 domdoc
*This
= impl_from_IObjectSafety(iface
);
2399 return IXMLDocument_AddRef((IXMLDocument
*)This
);
2402 static ULONG WINAPI
xmldoc_Safety_Release(IObjectSafety
*iface
)
2404 domdoc
*This
= impl_from_IObjectSafety(iface
);
2405 return IXMLDocument_Release((IXMLDocument
*)This
);
2408 #define SAFETY_SUPPORTED_OPTIONS (INTERFACESAFE_FOR_UNTRUSTED_CALLER|INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_SECURITY_MANAGER)
2410 static HRESULT WINAPI
xmldoc_Safety_GetInterfaceSafetyOptions(IObjectSafety
*iface
, REFIID riid
,
2411 DWORD
*pdwSupportedOptions
, DWORD
*pdwEnabledOptions
)
2413 domdoc
*This
= impl_from_IObjectSafety(iface
);
2415 TRACE("(%p)->(%s %p %p)\n", This
, debugstr_guid(riid
), pdwSupportedOptions
, pdwEnabledOptions
);
2417 if(!pdwSupportedOptions
|| !pdwEnabledOptions
)
2420 *pdwSupportedOptions
= SAFETY_SUPPORTED_OPTIONS
;
2421 *pdwEnabledOptions
= This
->safeopt
;
2426 static HRESULT WINAPI
xmldoc_Safety_SetInterfaceSafetyOptions(IObjectSafety
*iface
, REFIID riid
,
2427 DWORD dwOptionSetMask
, DWORD dwEnabledOptions
)
2429 domdoc
*This
= impl_from_IObjectSafety(iface
);
2430 TRACE("(%p)->(%s %x %x)\n", This
, debugstr_guid(riid
), dwOptionSetMask
, dwEnabledOptions
);
2432 if ((dwOptionSetMask
& ~SAFETY_SUPPORTED_OPTIONS
) != 0)
2435 This
->safeopt
= dwEnabledOptions
& dwOptionSetMask
& SAFETY_SUPPORTED_OPTIONS
;
2439 static const IObjectSafetyVtbl domdocObjectSafetyVtbl
= {
2440 xmldoc_Safety_QueryInterface
,
2441 xmldoc_Safety_AddRef
,
2442 xmldoc_Safety_Release
,
2443 xmldoc_Safety_GetInterfaceSafetyOptions
,
2444 xmldoc_Safety_SetInterfaceSafetyOptions
2448 static const tid_t domdoc_iface_tids
[] = {
2450 IXMLDOMDocument_tid
,
2451 IXMLDOMDocument2_tid
,
2454 static dispex_static_data_t domdoc_dispex
= {
2456 IXMLDOMDocument2_tid
,
2461 HRESULT
DOMDocument_create_from_xmldoc(xmlDocPtr xmldoc
, IXMLDOMDocument3
**document
)
2465 doc
= heap_alloc( sizeof (*doc
) );
2467 return E_OUTOFMEMORY
;
2469 doc
->lpVtbl
= &domdoc_vtbl
;
2470 doc
->lpvtblIPersistStreamInit
= &xmldoc_IPersistStreamInit_VTable
;
2471 doc
->lpvtblIObjectWithSite
= &domdocObjectSite
;
2472 doc
->lpvtblIObjectSafety
= &domdocObjectSafetyVtbl
;
2473 doc
->lpvtblISupportErrorInfo
= &support_error_vtbl
;
2475 doc
->async
= VARIANT_TRUE
;
2476 doc
->validating
= 0;
2478 doc
->preserving
= 0;
2486 init_xmlnode(&doc
->node
, (xmlNodePtr
)xmldoc
, (IXMLDOMNode
*)&doc
->lpVtbl
, &domdoc_dispex
);
2488 *document
= (IXMLDOMDocument3
*)&doc
->lpVtbl
;
2490 TRACE("returning iface %p\n", *document
);
2494 HRESULT
DOMDocument_create(const GUID
*clsid
, IUnknown
*pUnkOuter
, void **ppObj
)
2499 TRACE("(%s, %p, %p)\n", debugstr_guid(clsid
), pUnkOuter
, ppObj
);
2501 xmldoc
= xmlNewDoc(NULL
);
2503 return E_OUTOFMEMORY
;
2505 xmldoc
->_private
= create_priv();
2507 hr
= DOMDocument_create_from_xmldoc(xmldoc
, (IXMLDOMDocument3
**)ppObj
);
2514 /* properties that are dependent on object versions */
2515 if (IsEqualCLSID( clsid
, &CLSID_DOMDocument40
) ||
2516 IsEqualCLSID( clsid
, &CLSID_DOMDocument60
))
2518 domdoc
*This
= impl_from_IXMLDOMDocument3(*ppObj
);
2519 set_xpathmode(get_doc(This
));
2525 IUnknown
* create_domdoc( xmlNodePtr document
)
2530 TRACE("(%p)\n", document
);
2532 hr
= DOMDocument_create_from_xmldoc((xmlDocPtr
)document
, (IXMLDOMDocument3
**)&pObj
);
2541 HRESULT
DOMDocument_create(const GUID
*clsid
, IUnknown
*pUnkOuter
, void **ppObj
)
2543 MESSAGE("This program tried to use a DOMDocument object, but\n"
2544 "libxml2 support was not present at compile time.\n");