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
24 # include <libxml/HTMLtree.h>
25 # ifdef SONAME_LIBXSLT
26 # ifdef HAVE_LIBXSLT_PATTERN_H
27 # include <libxslt/pattern.h>
29 # ifdef HAVE_LIBXSLT_TRANSFORM_H
30 # include <libxslt/transform.h>
32 # include <libxslt/imports.h>
33 # include <libxslt/variables.h>
34 # include <libxslt/xsltutils.h>
35 # include <libxslt/xsltInternals.h>
42 extern void* libxslt_handle
;
43 # define MAKE_FUNCPTR(f) extern typeof(f) * p##f
44 MAKE_FUNCPTR(xsltApplyStylesheet
);
45 MAKE_FUNCPTR(xsltApplyStylesheetUser
);
46 MAKE_FUNCPTR(xsltCleanupGlobals
);
47 MAKE_FUNCPTR(xsltFreeStylesheet
);
48 MAKE_FUNCPTR(xsltFreeTransformContext
);
49 MAKE_FUNCPTR(xsltNewTransformContext
);
50 MAKE_FUNCPTR(xsltNextImport
);
51 MAKE_FUNCPTR(xsltParseStylesheetDoc
);
52 MAKE_FUNCPTR(xsltQuoteUserParams
);
53 MAKE_FUNCPTR(xsltSaveResultTo
);
57 static const IID IID_xmlnode
= {0x4f2f4ba2,0xb822,0x11df,{0x8b,0x8a,0x68,0x50,0xdf,0xd7,0x20,0x85}};
59 xmlNodePtr
xmlNodePtr_from_domnode( IXMLDOMNode
*iface
, xmlElementType type
)
65 This
= get_node_obj( iface
);
66 if ( !This
|| !This
->node
)
68 if ( type
&& This
->node
->type
!= type
)
73 BOOL
node_query_interface(xmlnode
*This
, REFIID riid
, void **ppv
)
75 if(IsEqualGUID(&IID_xmlnode
, riid
)) {
76 TRACE("(%p)->(IID_xmlnode %p)\n", This
, ppv
);
81 return dispex_query_interface(&This
->dispex
, riid
, ppv
);
84 /* common ISupportErrorInfo implementation */
86 ISupportErrorInfo ISupportErrorInfo_iface
;
92 static inline SupportErrorInfo
*impl_from_ISupportErrorInfo(ISupportErrorInfo
*iface
)
94 return CONTAINING_RECORD(iface
, SupportErrorInfo
, ISupportErrorInfo_iface
);
97 static HRESULT WINAPI
SupportErrorInfo_QueryInterface(ISupportErrorInfo
*iface
, REFIID riid
, void **obj
)
99 SupportErrorInfo
*This
= impl_from_ISupportErrorInfo(iface
);
100 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), obj
);
104 if (IsEqualGUID(riid
, &IID_IUnknown
) || IsEqualGUID(riid
, &IID_ISupportErrorInfo
)) {
106 ISupportErrorInfo_AddRef(iface
);
110 return E_NOINTERFACE
;
113 static ULONG WINAPI
SupportErrorInfo_AddRef(ISupportErrorInfo
*iface
)
115 SupportErrorInfo
*This
= impl_from_ISupportErrorInfo(iface
);
116 ULONG ref
= InterlockedIncrement(&This
->ref
);
117 TRACE("(%p)->(%d)\n", This
, ref
);
121 static ULONG WINAPI
SupportErrorInfo_Release(ISupportErrorInfo
*iface
)
123 SupportErrorInfo
*This
= impl_from_ISupportErrorInfo(iface
);
124 LONG ref
= InterlockedDecrement(&This
->ref
);
126 TRACE("(%p)->(%d)\n", This
, ref
);
134 static HRESULT WINAPI
SupportErrorInfo_InterfaceSupportsErrorInfo(ISupportErrorInfo
*iface
, REFIID riid
)
136 SupportErrorInfo
*This
= impl_from_ISupportErrorInfo(iface
);
137 enum tid_t
const *tid
;
139 TRACE("(%p)->(%s)\n", This
, debugstr_guid(riid
));
142 while (*tid
!= NULL_tid
)
144 if (IsEqualGUID(riid
, get_riid_from_tid(*tid
)))
152 static const struct ISupportErrorInfoVtbl SupportErrorInfoVtbl
= {
153 SupportErrorInfo_QueryInterface
,
154 SupportErrorInfo_AddRef
,
155 SupportErrorInfo_Release
,
156 SupportErrorInfo_InterfaceSupportsErrorInfo
159 HRESULT
node_create_supporterrorinfo(enum tid_t
const *iids
, void **obj
)
161 SupportErrorInfo
*This
;
163 This
= heap_alloc(sizeof(*This
));
164 if (!This
) return E_OUTOFMEMORY
;
166 This
->ISupportErrorInfo_iface
.lpVtbl
= &SupportErrorInfoVtbl
;
170 *obj
= &This
->ISupportErrorInfo_iface
;
175 xmlnode
*get_node_obj(IXMLDOMNode
*node
)
180 hres
= IXMLDOMNode_QueryInterface(node
, &IID_xmlnode
, (void**)&obj
);
181 if (!obj
) WARN("node is not our IXMLDOMNode implementation\n");
182 return SUCCEEDED(hres
) ? obj
: NULL
;
185 HRESULT
node_get_nodeName(xmlnode
*This
, BSTR
*name
)
193 hr
= node_get_base_name(This
, &base
);
194 if (hr
!= S_OK
) return hr
;
196 hr
= node_get_prefix(This
, &prefix
);
199 static const WCHAR colW
= ':';
203 ptr
= *name
= SysAllocStringLen(NULL
, SysStringLen(base
) + SysStringLen(prefix
) + 1);
204 memcpy(ptr
, prefix
, SysStringByteLen(prefix
));
205 ptr
+= SysStringLen(prefix
);
206 memcpy(ptr
++, &colW
, sizeof(WCHAR
));
207 memcpy(ptr
, base
, SysStringByteLen(base
));
210 SysFreeString(prefix
);
218 HRESULT
node_get_content(xmlnode
*This
, VARIANT
*value
)
225 content
= xmlNodeGetContent(This
->node
);
226 V_VT(value
) = VT_BSTR
;
227 V_BSTR(value
) = bstr_from_xmlChar( content
);
230 TRACE("%p returned %s\n", This
, debugstr_w(V_BSTR(value
)));
234 HRESULT
node_set_content(xmlnode
*This
, LPCWSTR value
)
238 TRACE("(%p)->(%s)\n", This
, debugstr_w(value
));
239 str
= xmlchar_from_wchar(value
);
241 return E_OUTOFMEMORY
;
243 xmlNodeSetContent(This
->node
, str
);
248 static HRESULT
node_set_content_escaped(xmlnode
*This
, LPCWSTR value
)
250 xmlChar
*str
, *escaped
;
252 TRACE("(%p)->(%s)\n", This
, debugstr_w(value
));
253 str
= xmlchar_from_wchar(value
);
255 return E_OUTOFMEMORY
;
257 escaped
= xmlEncodeSpecialChars(NULL
, str
);
261 return E_OUTOFMEMORY
;
264 xmlNodeSetContent(This
->node
, escaped
);
272 HRESULT
node_put_value(xmlnode
*This
, VARIANT
*value
)
276 if (V_VT(value
) != VT_BSTR
)
278 VARIANT string_value
;
280 VariantInit(&string_value
);
281 hr
= VariantChangeType(&string_value
, value
, 0, VT_BSTR
);
283 WARN("Couldn't convert to VT_BSTR\n");
287 hr
= node_set_content(This
, V_BSTR(&string_value
));
288 VariantClear(&string_value
);
291 hr
= node_set_content(This
, V_BSTR(value
));
296 HRESULT
node_put_value_escaped(xmlnode
*This
, VARIANT
*value
)
300 if (V_VT(value
) != VT_BSTR
)
302 VARIANT string_value
;
304 VariantInit(&string_value
);
305 hr
= VariantChangeType(&string_value
, value
, 0, VT_BSTR
);
307 WARN("Couldn't convert to VT_BSTR\n");
311 hr
= node_set_content_escaped(This
, V_BSTR(&string_value
));
312 VariantClear(&string_value
);
315 hr
= node_set_content_escaped(This
, V_BSTR(value
));
320 static HRESULT
get_node(
326 TRACE("(%p)->(%s %p %p)\n", This
, name
, node
, out
);
331 /* if we don't have a doc, use our parent. */
332 if(node
&& !node
->doc
&& node
->parent
)
333 node
->doc
= node
->parent
->doc
;
335 *out
= create_node( node
);
341 HRESULT
node_get_parent(xmlnode
*This
, IXMLDOMNode
**parent
)
343 return get_node( This
, "parent", This
->node
->parent
, parent
);
346 HRESULT
node_get_child_nodes(xmlnode
*This
, IXMLDOMNodeList
**ret
)
351 *ret
= create_children_nodelist(This
->node
);
353 return E_OUTOFMEMORY
;
358 HRESULT
node_get_first_child(xmlnode
*This
, IXMLDOMNode
**ret
)
360 return get_node(This
, "firstChild", This
->node
->children
, ret
);
363 HRESULT
node_get_last_child(xmlnode
*This
, IXMLDOMNode
**ret
)
365 return get_node(This
, "lastChild", This
->node
->last
, ret
);
368 HRESULT
node_get_previous_sibling(xmlnode
*This
, IXMLDOMNode
**ret
)
370 return get_node(This
, "previous", This
->node
->prev
, ret
);
373 HRESULT
node_get_next_sibling(xmlnode
*This
, IXMLDOMNode
**ret
)
375 return get_node(This
, "next", This
->node
->next
, ret
);
378 static int node_get_inst_cnt(xmlNodePtr node
)
380 int ret
= *(LONG
*)&node
->_private
;
383 /* add attribute counts */
384 if (node
->type
== XML_ELEMENT_NODE
)
386 xmlAttrPtr prop
= node
->properties
;
390 ret
+= node_get_inst_cnt((xmlNodePtr
)prop
);
395 /* add children counts */
396 child
= node
->children
;
399 ret
+= node_get_inst_cnt(child
);
406 int xmlnode_get_inst_cnt(xmlnode
*node
)
408 return node_get_inst_cnt(node
->node
);
411 HRESULT
node_insert_before(xmlnode
*This
, IXMLDOMNode
*new_child
, const VARIANT
*ref_child
,
414 IXMLDOMNode
*before
= NULL
;
423 node_obj
= get_node_obj(new_child
);
424 if(!node_obj
) return E_FAIL
;
426 switch(V_VT(ref_child
))
434 if (V_UNKNOWN(ref_child
))
436 hr
= IUnknown_QueryInterface(V_UNKNOWN(ref_child
), &IID_IXMLDOMNode
, (void**)&before
);
437 if(FAILED(hr
)) return hr
;
442 FIXME("refChild var type %x\n", V_VT(ref_child
));
446 TRACE("new child %p, This->node %p\n", node_obj
->node
, This
->node
);
448 if(!node_obj
->node
->parent
)
449 if(xmldoc_remove_orphan(node_obj
->node
->doc
, node_obj
->node
) != S_OK
)
450 WARN("%p is not an orphan of %p\n", node_obj
->node
, node_obj
->node
->doc
);
452 refcount
= xmlnode_get_inst_cnt(node_obj
);
456 xmlnode
*before_node_obj
= get_node_obj(before
);
457 IXMLDOMNode_Release(before
);
458 if(!before_node_obj
) return E_FAIL
;
460 /* unlink from current parent first */
463 hr
= IXMLDOMNode_removeChild(node_obj
->parent
, node_obj
->iface
, NULL
);
464 if (hr
== S_OK
) xmldoc_remove_orphan(node_obj
->node
->doc
, node_obj
->node
);
467 doc
= node_obj
->node
->doc
;
469 /* refs count including subtree */
470 if (doc
!= before_node_obj
->node
->doc
)
471 refcount
= xmlnode_get_inst_cnt(node_obj
);
473 if (refcount
) xmldoc_add_refs(before_node_obj
->node
->doc
, refcount
);
474 xmlAddPrevSibling(before_node_obj
->node
, node_obj
->node
);
475 if (refcount
) xmldoc_release_refs(doc
, refcount
);
476 node_obj
->parent
= This
->parent
;
480 /* unlink from current parent first */
483 hr
= IXMLDOMNode_removeChild(node_obj
->parent
, node_obj
->iface
, NULL
);
484 if (hr
== S_OK
) xmldoc_remove_orphan(node_obj
->node
->doc
, node_obj
->node
);
486 doc
= node_obj
->node
->doc
;
488 if (doc
!= This
->node
->doc
)
489 refcount
= xmlnode_get_inst_cnt(node_obj
);
491 if (refcount
) xmldoc_add_refs(This
->node
->doc
, refcount
);
492 /* xmlAddChild doesn't unlink node from previous parent */
493 xmlUnlinkNode(node_obj
->node
);
494 xmlAddChild(This
->node
, node_obj
->node
);
495 if (refcount
) xmldoc_release_refs(doc
, refcount
);
496 node_obj
->parent
= This
->iface
;
501 IXMLDOMNode_AddRef(new_child
);
509 HRESULT
node_replace_child(xmlnode
*This
, IXMLDOMNode
*newChild
, IXMLDOMNode
*oldChild
,
512 xmlnode
*old_child
, *new_child
;
513 xmlDocPtr leaving_doc
;
514 xmlNode
*my_ancestor
;
517 /* Do not believe any documentation telling that newChild == NULL
518 means removal. It does certainly *not* apply to msxml3! */
519 if(!newChild
|| !oldChild
)
525 old_child
= get_node_obj(oldChild
);
526 if(!old_child
) return E_FAIL
;
528 if(old_child
->node
->parent
!= This
->node
)
530 WARN("childNode %p is not a child of %p\n", oldChild
, This
);
534 new_child
= get_node_obj(newChild
);
535 if(!new_child
) return E_FAIL
;
537 my_ancestor
= This
->node
;
540 if(my_ancestor
== new_child
->node
)
542 WARN("tried to create loop\n");
545 my_ancestor
= my_ancestor
->parent
;
548 if(!new_child
->node
->parent
)
549 if(xmldoc_remove_orphan(new_child
->node
->doc
, new_child
->node
) != S_OK
)
550 WARN("%p is not an orphan of %p\n", new_child
->node
, new_child
->node
->doc
);
552 leaving_doc
= new_child
->node
->doc
;
554 if (leaving_doc
!= old_child
->node
->doc
)
555 refcount
= xmlnode_get_inst_cnt(new_child
);
557 if (refcount
) xmldoc_add_refs(old_child
->node
->doc
, refcount
);
558 xmlReplaceNode(old_child
->node
, new_child
->node
);
559 if (refcount
) xmldoc_release_refs(leaving_doc
, refcount
);
560 new_child
->parent
= old_child
->parent
;
561 old_child
->parent
= NULL
;
563 xmldoc_add_orphan(old_child
->node
->doc
, old_child
->node
);
567 IXMLDOMNode_AddRef(oldChild
);
574 HRESULT
node_remove_child(xmlnode
*This
, IXMLDOMNode
* child
, IXMLDOMNode
** oldChild
)
578 if(!child
) return E_INVALIDARG
;
583 child_node
= get_node_obj(child
);
584 if(!child_node
) return E_FAIL
;
586 if(child_node
->node
->parent
!= This
->node
)
588 WARN("childNode %p is not a child of %p\n", child
, This
);
592 xmlUnlinkNode(child_node
->node
);
593 child_node
->parent
= NULL
;
594 xmldoc_add_orphan(child_node
->node
->doc
, child_node
->node
);
598 IXMLDOMNode_AddRef(child
);
605 HRESULT
node_append_child(xmlnode
*This
, IXMLDOMNode
*child
, IXMLDOMNode
**outChild
)
614 hr
= IXMLDOMNode_get_nodeType(child
, &type
);
615 if(FAILED(hr
) || type
== NODE_ATTRIBUTE
) {
616 if (outChild
) *outChild
= NULL
;
621 return IXMLDOMNode_insertBefore(This
->iface
, child
, var
, outChild
);
624 HRESULT
node_has_childnodes(const xmlnode
*This
, VARIANT_BOOL
*ret
)
626 if (!ret
) return E_INVALIDARG
;
628 if (!This
->node
->children
)
630 *ret
= VARIANT_FALSE
;
638 HRESULT
node_get_owner_doc(const xmlnode
*This
, IXMLDOMDocument
**doc
)
640 return get_domdoc_from_xmldoc(This
->node
->doc
, (IXMLDOMDocument3
**)doc
);
643 HRESULT
node_clone(xmlnode
*This
, VARIANT_BOOL deep
, IXMLDOMNode
**cloneNode
)
648 if(!cloneNode
) return E_INVALIDARG
;
650 clone
= xmlCopyNode(This
->node
, deep
? 1 : 2);
653 xmlSetTreeDoc(clone
, This
->node
->doc
);
654 xmldoc_add_orphan(clone
->doc
, clone
);
656 node
= create_node(clone
);
659 ERR("Copy failed\n");
660 xmldoc_remove_orphan(clone
->doc
, clone
);
669 ERR("Copy failed\n");
676 static inline xmlChar
* trim_whitespace(xmlChar
* str
)
684 while (*ret
&& isspace(*ret
))
686 len
= xmlStrlen(ret
);
688 while (isspace(ret
[len
-1])) --len
;
690 ret
= xmlStrndup(ret
, len
);
695 static xmlChar
* do_get_text(xmlNodePtr node
)
699 BOOL preserving
= is_preserving_whitespace(node
);
703 str
= xmlNodeGetContent(node
);
707 xmlElementType prev_type
= XML_TEXT_NODE
;
709 str
= xmlStrdup(BAD_CAST
"");
710 for (child
= node
->children
; child
!= NULL
; child
= child
->next
)
714 case XML_ELEMENT_NODE
:
715 tmp
= do_get_text(child
);
718 case XML_CDATA_SECTION_NODE
:
719 case XML_ENTITY_REF_NODE
:
720 case XML_ENTITY_NODE
:
721 tmp
= xmlNodeGetContent(child
);
732 if (prev_type
== XML_ELEMENT_NODE
&& child
->type
== XML_ELEMENT_NODE
)
733 str
= xmlStrcat(str
, BAD_CAST
" ");
734 str
= xmlStrcat(str
, tmp
);
735 prev_type
= child
->type
;
744 case XML_ELEMENT_NODE
:
746 case XML_ENTITY_REF_NODE
:
747 case XML_ENTITY_NODE
:
748 case XML_DOCUMENT_NODE
:
749 case XML_DOCUMENT_FRAG_NODE
:
751 str
= trim_whitespace(str
);
760 HRESULT
node_get_text(const xmlnode
*This
, BSTR
*text
)
765 if (!text
) return E_INVALIDARG
;
767 content
= do_get_text(This
->node
);
770 str
= bstr_from_xmlChar(content
);
774 /* Always return a string. */
775 if (!str
) str
= SysAllocStringLen( NULL
, 0 );
777 TRACE("%p %s\n", This
, debugstr_w(str
) );
783 HRESULT
node_put_text(xmlnode
*This
, BSTR text
)
787 TRACE("(%p)->(%s)\n", This
, debugstr_w(text
));
789 str
= xmlchar_from_wchar(text
);
791 /* Escape the string. */
792 str2
= xmlEncodeEntitiesReentrant(This
->node
->doc
, str
);
795 xmlNodeSetContent(This
->node
, str2
);
801 BSTR
EnsureCorrectEOL(BSTR sInput
)
808 nLen
= SysStringLen(sInput
);
809 /* Count line endings */
810 for(i
=0; i
< nLen
; i
++)
812 if(sInput
[i
] == '\n')
816 TRACE("len=%d, num=%d\n", nLen
, nNum
);
818 /* Add linefeed as needed */
822 sNew
= SysAllocStringLen(NULL
, nLen
+ nNum
);
823 for(i
=0; i
< nLen
; i
++)
825 if(sInput
[i
] == '\n')
827 sNew
[i
+nPlace
] = '\r';
830 sNew
[i
+nPlace
] = sInput
[i
];
833 SysFreeString(sInput
);
840 TRACE("len %d\n", SysStringLen(sNew
));
846 * We are trying to replicate the same behaviour as msxml by converting
847 * line endings to \r\n and using indents as \t. The problem is that msxml
848 * only formats nodes that have a line ending. Using libxml we cannot
849 * reproduce behaviour exactly.
852 HRESULT
node_get_xml(xmlnode
*This
, BOOL ensure_eol
, BSTR
*ret
)
854 xmlBufferPtr xml_buf
;
863 xml_buf
= xmlBufferCreate();
865 return E_OUTOFMEMORY
;
867 xmldecl
= xmldoc_unlink_xmldecl( This
->node
->doc
);
869 size
= xmlNodeDump(xml_buf
, This
->node
->doc
, This
->node
, 0, 1);
871 const xmlChar
*buf_content
;
874 /* Attribute Nodes return a space in front of their name */
875 buf_content
= xmlBufferContent(xml_buf
);
877 content
= bstr_from_xmlChar(buf_content
+ (buf_content
[0] == ' ' ? 1 : 0));
879 content
= EnsureCorrectEOL(content
);
883 *ret
= SysAllocStringLen(NULL
, 0);
886 xmlBufferFree(xml_buf
);
887 xmldoc_link_xmldecl( This
->node
->doc
, xmldecl
);
888 return *ret
? S_OK
: E_OUTOFMEMORY
;
891 #ifdef SONAME_LIBXSLT
893 /* duplicates xmlBufferWriteQuotedString() logic */
894 static void xml_write_quotedstring(xmlOutputBufferPtr buf
, const xmlChar
*string
)
896 const xmlChar
*cur
, *base
;
898 if (xmlStrchr(string
, '\"'))
900 if (xmlStrchr(string
, '\''))
902 xmlOutputBufferWrite(buf
, 1, "\"");
910 xmlOutputBufferWrite(buf
, cur
-base
, (const char*)base
);
911 xmlOutputBufferWrite(buf
, 6, """);
919 xmlOutputBufferWrite(buf
, cur
-base
, (const char*)base
);
920 xmlOutputBufferWrite(buf
, 1, "\"");
924 xmlOutputBufferWrite(buf
, 1, "\'");
925 xmlOutputBufferWriteString(buf
, (const char*)string
);
926 xmlOutputBufferWrite(buf
, 1, "\'");
931 xmlOutputBufferWrite(buf
, 1, "\"");
932 xmlOutputBufferWriteString(buf
, (const char*)string
);
933 xmlOutputBufferWrite(buf
, 1, "\"");
937 static int XMLCALL
transform_to_stream_write(void *context
, const char *buffer
, int len
)
940 HRESULT hr
= IStream_Write((IStream
*)context
, buffer
, len
, &written
);
941 return hr
== S_OK
? written
: -1;
944 /* Output for method "text" */
945 static void transform_write_text(xmlDocPtr result
, xsltStylesheetPtr style
, xmlOutputBufferPtr output
)
947 xmlNodePtr cur
= result
->children
;
950 if (cur
->type
== XML_TEXT_NODE
)
951 xmlOutputBufferWriteString(output
, (const char*)cur
->content
);
953 /* skip to next node */
956 if ((cur
->children
->type
!= XML_ENTITY_DECL
) &&
957 (cur
->children
->type
!= XML_ENTITY_REF_NODE
) &&
958 (cur
->children
->type
!= XML_ENTITY_NODE
))
975 if (cur
== (xmlNodePtr
) style
->doc
) {
987 #undef XSLT_GET_IMPORT_PTR
988 #define XSLT_GET_IMPORT_PTR(res, style, name) { \
989 xsltStylesheetPtr st = style; \
991 while (st != NULL) { \
992 if (st->name != NULL) { res = st->name; break; } \
993 st = pxsltNextImport(st); \
996 #undef XSLT_GET_IMPORT_INT
997 #define XSLT_GET_IMPORT_INT(res, style, name) { \
998 xsltStylesheetPtr st = style; \
1000 while (st != NULL) { \
1001 if (st->name != -1) { res = st->name; break; } \
1002 st = pxsltNextImport(st); \
1005 static void transform_write_xmldecl(xmlDocPtr result
, xsltStylesheetPtr style
, BOOL omit_encoding
, xmlOutputBufferPtr output
)
1007 int omit_xmldecl
, standalone
;
1009 XSLT_GET_IMPORT_INT(omit_xmldecl
, style
, omitXmlDeclaration
);
1010 if (omit_xmldecl
== 1) return;
1012 XSLT_GET_IMPORT_INT(standalone
, style
, standalone
);
1014 xmlOutputBufferWriteString(output
, "<?xml version=");
1015 if (result
->version
)
1017 xmlOutputBufferWriteString(output
, "\"");
1018 xmlOutputBufferWriteString(output
, (const char *)result
->version
);
1019 xmlOutputBufferWriteString(output
, "\"");
1022 xmlOutputBufferWriteString(output
, "\"1.0\"");
1026 const xmlChar
*encoding
;
1028 /* default encoding is UTF-16 */
1029 XSLT_GET_IMPORT_PTR(encoding
, style
, encoding
);
1030 xmlOutputBufferWriteString(output
, " encoding=");
1031 xmlOutputBufferWriteString(output
, "\"");
1032 xmlOutputBufferWriteString(output
, encoding
? (const char *)encoding
: "UTF-16");
1033 xmlOutputBufferWriteString(output
, "\"");
1036 /* standalone attribute */
1037 if (standalone
!= -1)
1038 xmlOutputBufferWriteString(output
, standalone
== 0 ? " standalone=\"no\"" : " standalone=\"yes\"");
1040 xmlOutputBufferWriteString(output
, "?>");
1043 static void htmldtd_dumpcontent(xmlOutputBufferPtr buf
, xmlDocPtr doc
)
1045 xmlDtdPtr cur
= doc
->intSubset
;
1047 xmlOutputBufferWriteString(buf
, "<!DOCTYPE ");
1048 xmlOutputBufferWriteString(buf
, (const char *)cur
->name
);
1049 if (cur
->ExternalID
)
1051 xmlOutputBufferWriteString(buf
, " PUBLIC ");
1052 xml_write_quotedstring(buf
, cur
->ExternalID
);
1055 xmlOutputBufferWriteString(buf
, " ");
1056 xml_write_quotedstring(buf
, cur
->SystemID
);
1059 else if (cur
->SystemID
)
1061 xmlOutputBufferWriteString(buf
, " SYSTEM ");
1062 xml_write_quotedstring(buf
, cur
->SystemID
);
1064 xmlOutputBufferWriteString(buf
, ">\n");
1067 /* Duplicates htmlDocContentDumpFormatOutput() the way we need it - doesn't add trailing newline. */
1068 static void htmldoc_dumpcontent(xmlOutputBufferPtr buf
, xmlDocPtr doc
, const char *encoding
, int format
)
1070 xmlElementType type
;
1072 /* force HTML output */
1074 doc
->type
= XML_HTML_DOCUMENT_NODE
;
1076 htmldtd_dumpcontent(buf
, doc
);
1077 if (doc
->children
) {
1078 xmlNodePtr cur
= doc
->children
;
1080 htmlNodeDumpFormatOutput(buf
, doc
, cur
, encoding
, format
);
1087 static inline BOOL
transform_is_empty_resultdoc(xmlDocPtr result
)
1089 return !result
->children
|| ((result
->children
->type
== XML_DTD_NODE
) && !result
->children
->next
);
1092 static inline BOOL
transform_is_valid_method(xsltStylesheetPtr style
)
1094 return !style
->methodURI
|| !(style
->method
&& xmlStrEqual(style
->method
, (const xmlChar
*)"xhtml"));
1097 /* Helper to write transformation result to specified output buffer. */
1098 static HRESULT
node_transform_write(xsltStylesheetPtr style
, xmlDocPtr result
, BOOL omit_encoding
, const char *encoding
, xmlOutputBufferPtr output
)
1100 const xmlChar
*method
;
1103 if (!transform_is_valid_method(style
))
1105 ERR("unknown output method\n");
1109 XSLT_GET_IMPORT_PTR(method
, style
, method
)
1110 XSLT_GET_IMPORT_INT(indent
, style
, indent
);
1112 if (!method
&& (result
->type
== XML_HTML_DOCUMENT_NODE
))
1113 method
= (const xmlChar
*) "html";
1115 if (method
&& xmlStrEqual(method
, (const xmlChar
*)"html"))
1117 htmlSetMetaEncoding(result
, (const xmlChar
*)encoding
);
1120 htmldoc_dumpcontent(output
, result
, (const char*)encoding
, indent
);
1122 else if (method
&& xmlStrEqual(method
, (const xmlChar
*)"xhtml"))
1124 htmlSetMetaEncoding(result
, (const xmlChar
*) encoding
);
1125 htmlDocContentDumpOutput(output
, result
, encoding
);
1127 else if (method
&& xmlStrEqual(method
, (const xmlChar
*)"text"))
1128 transform_write_text(result
, style
, output
);
1131 transform_write_xmldecl(result
, style
, omit_encoding
, output
);
1133 if (result
->children
)
1135 xmlNodePtr child
= result
->children
;
1139 xmlNodeDumpOutput(output
, result
, child
, 0, indent
== 1, encoding
);
1140 if (indent
&& ((child
->type
== XML_DTD_NODE
) || ((child
->type
== XML_COMMENT_NODE
) && child
->next
)))
1141 xmlOutputBufferWriteString(output
, "\r\n");
1142 child
= child
->next
;
1147 xmlOutputBufferFlush(output
);
1151 /* For BSTR output is always UTF-16, without 'encoding' attribute */
1152 static HRESULT
node_transform_write_to_bstr(xsltStylesheetPtr style
, xmlDocPtr result
, BSTR
*str
)
1156 if (transform_is_empty_resultdoc(result
))
1157 *str
= SysAllocStringLen(NULL
, 0);
1160 xmlOutputBufferPtr output
= xmlAllocOutputBuffer(xmlFindCharEncodingHandler("UTF-16"));
1161 const xmlChar
*content
;
1166 return E_OUTOFMEMORY
;
1168 hr
= node_transform_write(style
, result
, TRUE
, "UTF-16", output
);
1169 #ifdef LIBXML2_NEW_BUFFER
1170 content
= xmlBufContent(output
->conv
);
1171 len
= xmlBufUse(output
->conv
);
1173 content
= xmlBufferContent(output
->conv
);
1174 len
= xmlBufferLength(output
->conv
);
1176 /* UTF-16 encoder places UTF-16 bom, we don't need it for BSTR */
1177 content
+= sizeof(WCHAR
);
1178 *str
= SysAllocStringLen((WCHAR
*)content
, len
/sizeof(WCHAR
) - 1);
1179 xmlOutputBufferClose(output
);
1182 return *str
? hr
: E_OUTOFMEMORY
;
1185 static HRESULT
node_transform_write_to_stream(xsltStylesheetPtr style
, xmlDocPtr result
, IStream
*stream
)
1187 static const xmlChar
*utf16
= (const xmlChar
*)"UTF-16";
1188 xmlOutputBufferPtr output
;
1189 const xmlChar
*encoding
;
1192 if (transform_is_empty_resultdoc(result
))
1194 WARN("empty result document\n");
1198 if (style
->methodURI
&& (!style
->method
|| !xmlStrEqual(style
->method
, (const xmlChar
*) "xhtml")))
1200 ERR("unknown output method\n");
1204 /* default encoding is UTF-16 */
1205 XSLT_GET_IMPORT_PTR(encoding
, style
, encoding
);
1209 output
= xmlOutputBufferCreateIO(transform_to_stream_write
, NULL
, stream
, xmlFindCharEncodingHandler((const char*)encoding
));
1211 return E_OUTOFMEMORY
;
1213 hr
= node_transform_write(style
, result
, FALSE
, (const char*)encoding
, output
);
1214 xmlOutputBufferClose(output
);
1220 HRESULT
node_transform_node_params(const xmlnode
*This
, IXMLDOMNode
*stylesheet
, BSTR
*p
,
1221 IStream
*stream
, const struct xslprocessor_params
*params
)
1223 #ifdef SONAME_LIBXSLT
1224 xsltStylesheetPtr xsltSS
;
1228 if (!libxslt_handle
) return E_NOTIMPL
;
1229 if (!stylesheet
|| !p
) return E_INVALIDARG
;
1233 sheet
= get_node_obj(stylesheet
);
1234 if(!sheet
) return E_FAIL
;
1236 xsltSS
= pxsltParseStylesheetDoc(sheet
->node
->doc
);
1239 const char **xslparams
= NULL
;
1243 /* convert our parameter list to libxml2 format */
1244 if (params
&& params
->count
)
1246 struct xslprocessor_par
*par
;
1249 xslparams
= heap_alloc((params
->count
*2 + 1)*sizeof(char*));
1250 LIST_FOR_EACH_ENTRY(par
, ¶ms
->list
, struct xslprocessor_par
, entry
)
1252 xslparams
[i
++] = (char*)xmlchar_from_wchar(par
->name
);
1253 xslparams
[i
++] = (char*)xmlchar_from_wchar(par
->value
);
1255 xslparams
[i
] = NULL
;
1260 xsltTransformContextPtr ctxt
= pxsltNewTransformContext(xsltSS
, This
->node
->doc
);
1262 /* push parameters to user context */
1263 pxsltQuoteUserParams(ctxt
, xslparams
);
1264 result
= pxsltApplyStylesheetUser(xsltSS
, This
->node
->doc
, NULL
, NULL
, NULL
, ctxt
);
1265 pxsltFreeTransformContext(ctxt
);
1267 for (i
= 0; i
< params
->count
*2; i
++)
1268 heap_free((char*)xslparams
[i
]);
1269 heap_free(xslparams
);
1272 result
= pxsltApplyStylesheet(xsltSS
, This
->node
->doc
, NULL
);
1277 hr
= node_transform_write_to_stream(xsltSS
, result
, stream
);
1279 hr
= node_transform_write_to_bstr(xsltSS
, result
, p
);
1282 /* libxslt "helpfully" frees the XML document the stylesheet was
1283 generated from, too */
1285 pxsltFreeStylesheet(xsltSS
);
1288 if(!*p
) *p
= SysAllocStringLen(NULL
, 0);
1292 FIXME("libxslt headers were not found at compile time\n");
1297 HRESULT
node_transform_node(const xmlnode
*node
, IXMLDOMNode
*stylesheet
, BSTR
*p
)
1299 return node_transform_node_params(node
, stylesheet
, p
, NULL
, NULL
);
1302 HRESULT
node_select_nodes(const xmlnode
*This
, BSTR query
, IXMLDOMNodeList
**nodes
)
1307 if (!query
|| !nodes
) return E_INVALIDARG
;
1309 str
= xmlchar_from_wchar(query
);
1310 hr
= create_selection(This
->node
, str
, nodes
);
1316 HRESULT
node_select_singlenode(const xmlnode
*This
, BSTR query
, IXMLDOMNode
**node
)
1318 IXMLDOMNodeList
*list
;
1321 hr
= node_select_nodes(This
, query
, &list
);
1324 hr
= IXMLDOMNodeList_nextNode(list
, node
);
1325 IXMLDOMNodeList_Release(list
);
1330 HRESULT
node_get_namespaceURI(xmlnode
*This
, BSTR
*namespaceURI
)
1332 xmlNsPtr ns
= This
->node
->ns
;
1335 return E_INVALIDARG
;
1337 *namespaceURI
= NULL
;
1340 *namespaceURI
= bstr_from_xmlChar(ns
->href
);
1342 TRACE("uri: %s\n", debugstr_w(*namespaceURI
));
1344 return *namespaceURI
? S_OK
: S_FALSE
;
1347 HRESULT
node_get_prefix(xmlnode
*This
, BSTR
*prefix
)
1349 xmlNsPtr ns
= This
->node
->ns
;
1351 if (!prefix
) return E_INVALIDARG
;
1355 if (ns
&& ns
->prefix
)
1356 *prefix
= bstr_from_xmlChar(ns
->prefix
);
1358 TRACE("prefix: %s\n", debugstr_w(*prefix
));
1360 return *prefix
? S_OK
: S_FALSE
;
1363 HRESULT
node_get_base_name(xmlnode
*This
, BSTR
*name
)
1365 if (!name
) return E_INVALIDARG
;
1367 *name
= bstr_from_xmlChar(This
->node
->name
);
1368 if (!*name
) return E_OUTOFMEMORY
;
1370 TRACE("returning %s\n", debugstr_w(*name
));
1375 /* _private field holds a number of COM instances spawned from this libxml2 node */
1376 static void xmlnode_add_ref(xmlNodePtr node
)
1378 if (node
->type
== XML_DOCUMENT_NODE
) return;
1379 InterlockedIncrement((LONG
*)&node
->_private
);
1382 static void xmlnode_release(xmlNodePtr node
)
1384 if (node
->type
== XML_DOCUMENT_NODE
) return;
1385 InterlockedDecrement((LONG
*)&node
->_private
);
1388 void destroy_xmlnode(xmlnode
*This
)
1392 xmlnode_release(This
->node
);
1393 xmldoc_release(This
->node
->doc
);
1397 void init_xmlnode(xmlnode
*This
, xmlNodePtr node
, IXMLDOMNode
*node_iface
, dispex_static_data_t
*dispex_data
)
1401 xmlnode_add_ref(node
);
1402 xmldoc_add_ref(node
->doc
);
1406 This
->iface
= node_iface
;
1407 This
->parent
= NULL
;
1409 init_dispex(&This
->dispex
, (IUnknown
*)This
->iface
, dispex_data
);
1414 IXMLDOMNode IXMLDOMNode_iface
;
1418 static inline unknode
*unknode_from_IXMLDOMNode(IXMLDOMNode
*iface
)
1420 return CONTAINING_RECORD(iface
, unknode
, IXMLDOMNode_iface
);
1423 static HRESULT WINAPI
unknode_QueryInterface(
1428 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1430 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppvObject
);
1432 if (IsEqualGUID(riid
, &IID_IUnknown
)) {
1434 }else if (IsEqualGUID( riid
, &IID_IDispatch
) ||
1435 IsEqualGUID( riid
, &IID_IXMLDOMNode
)) {
1436 *ppvObject
= &This
->IXMLDOMNode_iface
;
1437 }else if(node_query_interface(&This
->node
, riid
, ppvObject
)) {
1438 return *ppvObject
? S_OK
: E_NOINTERFACE
;
1440 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
1442 return E_NOINTERFACE
;
1445 IUnknown_AddRef((IUnknown
*)*ppvObject
);
1449 static ULONG WINAPI
unknode_AddRef(
1450 IXMLDOMNode
*iface
)
1452 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1454 return InterlockedIncrement(&This
->ref
);
1457 static ULONG WINAPI
unknode_Release(
1458 IXMLDOMNode
*iface
)
1460 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1463 ref
= InterlockedDecrement( &This
->ref
);
1465 destroy_xmlnode(&This
->node
);
1472 static HRESULT WINAPI
unknode_GetTypeInfoCount(
1476 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1478 TRACE("(%p)->(%p)\n", This
, pctinfo
);
1485 static HRESULT WINAPI
unknode_GetTypeInfo(
1489 ITypeInfo
** ppTInfo
)
1491 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1494 TRACE("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
1496 hr
= get_typeinfo(IXMLDOMNode_tid
, ppTInfo
);
1501 static HRESULT WINAPI
unknode_GetIDsOfNames(
1504 LPOLESTR
* rgszNames
,
1509 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1511 ITypeInfo
*typeinfo
;
1514 TRACE("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
1517 if(!rgszNames
|| cNames
== 0 || !rgDispId
)
1518 return E_INVALIDARG
;
1520 hr
= get_typeinfo(IXMLDOMNode_tid
, &typeinfo
);
1523 hr
= ITypeInfo_GetIDsOfNames(typeinfo
, rgszNames
, cNames
, rgDispId
);
1524 ITypeInfo_Release(typeinfo
);
1530 static HRESULT WINAPI
unknode_Invoke(
1532 DISPID dispIdMember
,
1536 DISPPARAMS
* pDispParams
,
1537 VARIANT
* pVarResult
,
1538 EXCEPINFO
* pExcepInfo
,
1541 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1542 ITypeInfo
*typeinfo
;
1545 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
1546 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
1548 hr
= get_typeinfo(IXMLDOMNode_tid
, &typeinfo
);
1551 hr
= ITypeInfo_Invoke(typeinfo
, &This
->IXMLDOMNode_iface
, dispIdMember
, wFlags
, pDispParams
,
1552 pVarResult
, pExcepInfo
, puArgErr
);
1553 ITypeInfo_Release(typeinfo
);
1559 static HRESULT WINAPI
unknode_get_nodeName(
1563 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1565 FIXME("(%p)->(%p)\n", This
, p
);
1567 return node_get_nodeName(&This
->node
, p
);
1570 static HRESULT WINAPI
unknode_get_nodeValue(
1574 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1576 FIXME("(%p)->(%p)\n", This
, value
);
1579 return E_INVALIDARG
;
1581 V_VT(value
) = VT_NULL
;
1585 static HRESULT WINAPI
unknode_put_nodeValue(
1589 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1590 FIXME("(%p)->(v%d)\n", This
, V_VT(&value
));
1594 static HRESULT WINAPI
unknode_get_nodeType(
1596 DOMNodeType
* domNodeType
)
1598 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1600 FIXME("(%p)->(%p)\n", This
, domNodeType
);
1602 *domNodeType
= This
->node
.node
->type
;
1606 static HRESULT WINAPI
unknode_get_parentNode(
1608 IXMLDOMNode
** parent
)
1610 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1611 FIXME("(%p)->(%p)\n", This
, parent
);
1612 if (!parent
) return E_INVALIDARG
;
1617 static HRESULT WINAPI
unknode_get_childNodes(
1619 IXMLDOMNodeList
** outList
)
1621 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1623 TRACE("(%p)->(%p)\n", This
, outList
);
1625 return node_get_child_nodes(&This
->node
, outList
);
1628 static HRESULT WINAPI
unknode_get_firstChild(
1630 IXMLDOMNode
** domNode
)
1632 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1634 TRACE("(%p)->(%p)\n", This
, domNode
);
1636 return node_get_first_child(&This
->node
, domNode
);
1639 static HRESULT WINAPI
unknode_get_lastChild(
1641 IXMLDOMNode
** domNode
)
1643 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1645 TRACE("(%p)->(%p)\n", This
, domNode
);
1647 return node_get_last_child(&This
->node
, domNode
);
1650 static HRESULT WINAPI
unknode_get_previousSibling(
1652 IXMLDOMNode
** domNode
)
1654 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1656 TRACE("(%p)->(%p)\n", This
, domNode
);
1658 return node_get_previous_sibling(&This
->node
, domNode
);
1661 static HRESULT WINAPI
unknode_get_nextSibling(
1663 IXMLDOMNode
** domNode
)
1665 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1667 TRACE("(%p)->(%p)\n", This
, domNode
);
1669 return node_get_next_sibling(&This
->node
, domNode
);
1672 static HRESULT WINAPI
unknode_get_attributes(
1674 IXMLDOMNamedNodeMap
** attributeMap
)
1676 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1678 FIXME("(%p)->(%p)\n", This
, attributeMap
);
1680 return return_null_ptr((void**)attributeMap
);
1683 static HRESULT WINAPI
unknode_insertBefore(
1685 IXMLDOMNode
* newNode
, VARIANT refChild
,
1686 IXMLDOMNode
** outOldNode
)
1688 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1690 FIXME("(%p)->(%p x%d %p)\n", This
, newNode
, V_VT(&refChild
), outOldNode
);
1692 return node_insert_before(&This
->node
, newNode
, &refChild
, outOldNode
);
1695 static HRESULT WINAPI
unknode_replaceChild(
1697 IXMLDOMNode
* newNode
,
1698 IXMLDOMNode
* oldNode
,
1699 IXMLDOMNode
** outOldNode
)
1701 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1703 FIXME("(%p)->(%p %p %p)\n", This
, newNode
, oldNode
, outOldNode
);
1705 return node_replace_child(&This
->node
, newNode
, oldNode
, outOldNode
);
1708 static HRESULT WINAPI
unknode_removeChild(
1710 IXMLDOMNode
* domNode
, IXMLDOMNode
** oldNode
)
1712 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1713 return node_remove_child(&This
->node
, domNode
, oldNode
);
1716 static HRESULT WINAPI
unknode_appendChild(
1718 IXMLDOMNode
* newNode
, IXMLDOMNode
** outNewNode
)
1720 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1721 return node_append_child(&This
->node
, newNode
, outNewNode
);
1724 static HRESULT WINAPI
unknode_hasChildNodes(
1726 VARIANT_BOOL
* pbool
)
1728 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1729 return node_has_childnodes(&This
->node
, pbool
);
1732 static HRESULT WINAPI
unknode_get_ownerDocument(
1734 IXMLDOMDocument
** domDocument
)
1736 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1737 return node_get_owner_doc(&This
->node
, domDocument
);
1740 static HRESULT WINAPI
unknode_cloneNode(
1742 VARIANT_BOOL pbool
, IXMLDOMNode
** outNode
)
1744 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1745 return node_clone(&This
->node
, pbool
, outNode
);
1748 static HRESULT WINAPI
unknode_get_nodeTypeString(
1752 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1754 FIXME("(%p)->(%p)\n", This
, p
);
1756 return node_get_nodeName(&This
->node
, p
);
1759 static HRESULT WINAPI
unknode_get_text(
1763 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1764 return node_get_text(&This
->node
, p
);
1767 static HRESULT WINAPI
unknode_put_text(
1771 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1772 return node_put_text(&This
->node
, p
);
1775 static HRESULT WINAPI
unknode_get_specified(
1777 VARIANT_BOOL
* isSpecified
)
1779 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1780 FIXME("(%p)->(%p) stub!\n", This
, isSpecified
);
1781 *isSpecified
= VARIANT_TRUE
;
1785 static HRESULT WINAPI
unknode_get_definition(
1787 IXMLDOMNode
** definitionNode
)
1789 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1790 FIXME("(%p)->(%p)\n", This
, definitionNode
);
1794 static HRESULT WINAPI
unknode_get_nodeTypedValue(
1798 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1799 FIXME("(%p)->(%p)\n", This
, var1
);
1800 return return_null_var(var1
);
1803 static HRESULT WINAPI
unknode_put_nodeTypedValue(
1807 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1808 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&typedValue
));
1812 static HRESULT WINAPI
unknode_get_dataType(
1816 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1817 TRACE("(%p)->(%p)\n", This
, var1
);
1818 return return_null_var(var1
);
1821 static HRESULT WINAPI
unknode_put_dataType(
1825 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1827 FIXME("(%p)->(%s)\n", This
, debugstr_w(p
));
1830 return E_INVALIDARG
;
1835 static HRESULT WINAPI
unknode_get_xml(
1839 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1841 FIXME("(%p)->(%p)\n", This
, p
);
1843 return node_get_xml(&This
->node
, FALSE
, p
);
1846 static HRESULT WINAPI
unknode_transformNode(
1848 IXMLDOMNode
* domNode
, BSTR
* p
)
1850 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1851 return node_transform_node(&This
->node
, domNode
, p
);
1854 static HRESULT WINAPI
unknode_selectNodes(
1856 BSTR p
, IXMLDOMNodeList
** outList
)
1858 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1859 return node_select_nodes(&This
->node
, p
, outList
);
1862 static HRESULT WINAPI
unknode_selectSingleNode(
1864 BSTR p
, IXMLDOMNode
** outNode
)
1866 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1867 return node_select_singlenode(&This
->node
, p
, outNode
);
1870 static HRESULT WINAPI
unknode_get_parsed(
1872 VARIANT_BOOL
* isParsed
)
1874 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1875 FIXME("(%p)->(%p) stub!\n", This
, isParsed
);
1876 *isParsed
= VARIANT_TRUE
;
1880 static HRESULT WINAPI
unknode_get_namespaceURI(
1884 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1885 TRACE("(%p)->(%p)\n", This
, p
);
1886 return node_get_namespaceURI(&This
->node
, p
);
1889 static HRESULT WINAPI
unknode_get_prefix(
1893 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1894 return node_get_prefix(&This
->node
, p
);
1897 static HRESULT WINAPI
unknode_get_baseName(
1901 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1902 return node_get_base_name(&This
->node
, p
);
1905 static HRESULT WINAPI
unknode_transformNodeToObject(
1907 IXMLDOMNode
* domNode
, VARIANT var1
)
1909 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1910 FIXME("(%p)->(%p %s)\n", This
, domNode
, debugstr_variant(&var1
));
1914 static const struct IXMLDOMNodeVtbl unknode_vtbl
=
1916 unknode_QueryInterface
,
1919 unknode_GetTypeInfoCount
,
1920 unknode_GetTypeInfo
,
1921 unknode_GetIDsOfNames
,
1923 unknode_get_nodeName
,
1924 unknode_get_nodeValue
,
1925 unknode_put_nodeValue
,
1926 unknode_get_nodeType
,
1927 unknode_get_parentNode
,
1928 unknode_get_childNodes
,
1929 unknode_get_firstChild
,
1930 unknode_get_lastChild
,
1931 unknode_get_previousSibling
,
1932 unknode_get_nextSibling
,
1933 unknode_get_attributes
,
1934 unknode_insertBefore
,
1935 unknode_replaceChild
,
1936 unknode_removeChild
,
1937 unknode_appendChild
,
1938 unknode_hasChildNodes
,
1939 unknode_get_ownerDocument
,
1941 unknode_get_nodeTypeString
,
1944 unknode_get_specified
,
1945 unknode_get_definition
,
1946 unknode_get_nodeTypedValue
,
1947 unknode_put_nodeTypedValue
,
1948 unknode_get_dataType
,
1949 unknode_put_dataType
,
1951 unknode_transformNode
,
1952 unknode_selectNodes
,
1953 unknode_selectSingleNode
,
1955 unknode_get_namespaceURI
,
1957 unknode_get_baseName
,
1958 unknode_transformNodeToObject
1961 IXMLDOMNode
*create_node( xmlNodePtr node
)
1970 TRACE("type %d\n", node
->type
);
1973 case XML_ELEMENT_NODE
:
1974 pUnk
= create_element( node
);
1976 case XML_ATTRIBUTE_NODE
:
1977 pUnk
= create_attribute( node
);
1980 pUnk
= create_text( node
);
1982 case XML_CDATA_SECTION_NODE
:
1983 pUnk
= create_cdata( node
);
1985 case XML_ENTITY_REF_NODE
:
1986 pUnk
= create_doc_entity_ref( node
);
1989 pUnk
= create_pi( node
);
1991 case XML_COMMENT_NODE
:
1992 pUnk
= create_comment( node
);
1994 case XML_DOCUMENT_NODE
:
1995 pUnk
= create_domdoc( node
);
1997 case XML_DOCUMENT_FRAG_NODE
:
1998 pUnk
= create_doc_fragment( node
);
2001 pUnk
= create_doc_type( node
);
2006 FIXME("only creating basic node for type %d\n", node
->type
);
2008 new_node
= heap_alloc(sizeof(unknode
));
2012 new_node
->IXMLDOMNode_iface
.lpVtbl
= &unknode_vtbl
;
2014 init_xmlnode(&new_node
->node
, node
, &new_node
->IXMLDOMNode_iface
, NULL
);
2015 pUnk
= (IUnknown
*)&new_node
->IXMLDOMNode_iface
;
2019 hr
= IUnknown_QueryInterface(pUnk
, &IID_IXMLDOMNode
, (LPVOID
*)&ret
);
2020 IUnknown_Release(pUnk
);
2021 if(FAILED(hr
)) return NULL
;