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
28 # include <libxml/parser.h>
29 # include <libxml/xmlerror.h>
30 # include <libxml/HTMLtree.h>
31 # ifdef SONAME_LIBXSLT
32 # ifdef HAVE_LIBXSLT_PATTERN_H
33 # include <libxslt/pattern.h>
35 # ifdef HAVE_LIBXSLT_TRANSFORM_H
36 # include <libxslt/transform.h>
38 # include <libxslt/imports.h>
39 # include <libxslt/variables.h>
40 # include <libxslt/xsltutils.h>
41 # include <libxslt/xsltInternals.h>
52 #include "msxml_private.h"
54 #include "wine/debug.h"
58 WINE_DEFAULT_DEBUG_CHANNEL(msxml
);
61 extern void* libxslt_handle
;
62 # define MAKE_FUNCPTR(f) extern typeof(f) * p##f
63 MAKE_FUNCPTR(xsltApplyStylesheet
);
64 MAKE_FUNCPTR(xsltApplyStylesheetUser
);
65 MAKE_FUNCPTR(xsltCleanupGlobals
);
66 MAKE_FUNCPTR(xsltFreeStylesheet
);
67 MAKE_FUNCPTR(xsltFreeTransformContext
);
68 MAKE_FUNCPTR(xsltNewTransformContext
);
69 MAKE_FUNCPTR(xsltNextImport
);
70 MAKE_FUNCPTR(xsltParseStylesheetDoc
);
71 MAKE_FUNCPTR(xsltQuoteUserParams
);
72 MAKE_FUNCPTR(xsltSaveResultTo
);
75 WINE_DECLARE_DEBUG_CHANNEL(winediag
);
78 static const IID IID_xmlnode
= {0x4f2f4ba2,0xb822,0x11df,{0x8b,0x8a,0x68,0x50,0xdf,0xd7,0x20,0x85}};
80 xmlNodePtr
xmlNodePtr_from_domnode( IXMLDOMNode
*iface
, xmlElementType type
)
86 This
= get_node_obj( iface
);
87 if ( !This
|| !This
->node
)
89 if ( type
&& This
->node
->type
!= type
)
94 BOOL
node_query_interface(xmlnode
*This
, REFIID riid
, void **ppv
)
96 if(IsEqualGUID(&IID_xmlnode
, riid
)) {
97 TRACE("(%p)->(IID_xmlnode %p)\n", This
, ppv
);
102 return dispex_query_interface(&This
->dispex
, riid
, ppv
);
105 /* common ISupportErrorInfo implementation */
107 ISupportErrorInfo ISupportErrorInfo_iface
;
113 static inline SupportErrorInfo
*impl_from_ISupportErrorInfo(ISupportErrorInfo
*iface
)
115 return CONTAINING_RECORD(iface
, SupportErrorInfo
, ISupportErrorInfo_iface
);
118 static HRESULT WINAPI
SupportErrorInfo_QueryInterface(ISupportErrorInfo
*iface
, REFIID riid
, void **obj
)
120 SupportErrorInfo
*This
= impl_from_ISupportErrorInfo(iface
);
121 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), obj
);
125 if (IsEqualGUID(riid
, &IID_IUnknown
) || IsEqualGUID(riid
, &IID_ISupportErrorInfo
)) {
127 ISupportErrorInfo_AddRef(iface
);
131 return E_NOINTERFACE
;
134 static ULONG WINAPI
SupportErrorInfo_AddRef(ISupportErrorInfo
*iface
)
136 SupportErrorInfo
*This
= impl_from_ISupportErrorInfo(iface
);
137 ULONG ref
= InterlockedIncrement(&This
->ref
);
138 TRACE("(%p)->(%d)\n", This
, ref
);
142 static ULONG WINAPI
SupportErrorInfo_Release(ISupportErrorInfo
*iface
)
144 SupportErrorInfo
*This
= impl_from_ISupportErrorInfo(iface
);
145 LONG ref
= InterlockedDecrement(&This
->ref
);
147 TRACE("(%p)->(%d)\n", This
, ref
);
155 static HRESULT WINAPI
SupportErrorInfo_InterfaceSupportsErrorInfo(ISupportErrorInfo
*iface
, REFIID riid
)
157 SupportErrorInfo
*This
= impl_from_ISupportErrorInfo(iface
);
158 enum tid_t
const *tid
;
160 TRACE("(%p)->(%s)\n", This
, debugstr_guid(riid
));
163 while (*tid
!= NULL_tid
)
165 if (IsEqualGUID(riid
, get_riid_from_tid(*tid
)))
173 static const struct ISupportErrorInfoVtbl SupportErrorInfoVtbl
= {
174 SupportErrorInfo_QueryInterface
,
175 SupportErrorInfo_AddRef
,
176 SupportErrorInfo_Release
,
177 SupportErrorInfo_InterfaceSupportsErrorInfo
180 HRESULT
node_create_supporterrorinfo(enum tid_t
const *iids
, void **obj
)
182 SupportErrorInfo
*This
;
184 This
= heap_alloc(sizeof(*This
));
185 if (!This
) return E_OUTOFMEMORY
;
187 This
->ISupportErrorInfo_iface
.lpVtbl
= &SupportErrorInfoVtbl
;
191 *obj
= &This
->ISupportErrorInfo_iface
;
196 xmlnode
*get_node_obj(IXMLDOMNode
*node
)
201 hres
= IXMLDOMNode_QueryInterface(node
, &IID_xmlnode
, (void**)&obj
);
202 if (!obj
) WARN("node is not our IXMLDOMNode implementation\n");
203 return SUCCEEDED(hres
) ? obj
: NULL
;
206 HRESULT
node_get_nodeName(xmlnode
*This
, BSTR
*name
)
214 hr
= node_get_base_name(This
, &base
);
215 if (hr
!= S_OK
) return hr
;
217 hr
= node_get_prefix(This
, &prefix
);
220 static const WCHAR colW
= ':';
224 ptr
= *name
= SysAllocStringLen(NULL
, SysStringLen(base
) + SysStringLen(prefix
) + 1);
225 memcpy(ptr
, prefix
, SysStringByteLen(prefix
));
226 ptr
+= SysStringLen(prefix
);
227 memcpy(ptr
++, &colW
, sizeof(WCHAR
));
228 memcpy(ptr
, base
, SysStringByteLen(base
));
231 SysFreeString(prefix
);
239 HRESULT
node_get_content(xmlnode
*This
, VARIANT
*value
)
246 content
= xmlNodeGetContent(This
->node
);
247 V_VT(value
) = VT_BSTR
;
248 V_BSTR(value
) = bstr_from_xmlChar( content
);
251 TRACE("%p returned %s\n", This
, debugstr_w(V_BSTR(value
)));
255 HRESULT
node_set_content(xmlnode
*This
, LPCWSTR value
)
259 TRACE("(%p)->(%s)\n", This
, debugstr_w(value
));
260 str
= xmlchar_from_wchar(value
);
262 return E_OUTOFMEMORY
;
264 xmlNodeSetContent(This
->node
, str
);
269 static HRESULT
node_set_content_escaped(xmlnode
*This
, LPCWSTR value
)
271 xmlChar
*str
, *escaped
;
273 TRACE("(%p)->(%s)\n", This
, debugstr_w(value
));
274 str
= xmlchar_from_wchar(value
);
276 return E_OUTOFMEMORY
;
278 escaped
= xmlEncodeSpecialChars(NULL
, str
);
282 return E_OUTOFMEMORY
;
285 xmlNodeSetContent(This
->node
, escaped
);
293 HRESULT
node_put_value(xmlnode
*This
, VARIANT
*value
)
297 if (V_VT(value
) != VT_BSTR
)
299 VARIANT string_value
;
301 VariantInit(&string_value
);
302 hr
= VariantChangeType(&string_value
, value
, 0, VT_BSTR
);
304 WARN("Couldn't convert to VT_BSTR\n");
308 hr
= node_set_content(This
, V_BSTR(&string_value
));
309 VariantClear(&string_value
);
312 hr
= node_set_content(This
, V_BSTR(value
));
317 HRESULT
node_put_value_escaped(xmlnode
*This
, VARIANT
*value
)
321 if (V_VT(value
) != VT_BSTR
)
323 VARIANT string_value
;
325 VariantInit(&string_value
);
326 hr
= VariantChangeType(&string_value
, value
, 0, VT_BSTR
);
328 WARN("Couldn't convert to VT_BSTR\n");
332 hr
= node_set_content_escaped(This
, V_BSTR(&string_value
));
333 VariantClear(&string_value
);
336 hr
= node_set_content_escaped(This
, V_BSTR(value
));
341 static HRESULT
get_node(
347 TRACE("(%p)->(%s %p %p)\n", This
, name
, node
, out
);
352 /* if we don't have a doc, use our parent. */
353 if(node
&& !node
->doc
&& node
->parent
)
354 node
->doc
= node
->parent
->doc
;
356 *out
= create_node( node
);
362 HRESULT
node_get_parent(xmlnode
*This
, IXMLDOMNode
**parent
)
364 return get_node( This
, "parent", This
->node
->parent
, parent
);
367 HRESULT
node_get_child_nodes(xmlnode
*This
, IXMLDOMNodeList
**ret
)
372 *ret
= create_children_nodelist(This
->node
);
374 return E_OUTOFMEMORY
;
379 HRESULT
node_get_first_child(xmlnode
*This
, IXMLDOMNode
**ret
)
381 return get_node(This
, "firstChild", This
->node
->children
, ret
);
384 HRESULT
node_get_last_child(xmlnode
*This
, IXMLDOMNode
**ret
)
386 return get_node(This
, "lastChild", This
->node
->last
, ret
);
389 HRESULT
node_get_previous_sibling(xmlnode
*This
, IXMLDOMNode
**ret
)
391 return get_node(This
, "previous", This
->node
->prev
, ret
);
394 HRESULT
node_get_next_sibling(xmlnode
*This
, IXMLDOMNode
**ret
)
396 return get_node(This
, "next", This
->node
->next
, ret
);
399 static int node_get_inst_cnt(xmlNodePtr node
)
401 int ret
= *(LONG
*)&node
->_private
;
404 /* add attribute counts */
405 if (node
->type
== XML_ELEMENT_NODE
)
407 xmlAttrPtr prop
= node
->properties
;
411 ret
+= node_get_inst_cnt((xmlNodePtr
)prop
);
416 /* add children counts */
417 child
= node
->children
;
420 ret
+= node_get_inst_cnt(child
);
427 int xmlnode_get_inst_cnt(xmlnode
*node
)
429 return node_get_inst_cnt(node
->node
);
432 HRESULT
node_insert_before(xmlnode
*This
, IXMLDOMNode
*new_child
, const VARIANT
*ref_child
,
435 IXMLDOMNode
*before
= NULL
;
444 node_obj
= get_node_obj(new_child
);
445 if(!node_obj
) return E_FAIL
;
447 switch(V_VT(ref_child
))
455 if (V_UNKNOWN(ref_child
))
457 hr
= IUnknown_QueryInterface(V_UNKNOWN(ref_child
), &IID_IXMLDOMNode
, (void**)&before
);
458 if(FAILED(hr
)) return hr
;
463 FIXME("refChild var type %x\n", V_VT(ref_child
));
467 TRACE("new child %p, This->node %p\n", node_obj
->node
, This
->node
);
469 if(!node_obj
->node
->parent
)
470 if(xmldoc_remove_orphan(node_obj
->node
->doc
, node_obj
->node
) != S_OK
)
471 WARN("%p is not an orphan of %p\n", node_obj
->node
, node_obj
->node
->doc
);
473 refcount
= xmlnode_get_inst_cnt(node_obj
);
477 xmlnode
*before_node_obj
= get_node_obj(before
);
478 IXMLDOMNode_Release(before
);
479 if(!before_node_obj
) return E_FAIL
;
482 /* unlink from current parent first */
485 hr
= IXMLDOMNode_removeChild(node_obj
->parent
, node_obj
->iface
, NULL
);
486 if (hr
== S_OK
) xmldoc_remove_orphan(node_obj
->node
->doc
, node_obj
->node
);
488 doc
= node_obj
->node
->doc
;
492 xmlnode
*before_node_obj
= get_node_obj(before
);
494 /* refs count including subtree */
495 if (doc
!= before_node_obj
->node
->doc
)
496 refcount
= xmlnode_get_inst_cnt(node_obj
);
498 if (refcount
) xmldoc_add_refs(before_node_obj
->node
->doc
, refcount
);
499 node_obj
->node
= xmlAddPrevSibling(before_node_obj
->node
, node_obj
->node
);
500 if (refcount
) xmldoc_release_refs(doc
, refcount
);
501 node_obj
->parent
= This
->parent
;
505 if (doc
!= This
->node
->doc
)
506 refcount
= xmlnode_get_inst_cnt(node_obj
);
508 if (refcount
) xmldoc_add_refs(This
->node
->doc
, refcount
);
509 /* xmlAddChild doesn't unlink node from previous parent */
510 xmlUnlinkNode(node_obj
->node
);
511 node_obj
->node
= xmlAddChild(This
->node
, node_obj
->node
);
512 if (refcount
) xmldoc_release_refs(doc
, refcount
);
513 node_obj
->parent
= This
->iface
;
518 IXMLDOMNode_AddRef(new_child
);
526 HRESULT
node_replace_child(xmlnode
*This
, IXMLDOMNode
*newChild
, IXMLDOMNode
*oldChild
,
529 xmlnode
*old_child
, *new_child
;
530 xmlDocPtr leaving_doc
;
531 xmlNode
*my_ancestor
;
534 /* Do not believe any documentation telling that newChild == NULL
535 means removal. It does certainly *not* apply to msxml3! */
536 if(!newChild
|| !oldChild
)
542 old_child
= get_node_obj(oldChild
);
543 if(!old_child
) return E_FAIL
;
545 if(old_child
->node
->parent
!= This
->node
)
547 WARN("childNode %p is not a child of %p\n", oldChild
, This
);
551 new_child
= get_node_obj(newChild
);
552 if(!new_child
) return E_FAIL
;
554 my_ancestor
= This
->node
;
557 if(my_ancestor
== new_child
->node
)
559 WARN("tried to create loop\n");
562 my_ancestor
= my_ancestor
->parent
;
565 if(!new_child
->node
->parent
)
566 if(xmldoc_remove_orphan(new_child
->node
->doc
, new_child
->node
) != S_OK
)
567 WARN("%p is not an orphan of %p\n", new_child
->node
, new_child
->node
->doc
);
569 leaving_doc
= new_child
->node
->doc
;
571 if (leaving_doc
!= old_child
->node
->doc
)
572 refcount
= xmlnode_get_inst_cnt(new_child
);
574 if (refcount
) xmldoc_add_refs(old_child
->node
->doc
, refcount
);
575 xmlReplaceNode(old_child
->node
, new_child
->node
);
576 if (refcount
) xmldoc_release_refs(leaving_doc
, refcount
);
577 new_child
->parent
= old_child
->parent
;
578 old_child
->parent
= NULL
;
580 xmldoc_add_orphan(old_child
->node
->doc
, old_child
->node
);
584 IXMLDOMNode_AddRef(oldChild
);
591 HRESULT
node_remove_child(xmlnode
*This
, IXMLDOMNode
* child
, IXMLDOMNode
** oldChild
)
595 if(!child
) return E_INVALIDARG
;
600 child_node
= get_node_obj(child
);
601 if(!child_node
) return E_FAIL
;
603 if(child_node
->node
->parent
!= This
->node
)
605 WARN("childNode %p is not a child of %p\n", child
, This
);
609 xmlUnlinkNode(child_node
->node
);
610 child_node
->parent
= NULL
;
611 xmldoc_add_orphan(child_node
->node
->doc
, child_node
->node
);
615 IXMLDOMNode_AddRef(child
);
622 HRESULT
node_append_child(xmlnode
*This
, IXMLDOMNode
*child
, IXMLDOMNode
**outChild
)
631 hr
= IXMLDOMNode_get_nodeType(child
, &type
);
632 if(FAILED(hr
) || type
== NODE_ATTRIBUTE
) {
633 if (outChild
) *outChild
= NULL
;
638 return IXMLDOMNode_insertBefore(This
->iface
, child
, var
, outChild
);
641 HRESULT
node_has_childnodes(const xmlnode
*This
, VARIANT_BOOL
*ret
)
643 if (!ret
) return E_INVALIDARG
;
645 if (!This
->node
->children
)
647 *ret
= VARIANT_FALSE
;
655 HRESULT
node_get_owner_doc(const xmlnode
*This
, IXMLDOMDocument
**doc
)
659 return get_domdoc_from_xmldoc(This
->node
->doc
, (IXMLDOMDocument3
**)doc
);
662 HRESULT
node_clone(xmlnode
*This
, VARIANT_BOOL deep
, IXMLDOMNode
**cloneNode
)
667 if(!cloneNode
) return E_INVALIDARG
;
669 clone
= xmlCopyNode(This
->node
, deep
? 1 : 2);
672 xmlSetTreeDoc(clone
, This
->node
->doc
);
673 xmldoc_add_orphan(clone
->doc
, clone
);
675 node
= create_node(clone
);
678 ERR("Copy failed\n");
679 xmldoc_remove_orphan(clone
->doc
, clone
);
688 ERR("Copy failed\n");
695 static inline xmlChar
* trim_whitespace(xmlChar
* str
)
703 while (*ret
&& isspace(*ret
))
705 len
= xmlStrlen(ret
);
707 while (isspace(ret
[len
-1])) --len
;
709 ret
= xmlStrndup(ret
, len
);
714 static xmlChar
* do_get_text(xmlNodePtr node
)
718 BOOL preserving
= is_preserving_whitespace(node
);
722 str
= xmlNodeGetContent(node
);
726 xmlElementType prev_type
= XML_TEXT_NODE
;
728 str
= xmlStrdup(BAD_CAST
"");
729 for (child
= node
->children
; child
!= NULL
; child
= child
->next
)
733 case XML_ELEMENT_NODE
:
734 tmp
= do_get_text(child
);
737 case XML_CDATA_SECTION_NODE
:
738 case XML_ENTITY_REF_NODE
:
739 case XML_ENTITY_NODE
:
740 tmp
= xmlNodeGetContent(child
);
751 if (prev_type
== XML_ELEMENT_NODE
&& child
->type
== XML_ELEMENT_NODE
)
752 str
= xmlStrcat(str
, BAD_CAST
" ");
753 str
= xmlStrcat(str
, tmp
);
754 prev_type
= child
->type
;
763 case XML_ELEMENT_NODE
:
765 case XML_ENTITY_REF_NODE
:
766 case XML_ENTITY_NODE
:
767 case XML_DOCUMENT_NODE
:
768 case XML_DOCUMENT_FRAG_NODE
:
770 str
= trim_whitespace(str
);
779 HRESULT
node_get_text(const xmlnode
*This
, BSTR
*text
)
784 if (!text
) return E_INVALIDARG
;
786 content
= do_get_text(This
->node
);
789 str
= bstr_from_xmlChar(content
);
793 /* Always return a string. */
794 if (!str
) str
= SysAllocStringLen( NULL
, 0 );
796 TRACE("%p %s\n", This
, debugstr_w(str
) );
802 HRESULT
node_put_text(xmlnode
*This
, BSTR text
)
806 TRACE("(%p)->(%s)\n", This
, debugstr_w(text
));
808 str
= xmlchar_from_wchar(text
);
810 /* Escape the string. */
811 str2
= xmlEncodeEntitiesReentrant(This
->node
->doc
, str
);
814 xmlNodeSetContent(This
->node
, str2
);
820 BSTR
EnsureCorrectEOL(BSTR sInput
)
827 nLen
= SysStringLen(sInput
);
828 /* Count line endings */
829 for(i
=0; i
< nLen
; i
++)
831 if(sInput
[i
] == '\n')
835 TRACE("len=%d, num=%d\n", nLen
, nNum
);
837 /* Add linefeed as needed */
841 sNew
= SysAllocStringLen(NULL
, nLen
+ nNum
);
842 for(i
=0; i
< nLen
; i
++)
844 if(sInput
[i
] == '\n')
846 sNew
[i
+nPlace
] = '\r';
849 sNew
[i
+nPlace
] = sInput
[i
];
852 SysFreeString(sInput
);
859 TRACE("len %d\n", SysStringLen(sNew
));
865 * We are trying to replicate the same behaviour as msxml by converting
866 * line endings to \r\n and using indents as \t. The problem is that msxml
867 * only formats nodes that have a line ending. Using libxml we cannot
868 * reproduce behaviour exactly.
871 HRESULT
node_get_xml(xmlnode
*This
, BOOL ensure_eol
, BSTR
*ret
)
873 xmlBufferPtr xml_buf
;
882 xml_buf
= xmlBufferCreate();
884 return E_OUTOFMEMORY
;
886 xmldecl
= xmldoc_unlink_xmldecl( This
->node
->doc
);
888 size
= xmlNodeDump(xml_buf
, This
->node
->doc
, This
->node
, 0, 1);
890 const xmlChar
*buf_content
;
893 /* Attribute Nodes return a space in front of their name */
894 buf_content
= xmlBufferContent(xml_buf
);
896 content
= bstr_from_xmlChar(buf_content
+ (buf_content
[0] == ' ' ? 1 : 0));
898 content
= EnsureCorrectEOL(content
);
902 *ret
= SysAllocStringLen(NULL
, 0);
905 xmlBufferFree(xml_buf
);
906 xmldoc_link_xmldecl( This
->node
->doc
, xmldecl
);
907 return *ret
? S_OK
: E_OUTOFMEMORY
;
910 #ifdef SONAME_LIBXSLT
912 /* duplicates xmlBufferWriteQuotedString() logic */
913 static void xml_write_quotedstring(xmlOutputBufferPtr buf
, const xmlChar
*string
)
915 const xmlChar
*cur
, *base
;
917 if (xmlStrchr(string
, '\"'))
919 if (xmlStrchr(string
, '\''))
921 xmlOutputBufferWrite(buf
, 1, "\"");
929 xmlOutputBufferWrite(buf
, cur
-base
, (const char*)base
);
930 xmlOutputBufferWrite(buf
, 6, """);
938 xmlOutputBufferWrite(buf
, cur
-base
, (const char*)base
);
939 xmlOutputBufferWrite(buf
, 1, "\"");
943 xmlOutputBufferWrite(buf
, 1, "\'");
944 xmlOutputBufferWriteString(buf
, (const char*)string
);
945 xmlOutputBufferWrite(buf
, 1, "\'");
950 xmlOutputBufferWrite(buf
, 1, "\"");
951 xmlOutputBufferWriteString(buf
, (const char*)string
);
952 xmlOutputBufferWrite(buf
, 1, "\"");
956 static int XMLCALL
transform_to_stream_write(void *context
, const char *buffer
, int len
)
959 HRESULT hr
= IStream_Write((IStream
*)context
, buffer
, len
, &written
);
960 return hr
== S_OK
? written
: -1;
963 /* Output for method "text" */
964 static void transform_write_text(xmlDocPtr result
, xsltStylesheetPtr style
, xmlOutputBufferPtr output
)
966 xmlNodePtr cur
= result
->children
;
969 if (cur
->type
== XML_TEXT_NODE
)
970 xmlOutputBufferWriteString(output
, (const char*)cur
->content
);
972 /* skip to next node */
975 if ((cur
->children
->type
!= XML_ENTITY_DECL
) &&
976 (cur
->children
->type
!= XML_ENTITY_REF_NODE
) &&
977 (cur
->children
->type
!= XML_ENTITY_NODE
))
994 if (cur
== (xmlNodePtr
) style
->doc
) {
1006 #undef XSLT_GET_IMPORT_PTR
1007 #define XSLT_GET_IMPORT_PTR(res, style, name) { \
1008 xsltStylesheetPtr st = style; \
1010 while (st != NULL) { \
1011 if (st->name != NULL) { res = st->name; break; } \
1012 st = pxsltNextImport(st); \
1015 #undef XSLT_GET_IMPORT_INT
1016 #define XSLT_GET_IMPORT_INT(res, style, name) { \
1017 xsltStylesheetPtr st = style; \
1019 while (st != NULL) { \
1020 if (st->name != -1) { res = st->name; break; } \
1021 st = pxsltNextImport(st); \
1024 static void transform_write_xmldecl(xmlDocPtr result
, xsltStylesheetPtr style
, BOOL omit_encoding
, xmlOutputBufferPtr output
)
1026 int omit_xmldecl
, standalone
;
1028 XSLT_GET_IMPORT_INT(omit_xmldecl
, style
, omitXmlDeclaration
);
1029 if (omit_xmldecl
== 1) return;
1031 XSLT_GET_IMPORT_INT(standalone
, style
, standalone
);
1033 xmlOutputBufferWriteString(output
, "<?xml version=");
1034 if (result
->version
)
1036 xmlOutputBufferWriteString(output
, "\"");
1037 xmlOutputBufferWriteString(output
, (const char *)result
->version
);
1038 xmlOutputBufferWriteString(output
, "\"");
1041 xmlOutputBufferWriteString(output
, "\"1.0\"");
1045 const xmlChar
*encoding
;
1047 /* default encoding is UTF-16 */
1048 XSLT_GET_IMPORT_PTR(encoding
, style
, encoding
);
1049 xmlOutputBufferWriteString(output
, " encoding=");
1050 xmlOutputBufferWriteString(output
, "\"");
1051 xmlOutputBufferWriteString(output
, encoding
? (const char *)encoding
: "UTF-16");
1052 xmlOutputBufferWriteString(output
, "\"");
1055 /* standalone attribute */
1056 if (standalone
!= -1)
1057 xmlOutputBufferWriteString(output
, standalone
== 0 ? " standalone=\"no\"" : " standalone=\"yes\"");
1059 xmlOutputBufferWriteString(output
, "?>");
1062 static void htmldtd_dumpcontent(xmlOutputBufferPtr buf
, xmlDocPtr doc
)
1064 xmlDtdPtr cur
= doc
->intSubset
;
1066 xmlOutputBufferWriteString(buf
, "<!DOCTYPE ");
1067 xmlOutputBufferWriteString(buf
, (const char *)cur
->name
);
1068 if (cur
->ExternalID
)
1070 xmlOutputBufferWriteString(buf
, " PUBLIC ");
1071 xml_write_quotedstring(buf
, cur
->ExternalID
);
1074 xmlOutputBufferWriteString(buf
, " ");
1075 xml_write_quotedstring(buf
, cur
->SystemID
);
1078 else if (cur
->SystemID
)
1080 xmlOutputBufferWriteString(buf
, " SYSTEM ");
1081 xml_write_quotedstring(buf
, cur
->SystemID
);
1083 xmlOutputBufferWriteString(buf
, ">\n");
1086 /* Duplicates htmlDocContentDumpFormatOutput() the way we need it - doesn't add trailing newline. */
1087 static void htmldoc_dumpcontent(xmlOutputBufferPtr buf
, xmlDocPtr doc
, const char *encoding
, int format
)
1089 xmlElementType type
;
1091 /* force HTML output */
1093 doc
->type
= XML_HTML_DOCUMENT_NODE
;
1095 htmldtd_dumpcontent(buf
, doc
);
1096 if (doc
->children
) {
1097 xmlNodePtr cur
= doc
->children
;
1099 htmlNodeDumpFormatOutput(buf
, doc
, cur
, encoding
, format
);
1106 static inline BOOL
transform_is_empty_resultdoc(xmlDocPtr result
)
1108 return !result
->children
|| ((result
->children
->type
== XML_DTD_NODE
) && !result
->children
->next
);
1111 static inline BOOL
transform_is_valid_method(xsltStylesheetPtr style
)
1113 return !style
->methodURI
|| !(style
->method
&& xmlStrEqual(style
->method
, (const xmlChar
*)"xhtml"));
1116 /* Helper to write transformation result to specified output buffer. */
1117 static HRESULT
node_transform_write(xsltStylesheetPtr style
, xmlDocPtr result
, BOOL omit_encoding
, const char *encoding
, xmlOutputBufferPtr output
)
1119 const xmlChar
*method
;
1122 if (!transform_is_valid_method(style
))
1124 ERR("unknown output method\n");
1128 XSLT_GET_IMPORT_PTR(method
, style
, method
)
1129 XSLT_GET_IMPORT_INT(indent
, style
, indent
);
1131 if (!method
&& (result
->type
== XML_HTML_DOCUMENT_NODE
))
1132 method
= (const xmlChar
*) "html";
1134 if (method
&& xmlStrEqual(method
, (const xmlChar
*)"html"))
1136 htmlSetMetaEncoding(result
, (const xmlChar
*)encoding
);
1139 htmldoc_dumpcontent(output
, result
, (const char*)encoding
, indent
);
1141 else if (method
&& xmlStrEqual(method
, (const xmlChar
*)"xhtml"))
1143 htmlSetMetaEncoding(result
, (const xmlChar
*) encoding
);
1144 htmlDocContentDumpOutput(output
, result
, encoding
);
1146 else if (method
&& xmlStrEqual(method
, (const xmlChar
*)"text"))
1147 transform_write_text(result
, style
, output
);
1150 transform_write_xmldecl(result
, style
, omit_encoding
, output
);
1152 if (result
->children
)
1154 xmlNodePtr child
= result
->children
;
1158 xmlNodeDumpOutput(output
, result
, child
, 0, indent
== 1, encoding
);
1159 if (indent
&& ((child
->type
== XML_DTD_NODE
) || ((child
->type
== XML_COMMENT_NODE
) && child
->next
)))
1160 xmlOutputBufferWriteString(output
, "\r\n");
1161 child
= child
->next
;
1166 xmlOutputBufferFlush(output
);
1170 /* For BSTR output is always UTF-16, without 'encoding' attribute */
1171 static HRESULT
node_transform_write_to_bstr(xsltStylesheetPtr style
, xmlDocPtr result
, BSTR
*str
)
1175 if (transform_is_empty_resultdoc(result
))
1176 *str
= SysAllocStringLen(NULL
, 0);
1179 xmlOutputBufferPtr output
= xmlAllocOutputBuffer(xmlFindCharEncodingHandler("UTF-16"));
1180 const xmlChar
*content
;
1185 return E_OUTOFMEMORY
;
1187 hr
= node_transform_write(style
, result
, TRUE
, "UTF-16", output
);
1188 #ifdef LIBXML2_NEW_BUFFER
1189 content
= xmlBufContent(output
->conv
);
1190 len
= xmlBufUse(output
->conv
);
1192 content
= xmlBufferContent(output
->conv
);
1193 len
= xmlBufferLength(output
->conv
);
1195 /* UTF-16 encoder places UTF-16 bom, we don't need it for BSTR */
1196 content
+= sizeof(WCHAR
);
1197 *str
= SysAllocStringLen((WCHAR
*)content
, len
/sizeof(WCHAR
) - 1);
1198 xmlOutputBufferClose(output
);
1201 return *str
? hr
: E_OUTOFMEMORY
;
1204 static HRESULT
node_transform_write_to_stream(xsltStylesheetPtr style
, xmlDocPtr result
, IStream
*stream
)
1206 static const xmlChar
*utf16
= (const xmlChar
*)"UTF-16";
1207 xmlOutputBufferPtr output
;
1208 const xmlChar
*encoding
;
1211 if (transform_is_empty_resultdoc(result
))
1213 WARN("empty result document\n");
1217 if (style
->methodURI
&& (!style
->method
|| !xmlStrEqual(style
->method
, (const xmlChar
*) "xhtml")))
1219 ERR("unknown output method\n");
1223 /* default encoding is UTF-16 */
1224 XSLT_GET_IMPORT_PTR(encoding
, style
, encoding
);
1228 output
= xmlOutputBufferCreateIO(transform_to_stream_write
, NULL
, stream
, xmlFindCharEncodingHandler((const char*)encoding
));
1230 return E_OUTOFMEMORY
;
1232 hr
= node_transform_write(style
, result
, FALSE
, (const char*)encoding
, output
);
1233 xmlOutputBufferClose(output
);
1239 HRESULT
node_transform_node_params(const xmlnode
*This
, IXMLDOMNode
*stylesheet
, BSTR
*p
,
1240 IStream
*stream
, const struct xslprocessor_params
*params
)
1242 #ifdef SONAME_LIBXSLT
1243 xsltStylesheetPtr xsltSS
;
1247 if (!libxslt_handle
) return E_NOTIMPL
;
1248 if (!stylesheet
|| !p
) return E_INVALIDARG
;
1252 sheet
= get_node_obj(stylesheet
);
1253 if(!sheet
) return E_FAIL
;
1255 xsltSS
= pxsltParseStylesheetDoc(sheet
->node
->doc
);
1258 const char **xslparams
= NULL
;
1262 /* convert our parameter list to libxml2 format */
1263 if (params
&& params
->count
)
1265 struct xslprocessor_par
*par
;
1268 xslparams
= heap_alloc((params
->count
*2 + 1)*sizeof(char*));
1269 LIST_FOR_EACH_ENTRY(par
, ¶ms
->list
, struct xslprocessor_par
, entry
)
1271 xslparams
[i
++] = (char*)xmlchar_from_wchar(par
->name
);
1272 xslparams
[i
++] = (char*)xmlchar_from_wchar(par
->value
);
1274 xslparams
[i
] = NULL
;
1279 xsltTransformContextPtr ctxt
= pxsltNewTransformContext(xsltSS
, This
->node
->doc
);
1281 /* push parameters to user context */
1282 pxsltQuoteUserParams(ctxt
, xslparams
);
1283 result
= pxsltApplyStylesheetUser(xsltSS
, This
->node
->doc
, NULL
, NULL
, NULL
, ctxt
);
1284 pxsltFreeTransformContext(ctxt
);
1286 for (i
= 0; i
< params
->count
*2; i
++)
1287 heap_free((char*)xslparams
[i
]);
1288 heap_free(xslparams
);
1291 result
= pxsltApplyStylesheet(xsltSS
, This
->node
->doc
, NULL
);
1296 hr
= node_transform_write_to_stream(xsltSS
, result
, stream
);
1298 hr
= node_transform_write_to_bstr(xsltSS
, result
, p
);
1301 /* libxslt "helpfully" frees the XML document the stylesheet was
1302 generated from, too */
1304 pxsltFreeStylesheet(xsltSS
);
1307 if(!*p
) *p
= SysAllocStringLen(NULL
, 0);
1311 ERR_(winediag
)("libxslt headers were not found at compile time. Expect problems.\n");
1317 HRESULT
node_transform_node(const xmlnode
*node
, IXMLDOMNode
*stylesheet
, BSTR
*p
)
1319 return node_transform_node_params(node
, stylesheet
, p
, NULL
, NULL
);
1322 HRESULT
node_select_nodes(const xmlnode
*This
, BSTR query
, IXMLDOMNodeList
**nodes
)
1327 if (!query
|| !nodes
) return E_INVALIDARG
;
1329 str
= xmlchar_from_wchar(query
);
1330 hr
= create_selection(This
->node
, str
, nodes
);
1336 HRESULT
node_select_singlenode(const xmlnode
*This
, BSTR query
, IXMLDOMNode
**node
)
1338 IXMLDOMNodeList
*list
;
1341 hr
= node_select_nodes(This
, query
, &list
);
1344 hr
= IXMLDOMNodeList_nextNode(list
, node
);
1345 IXMLDOMNodeList_Release(list
);
1350 HRESULT
node_get_namespaceURI(xmlnode
*This
, BSTR
*namespaceURI
)
1352 xmlNsPtr ns
= This
->node
->ns
;
1355 return E_INVALIDARG
;
1357 *namespaceURI
= NULL
;
1360 *namespaceURI
= bstr_from_xmlChar(ns
->href
);
1362 TRACE("uri: %s\n", debugstr_w(*namespaceURI
));
1364 return *namespaceURI
? S_OK
: S_FALSE
;
1367 HRESULT
node_get_prefix(xmlnode
*This
, BSTR
*prefix
)
1369 xmlNsPtr ns
= This
->node
->ns
;
1371 if (!prefix
) return E_INVALIDARG
;
1375 if (ns
&& ns
->prefix
)
1376 *prefix
= bstr_from_xmlChar(ns
->prefix
);
1378 TRACE("prefix: %s\n", debugstr_w(*prefix
));
1380 return *prefix
? S_OK
: S_FALSE
;
1383 HRESULT
node_get_base_name(xmlnode
*This
, BSTR
*name
)
1385 if (!name
) return E_INVALIDARG
;
1387 *name
= bstr_from_xmlChar(This
->node
->name
);
1388 if (!*name
) return E_OUTOFMEMORY
;
1390 TRACE("returning %s\n", debugstr_w(*name
));
1395 /* _private field holds a number of COM instances spawned from this libxml2 node */
1396 static void xmlnode_add_ref(xmlNodePtr node
)
1398 if (node
->type
== XML_DOCUMENT_NODE
) return;
1399 InterlockedIncrement((LONG
*)&node
->_private
);
1402 static void xmlnode_release(xmlNodePtr node
)
1404 if (node
->type
== XML_DOCUMENT_NODE
) return;
1405 InterlockedDecrement((LONG
*)&node
->_private
);
1408 void destroy_xmlnode(xmlnode
*This
)
1412 xmlnode_release(This
->node
);
1413 xmldoc_release(This
->node
->doc
);
1417 void init_xmlnode(xmlnode
*This
, xmlNodePtr node
, IXMLDOMNode
*node_iface
, dispex_static_data_t
*dispex_data
)
1421 xmlnode_add_ref(node
);
1422 xmldoc_add_ref(node
->doc
);
1426 This
->iface
= node_iface
;
1427 This
->parent
= NULL
;
1429 init_dispex(&This
->dispex
, (IUnknown
*)This
->iface
, dispex_data
);
1434 IXMLDOMNode IXMLDOMNode_iface
;
1438 static inline unknode
*unknode_from_IXMLDOMNode(IXMLDOMNode
*iface
)
1440 return CONTAINING_RECORD(iface
, unknode
, IXMLDOMNode_iface
);
1443 static HRESULT WINAPI
unknode_QueryInterface(
1448 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1450 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppvObject
);
1452 if (IsEqualGUID(riid
, &IID_IUnknown
)) {
1454 }else if (IsEqualGUID( riid
, &IID_IDispatch
) ||
1455 IsEqualGUID( riid
, &IID_IXMLDOMNode
)) {
1456 *ppvObject
= &This
->IXMLDOMNode_iface
;
1457 }else if(node_query_interface(&This
->node
, riid
, ppvObject
)) {
1458 return *ppvObject
? S_OK
: E_NOINTERFACE
;
1460 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
1462 return E_NOINTERFACE
;
1465 IUnknown_AddRef((IUnknown
*)*ppvObject
);
1469 static ULONG WINAPI
unknode_AddRef(
1470 IXMLDOMNode
*iface
)
1472 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1474 return InterlockedIncrement(&This
->ref
);
1477 static ULONG WINAPI
unknode_Release(
1478 IXMLDOMNode
*iface
)
1480 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1483 ref
= InterlockedDecrement( &This
->ref
);
1485 destroy_xmlnode(&This
->node
);
1492 static HRESULT WINAPI
unknode_GetTypeInfoCount(
1496 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1498 TRACE("(%p)->(%p)\n", This
, pctinfo
);
1505 static HRESULT WINAPI
unknode_GetTypeInfo(
1509 ITypeInfo
** ppTInfo
)
1511 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1514 TRACE("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
1516 hr
= get_typeinfo(IXMLDOMNode_tid
, ppTInfo
);
1521 static HRESULT WINAPI
unknode_GetIDsOfNames(
1524 LPOLESTR
* rgszNames
,
1529 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1531 ITypeInfo
*typeinfo
;
1534 TRACE("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
1537 if(!rgszNames
|| cNames
== 0 || !rgDispId
)
1538 return E_INVALIDARG
;
1540 hr
= get_typeinfo(IXMLDOMNode_tid
, &typeinfo
);
1543 hr
= ITypeInfo_GetIDsOfNames(typeinfo
, rgszNames
, cNames
, rgDispId
);
1544 ITypeInfo_Release(typeinfo
);
1550 static HRESULT WINAPI
unknode_Invoke(
1552 DISPID dispIdMember
,
1556 DISPPARAMS
* pDispParams
,
1557 VARIANT
* pVarResult
,
1558 EXCEPINFO
* pExcepInfo
,
1561 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1562 ITypeInfo
*typeinfo
;
1565 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
1566 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
1568 hr
= get_typeinfo(IXMLDOMNode_tid
, &typeinfo
);
1571 hr
= ITypeInfo_Invoke(typeinfo
, &This
->IXMLDOMNode_iface
, dispIdMember
, wFlags
, pDispParams
,
1572 pVarResult
, pExcepInfo
, puArgErr
);
1573 ITypeInfo_Release(typeinfo
);
1579 static HRESULT WINAPI
unknode_get_nodeName(
1583 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1585 FIXME("(%p)->(%p)\n", This
, p
);
1587 return node_get_nodeName(&This
->node
, p
);
1590 static HRESULT WINAPI
unknode_get_nodeValue(
1594 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1596 FIXME("(%p)->(%p)\n", This
, value
);
1599 return E_INVALIDARG
;
1601 V_VT(value
) = VT_NULL
;
1605 static HRESULT WINAPI
unknode_put_nodeValue(
1609 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1610 FIXME("(%p)->(v%d)\n", This
, V_VT(&value
));
1614 static HRESULT WINAPI
unknode_get_nodeType(
1616 DOMNodeType
* domNodeType
)
1618 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1620 FIXME("(%p)->(%p)\n", This
, domNodeType
);
1622 switch (This
->node
.node
->type
)
1624 case XML_ELEMENT_NODE
:
1625 case XML_ATTRIBUTE_NODE
:
1627 case XML_CDATA_SECTION_NODE
:
1628 case XML_ENTITY_REF_NODE
:
1629 case XML_ENTITY_NODE
:
1631 case XML_COMMENT_NODE
:
1632 case XML_DOCUMENT_NODE
:
1633 case XML_DOCUMENT_TYPE_NODE
:
1634 case XML_DOCUMENT_FRAG_NODE
:
1635 case XML_NOTATION_NODE
:
1636 /* we only care about this set of types, libxml2 type values are
1637 exactly what we need */
1638 *domNodeType
= (DOMNodeType
)This
->node
.node
->type
;
1641 *domNodeType
= NODE_INVALID
;
1648 static HRESULT WINAPI
unknode_get_parentNode(
1650 IXMLDOMNode
** parent
)
1652 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1653 FIXME("(%p)->(%p)\n", This
, parent
);
1654 if (!parent
) return E_INVALIDARG
;
1659 static HRESULT WINAPI
unknode_get_childNodes(
1661 IXMLDOMNodeList
** outList
)
1663 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1665 TRACE("(%p)->(%p)\n", This
, outList
);
1667 return node_get_child_nodes(&This
->node
, outList
);
1670 static HRESULT WINAPI
unknode_get_firstChild(
1672 IXMLDOMNode
** domNode
)
1674 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1676 TRACE("(%p)->(%p)\n", This
, domNode
);
1678 return node_get_first_child(&This
->node
, domNode
);
1681 static HRESULT WINAPI
unknode_get_lastChild(
1683 IXMLDOMNode
** domNode
)
1685 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1687 TRACE("(%p)->(%p)\n", This
, domNode
);
1689 return node_get_last_child(&This
->node
, domNode
);
1692 static HRESULT WINAPI
unknode_get_previousSibling(
1694 IXMLDOMNode
** domNode
)
1696 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1698 TRACE("(%p)->(%p)\n", This
, domNode
);
1700 return node_get_previous_sibling(&This
->node
, domNode
);
1703 static HRESULT WINAPI
unknode_get_nextSibling(
1705 IXMLDOMNode
** domNode
)
1707 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1709 TRACE("(%p)->(%p)\n", This
, domNode
);
1711 return node_get_next_sibling(&This
->node
, domNode
);
1714 static HRESULT WINAPI
unknode_get_attributes(
1716 IXMLDOMNamedNodeMap
** attributeMap
)
1718 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1720 FIXME("(%p)->(%p)\n", This
, attributeMap
);
1722 return return_null_ptr((void**)attributeMap
);
1725 static HRESULT WINAPI
unknode_insertBefore(
1727 IXMLDOMNode
* newNode
, VARIANT refChild
,
1728 IXMLDOMNode
** outOldNode
)
1730 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1732 FIXME("(%p)->(%p x%d %p)\n", This
, newNode
, V_VT(&refChild
), outOldNode
);
1734 return node_insert_before(&This
->node
, newNode
, &refChild
, outOldNode
);
1737 static HRESULT WINAPI
unknode_replaceChild(
1739 IXMLDOMNode
* newNode
,
1740 IXMLDOMNode
* oldNode
,
1741 IXMLDOMNode
** outOldNode
)
1743 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1745 FIXME("(%p)->(%p %p %p)\n", This
, newNode
, oldNode
, outOldNode
);
1747 return node_replace_child(&This
->node
, newNode
, oldNode
, outOldNode
);
1750 static HRESULT WINAPI
unknode_removeChild(
1752 IXMLDOMNode
* domNode
, IXMLDOMNode
** oldNode
)
1754 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1755 return node_remove_child(&This
->node
, domNode
, oldNode
);
1758 static HRESULT WINAPI
unknode_appendChild(
1760 IXMLDOMNode
* newNode
, IXMLDOMNode
** outNewNode
)
1762 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1763 return node_append_child(&This
->node
, newNode
, outNewNode
);
1766 static HRESULT WINAPI
unknode_hasChildNodes(
1768 VARIANT_BOOL
* pbool
)
1770 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1771 return node_has_childnodes(&This
->node
, pbool
);
1774 static HRESULT WINAPI
unknode_get_ownerDocument(
1776 IXMLDOMDocument
** domDocument
)
1778 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1779 return node_get_owner_doc(&This
->node
, domDocument
);
1782 static HRESULT WINAPI
unknode_cloneNode(
1784 VARIANT_BOOL pbool
, IXMLDOMNode
** outNode
)
1786 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1787 return node_clone(&This
->node
, pbool
, outNode
);
1790 static HRESULT WINAPI
unknode_get_nodeTypeString(
1794 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1796 FIXME("(%p)->(%p)\n", This
, p
);
1798 return node_get_nodeName(&This
->node
, p
);
1801 static HRESULT WINAPI
unknode_get_text(
1805 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1806 return node_get_text(&This
->node
, p
);
1809 static HRESULT WINAPI
unknode_put_text(
1813 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1814 return node_put_text(&This
->node
, p
);
1817 static HRESULT WINAPI
unknode_get_specified(
1819 VARIANT_BOOL
* isSpecified
)
1821 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1822 FIXME("(%p)->(%p) stub!\n", This
, isSpecified
);
1823 *isSpecified
= VARIANT_TRUE
;
1827 static HRESULT WINAPI
unknode_get_definition(
1829 IXMLDOMNode
** definitionNode
)
1831 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1832 FIXME("(%p)->(%p)\n", This
, definitionNode
);
1836 static HRESULT WINAPI
unknode_get_nodeTypedValue(
1840 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1841 FIXME("(%p)->(%p)\n", This
, var1
);
1842 return return_null_var(var1
);
1845 static HRESULT WINAPI
unknode_put_nodeTypedValue(
1849 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1850 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&typedValue
));
1854 static HRESULT WINAPI
unknode_get_dataType(
1858 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1859 TRACE("(%p)->(%p)\n", This
, var1
);
1860 return return_null_var(var1
);
1863 static HRESULT WINAPI
unknode_put_dataType(
1867 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1869 FIXME("(%p)->(%s)\n", This
, debugstr_w(p
));
1872 return E_INVALIDARG
;
1877 static HRESULT WINAPI
unknode_get_xml(
1881 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1883 FIXME("(%p)->(%p)\n", This
, p
);
1885 return node_get_xml(&This
->node
, FALSE
, p
);
1888 static HRESULT WINAPI
unknode_transformNode(
1890 IXMLDOMNode
* domNode
, BSTR
* p
)
1892 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1893 return node_transform_node(&This
->node
, domNode
, p
);
1896 static HRESULT WINAPI
unknode_selectNodes(
1898 BSTR p
, IXMLDOMNodeList
** outList
)
1900 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1901 return node_select_nodes(&This
->node
, p
, outList
);
1904 static HRESULT WINAPI
unknode_selectSingleNode(
1906 BSTR p
, IXMLDOMNode
** outNode
)
1908 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1909 return node_select_singlenode(&This
->node
, p
, outNode
);
1912 static HRESULT WINAPI
unknode_get_parsed(
1914 VARIANT_BOOL
* isParsed
)
1916 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1917 FIXME("(%p)->(%p) stub!\n", This
, isParsed
);
1918 *isParsed
= VARIANT_TRUE
;
1922 static HRESULT WINAPI
unknode_get_namespaceURI(
1926 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1927 TRACE("(%p)->(%p)\n", This
, p
);
1928 return node_get_namespaceURI(&This
->node
, p
);
1931 static HRESULT WINAPI
unknode_get_prefix(
1935 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1936 return node_get_prefix(&This
->node
, p
);
1939 static HRESULT WINAPI
unknode_get_baseName(
1943 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1944 return node_get_base_name(&This
->node
, p
);
1947 static HRESULT WINAPI
unknode_transformNodeToObject(
1949 IXMLDOMNode
* domNode
, VARIANT var1
)
1951 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1952 FIXME("(%p)->(%p %s)\n", This
, domNode
, debugstr_variant(&var1
));
1956 static const struct IXMLDOMNodeVtbl unknode_vtbl
=
1958 unknode_QueryInterface
,
1961 unknode_GetTypeInfoCount
,
1962 unknode_GetTypeInfo
,
1963 unknode_GetIDsOfNames
,
1965 unknode_get_nodeName
,
1966 unknode_get_nodeValue
,
1967 unknode_put_nodeValue
,
1968 unknode_get_nodeType
,
1969 unknode_get_parentNode
,
1970 unknode_get_childNodes
,
1971 unknode_get_firstChild
,
1972 unknode_get_lastChild
,
1973 unknode_get_previousSibling
,
1974 unknode_get_nextSibling
,
1975 unknode_get_attributes
,
1976 unknode_insertBefore
,
1977 unknode_replaceChild
,
1978 unknode_removeChild
,
1979 unknode_appendChild
,
1980 unknode_hasChildNodes
,
1981 unknode_get_ownerDocument
,
1983 unknode_get_nodeTypeString
,
1986 unknode_get_specified
,
1987 unknode_get_definition
,
1988 unknode_get_nodeTypedValue
,
1989 unknode_put_nodeTypedValue
,
1990 unknode_get_dataType
,
1991 unknode_put_dataType
,
1993 unknode_transformNode
,
1994 unknode_selectNodes
,
1995 unknode_selectSingleNode
,
1997 unknode_get_namespaceURI
,
1999 unknode_get_baseName
,
2000 unknode_transformNodeToObject
2003 IXMLDOMNode
*create_node( xmlNodePtr node
)
2012 TRACE("type %d\n", node
->type
);
2015 case XML_ELEMENT_NODE
:
2016 pUnk
= create_element( node
);
2018 case XML_ATTRIBUTE_NODE
:
2019 pUnk
= create_attribute( node
);
2022 pUnk
= create_text( node
);
2024 case XML_CDATA_SECTION_NODE
:
2025 pUnk
= create_cdata( node
);
2027 case XML_ENTITY_REF_NODE
:
2028 pUnk
= create_doc_entity_ref( node
);
2031 pUnk
= create_pi( node
);
2033 case XML_COMMENT_NODE
:
2034 pUnk
= create_comment( node
);
2036 case XML_DOCUMENT_NODE
:
2037 pUnk
= create_domdoc( node
);
2039 case XML_DOCUMENT_FRAG_NODE
:
2040 pUnk
= create_doc_fragment( node
);
2043 case XML_DOCUMENT_TYPE_NODE
:
2044 pUnk
= create_doc_type( node
);
2046 case XML_ENTITY_NODE
:
2047 case XML_NOTATION_NODE
: {
2050 FIXME("only creating basic node for type %d\n", node
->type
);
2052 new_node
= heap_alloc(sizeof(unknode
));
2056 new_node
->IXMLDOMNode_iface
.lpVtbl
= &unknode_vtbl
;
2058 init_xmlnode(&new_node
->node
, node
, &new_node
->IXMLDOMNode_iface
, NULL
);
2059 pUnk
= (IUnknown
*)&new_node
->IXMLDOMNode_iface
;
2063 ERR("Called for unsupported node type %d\n", node
->type
);
2067 hr
= IUnknown_QueryInterface(pUnk
, &IID_IXMLDOMNode
, (LPVOID
*)&ret
);
2068 IUnknown_Release(pUnk
);
2069 if(FAILED(hr
)) return NULL
;