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"
37 # include <libxml/HTMLtree.h>
40 #include "wine/debug.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
46 static const WCHAR szBinBase64[] = {'b','i','n','.','b','a','s','e','6','4',0};
47 static const WCHAR szString[] = {'s','t','r','i','n','g',0};
48 static const WCHAR szNumber[] = {'n','u','m','b','e','r',0};
49 static const WCHAR szInt[] = {'I','n','t',0};
50 static const WCHAR szFixed[] = {'F','i','x','e','d','.','1','4','.','4',0};
51 static const WCHAR szBoolean[] = {'B','o','o','l','e','a','n',0};
52 static const WCHAR szDateTime[] = {'d','a','t','e','T','i','m','e',0};
53 static const WCHAR szDateTimeTZ[] = {'d','a','t','e','T','i','m','e','.','t','z',0};
54 static const WCHAR szDate[] = {'D','a','t','e',0};
55 static const WCHAR szTime[] = {'T','i','m','e',0};
56 static const WCHAR szTimeTZ[] = {'T','i','m','e','.','t','z',0};
57 static const WCHAR szI1[] = {'i','1',0};
58 static const WCHAR szI2[] = {'i','2',0};
59 static const WCHAR szI4[] = {'i','4',0};
60 static const WCHAR szIU1[] = {'u','i','1',0};
61 static const WCHAR szIU2[] = {'u','i','2',0};
62 static const WCHAR szIU4[] = {'u','i','4',0};
63 static const WCHAR szR4[] = {'r','4',0};
64 static const WCHAR szR8[] = {'r','8',0};
65 static const WCHAR szFloat[] = {'f','l','o','a','t',0};
66 static const WCHAR szUUID[] = {'u','u','i','d',0};
67 static const WCHAR szBinHex[] = {'b','i','n','.','h','e','x',0};
69 static const IID IID_xmlnode = {0x4f2f4ba2,0xb822,0x11df,{0x8b,0x8a,0x68,0x50,0xdf,0xd7,0x20,0x85}};
71 xmlNodePtr xmlNodePtr_from_domnode( IXMLDOMNode *iface, xmlElementType type )
77 This = get_node_obj( iface );
78 if ( !This || !This->node )
80 if ( type && This->node->type != type )
85 BOOL node_query_interface(xmlnode *This, REFIID riid, void **ppv)
87 if(IsEqualGUID(&IID_xmlnode, riid)) {
88 TRACE("(%p)->(IID_xmlnode %p)\n", This, ppv);
93 if(This->dispex.outer)
94 return dispex_query_interface(&This->dispex, riid, ppv);
99 xmlnode *get_node_obj(IXMLDOMNode *node)
104 hres = IXMLDOMNode_QueryInterface(node, &IID_xmlnode, (void**)&obj);
105 return SUCCEEDED(hres) ? obj : NULL;
108 static inline xmlnode *impl_from_IXMLDOMNode( IXMLDOMNode *iface )
110 return (xmlnode *)((char*)iface - FIELD_OFFSET(xmlnode, lpVtbl));
113 static HRESULT WINAPI xmlnode_QueryInterface(
118 ERR("Should not be called\n");
119 return E_NOINTERFACE;
122 static ULONG WINAPI xmlnode_AddRef(
125 ERR("Should not be called\n");
129 static ULONG WINAPI xmlnode_Release(
132 ERR("Should not be called\n");
136 static HRESULT WINAPI xmlnode_GetTypeInfoCount(
140 ERR("Should not be called\n");
144 static HRESULT WINAPI xmlnode_GetTypeInfo(
148 ITypeInfo** ppTInfo )
150 ERR("Should not be called\n");
154 static HRESULT WINAPI xmlnode_GetIDsOfNames(
162 ERR("Should not be called\n");
166 static HRESULT WINAPI xmlnode_Invoke(
172 DISPPARAMS* pDispParams,
174 EXCEPINFO* pExcepInfo,
177 ERR("Should not be called\n");
181 HRESULT node_get_nodeName(xmlnode *This, BSTR *name)
186 *name = bstr_from_xmlChar(This->node->name);
193 static HRESULT WINAPI xmlnode_get_nodeName(
197 ERR("Should not be called\n");
201 HRESULT node_get_content(xmlnode *This, VARIANT *value)
208 content = xmlNodeGetContent(This->node);
209 V_VT(value) = VT_BSTR;
210 V_BSTR(value) = bstr_from_xmlChar( content );
213 TRACE("%p returned %s\n", This, debugstr_w(V_BSTR(value)));
217 static HRESULT WINAPI xmlnode_get_nodeValue(
221 ERR("Should not be called\n");
225 HRESULT node_put_value(xmlnode *This, VARIANT *value)
227 VARIANT string_value;
231 VariantInit(&string_value);
232 hr = VariantChangeType(&string_value, value, 0, VT_BSTR);
234 WARN("Couldn't convert to VT_BSTR\n");
238 str = xmlChar_from_wchar(V_BSTR(&string_value));
239 VariantClear(&string_value);
241 xmlNodeSetContent(This->node, str);
246 static HRESULT WINAPI xmlnode_put_nodeValue(
250 ERR("Should not be called\n");
254 static HRESULT WINAPI xmlnode_get_nodeType(
258 ERR("Should not be called\n");
262 static HRESULT get_node(
268 TRACE("(%p)->(%s %p %p)\n", This, name, node, out );
273 /* if we don't have a doc, use our parent. */
274 if(node && !node->doc && node->parent)
275 node->doc = node->parent->doc;
277 *out = create_node( node );
283 HRESULT node_get_parent(xmlnode *This, IXMLDOMNode **parent)
285 return get_node( This, "parent", This->node->parent, parent );
288 static HRESULT WINAPI xmlnode_get_parentNode(
290 IXMLDOMNode** parent)
292 ERR("Should not be called\n");
296 HRESULT node_get_child_nodes(xmlnode *This, IXMLDOMNodeList **ret)
301 *ret = create_children_nodelist(This->node);
303 return E_OUTOFMEMORY;
308 static HRESULT WINAPI xmlnode_get_childNodes(
310 IXMLDOMNodeList** childList)
312 ERR("Should not be called\n");
316 HRESULT node_get_first_child(xmlnode *This, IXMLDOMNode **ret)
318 return get_node(This, "firstChild", This->node->children, ret);
321 static HRESULT WINAPI xmlnode_get_firstChild(
323 IXMLDOMNode** firstChild)
325 ERR("Should not be called\n");
329 HRESULT node_get_last_child(xmlnode *This, IXMLDOMNode **ret)
331 return get_node(This, "lastChild", This->node->last, ret);
334 static HRESULT WINAPI xmlnode_get_lastChild(
336 IXMLDOMNode** lastChild)
338 ERR("Should not be called\n");
342 HRESULT node_get_previous_sibling(xmlnode *This, IXMLDOMNode **ret)
344 return get_node(This, "previous", This->node->prev, ret);
347 static HRESULT WINAPI xmlnode_get_previousSibling(
349 IXMLDOMNode** previousSibling)
351 ERR("Should not be called\n");
355 HRESULT node_get_next_sibling(xmlnode *This, IXMLDOMNode **ret)
357 return get_node(This, "next", This->node->next, ret);
360 static HRESULT WINAPI xmlnode_get_nextSibling(
362 IXMLDOMNode** nextSibling)
364 ERR("Should not be called\n");
368 static HRESULT WINAPI xmlnode_get_attributes(
370 IXMLDOMNamedNodeMap** attributeMap)
372 ERR("Should not be called\n");
376 HRESULT node_insert_before(xmlnode *This, IXMLDOMNode *new_child, const VARIANT *ref_child,
379 xmlNodePtr before_node, new_child_node;
380 IXMLDOMNode *before = NULL;
387 node_obj = get_node_obj(new_child);
389 FIXME("newChild is not our node implementation\n");
393 switch(V_VT(ref_child))
401 hr = IUnknown_QueryInterface(V_UNKNOWN(ref_child), &IID_IXMLDOMNode, (LPVOID)&before);
402 if(FAILED(hr)) return hr;
406 FIXME("refChild var type %x\n", V_VT(ref_child));
410 new_child_node = node_obj->node;
411 TRACE("new_child_node %p This->node %p\n", new_child_node, This->node);
413 if(!new_child_node->parent)
414 if(xmldoc_remove_orphan(new_child_node->doc, new_child_node) != S_OK)
415 WARN("%p is not an orphan of %p\n", new_child_node, new_child_node->doc);
419 node_obj = get_node_obj(before);
420 IXMLDOMNode_Release(before);
422 FIXME("before node is not our node implementation\n");
426 before_node = node_obj->node;
427 xmlAddPrevSibling(before_node, new_child_node);
431 xmlAddChild(This->node, new_child_node);
435 IXMLDOMNode_AddRef(new_child);
443 static HRESULT WINAPI xmlnode_insertBefore(
445 IXMLDOMNode* newChild,
447 IXMLDOMNode** outNewChild)
449 ERR("Should not be called\n");
453 static HRESULT WINAPI xmlnode_replaceChild(
455 IXMLDOMNode* newChild,
456 IXMLDOMNode* oldChild,
457 IXMLDOMNode** outOldChild)
459 xmlnode *This = impl_from_IXMLDOMNode( iface );
460 xmlnode *old_child, *new_child;
461 xmlDocPtr leaving_doc;
462 xmlNode *my_ancestor;
464 TRACE("(%p)->(%p %p %p)\n", This, newChild, oldChild, outOldChild);
466 /* Do not believe any documentation telling that newChild == NULL
467 means removal. It does certainly *not* apply to msxml3! */
468 if(!newChild || !oldChild)
474 old_child = get_node_obj(oldChild);
476 FIXME("oldChild is not our node implementation\n");
480 if(old_child->node->parent != This->node)
482 WARN("childNode %p is not a child of %p\n", oldChild, iface);
486 new_child = get_node_obj(newChild);
488 FIXME("newChild is not our node implementation\n");
492 my_ancestor = This->node;
495 if(my_ancestor == new_child->node)
497 WARN("tried to create loop\n");
500 my_ancestor = my_ancestor->parent;
503 if(!new_child->node->parent)
504 if(xmldoc_remove_orphan(new_child->node->doc, new_child->node) != S_OK)
505 WARN("%p is not an orphan of %p\n", new_child->node, new_child->node->doc);
507 leaving_doc = new_child->node->doc;
508 xmldoc_add_ref(old_child->node->doc);
509 xmlReplaceNode(old_child->node, new_child->node);
510 xmldoc_release(leaving_doc);
512 xmldoc_add_orphan(old_child->node->doc, old_child->node);
516 IXMLDOMNode_AddRef(oldChild);
517 *outOldChild = oldChild;
523 static HRESULT WINAPI xmlnode_removeChild(
525 IXMLDOMNode* childNode,
526 IXMLDOMNode** oldChild)
528 xmlnode *This = impl_from_IXMLDOMNode( iface );
531 TRACE("(%p)->(%p %p)\n", This, childNode, oldChild);
533 if(!childNode) return E_INVALIDARG;
538 child_node = get_node_obj(childNode);
540 FIXME("childNode is not our node implementation\n");
544 if(child_node->node->parent != This->node)
546 WARN("childNode %p is not a child of %p\n", childNode, iface);
550 xmlUnlinkNode(child_node->node);
554 IXMLDOMNode_AddRef(childNode);
555 *oldChild = childNode;
561 static HRESULT WINAPI xmlnode_appendChild(
563 IXMLDOMNode* newChild,
564 IXMLDOMNode** outNewChild)
566 xmlnode *This = impl_from_IXMLDOMNode( iface );
571 TRACE("(%p)->(%p %p)\n", This, newChild, outNewChild);
573 hr = IXMLDOMNode_get_nodeType(newChild, &type);
574 if(FAILED(hr) || type == NODE_ATTRIBUTE) {
575 if(outNewChild) *outNewChild = NULL;
580 return IXMLDOMNode_insertBefore(This->iface, newChild, var, outNewChild);
583 static HRESULT WINAPI xmlnode_hasChildNodes(
585 VARIANT_BOOL* hasChild)
587 xmlnode *This = impl_from_IXMLDOMNode( iface );
589 TRACE("(%p)->(%p)\n", This, hasChild);
593 if (!This->node->children)
595 *hasChild = VARIANT_FALSE;
599 *hasChild = VARIANT_TRUE;
603 static HRESULT WINAPI xmlnode_get_ownerDocument(
605 IXMLDOMDocument** DOMDocument)
607 xmlnode *This = impl_from_IXMLDOMNode( iface );
609 TRACE("(%p)->(%p)\n", This, DOMDocument);
611 return DOMDocument_create_from_xmldoc(This->node->doc, (IXMLDOMDocument3**)DOMDocument);
614 static HRESULT WINAPI xmlnode_cloneNode(
617 IXMLDOMNode** cloneRoot)
619 xmlnode *This = impl_from_IXMLDOMNode( iface );
620 xmlNodePtr pClone = NULL;
621 IXMLDOMNode *pNode = NULL;
623 TRACE("(%p)->(%d %p)\n", This, deep, cloneRoot);
628 pClone = xmlCopyNode(This->node, deep ? 1 : 2);
631 pClone->doc = This->node->doc;
632 xmldoc_add_orphan(pClone->doc, pClone);
634 pNode = create_node(pClone);
637 ERR("Copy failed\n");
645 ERR("Copy failed\n");
652 static HRESULT WINAPI xmlnode_get_nodeTypeString(
656 xmlnode *This = impl_from_IXMLDOMNode( iface );
659 TRACE("(%p)->(%p)\n", This, xmlnodeType );
667 switch( This->node->type )
669 case XML_ATTRIBUTE_NODE:
670 str = (const xmlChar*) "attribute";
672 case XML_CDATA_SECTION_NODE:
673 str = (const xmlChar*) "cdatasection";
675 case XML_COMMENT_NODE:
676 str = (const xmlChar*) "comment";
678 case XML_DOCUMENT_NODE:
679 str = (const xmlChar*) "document";
681 case XML_DOCUMENT_FRAG_NODE:
682 str = (const xmlChar*) "documentfragment";
684 case XML_ELEMENT_NODE:
685 str = (const xmlChar*) "element";
687 case XML_ENTITY_NODE:
688 str = (const xmlChar*) "entity";
690 case XML_ENTITY_REF_NODE:
691 str = (const xmlChar*) "entityreference";
693 case XML_NOTATION_NODE:
694 str = (const xmlChar*) "notation";
697 str = (const xmlChar*) "processinginstruction";
700 str = (const xmlChar*) "text";
703 FIXME("Unknown node type (%d)\n", This->node->type);
704 str = This->node->name;
708 *xmlnodeType = bstr_from_xmlChar( str );
715 static HRESULT WINAPI xmlnode_get_text(
719 xmlnode *This = impl_from_IXMLDOMNode( iface );
723 TRACE("(%p, type %d)->(%p)\n", This, This->node->type, text);
728 pContent = xmlNodeGetContent((xmlNodePtr)This->node);
731 str = bstr_from_xmlChar(pContent);
735 /* Always return a string. */
736 if (!str) str = SysAllocStringLen( NULL, 0 );
738 TRACE("%p %s\n", This, debugstr_w(str) );
744 static HRESULT WINAPI xmlnode_put_text(
748 xmlnode *This = impl_from_IXMLDOMNode( iface );
751 TRACE("(%p)->(%s)\n", This, debugstr_w(text));
753 switch(This->node->type)
755 case XML_DOCUMENT_NODE:
761 str = xmlChar_from_wchar(text);
763 /* Escape the string. */
764 str2 = xmlEncodeEntitiesReentrant(This->node->doc, str);
767 xmlNodeSetContent(This->node, str2);
773 static HRESULT WINAPI xmlnode_get_specified(
775 VARIANT_BOOL* isSpecified)
777 xmlnode *This = impl_from_IXMLDOMNode( iface );
778 FIXME("(%p)->(%p) stub!\n", This, isSpecified);
779 *isSpecified = VARIANT_TRUE;
783 static HRESULT WINAPI xmlnode_get_definition(
785 IXMLDOMNode** definitionNode)
787 xmlnode *This = impl_from_IXMLDOMNode( iface );
788 FIXME("(%p)->(%p)\n", This, definitionNode);
792 static inline BYTE hex_to_byte(xmlChar c)
794 if(c <= '9') return c-'0';
795 if(c <= 'F') return c-'A'+10;
799 static inline BYTE base64_to_byte(xmlChar c)
801 if(c == '+') return 62;
802 if(c == '/') return 63;
803 if(c <= '9') return c-'0'+52;
804 if(c <= 'Z') return c-'A';
808 static inline HRESULT VARIANT_from_xmlChar(xmlChar *str, VARIANT *v, BSTR type)
810 if(!type || !lstrcmpiW(type, szString) ||
811 !lstrcmpiW(type, szNumber) || !lstrcmpiW(type, szUUID))
814 V_BSTR(v) = bstr_from_xmlChar(str);
817 return E_OUTOFMEMORY;
819 else if(!lstrcmpiW(type, szDateTime) || !lstrcmpiW(type, szDateTimeTZ) ||
820 !lstrcmpiW(type, szDate) || !lstrcmpiW(type, szTime) ||
821 !lstrcmpiW(type, szTimeTZ))
831 st.wDayOfWeek = st.wHour = st.wMinute = st.wSecond = st.wMilliseconds = 0;
833 V_VT(&src) = VT_BSTR;
834 V_BSTR(&src) = bstr_from_xmlChar(str);
837 return E_OUTOFMEMORY;
840 e = p + SysStringLen(V_BSTR(&src));
842 if(p+4<e && *(p+4)=='-') /* parse date (yyyy-mm-dd) */
845 st.wMonth = atoiW(p+5);
846 st.wDay = atoiW(p+8);
852 if(p+2<e && *(p+2)==':') /* parse time (hh:mm:ss.?) */
855 st.wMinute = atoiW(p+3);
856 st.wSecond = atoiW(p+6);
862 while(isdigitW(*p)) p++;
866 SystemTimeToVariantTime(&st, &date);
870 if(*p == '+') /* parse timezone offset (+hh:mm) */
871 V_DATE(v) += (DOUBLE)atoiW(p+1)/24 + (DOUBLE)atoiW(p+4)/1440;
872 else if(*p == '-') /* parse timezone offset (-hh:mm) */
873 V_DATE(v) -= (DOUBLE)atoiW(p+1)/24 + (DOUBLE)atoiW(p+4)/1440;
877 else if(!lstrcmpiW(type, szBinHex))
882 len = xmlStrlen(str)/2;
886 V_VT(v) = (VT_ARRAY|VT_UI1);
887 V_ARRAY(v) = SafeArrayCreate(VT_UI1, 1, &sab);
890 return E_OUTOFMEMORY;
893 ((BYTE*)V_ARRAY(v)->pvData)[i] = (hex_to_byte(str[2*i])<<4)
894 + hex_to_byte(str[2*i+1]);
896 else if(!lstrcmpiW(type, szBinBase64))
901 len = xmlStrlen(str);
902 if(str[len-2] == '=') i = 2;
903 else if(str[len-1] == '=') i = 1;
907 sab.cElements = len/4*3-i;
909 V_VT(v) = (VT_ARRAY|VT_UI1);
910 V_ARRAY(v) = SafeArrayCreate(VT_UI1, 1, &sab);
913 return E_OUTOFMEMORY;
915 for(i=0; i<len/4; i++)
917 ((BYTE*)V_ARRAY(v)->pvData)[3*i] = (base64_to_byte(str[4*i])<<2)
918 + (base64_to_byte(str[4*i+1])>>4);
919 if(3*i+1 < sab.cElements)
920 ((BYTE*)V_ARRAY(v)->pvData)[3*i+1] = (base64_to_byte(str[4*i+1])<<4)
921 + (base64_to_byte(str[4*i+2])>>2);
922 if(3*i+2 < sab.cElements)
923 ((BYTE*)V_ARRAY(v)->pvData)[3*i+2] = (base64_to_byte(str[4*i+2])<<6)
924 + base64_to_byte(str[4*i+3]);
932 if(!lstrcmpiW(type, szInt) || !lstrcmpiW(type, szI4))
934 else if(!lstrcmpiW(type, szFixed))
936 else if(!lstrcmpiW(type, szBoolean))
938 else if(!lstrcmpiW(type, szI1))
940 else if(!lstrcmpiW(type, szI2))
942 else if(!lstrcmpiW(type, szIU1))
944 else if(!lstrcmpiW(type, szIU2))
946 else if(!lstrcmpiW(type, szIU4))
948 else if(!lstrcmpiW(type, szR4))
950 else if(!lstrcmpiW(type, szR8) || !lstrcmpiW(type, szFloat))
954 FIXME("Type handling not yet implemented\n");
958 V_VT(&src) = VT_BSTR;
959 V_BSTR(&src) = bstr_from_xmlChar(str);
962 return E_OUTOFMEMORY;
964 hres = VariantChangeTypeEx(v, &src, MAKELCID(MAKELANGID(
965 LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT),0, V_VT(v));
973 static HRESULT WINAPI xmlnode_get_nodeTypedValue(
977 xmlnode *This = impl_from_IXMLDOMNode( iface );
980 HRESULT hres = S_FALSE;
982 TRACE("(%p)->(%p)\n", This, typedValue);
987 V_VT(typedValue) = VT_NULL;
989 if(This->node->type == XML_ELEMENT_NODE ||
990 This->node->type == XML_TEXT_NODE ||
991 This->node->type == XML_ENTITY_REF_NODE)
992 hres = IXMLDOMNode_get_dataType(This->iface, &type);
994 if(hres != S_OK && This->node->type != XML_ELEMENT_NODE)
995 return IXMLDOMNode_get_nodeValue(This->iface, typedValue);
997 content = xmlNodeGetContent(This->node);
998 hres = VARIANT_from_xmlChar(content, typedValue,
999 hres==S_OK ? V_BSTR(&type) : NULL);
1001 VariantClear(&type);
1006 static HRESULT WINAPI xmlnode_put_nodeTypedValue(
1010 xmlnode *This = impl_from_IXMLDOMNode( iface );
1011 FIXME("%p\n", This);
1015 static HRESULT WINAPI xmlnode_get_dataType(
1017 VARIANT* dataTypeName)
1019 xmlnode *This = impl_from_IXMLDOMNode( iface );
1022 TRACE("(%p)->(%p)\n", This, dataTypeName);
1025 return E_INVALIDARG;
1027 /* Attribute, CDATA Section, Comment, Document, Document Fragment,
1028 Entity, Notation, PI, and Text Node are non-typed. */
1029 V_BSTR(dataTypeName) = NULL;
1030 V_VT(dataTypeName) = VT_NULL;
1032 switch ( This->node->type )
1034 case XML_ELEMENT_NODE:
1035 pVal = xmlGetNsProp(This->node, (const xmlChar*)"dt",
1036 (const xmlChar*)"urn:schemas-microsoft-com:datatypes");
1039 V_VT(dataTypeName) = VT_BSTR;
1040 V_BSTR(dataTypeName) = bstr_from_xmlChar( pVal );
1044 case XML_ENTITY_REF_NODE:
1045 FIXME("XML_ENTITY_REF_NODE should return a valid value.\n");
1048 TRACE("Type %d returning NULL\n", This->node->type);
1051 /* non-typed nodes return S_FALSE */
1052 if(V_VT(dataTypeName) == VT_NULL)
1060 static HRESULT WINAPI xmlnode_put_dataType(
1064 xmlnode *This = impl_from_IXMLDOMNode( iface );
1065 HRESULT hr = E_FAIL;
1067 TRACE("(%p)->(%s)\n", This, debugstr_w(dataTypeName));
1069 if(dataTypeName == NULL)
1070 return E_INVALIDARG;
1072 /* An example of this is. The Text in the node needs to be a 0 or 1 for a boolean type.
1073 This applies to changing types (string->bool) or setting a new one
1075 FIXME("Need to Validate the data before allowing a type to be set.\n");
1077 /* Check all supported types. */
1078 if(lstrcmpiW(dataTypeName,szString) == 0 ||
1079 lstrcmpiW(dataTypeName,szNumber) == 0 ||
1080 lstrcmpiW(dataTypeName,szUUID) == 0 ||
1081 lstrcmpiW(dataTypeName,szInt) == 0 ||
1082 lstrcmpiW(dataTypeName,szI4) == 0 ||
1083 lstrcmpiW(dataTypeName,szFixed) == 0 ||
1084 lstrcmpiW(dataTypeName,szBoolean) == 0 ||
1085 lstrcmpiW(dataTypeName,szDateTime) == 0 ||
1086 lstrcmpiW(dataTypeName,szDateTimeTZ) == 0 ||
1087 lstrcmpiW(dataTypeName,szDate) == 0 ||
1088 lstrcmpiW(dataTypeName,szTime) == 0 ||
1089 lstrcmpiW(dataTypeName,szTimeTZ) == 0 ||
1090 lstrcmpiW(dataTypeName,szI1) == 0 ||
1091 lstrcmpiW(dataTypeName,szI2) == 0 ||
1092 lstrcmpiW(dataTypeName,szIU1) == 0 ||
1093 lstrcmpiW(dataTypeName,szIU2) == 0 ||
1094 lstrcmpiW(dataTypeName,szIU4) == 0 ||
1095 lstrcmpiW(dataTypeName,szR4) == 0 ||
1096 lstrcmpiW(dataTypeName,szR8) == 0 ||
1097 lstrcmpiW(dataTypeName,szFloat) == 0 ||
1098 lstrcmpiW(dataTypeName,szBinHex) == 0 ||
1099 lstrcmpiW(dataTypeName,szBinBase64) == 0)
1101 xmlChar* str = xmlChar_from_wchar(dataTypeName);
1104 if (!str) return E_OUTOFMEMORY;
1106 attr = xmlHasNsProp(This->node, (const xmlChar*)"dt",
1107 (const xmlChar*)"urn:schemas-microsoft-com:datatypes");
1110 attr = xmlSetNsProp(This->node, attr->ns, (const xmlChar*)"dt", str);
1115 xmlNsPtr ns = xmlNewNs(This->node, (const xmlChar*)"urn:schemas-microsoft-com:datatypes", (const xmlChar*)"dt");
1118 attr = xmlNewNsProp(This->node, ns, (const xmlChar*)"dt", str);
1121 xmlAddChild(This->node, (xmlNodePtr)attr);
1125 ERR("Failed to create Attribute\n");
1128 ERR("Failed to create Namespace\n");
1136 static BSTR EnsureCorrectEOL(BSTR sInput)
1143 nLen = lstrlenW(sInput);
1144 /* Count line endings */
1145 for(i=0; i < nLen; i++)
1147 if(sInput[i] == '\n')
1151 TRACE("len=%d, num=%d\n", nLen, nNum);
1153 /* Add linefeed as needed */
1157 sNew = SysAllocStringLen(NULL, nLen + nNum+1);
1158 for(i=0; i < nLen; i++)
1160 if(sInput[i] == '\n')
1162 sNew[i+nPlace] = '\r';
1165 sNew[i+nPlace] = sInput[i];
1168 SysFreeString(sInput);
1175 TRACE("len %d\n", lstrlenW(sNew));
1180 /* Removes encoding information and last character (nullbyte) */
1181 static BSTR EnsureNoEncoding(BSTR sInput)
1183 static const WCHAR wszEncoding[] = {'e','n','c','o','d','i','n','g','='};
1188 while(*pBeg != '\n' && memcmp(pBeg, wszEncoding, sizeof(wszEncoding)))
1193 SysReAllocStringLen(&sInput, sInput, SysStringLen(sInput)-1);
1198 pEnd = pBeg + sizeof(wszEncoding)/sizeof(WCHAR) + 2;
1199 while(*pEnd != '\"') pEnd++;
1202 sNew = SysAllocStringLen(NULL,
1203 pBeg-sInput + SysStringLen(sInput)-(pEnd-sInput)-1);
1204 memcpy(sNew, sInput, (pBeg-sInput)*sizeof(WCHAR));
1205 memcpy(&sNew[pBeg-sInput], pEnd, (SysStringLen(sInput)-(pEnd-sInput)-1)*sizeof(WCHAR));
1207 SysFreeString(sInput);
1212 * We are trying to replicate the same behaviour as msxml by converting
1213 * line endings to \r\n and using indents as \t. The problem is that msxml
1214 * only formats nodes that have a line ending. Using libxml we cannot
1215 * reproduce behaviour exactly.
1218 static HRESULT WINAPI xmlnode_get_xml(
1222 xmlnode *This = impl_from_IXMLDOMNode( iface );
1223 xmlBufferPtr pXmlBuf;
1227 TRACE("(%p %d)->(%p)\n", This, This->node->type, xmlString);
1230 return E_INVALIDARG;
1234 xmldecl = xmldoc_unlink_xmldecl( This->node->doc );
1236 pXmlBuf = xmlBufferCreate();
1239 nSize = xmlNodeDump(pXmlBuf, This->node->doc, This->node, 0, 1);
1242 const xmlChar *pContent;
1245 /* Attribute Nodes return a space in front of their name */
1246 pContent = xmlBufferContent(pXmlBuf);
1247 if( ((const char*)pContent)[0] == ' ')
1248 bstrContent = bstr_from_xmlChar(pContent+1);
1250 bstrContent = bstr_from_xmlChar(pContent);
1252 switch(This->node->type)
1254 case XML_ELEMENT_NODE:
1255 *xmlString = EnsureCorrectEOL(bstrContent);
1257 case XML_DOCUMENT_NODE:
1258 *xmlString = EnsureCorrectEOL(bstrContent);
1259 *xmlString = EnsureNoEncoding(*xmlString);
1262 *xmlString = bstrContent;
1266 xmlBufferFree(pXmlBuf);
1269 xmldoc_link_xmldecl( This->node->doc, xmldecl );
1271 /* Always returns a string. */
1272 if(*xmlString == NULL) *xmlString = SysAllocStringLen( NULL, 0 );
1277 static HRESULT WINAPI xmlnode_transformNode(
1279 IXMLDOMNode* styleSheet,
1282 #ifdef SONAME_LIBXSLT
1283 xmlnode *This = impl_from_IXMLDOMNode( iface );
1284 xmlnode *pStyleSheet = NULL;
1285 xsltStylesheetPtr xsltSS = NULL;
1286 xmlDocPtr result = NULL;
1288 TRACE("(%p)->(%p %p)\n", This, styleSheet, xmlString);
1290 if (!libxslt_handle)
1292 if(!styleSheet || !xmlString)
1293 return E_INVALIDARG;
1297 pStyleSheet = get_node_obj(styleSheet);
1299 FIXME("styleSheet is not our xmlnode implementation\n");
1303 xsltSS = pxsltParseStylesheetDoc( pStyleSheet->node->doc);
1306 result = pxsltApplyStylesheet(xsltSS, This->node->doc, NULL);
1309 const xmlChar *pContent;
1311 if(result->type == XML_HTML_DOCUMENT_NODE)
1313 xmlOutputBufferPtr pOutput = xmlAllocOutputBuffer(NULL);
1316 htmlDocContentDumpOutput(pOutput, result->doc, NULL);
1317 pContent = xmlBufferContent(pOutput->buffer);
1318 *xmlString = bstr_from_xmlChar(pContent);
1319 xmlOutputBufferClose(pOutput);
1324 xmlBufferPtr pXmlBuf;
1327 pXmlBuf = xmlBufferCreate();
1330 nSize = xmlNodeDump(pXmlBuf, NULL, (xmlNodePtr)result, 0, 0);
1333 pContent = xmlBufferContent(pXmlBuf);
1334 *xmlString = bstr_from_xmlChar(pContent);
1336 xmlBufferFree(pXmlBuf);
1341 /* libxslt "helpfully" frees the XML document the stylesheet was
1342 generated from, too */
1344 pxsltFreeStylesheet(xsltSS);
1347 if(*xmlString == NULL)
1348 *xmlString = SysAllocStringLen(NULL, 0);
1352 FIXME("libxslt headers were not found at compile time\n");
1357 static HRESULT WINAPI xmlnode_selectNodes(
1360 IXMLDOMNodeList** resultList)
1362 xmlnode *This = impl_from_IXMLDOMNode( iface );
1364 TRACE("(%p)->(%s %p)\n", This, debugstr_w(queryString), resultList );
1366 return queryresult_create( This->node, queryString, resultList );
1369 static HRESULT WINAPI xmlnode_selectSingleNode(
1372 IXMLDOMNode** resultNode)
1374 xmlnode *This = impl_from_IXMLDOMNode( iface );
1375 IXMLDOMNodeList *list;
1378 TRACE("(%p)->(%s %p)\n", This, debugstr_w(queryString), resultNode );
1381 r = IXMLDOMNode_selectNodes(This->iface, queryString, &list);
1384 r = IXMLDOMNodeList_nextNode(list, resultNode);
1385 IXMLDOMNodeList_Release(list);
1390 static HRESULT WINAPI xmlnode_get_parsed(
1392 VARIANT_BOOL* isParsed)
1394 xmlnode *This = impl_from_IXMLDOMNode( iface );
1395 FIXME("(%p)->(%p) stub!\n", This, isParsed);
1396 *isParsed = VARIANT_TRUE;
1400 static HRESULT WINAPI xmlnode_get_namespaceURI(
1404 xmlnode *This = impl_from_IXMLDOMNode( iface );
1405 HRESULT hr = S_FALSE;
1408 TRACE("(%p)->(%p)\n", This, namespaceURI );
1411 return E_INVALIDARG;
1413 *namespaceURI = NULL;
1415 pNSList = xmlGetNsList(This->node->doc, This->node);
1418 *namespaceURI = bstr_from_xmlChar( pNSList[0]->href );
1427 static HRESULT WINAPI xmlnode_get_prefix(
1431 xmlnode *This = impl_from_IXMLDOMNode( iface );
1432 HRESULT hr = S_FALSE;
1435 TRACE("(%p)->(%p)\n", This, prefixString );
1438 return E_INVALIDARG;
1440 *prefixString = NULL;
1442 pNSList = xmlGetNsList(This->node->doc, This->node);
1445 *prefixString = bstr_from_xmlChar( pNSList[0]->prefix );
1454 static HRESULT WINAPI xmlnode_get_baseName(
1458 xmlnode *This = impl_from_IXMLDOMNode( iface );
1460 HRESULT r = S_FALSE;
1462 TRACE("(%p)->(%p)\n", This, nameString );
1465 return E_INVALIDARG;
1467 switch ( This->node->type )
1469 case XML_ELEMENT_NODE:
1470 case XML_ATTRIBUTE_NODE:
1472 str = bstr_from_xmlChar( This->node->name );
1476 case XML_COMMENT_NODE:
1477 case XML_DOCUMENT_NODE:
1480 ERR("Unhandled type %d\n", This->node->type );
1484 TRACE("returning %08x str = %s\n", r, debugstr_w( str ) );
1490 static HRESULT WINAPI xmlnode_transformNodeToObject(
1492 IXMLDOMNode* stylesheet,
1493 VARIANT outputObject)
1495 xmlnode *This = impl_from_IXMLDOMNode( iface );
1496 FIXME("(%p)->(%p)\n", This, stylesheet);
1500 static const struct IXMLDOMNodeVtbl xmlnode_vtbl =
1502 xmlnode_QueryInterface,
1505 xmlnode_GetTypeInfoCount,
1506 xmlnode_GetTypeInfo,
1507 xmlnode_GetIDsOfNames,
1509 xmlnode_get_nodeName,
1510 xmlnode_get_nodeValue,
1511 xmlnode_put_nodeValue,
1512 xmlnode_get_nodeType,
1513 xmlnode_get_parentNode,
1514 xmlnode_get_childNodes,
1515 xmlnode_get_firstChild,
1516 xmlnode_get_lastChild,
1517 xmlnode_get_previousSibling,
1518 xmlnode_get_nextSibling,
1519 xmlnode_get_attributes,
1520 xmlnode_insertBefore,
1521 xmlnode_replaceChild,
1522 xmlnode_removeChild,
1523 xmlnode_appendChild,
1524 xmlnode_hasChildNodes,
1525 xmlnode_get_ownerDocument,
1527 xmlnode_get_nodeTypeString,
1530 xmlnode_get_specified,
1531 xmlnode_get_definition,
1532 xmlnode_get_nodeTypedValue,
1533 xmlnode_put_nodeTypedValue,
1534 xmlnode_get_dataType,
1535 xmlnode_put_dataType,
1537 xmlnode_transformNode,
1538 xmlnode_selectNodes,
1539 xmlnode_selectSingleNode,
1541 xmlnode_get_namespaceURI,
1543 xmlnode_get_baseName,
1544 xmlnode_transformNodeToObject,
1547 void destroy_xmlnode(xmlnode *This)
1550 xmldoc_release(This->node->doc);
1553 void init_xmlnode(xmlnode *This, xmlNodePtr node, IXMLDOMNode *node_iface, dispex_static_data_t *dispex_data)
1556 xmldoc_add_ref( node->doc );
1558 This->lpVtbl = &xmlnode_vtbl;
1560 This->iface = node_iface;
1563 init_dispex(&This->dispex, (IUnknown*)This->iface, dispex_data);
1565 This->dispex.outer = NULL;
1570 const IXMLDOMNodeVtbl *lpVtbl;
1574 static inline unknode *impl_from_unkIXMLDOMNode(IXMLDOMNode *iface)
1576 return (unknode *)((char*)iface - FIELD_OFFSET(unknode, lpVtbl));
1579 static HRESULT WINAPI unknode_QueryInterface(
1584 unknode *This = impl_from_unkIXMLDOMNode( iface );
1586 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject);
1588 if (IsEqualGUID(riid, &IID_IUnknown)) {
1590 }else if (IsEqualGUID( riid, &IID_IDispatch) ||
1591 IsEqualGUID( riid, &IID_IXMLDOMNode)) {
1592 *ppvObject = &This->lpVtbl;
1593 }else if(node_query_interface(&This->node, riid, ppvObject)) {
1594 return *ppvObject ? S_OK : E_NOINTERFACE;
1596 FIXME("interface %s not implemented\n", debugstr_guid(riid));
1598 return E_NOINTERFACE;
1601 IUnknown_AddRef((IUnknown*)*ppvObject);
1605 static ULONG WINAPI unknode_AddRef(
1606 IXMLDOMNode *iface )
1608 unknode *This = impl_from_unkIXMLDOMNode( iface );
1610 return InterlockedIncrement(&This->ref);
1613 static ULONG WINAPI unknode_Release(
1614 IXMLDOMNode *iface )
1616 unknode *This = impl_from_unkIXMLDOMNode( iface );
1619 ref = InterlockedDecrement( &This->ref );
1621 destroy_xmlnode(&This->node);
1628 static HRESULT WINAPI unknode_GetTypeInfoCount(
1632 unknode *This = impl_from_unkIXMLDOMNode( iface );
1634 TRACE("(%p)->(%p)\n", This, pctinfo);
1641 static HRESULT WINAPI unknode_GetTypeInfo(
1645 ITypeInfo** ppTInfo )
1647 unknode *This = impl_from_unkIXMLDOMNode( iface );
1650 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
1652 hr = get_typeinfo(IXMLDOMNode_tid, ppTInfo);
1657 static HRESULT WINAPI unknode_GetIDsOfNames(
1660 LPOLESTR* rgszNames,
1665 unknode *This = impl_from_unkIXMLDOMNode( iface );
1667 ITypeInfo *typeinfo;
1670 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
1673 if(!rgszNames || cNames == 0 || !rgDispId)
1674 return E_INVALIDARG;
1676 hr = get_typeinfo(IXMLDOMNode_tid, &typeinfo);
1679 hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
1680 ITypeInfo_Release(typeinfo);
1686 static HRESULT WINAPI unknode_Invoke(
1688 DISPID dispIdMember,
1692 DISPPARAMS* pDispParams,
1693 VARIANT* pVarResult,
1694 EXCEPINFO* pExcepInfo,
1697 unknode *This = impl_from_unkIXMLDOMNode( iface );
1698 ITypeInfo *typeinfo;
1701 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
1702 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1704 hr = get_typeinfo(IXMLDOMNode_tid, &typeinfo);
1707 hr = ITypeInfo_Invoke(typeinfo, &(This->lpVtbl), dispIdMember, wFlags, pDispParams,
1708 pVarResult, pExcepInfo, puArgErr);
1709 ITypeInfo_Release(typeinfo);
1715 static HRESULT WINAPI unknode_get_nodeName(
1719 unknode *This = impl_from_unkIXMLDOMNode( iface );
1721 FIXME("(%p)->(%p)\n", This, p);
1723 return node_get_nodeName(&This->node, p);
1726 static HRESULT WINAPI unknode_get_nodeValue(
1730 unknode *This = impl_from_unkIXMLDOMNode( iface );
1732 FIXME("(%p)->(%p)\n", This, value);
1735 return E_INVALIDARG;
1737 V_VT(value) = VT_NULL;
1741 static HRESULT WINAPI unknode_put_nodeValue(
1745 unknode *This = impl_from_unkIXMLDOMNode( iface );
1746 FIXME("(%p)->(v%d)\n", This, V_VT(&value));
1750 static HRESULT WINAPI unknode_get_nodeType(
1752 DOMNodeType* domNodeType )
1754 unknode *This = impl_from_unkIXMLDOMNode( iface );
1756 FIXME("(%p)->(%p)\n", This, domNodeType);
1758 *domNodeType = This->node.node->type;
1762 static HRESULT WINAPI unknode_get_parentNode(
1764 IXMLDOMNode** parent )
1766 unknode *This = impl_from_unkIXMLDOMNode( iface );
1767 FIXME("(%p)->(%p)\n", This, parent);
1768 if (!parent) return E_INVALIDARG;
1773 static HRESULT WINAPI unknode_get_childNodes(
1775 IXMLDOMNodeList** outList)
1777 unknode *This = impl_from_unkIXMLDOMNode( iface );
1779 TRACE("(%p)->(%p)\n", This, outList);
1781 return node_get_child_nodes(&This->node, outList);
1784 static HRESULT WINAPI unknode_get_firstChild(
1786 IXMLDOMNode** domNode)
1788 unknode *This = impl_from_unkIXMLDOMNode( iface );
1790 TRACE("(%p)->(%p)\n", This, domNode);
1792 return node_get_first_child(&This->node, domNode);
1795 static HRESULT WINAPI unknode_get_lastChild(
1797 IXMLDOMNode** domNode)
1799 unknode *This = impl_from_unkIXMLDOMNode( iface );
1801 TRACE("(%p)->(%p)\n", This, domNode);
1803 return node_get_last_child(&This->node, domNode);
1806 static HRESULT WINAPI unknode_get_previousSibling(
1808 IXMLDOMNode** domNode)
1810 unknode *This = impl_from_unkIXMLDOMNode( iface );
1812 TRACE("(%p)->(%p)\n", This, domNode);
1814 return node_get_previous_sibling(&This->node, domNode);
1817 static HRESULT WINAPI unknode_get_nextSibling(
1819 IXMLDOMNode** domNode)
1821 unknode *This = impl_from_unkIXMLDOMNode( iface );
1823 TRACE("(%p)->(%p)\n", This, domNode);
1825 return node_get_next_sibling(&This->node, domNode);
1828 static HRESULT WINAPI unknode_get_attributes(
1830 IXMLDOMNamedNodeMap** attributeMap)
1832 unknode *This = impl_from_unkIXMLDOMNode( iface );
1834 FIXME("(%p)->(%p)\n", This, attributeMap);
1836 return return_null_ptr((void**)attributeMap);
1839 static HRESULT WINAPI unknode_insertBefore(
1841 IXMLDOMNode* newNode, VARIANT refChild,
1842 IXMLDOMNode** outOldNode)
1844 unknode *This = impl_from_unkIXMLDOMNode( iface );
1846 FIXME("(%p)->(%p x%d %p)\n", This, newNode, V_VT(&refChild), outOldNode);
1848 return node_insert_before(&This->node, newNode, &refChild, outOldNode);
1851 static HRESULT WINAPI unknode_replaceChild(
1853 IXMLDOMNode* newNode,
1854 IXMLDOMNode* oldNode,
1855 IXMLDOMNode** outOldNode)
1857 unknode *This = impl_from_unkIXMLDOMNode( iface );
1858 return IXMLDOMNode_replaceChild( IXMLDOMNode_from_impl(&This->node), newNode, oldNode, outOldNode );
1861 static HRESULT WINAPI unknode_removeChild(
1863 IXMLDOMNode* domNode, IXMLDOMNode** oldNode)
1865 unknode *This = impl_from_unkIXMLDOMNode( iface );
1866 return IXMLDOMNode_removeChild( IXMLDOMNode_from_impl(&This->node), domNode, oldNode );
1869 static HRESULT WINAPI unknode_appendChild(
1871 IXMLDOMNode* newNode, IXMLDOMNode** outNewNode)
1873 unknode *This = impl_from_unkIXMLDOMNode( iface );
1874 return IXMLDOMNode_appendChild( IXMLDOMNode_from_impl(&This->node), newNode, outNewNode );
1877 static HRESULT WINAPI unknode_hasChildNodes(
1879 VARIANT_BOOL* pbool)
1881 unknode *This = impl_from_unkIXMLDOMNode( iface );
1882 return IXMLDOMNode_hasChildNodes( IXMLDOMNode_from_impl(&This->node), pbool );
1885 static HRESULT WINAPI unknode_get_ownerDocument(
1887 IXMLDOMDocument** domDocument)
1889 unknode *This = impl_from_unkIXMLDOMNode( iface );
1890 return IXMLDOMNode_get_ownerDocument( IXMLDOMNode_from_impl(&This->node), domDocument );
1893 static HRESULT WINAPI unknode_cloneNode(
1895 VARIANT_BOOL pbool, IXMLDOMNode** outNode)
1897 unknode *This = impl_from_unkIXMLDOMNode( iface );
1898 return IXMLDOMNode_cloneNode( IXMLDOMNode_from_impl(&This->node), pbool, outNode );
1901 static HRESULT WINAPI unknode_get_nodeTypeString(
1905 unknode *This = impl_from_unkIXMLDOMNode( iface );
1906 return IXMLDOMNode_get_nodeTypeString( IXMLDOMNode_from_impl(&This->node), p );
1909 static HRESULT WINAPI unknode_get_text(
1913 unknode *This = impl_from_unkIXMLDOMNode( iface );
1914 return IXMLDOMNode_get_text( IXMLDOMNode_from_impl(&This->node), p );
1917 static HRESULT WINAPI unknode_put_text(
1921 unknode *This = impl_from_unkIXMLDOMNode( iface );
1922 return IXMLDOMNode_put_text( IXMLDOMNode_from_impl(&This->node), p );
1925 static HRESULT WINAPI unknode_get_specified(
1927 VARIANT_BOOL* pbool)
1929 unknode *This = impl_from_unkIXMLDOMNode( iface );
1930 return IXMLDOMNode_get_specified( IXMLDOMNode_from_impl(&This->node), pbool );
1933 static HRESULT WINAPI unknode_get_definition(
1935 IXMLDOMNode** domNode)
1937 unknode *This = impl_from_unkIXMLDOMNode( iface );
1938 return IXMLDOMNode_get_definition( IXMLDOMNode_from_impl(&This->node), domNode );
1941 static HRESULT WINAPI unknode_get_nodeTypedValue(
1945 unknode *This = impl_from_unkIXMLDOMNode( iface );
1946 return IXMLDOMNode_get_nodeTypedValue( IXMLDOMNode_from_impl(&This->node), var1 );
1949 static HRESULT WINAPI unknode_put_nodeTypedValue(
1953 unknode *This = impl_from_unkIXMLDOMNode( iface );
1954 return IXMLDOMNode_put_nodeTypedValue( IXMLDOMNode_from_impl(&This->node), var1 );
1957 static HRESULT WINAPI unknode_get_dataType(
1961 unknode *This = impl_from_unkIXMLDOMNode( iface );
1962 return IXMLDOMNode_get_dataType( IXMLDOMNode_from_impl(&This->node), var1 );
1965 static HRESULT WINAPI unknode_put_dataType(
1969 unknode *This = impl_from_unkIXMLDOMNode( iface );
1970 return IXMLDOMNode_put_dataType( IXMLDOMNode_from_impl(&This->node), p );
1973 static HRESULT WINAPI unknode_get_xml(
1977 unknode *This = impl_from_unkIXMLDOMNode( iface );
1978 return IXMLDOMNode_get_xml( IXMLDOMNode_from_impl(&This->node), p );
1981 static HRESULT WINAPI unknode_transformNode(
1983 IXMLDOMNode* domNode, BSTR* p)
1985 unknode *This = impl_from_unkIXMLDOMNode( iface );
1986 return IXMLDOMNode_transformNode( IXMLDOMNode_from_impl(&This->node), domNode, p );
1989 static HRESULT WINAPI unknode_selectNodes(
1991 BSTR p, IXMLDOMNodeList** outList)
1993 unknode *This = impl_from_unkIXMLDOMNode( iface );
1994 return IXMLDOMNode_selectNodes( IXMLDOMNode_from_impl(&This->node), p, outList );
1997 static HRESULT WINAPI unknode_selectSingleNode(
1999 BSTR p, IXMLDOMNode** outNode)
2001 unknode *This = impl_from_unkIXMLDOMNode( iface );
2002 return IXMLDOMNode_selectSingleNode( IXMLDOMNode_from_impl(&This->node), p, outNode );
2005 static HRESULT WINAPI unknode_get_parsed(
2007 VARIANT_BOOL* pbool)
2009 unknode *This = impl_from_unkIXMLDOMNode( iface );
2010 return IXMLDOMNode_get_parsed( IXMLDOMNode_from_impl(&This->node), pbool );
2013 static HRESULT WINAPI unknode_get_namespaceURI(
2017 unknode *This = impl_from_unkIXMLDOMNode( iface );
2018 return IXMLDOMNode_get_namespaceURI( IXMLDOMNode_from_impl(&This->node), p );
2021 static HRESULT WINAPI unknode_get_prefix(
2025 unknode *This = impl_from_unkIXMLDOMNode( iface );
2026 return IXMLDOMNode_get_prefix( IXMLDOMNode_from_impl(&This->node), p );
2029 static HRESULT WINAPI unknode_get_baseName(
2033 unknode *This = impl_from_unkIXMLDOMNode( iface );
2034 return IXMLDOMNode_get_baseName( IXMLDOMNode_from_impl(&This->node), p );
2037 static HRESULT WINAPI unknode_transformNodeToObject(
2039 IXMLDOMNode* domNode, VARIANT var1)
2041 unknode *This = impl_from_unkIXMLDOMNode( iface );
2042 return IXMLDOMNode_transformNodeToObject( IXMLDOMNode_from_impl(&This->node), domNode, var1 );
2045 static const struct IXMLDOMNodeVtbl unknode_vtbl =
2047 unknode_QueryInterface,
2050 unknode_GetTypeInfoCount,
2051 unknode_GetTypeInfo,
2052 unknode_GetIDsOfNames,
2054 unknode_get_nodeName,
2055 unknode_get_nodeValue,
2056 unknode_put_nodeValue,
2057 unknode_get_nodeType,
2058 unknode_get_parentNode,
2059 unknode_get_childNodes,
2060 unknode_get_firstChild,
2061 unknode_get_lastChild,
2062 unknode_get_previousSibling,
2063 unknode_get_nextSibling,
2064 unknode_get_attributes,
2065 unknode_insertBefore,
2066 unknode_replaceChild,
2067 unknode_removeChild,
2068 unknode_appendChild,
2069 unknode_hasChildNodes,
2070 unknode_get_ownerDocument,
2072 unknode_get_nodeTypeString,
2075 unknode_get_specified,
2076 unknode_get_definition,
2077 unknode_get_nodeTypedValue,
2078 unknode_put_nodeTypedValue,
2079 unknode_get_dataType,
2080 unknode_put_dataType,
2082 unknode_transformNode,
2083 unknode_selectNodes,
2084 unknode_selectSingleNode,
2086 unknode_get_namespaceURI,
2088 unknode_get_baseName,
2089 unknode_transformNodeToObject
2092 IXMLDOMNode *create_node( xmlNodePtr node )
2101 TRACE("type %d\n", node->type);
2104 case XML_ELEMENT_NODE:
2105 pUnk = create_element( node );
2107 case XML_ATTRIBUTE_NODE:
2108 pUnk = create_attribute( node );
2111 pUnk = create_text( node );
2113 case XML_CDATA_SECTION_NODE:
2114 pUnk = create_cdata( node );
2116 case XML_ENTITY_REF_NODE:
2117 pUnk = create_doc_entity_ref( node );
2120 pUnk = create_pi( node );
2122 case XML_COMMENT_NODE:
2123 pUnk = create_comment( node );
2125 case XML_DOCUMENT_NODE:
2126 pUnk = create_domdoc( node );
2128 case XML_DOCUMENT_FRAG_NODE:
2129 pUnk = create_doc_fragment( node );
2134 FIXME("only creating basic node for type %d\n", node->type);
2136 new_node = heap_alloc(sizeof(unknode));
2140 new_node->lpVtbl = &unknode_vtbl;
2142 init_xmlnode(&new_node->node, node, (IXMLDOMNode*)&new_node->lpVtbl, NULL);
2143 pUnk = (IUnknown*)&new_node->lpVtbl;
2147 hr = IUnknown_QueryInterface(pUnk, &IID_IXMLDOMNode, (LPVOID*)&ret);
2148 IUnknown_Release(pUnk);
2149 if(FAILED(hr)) return NULL;