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
34 #include "msxml_private.h"
36 #include "wine/debug.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
42 static const WCHAR szBinBase64[] = {'b','i','n','.','b','a','s','e','6','4',0};
43 static const WCHAR szString[] = {'s','t','r','i','n','g',0};
44 static const WCHAR szNumber[] = {'n','u','m','b','e','r',0};
45 static const WCHAR szInt[] = {'I','n','t',0};
46 static const WCHAR szFixed[] = {'F','i','x','e','d','.','1','4','.','4',0};
47 static const WCHAR szBoolean[] = {'B','o','o','l','e','a','n',0};
48 static const WCHAR szDateTime[] = {'d','a','t','e','T','i','m','e',0};
49 static const WCHAR szDateTimeTZ[] = {'d','a','t','e','T','i','m','e','.','t','z',0};
50 static const WCHAR szDate[] = {'D','a','t','e',0};
51 static const WCHAR szTime[] = {'T','i','m','e',0};
52 static const WCHAR szTimeTZ[] = {'T','i','m','e','.','t','z',0};
53 static const WCHAR szI1[] = {'i','1',0};
54 static const WCHAR szByte[] = {'B','y','t','e',0};
55 static const WCHAR szI2[] = {'i','2',0};
56 static const WCHAR szI4[] = {'i','4',0};
57 static const WCHAR szIU1[] = {'u','i','1',0};
58 static const WCHAR szIU2[] = {'u','i','2',0};
59 static const WCHAR szIU4[] = {'u','i','4',0};
60 static const WCHAR szR4[] = {'r','4',0};
61 static const WCHAR szR8[] = {'r','8',0};
62 static const WCHAR szFloat[] = {'f','l','o','a','t',0};
63 static const WCHAR szUUID[] = {'u','u','i','d',0};
64 static const WCHAR szBinHex[] = {'b','i','n','.','h','e','x',0};
66 static inline xmlnode *impl_from_InternalUnknown( IUnknown *iface )
68 return (xmlnode *)((char*)iface - FIELD_OFFSET(xmlnode, lpInternalUnkVtbl));
71 xmlNodePtr xmlNodePtr_from_domnode( IXMLDOMNode *iface, xmlElementType type )
77 This = impl_from_IXMLDOMNode( iface );
80 if ( type && This->node->type != type )
85 void attach_xmlnode( IXMLDOMNode *node, xmlNodePtr xml )
87 xmlnode *This = impl_from_IXMLDOMNode( node );
90 xmldoc_release(This->node->doc);
94 xmldoc_add_ref(This->node->doc);
99 static HRESULT WINAPI xmlnode_QueryInterface(
104 xmlnode *This = impl_from_IXMLDOMNode( iface );
105 TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject);
107 return IUnknown_QueryInterface(This->pUnkOuter, riid, ppvObject);
110 static ULONG WINAPI xmlnode_AddRef(
113 xmlnode *This = impl_from_IXMLDOMNode( iface );
114 return IUnknown_AddRef(This->pUnkOuter);
117 static ULONG WINAPI xmlnode_Release(
120 xmlnode *This = impl_from_IXMLDOMNode( iface );
121 return IUnknown_Release(This->pUnkOuter);
124 static HRESULT WINAPI xmlnode_GetTypeInfoCount(
132 static HRESULT WINAPI xmlnode_GetTypeInfo(
136 ITypeInfo** ppTInfo )
142 static HRESULT WINAPI xmlnode_GetIDsOfNames(
154 static HRESULT WINAPI xmlnode_Invoke(
160 DISPPARAMS* pDispParams,
162 EXCEPINFO* pExcepInfo,
169 static HRESULT WINAPI xmlnode_get_nodeName(
173 xmlnode *This = impl_from_IXMLDOMNode( iface );
176 TRACE("%p\n", This );
184 switch( This->node->type )
186 case XML_CDATA_SECTION_NODE:
187 str = (const xmlChar*) "#cdata-section";
189 case XML_COMMENT_NODE:
190 str = (const xmlChar*) "#comment";
192 case XML_DOCUMENT_FRAG_NODE:
193 str = (const xmlChar*) "#document-fragment";
196 str = (const xmlChar*) "#text";
198 case XML_DOCUMENT_NODE:
199 str = (const xmlChar*) "#document";
201 case XML_ATTRIBUTE_NODE:
202 case XML_ELEMENT_NODE:
203 str = This->node->name;
206 FIXME("nodeName not mapped correctly (%d)\n", This->node->type);
207 str = This->node->name;
211 *name = bstr_from_xmlChar( str );
218 BSTR bstr_from_xmlChar( const xmlChar *buf )
227 len = MultiByteToWideChar( CP_UTF8, 0, (LPCSTR) buf, -1, NULL, 0 );
228 str = (LPWSTR) HeapAlloc( GetProcessHeap(), 0, len * sizeof (WCHAR) );
231 MultiByteToWideChar( CP_UTF8, 0, (LPCSTR) buf, -1, str, len );
232 bstr = SysAllocString( str );
233 HeapFree( GetProcessHeap(), 0, str );
237 static HRESULT WINAPI xmlnode_get_nodeValue(
241 xmlnode *This = impl_from_IXMLDOMNode( iface );
244 TRACE("%p %p\n", This, value);
249 V_BSTR(value) = NULL;
250 V_VT(value) = VT_NULL;
252 switch ( This->node->type )
254 case XML_ATTRIBUTE_NODE:
256 xmlChar *content = xmlNodeGetContent(This->node);
257 V_VT(value) = VT_BSTR;
258 V_BSTR(value) = bstr_from_xmlChar( content );
264 V_VT(value) = VT_BSTR;
265 V_BSTR(value) = bstr_from_xmlChar( This->node->content );
268 case XML_ELEMENT_NODE:
269 case XML_DOCUMENT_NODE:
270 /* these seem to return NULL */
274 FIXME("node %p type %d\n", This, This->node->type);
277 TRACE("%p returned %s\n", This, debugstr_w( V_BSTR(value) ) );
282 static HRESULT WINAPI xmlnode_put_nodeValue(
290 static HRESULT WINAPI xmlnode_get_nodeType(
294 xmlnode *This = impl_from_IXMLDOMNode( iface );
296 TRACE("%p %p\n", This, type);
298 assert( NODE_ELEMENT == XML_ELEMENT_NODE );
299 assert( NODE_NOTATION == XML_NOTATION_NODE );
301 *type = This->node->type;
306 static HRESULT get_node(
312 TRACE("%p->%s %p\n", This, name, node );
316 *out = create_node( node );
322 static HRESULT WINAPI xmlnode_get_parentNode(
324 IXMLDOMNode** parent)
326 xmlnode *This = impl_from_IXMLDOMNode( iface );
327 return get_node( This, "parent", This->node->parent, parent );
330 static HRESULT WINAPI xmlnode_get_childNodes(
332 IXMLDOMNodeList** childList)
334 xmlnode *This = impl_from_IXMLDOMNode( iface );
336 TRACE("%p %p\n", This, childList );
341 *childList = create_children_nodelist(This->node);
342 if (*childList == NULL)
343 return E_OUTOFMEMORY;
348 static HRESULT WINAPI xmlnode_get_firstChild(
350 IXMLDOMNode** firstChild)
352 xmlnode *This = impl_from_IXMLDOMNode( iface );
353 return get_node( This, "firstChild", This->node->children, firstChild );
356 static HRESULT WINAPI xmlnode_get_lastChild(
358 IXMLDOMNode** lastChild)
360 xmlnode *This = impl_from_IXMLDOMNode( iface );
362 TRACE("%p\n", This );
367 switch( This->node->type )
369 /* CDATASection, Comment, PI and Text Nodes do not support lastChild */
371 case XML_CDATA_SECTION_NODE:
373 case XML_COMMENT_NODE:
377 return get_node( This, "lastChild", This->node->last, lastChild );
381 static HRESULT WINAPI xmlnode_get_previousSibling(
383 IXMLDOMNode** previousSibling)
385 xmlnode *This = impl_from_IXMLDOMNode( iface );
387 TRACE("%p\n", This );
389 if (!previousSibling)
392 switch( This->node->type )
394 /* Attribute, Document and Document Fragment Nodes do not support previousSibling */
395 case XML_DOCUMENT_NODE:
396 case XML_DOCUMENT_FRAG_NODE:
397 case XML_ATTRIBUTE_NODE:
398 *previousSibling = NULL;
401 return get_node( This, "previous", This->node->prev, previousSibling );
405 static HRESULT WINAPI xmlnode_get_nextSibling(
407 IXMLDOMNode** nextSibling)
409 xmlnode *This = impl_from_IXMLDOMNode( iface );
411 TRACE("%p\n", This );
416 switch( This->node->type )
418 /* Attribute, Document and Document Fragment Nodes do not support nextSibling */
419 case XML_DOCUMENT_NODE:
420 case XML_DOCUMENT_FRAG_NODE:
421 case XML_ATTRIBUTE_NODE:
425 return get_node( This, "next", This->node->next, nextSibling );
429 static HRESULT WINAPI xmlnode_get_attributes(
431 IXMLDOMNamedNodeMap** attributeMap)
433 xmlnode *This = impl_from_IXMLDOMNode( iface );
439 switch( This->node->type )
441 /* Attribute, CDataSection, Comment, Documents, Documents Fragments,
442 Entity and Text Nodes does not support get_attributes */
443 case XML_ATTRIBUTE_NODE:
444 case XML_CDATA_SECTION_NODE:
445 case XML_COMMENT_NODE:
446 case XML_DOCUMENT_NODE:
447 case XML_DOCUMENT_FRAG_NODE:
448 case XML_ENTITY_NODE:
449 case XML_ENTITY_REF_NODE:
451 *attributeMap = NULL;
454 *attributeMap = create_nodemap( iface );
459 static HRESULT WINAPI xmlnode_insertBefore(
461 IXMLDOMNode* newChild,
463 IXMLDOMNode** outNewChild)
465 xmlnode *This = impl_from_IXMLDOMNode( iface );
466 xmlNodePtr before_node, new_child_node;
467 IXMLDOMNode *before = NULL, *new;
470 TRACE("(%p)->(%p,var,%p)\n",This,newChild,outNewChild);
475 switch(V_VT(&refChild))
482 hr = IUnknown_QueryInterface(V_UNKNOWN(&refChild), &IID_IXMLDOMNode, (LPVOID)&before);
483 if(FAILED(hr)) return hr;
487 hr = IDispatch_QueryInterface(V_DISPATCH(&refChild), &IID_IXMLDOMNode, (LPVOID)&before);
488 if(FAILED(hr)) return hr;
492 FIXME("refChild var type %x\n", V_VT(&refChild));
496 IXMLDOMNode_QueryInterface(newChild, &IID_IXMLDOMNode, (LPVOID)&new);
497 new_child_node = impl_from_IXMLDOMNode(new)->node;
498 TRACE("new_child_node %p This->node %p\n", new_child_node, This->node);
502 before_node = impl_from_IXMLDOMNode(before)->node;
503 xmlAddPrevSibling(before_node, new_child_node);
504 IXMLDOMNode_Release(before);
508 xmlAddChild(This->node, new_child_node);
511 IXMLDOMNode_Release(new);
512 IXMLDOMNode_AddRef(newChild);
514 *outNewChild = newChild;
520 static HRESULT WINAPI xmlnode_replaceChild(
522 IXMLDOMNode* newChild,
523 IXMLDOMNode* oldChild,
524 IXMLDOMNode** outOldChild)
530 static HRESULT WINAPI xmlnode_removeChild(
532 IXMLDOMNode* childNode,
533 IXMLDOMNode** oldChild)
535 xmlnode *This = impl_from_IXMLDOMNode( iface );
536 xmlNode *ancestor, *child_node_ptr;
540 TRACE("%p->(%p, %p)\n", This, childNode, oldChild);
544 if(!childNode) return E_INVALIDARG;
546 hr = IXMLDOMNode_QueryInterface(childNode, &IID_IXMLDOMNode, (LPVOID)&child);
550 child_node_ptr = ancestor = impl_from_IXMLDOMNode(child)->node;
551 while(ancestor->parent)
553 if(ancestor->parent == This->node)
555 ancestor = ancestor->parent;
557 if(!ancestor->parent)
559 WARN("childNode %p is not a child of %p\n", childNode, iface);
560 IXMLDOMNode_Release(child);
564 xmlUnlinkNode(child_node_ptr);
566 IXMLDOMNode_Release(child);
567 IXMLDOMNode_AddRef(childNode);
568 *oldChild = childNode;
572 static HRESULT WINAPI xmlnode_appendChild(
574 IXMLDOMNode* newChild,
575 IXMLDOMNode** outNewChild)
577 xmlnode *This = impl_from_IXMLDOMNode( iface );
578 IXMLDOMNode *pAttr = NULL;
581 TRACE("(%p)->(%p,%p)\n", This, newChild, outNewChild);
583 /* Cannot Append an Attribute node. */
584 IUnknown_QueryInterface(newChild, &IID_IXMLDOMNode, (LPVOID*)&pAttr);
587 xmlnode *ThisNew = impl_from_IXMLDOMNode( pAttr );
589 if(ThisNew->node->type == XML_ATTRIBUTE_NODE)
591 if(outNewChild) *outNewChild = NULL;
593 IUnknown_Release(pAttr);
598 IUnknown_Release(pAttr);
602 return IXMLDOMNode_insertBefore(iface, newChild, var, outNewChild);
605 static HRESULT WINAPI xmlnode_hasChildNodes(
607 VARIANT_BOOL* hasChild)
609 xmlnode *This = impl_from_IXMLDOMNode( iface );
615 if (!This->node->children)
617 *hasChild = VARIANT_FALSE;
621 *hasChild = VARIANT_TRUE;
625 static HRESULT WINAPI xmlnode_get_ownerDocument(
627 IXMLDOMDocument** DOMDocument)
633 static HRESULT WINAPI xmlnode_cloneNode(
636 IXMLDOMNode** cloneRoot)
638 xmlnode *This = impl_from_IXMLDOMNode( iface );
639 xmlNodePtr pClone = NULL;
640 IXMLDOMNode *pNode = NULL;
642 TRACE("%p (%d)\n", This, deep);
647 pClone = xmlCopyNode(This->node, deep ? 1 : 2);
650 pClone->doc = This->node->doc;
652 pNode = create_node(pClone);
655 ERR("Copy failed\n");
663 ERR("Copy failed\n");
670 static HRESULT WINAPI xmlnode_get_nodeTypeString(
674 xmlnode *This = impl_from_IXMLDOMNode( iface );
677 TRACE("%p\n", This );
685 switch( This->node->type )
687 case XML_ATTRIBUTE_NODE:
688 str = (const xmlChar*) "attribute";
690 case XML_CDATA_SECTION_NODE:
691 str = (const xmlChar*) "cdatasection";
693 case XML_COMMENT_NODE:
694 str = (const xmlChar*) "comment";
696 case XML_DOCUMENT_NODE:
697 str = (const xmlChar*) "document";
699 case XML_DOCUMENT_FRAG_NODE:
700 str = (const xmlChar*) "documentfragment";
702 case XML_ELEMENT_NODE:
703 str = (const xmlChar*) "element";
705 case XML_ENTITY_NODE:
706 str = (const xmlChar*) "entity";
708 case XML_ENTITY_REF_NODE:
709 str = (const xmlChar*) "entityreference";
711 case XML_NOTATION_NODE:
712 str = (const xmlChar*) "notation";
715 str = (const xmlChar*) "processinginstruction";
718 str = (const xmlChar*) "text";
721 FIXME("nodeName not mapped correctly (%d)\n", This->node->type);
722 str = This->node->name;
726 *xmlnodeType = bstr_from_xmlChar( str );
733 static HRESULT WINAPI xmlnode_get_text(
737 xmlnode *This = impl_from_IXMLDOMNode( iface );
745 switch(This->node->type)
747 case XML_ELEMENT_NODE:
748 case XML_ATTRIBUTE_NODE:
750 xmlNodePtr child = This->node->children;
751 if ( child && child->type == XML_TEXT_NODE )
752 str = bstr_from_xmlChar( child->content );
757 case XML_CDATA_SECTION_NODE:
759 case XML_COMMENT_NODE:
760 str = bstr_from_xmlChar( This->node->content );
764 FIXME("Unhandled node type %d\n", This->node->type);
767 /* Always return a string. */
768 if (!str) str = SysAllocStringLen( NULL, 0 );
770 TRACE("%p %s\n", This, debugstr_w(str) );
776 static HRESULT WINAPI xmlnode_put_text(
780 xmlnode *This = impl_from_IXMLDOMNode( iface );
785 switch(This->node->type)
787 case XML_DOCUMENT_NODE:
793 str = xmlChar_from_wchar((WCHAR*)text);
795 /* Escape the string. */
796 str = xmlEncodeEntitiesReentrant(This->node->doc, str);
797 str = xmlEncodeSpecialChars(This->node->doc, str);
799 xmlNodeSetContent(This->node, str);
805 static HRESULT WINAPI xmlnode_get_specified(
807 VARIANT_BOOL* isSpecified)
813 static HRESULT WINAPI xmlnode_get_definition(
815 IXMLDOMNode** definitionNode)
821 static HRESULT WINAPI xmlnode_get_nodeTypedValue(
825 FIXME("ignoring data type\n");
826 return xmlnode_get_nodeValue(iface, typedValue);
829 static HRESULT WINAPI xmlnode_put_nodeTypedValue(
837 static HRESULT WINAPI xmlnode_get_dataType(
839 VARIANT* dataTypeName)
841 xmlnode *This = impl_from_IXMLDOMNode( iface );
844 TRACE("iface %p\n", iface);
849 /* Attribute, CDATA Section, Comment, Document, Document Fragment,
850 Entity, Notation, PI, and Text Node are non-typed. */
851 V_BSTR(dataTypeName) = NULL;
852 V_VT(dataTypeName) = VT_NULL;
854 switch ( This->node->type )
856 case XML_ELEMENT_NODE:
857 pVal = xmlGetNsProp(This->node, (xmlChar*)"dt",
858 (xmlChar*)"urn:schemas-microsoft-com:datatypes");
861 V_VT(dataTypeName) = VT_BSTR;
862 V_BSTR(dataTypeName) = bstr_from_xmlChar( pVal );
866 case XML_ENTITY_REF_NODE:
867 FIXME("XML_ENTITY_REF_NODE should return a valid value.\n");
870 TRACE("Type %d returning NULL\n", This->node->type);
873 /* non-typed nodes return S_FALSE */
874 if(V_VT(dataTypeName) == VT_NULL)
882 static HRESULT WINAPI xmlnode_put_dataType(
886 xmlnode *This = impl_from_IXMLDOMNode( iface );
889 TRACE("iface %p\n", iface);
891 if(dataTypeName == NULL)
894 /* An example of this is. The Text in the node needs to be a 0 or 1 for a boolean type.
895 This applies to changing types (string->bool) or setting a new one
897 FIXME("Need to Validate the data before allowing a type to be set.\n");
899 /* Check all supported types. */
900 if(lstrcmpiW(dataTypeName,szString) == 0 ||
901 lstrcmpiW(dataTypeName,szNumber) == 0 ||
902 lstrcmpiW(dataTypeName,szUUID) == 0 ||
903 lstrcmpiW(dataTypeName,szInt) == 0 ||
904 lstrcmpiW(dataTypeName,szI4) == 0 ||
905 lstrcmpiW(dataTypeName,szFixed) == 0 ||
906 lstrcmpiW(dataTypeName,szBoolean) == 0 ||
907 lstrcmpiW(dataTypeName,szDateTime) == 0 ||
908 lstrcmpiW(dataTypeName,szDateTimeTZ) == 0 ||
909 lstrcmpiW(dataTypeName,szDate) == 0 ||
910 lstrcmpiW(dataTypeName,szTime) == 0 ||
911 lstrcmpiW(dataTypeName,szTimeTZ) == 0 ||
912 lstrcmpiW(dataTypeName,szI1) == 0 ||
913 lstrcmpiW(dataTypeName,szByte) == 0 ||
914 lstrcmpiW(dataTypeName,szI2) == 0 ||
915 lstrcmpiW(dataTypeName,szIU1) == 0 ||
916 lstrcmpiW(dataTypeName,szIU2) == 0 ||
917 lstrcmpiW(dataTypeName,szIU4) == 0 ||
918 lstrcmpiW(dataTypeName,szR4) == 0 ||
919 lstrcmpiW(dataTypeName,szR8) == 0 ||
920 lstrcmpiW(dataTypeName,szFloat) == 0 ||
921 lstrcmpiW(dataTypeName,szBinHex) == 0 ||
922 lstrcmpiW(dataTypeName,szBinBase64) == 0)
925 xmlAttrPtr pAttr = NULL;
926 xmlChar* str = xmlChar_from_wchar((WCHAR*)dataTypeName);
928 pAttr = xmlHasNsProp(This->node, (xmlChar*)"dt",
929 (xmlChar*)"urn:schemas-microsoft-com:datatypes");
932 pAttr = xmlSetNsProp(This->node, pAttr->ns, (xmlChar*)"dt", str);
938 pNS = xmlNewNs(This->node, (xmlChar*)"urn:schemas-microsoft-com:datatypes", (xmlChar*)"dt");
941 pAttr = xmlNewNsProp(This->node, pNS, (xmlChar*)"dt", str);
944 xmlAddChild(This->node, (xmlNodePtr)pAttr);
949 ERR("Failed to create Attribute\n");
952 ERR("Failed to Create Namepsace\n");
959 static HRESULT WINAPI xmlnode_get_xml(
963 xmlnode *This = impl_from_IXMLDOMNode( iface );
964 xmlBufferPtr pXmlBuf;
967 TRACE("iface %p\n", iface);
974 pXmlBuf = xmlBufferCreate();
977 nSize = xmlNodeDump(pXmlBuf, This->node->doc, This->node, 0, 0);
980 const xmlChar *pContent;
982 /* Attribute Nodes return a space infront of their name */
983 pContent = xmlBufferContent(pXmlBuf);
984 if( ((char*)pContent)[0] == ' ')
985 *xmlString = bstr_from_xmlChar(pContent+1);
987 *xmlString = bstr_from_xmlChar(pContent);
990 xmlBufferFree(pXmlBuf);
994 /* Always returns a string. */
995 if(*xmlString == NULL) *xmlString = SysAllocStringLen( NULL, 0 );
1000 static HRESULT WINAPI xmlnode_transformNode(
1002 IXMLDOMNode* styleSheet,
1009 static HRESULT WINAPI xmlnode_selectNodes(
1012 IXMLDOMNodeList** resultList)
1014 xmlnode *This = impl_from_IXMLDOMNode( iface );
1016 TRACE("%p %s %p\n", This, debugstr_w(queryString), resultList );
1018 return queryresult_create( This->node, queryString, resultList );
1021 static HRESULT WINAPI xmlnode_selectSingleNode(
1024 IXMLDOMNode** resultNode)
1026 xmlnode *This = impl_from_IXMLDOMNode( iface );
1027 IXMLDOMNodeList *list;
1030 TRACE("%p %s %p\n", This, debugstr_w(queryString), resultNode );
1033 r = IXMLDOMNode_selectNodes(iface, queryString, &list);
1036 r = IXMLDOMNodeList_nextNode(list, resultNode);
1037 IXMLDOMNodeList_Release(list);
1042 static HRESULT WINAPI xmlnode_get_parsed(
1044 VARIANT_BOOL* isParsed)
1050 static HRESULT WINAPI xmlnode_get_namespaceURI(
1058 static HRESULT WINAPI xmlnode_get_prefix(
1066 static HRESULT WINAPI xmlnode_get_baseName(
1070 xmlnode *This = impl_from_IXMLDOMNode( iface );
1072 HRESULT r = S_FALSE;
1074 TRACE("%p %p\n", This, nameString );
1077 return E_INVALIDARG;
1079 switch ( This->node->type )
1081 case XML_ELEMENT_NODE:
1082 case XML_ATTRIBUTE_NODE:
1083 str = bstr_from_xmlChar( This->node->name );
1089 ERR("Unhandled type %d\n", This->node->type );
1093 TRACE("returning %08x str = %s\n", r, debugstr_w( str ) );
1099 static HRESULT WINAPI xmlnode_transformNodeToObject(
1101 IXMLDOMNode* stylesheet,
1102 VARIANT outputObject)
1108 static const struct IXMLDOMNodeVtbl xmlnode_vtbl =
1110 xmlnode_QueryInterface,
1113 xmlnode_GetTypeInfoCount,
1114 xmlnode_GetTypeInfo,
1115 xmlnode_GetIDsOfNames,
1117 xmlnode_get_nodeName,
1118 xmlnode_get_nodeValue,
1119 xmlnode_put_nodeValue,
1120 xmlnode_get_nodeType,
1121 xmlnode_get_parentNode,
1122 xmlnode_get_childNodes,
1123 xmlnode_get_firstChild,
1124 xmlnode_get_lastChild,
1125 xmlnode_get_previousSibling,
1126 xmlnode_get_nextSibling,
1127 xmlnode_get_attributes,
1128 xmlnode_insertBefore,
1129 xmlnode_replaceChild,
1130 xmlnode_removeChild,
1131 xmlnode_appendChild,
1132 xmlnode_hasChildNodes,
1133 xmlnode_get_ownerDocument,
1135 xmlnode_get_nodeTypeString,
1138 xmlnode_get_specified,
1139 xmlnode_get_definition,
1140 xmlnode_get_nodeTypedValue,
1141 xmlnode_put_nodeTypedValue,
1142 xmlnode_get_dataType,
1143 xmlnode_put_dataType,
1145 xmlnode_transformNode,
1146 xmlnode_selectNodes,
1147 xmlnode_selectSingleNode,
1149 xmlnode_get_namespaceURI,
1151 xmlnode_get_baseName,
1152 xmlnode_transformNodeToObject,
1155 static HRESULT WINAPI Internal_QueryInterface(
1160 xmlnode *This = impl_from_InternalUnknown( iface );
1162 TRACE("%p %s %p\n", iface, debugstr_guid(riid), ppvObject);
1165 if ( IsEqualGUID( riid, &IID_IUnknown ))
1167 else if ( IsEqualGUID( riid, &IID_IDispatch ) ||
1168 IsEqualGUID( riid, &IID_IXMLDOMNode ) )
1169 *ppvObject = &This->lpVtbl;
1172 FIXME("interface %s not implemented\n", debugstr_guid(riid));
1174 return E_NOINTERFACE;
1177 IUnknown_AddRef( (IUnknown*)*ppvObject );
1182 static ULONG WINAPI Internal_AddRef(
1185 xmlnode *This = impl_from_InternalUnknown( iface );
1186 return InterlockedIncrement( &This->ref );
1189 static ULONG WINAPI Internal_Release(
1192 xmlnode *This = impl_from_InternalUnknown( iface );
1195 ref = InterlockedDecrement( &This->ref );
1199 xmldoc_release( This->node->doc );
1200 HeapFree( GetProcessHeap(), 0, This );
1206 static const struct IUnknownVtbl internal_unk_vtbl =
1208 Internal_QueryInterface,
1213 IUnknown *create_basic_node( xmlNodePtr node, IUnknown *pUnkOuter )
1217 This = HeapAlloc( GetProcessHeap(), 0, sizeof *This );
1222 xmldoc_add_ref( node->doc );
1224 This->lpVtbl = &xmlnode_vtbl;
1225 This->lpInternalUnkVtbl = &internal_unk_vtbl;
1228 This->pUnkOuter = pUnkOuter; /* Don't take a ref on outer Unknown */
1230 This->pUnkOuter = (IUnknown *)&This->lpInternalUnkVtbl;
1235 return (IUnknown*)&This->lpInternalUnkVtbl;
1238 IXMLDOMNode *create_node( xmlNodePtr node )
1247 TRACE("type %d\n", node->type);
1250 case XML_ELEMENT_NODE:
1251 pUnk = create_element( node, NULL );
1253 case XML_ATTRIBUTE_NODE:
1254 pUnk = create_attribute( node );
1257 pUnk = create_text( node );
1259 case XML_COMMENT_NODE:
1260 pUnk = create_comment( node );
1262 case XML_DOCUMENT_NODE:
1263 ERR("shouldn't be here!\n");
1266 FIXME("only creating basic node for type %d\n", node->type);
1267 pUnk = create_basic_node( node, NULL );
1270 hr = IUnknown_QueryInterface(pUnk, &IID_IXMLDOMNode, (LPVOID*)&ret);
1271 IUnknown_Release(pUnk);
1272 if(FAILED(hr)) return NULL;