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
);
56 WINE_DECLARE_DEBUG_CHANNEL(winediag
);
59 static const IID IID_xmlnode
= {0x4f2f4ba2,0xb822,0x11df,{0x8b,0x8a,0x68,0x50,0xdf,0xd7,0x20,0x85}};
61 xmlNodePtr
xmlNodePtr_from_domnode( IXMLDOMNode
*iface
, xmlElementType type
)
67 This
= get_node_obj( iface
);
68 if ( !This
|| !This
->node
)
70 if ( type
&& This
->node
->type
!= type
)
75 BOOL
node_query_interface(xmlnode
*This
, REFIID riid
, void **ppv
)
77 if(IsEqualGUID(&IID_xmlnode
, riid
)) {
78 TRACE("(%p)->(IID_xmlnode %p)\n", This
, ppv
);
83 return dispex_query_interface(&This
->dispex
, riid
, ppv
);
86 /* common ISupportErrorInfo implementation */
88 ISupportErrorInfo ISupportErrorInfo_iface
;
94 static inline SupportErrorInfo
*impl_from_ISupportErrorInfo(ISupportErrorInfo
*iface
)
96 return CONTAINING_RECORD(iface
, SupportErrorInfo
, ISupportErrorInfo_iface
);
99 static HRESULT WINAPI
SupportErrorInfo_QueryInterface(ISupportErrorInfo
*iface
, REFIID riid
, void **obj
)
101 SupportErrorInfo
*This
= impl_from_ISupportErrorInfo(iface
);
102 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), obj
);
106 if (IsEqualGUID(riid
, &IID_IUnknown
) || IsEqualGUID(riid
, &IID_ISupportErrorInfo
)) {
108 ISupportErrorInfo_AddRef(iface
);
112 return E_NOINTERFACE
;
115 static ULONG WINAPI
SupportErrorInfo_AddRef(ISupportErrorInfo
*iface
)
117 SupportErrorInfo
*This
= impl_from_ISupportErrorInfo(iface
);
118 ULONG ref
= InterlockedIncrement(&This
->ref
);
119 TRACE("(%p)->(%d)\n", This
, ref
);
123 static ULONG WINAPI
SupportErrorInfo_Release(ISupportErrorInfo
*iface
)
125 SupportErrorInfo
*This
= impl_from_ISupportErrorInfo(iface
);
126 LONG ref
= InterlockedDecrement(&This
->ref
);
128 TRACE("(%p)->(%d)\n", This
, ref
);
136 static HRESULT WINAPI
SupportErrorInfo_InterfaceSupportsErrorInfo(ISupportErrorInfo
*iface
, REFIID riid
)
138 SupportErrorInfo
*This
= impl_from_ISupportErrorInfo(iface
);
139 enum tid_t
const *tid
;
141 TRACE("(%p)->(%s)\n", This
, debugstr_guid(riid
));
144 while (*tid
!= NULL_tid
)
146 if (IsEqualGUID(riid
, get_riid_from_tid(*tid
)))
154 static const struct ISupportErrorInfoVtbl SupportErrorInfoVtbl
= {
155 SupportErrorInfo_QueryInterface
,
156 SupportErrorInfo_AddRef
,
157 SupportErrorInfo_Release
,
158 SupportErrorInfo_InterfaceSupportsErrorInfo
161 HRESULT
node_create_supporterrorinfo(enum tid_t
const *iids
, void **obj
)
163 SupportErrorInfo
*This
;
165 This
= heap_alloc(sizeof(*This
));
166 if (!This
) return E_OUTOFMEMORY
;
168 This
->ISupportErrorInfo_iface
.lpVtbl
= &SupportErrorInfoVtbl
;
172 *obj
= &This
->ISupportErrorInfo_iface
;
177 xmlnode
*get_node_obj(IXMLDOMNode
*node
)
182 hres
= IXMLDOMNode_QueryInterface(node
, &IID_xmlnode
, (void**)&obj
);
183 if (!obj
) WARN("node is not our IXMLDOMNode implementation\n");
184 return SUCCEEDED(hres
) ? obj
: NULL
;
187 HRESULT
node_get_nodeName(xmlnode
*This
, BSTR
*name
)
195 hr
= node_get_base_name(This
, &base
);
196 if (hr
!= S_OK
) return hr
;
198 hr
= node_get_prefix(This
, &prefix
);
201 static const WCHAR colW
= ':';
205 ptr
= *name
= SysAllocStringLen(NULL
, SysStringLen(base
) + SysStringLen(prefix
) + 1);
206 memcpy(ptr
, prefix
, SysStringByteLen(prefix
));
207 ptr
+= SysStringLen(prefix
);
208 memcpy(ptr
++, &colW
, sizeof(WCHAR
));
209 memcpy(ptr
, base
, SysStringByteLen(base
));
212 SysFreeString(prefix
);
220 HRESULT
node_get_content(xmlnode
*This
, VARIANT
*value
)
227 content
= xmlNodeGetContent(This
->node
);
228 V_VT(value
) = VT_BSTR
;
229 V_BSTR(value
) = bstr_from_xmlChar( content
);
232 TRACE("%p returned %s\n", This
, debugstr_w(V_BSTR(value
)));
236 HRESULT
node_set_content(xmlnode
*This
, LPCWSTR value
)
240 TRACE("(%p)->(%s)\n", This
, debugstr_w(value
));
241 str
= xmlchar_from_wchar(value
);
243 return E_OUTOFMEMORY
;
245 xmlNodeSetContent(This
->node
, str
);
250 static HRESULT
node_set_content_escaped(xmlnode
*This
, LPCWSTR value
)
252 xmlChar
*str
, *escaped
;
254 TRACE("(%p)->(%s)\n", This
, debugstr_w(value
));
255 str
= xmlchar_from_wchar(value
);
257 return E_OUTOFMEMORY
;
259 escaped
= xmlEncodeSpecialChars(NULL
, str
);
263 return E_OUTOFMEMORY
;
266 xmlNodeSetContent(This
->node
, escaped
);
274 HRESULT
node_put_value(xmlnode
*This
, VARIANT
*value
)
278 if (V_VT(value
) != VT_BSTR
)
280 VARIANT string_value
;
282 VariantInit(&string_value
);
283 hr
= VariantChangeType(&string_value
, value
, 0, VT_BSTR
);
285 WARN("Couldn't convert to VT_BSTR\n");
289 hr
= node_set_content(This
, V_BSTR(&string_value
));
290 VariantClear(&string_value
);
293 hr
= node_set_content(This
, V_BSTR(value
));
298 HRESULT
node_put_value_escaped(xmlnode
*This
, VARIANT
*value
)
302 if (V_VT(value
) != VT_BSTR
)
304 VARIANT string_value
;
306 VariantInit(&string_value
);
307 hr
= VariantChangeType(&string_value
, value
, 0, VT_BSTR
);
309 WARN("Couldn't convert to VT_BSTR\n");
313 hr
= node_set_content_escaped(This
, V_BSTR(&string_value
));
314 VariantClear(&string_value
);
317 hr
= node_set_content_escaped(This
, V_BSTR(value
));
322 static HRESULT
get_node(
328 TRACE("(%p)->(%s %p %p)\n", This
, name
, node
, out
);
333 /* if we don't have a doc, use our parent. */
334 if(node
&& !node
->doc
&& node
->parent
)
335 node
->doc
= node
->parent
->doc
;
337 *out
= create_node( node
);
343 HRESULT
node_get_parent(xmlnode
*This
, IXMLDOMNode
**parent
)
345 return get_node( This
, "parent", This
->node
->parent
, parent
);
348 HRESULT
node_get_child_nodes(xmlnode
*This
, IXMLDOMNodeList
**ret
)
353 *ret
= create_children_nodelist(This
->node
);
355 return E_OUTOFMEMORY
;
360 HRESULT
node_get_first_child(xmlnode
*This
, IXMLDOMNode
**ret
)
362 return get_node(This
, "firstChild", This
->node
->children
, ret
);
365 HRESULT
node_get_last_child(xmlnode
*This
, IXMLDOMNode
**ret
)
367 return get_node(This
, "lastChild", This
->node
->last
, ret
);
370 HRESULT
node_get_previous_sibling(xmlnode
*This
, IXMLDOMNode
**ret
)
372 return get_node(This
, "previous", This
->node
->prev
, ret
);
375 HRESULT
node_get_next_sibling(xmlnode
*This
, IXMLDOMNode
**ret
)
377 return get_node(This
, "next", This
->node
->next
, ret
);
380 static int node_get_inst_cnt(xmlNodePtr node
)
382 int ret
= *(LONG
*)&node
->_private
;
385 /* add attribute counts */
386 if (node
->type
== XML_ELEMENT_NODE
)
388 xmlAttrPtr prop
= node
->properties
;
392 ret
+= node_get_inst_cnt((xmlNodePtr
)prop
);
397 /* add children counts */
398 child
= node
->children
;
401 ret
+= node_get_inst_cnt(child
);
408 int xmlnode_get_inst_cnt(xmlnode
*node
)
410 return node_get_inst_cnt(node
->node
);
413 HRESULT
node_insert_before(xmlnode
*This
, IXMLDOMNode
*new_child
, const VARIANT
*ref_child
,
416 IXMLDOMNode
*before
= NULL
;
425 node_obj
= get_node_obj(new_child
);
426 if(!node_obj
) return E_FAIL
;
428 switch(V_VT(ref_child
))
436 if (V_UNKNOWN(ref_child
))
438 hr
= IUnknown_QueryInterface(V_UNKNOWN(ref_child
), &IID_IXMLDOMNode
, (void**)&before
);
439 if(FAILED(hr
)) return hr
;
444 FIXME("refChild var type %x\n", V_VT(ref_child
));
448 TRACE("new child %p, This->node %p\n", node_obj
->node
, This
->node
);
450 if(!node_obj
->node
->parent
)
451 if(xmldoc_remove_orphan(node_obj
->node
->doc
, node_obj
->node
) != S_OK
)
452 WARN("%p is not an orphan of %p\n", node_obj
->node
, node_obj
->node
->doc
);
454 refcount
= xmlnode_get_inst_cnt(node_obj
);
458 xmlnode
*before_node_obj
= get_node_obj(before
);
459 IXMLDOMNode_Release(before
);
460 if(!before_node_obj
) return E_FAIL
;
463 /* unlink from current parent first */
466 hr
= IXMLDOMNode_removeChild(node_obj
->parent
, node_obj
->iface
, NULL
);
467 if (hr
== S_OK
) xmldoc_remove_orphan(node_obj
->node
->doc
, node_obj
->node
);
469 doc
= node_obj
->node
->doc
;
473 xmlnode
*before_node_obj
= get_node_obj(before
);
475 /* refs count including subtree */
476 if (doc
!= before_node_obj
->node
->doc
)
477 refcount
= xmlnode_get_inst_cnt(node_obj
);
479 if (refcount
) xmldoc_add_refs(before_node_obj
->node
->doc
, refcount
);
480 node_obj
->node
= xmlAddPrevSibling(before_node_obj
->node
, node_obj
->node
);
481 if (refcount
) xmldoc_release_refs(doc
, refcount
);
482 node_obj
->parent
= This
->parent
;
486 if (doc
!= This
->node
->doc
)
487 refcount
= xmlnode_get_inst_cnt(node_obj
);
489 if (refcount
) xmldoc_add_refs(This
->node
->doc
, refcount
);
490 /* xmlAddChild doesn't unlink node from previous parent */
491 xmlUnlinkNode(node_obj
->node
);
492 node_obj
->node
= xmlAddChild(This
->node
, node_obj
->node
);
493 if (refcount
) xmldoc_release_refs(doc
, refcount
);
494 node_obj
->parent
= This
->iface
;
499 IXMLDOMNode_AddRef(new_child
);
507 HRESULT
node_replace_child(xmlnode
*This
, IXMLDOMNode
*newChild
, IXMLDOMNode
*oldChild
,
510 xmlnode
*old_child
, *new_child
;
511 xmlDocPtr leaving_doc
;
512 xmlNode
*my_ancestor
;
515 /* Do not believe any documentation telling that newChild == NULL
516 means removal. It does certainly *not* apply to msxml3! */
517 if(!newChild
|| !oldChild
)
523 old_child
= get_node_obj(oldChild
);
524 if(!old_child
) return E_FAIL
;
526 if(old_child
->node
->parent
!= This
->node
)
528 WARN("childNode %p is not a child of %p\n", oldChild
, This
);
532 new_child
= get_node_obj(newChild
);
533 if(!new_child
) return E_FAIL
;
535 my_ancestor
= This
->node
;
538 if(my_ancestor
== new_child
->node
)
540 WARN("tried to create loop\n");
543 my_ancestor
= my_ancestor
->parent
;
546 if(!new_child
->node
->parent
)
547 if(xmldoc_remove_orphan(new_child
->node
->doc
, new_child
->node
) != S_OK
)
548 WARN("%p is not an orphan of %p\n", new_child
->node
, new_child
->node
->doc
);
550 leaving_doc
= new_child
->node
->doc
;
552 if (leaving_doc
!= old_child
->node
->doc
)
553 refcount
= xmlnode_get_inst_cnt(new_child
);
555 if (refcount
) xmldoc_add_refs(old_child
->node
->doc
, refcount
);
556 xmlReplaceNode(old_child
->node
, new_child
->node
);
557 if (refcount
) xmldoc_release_refs(leaving_doc
, refcount
);
558 new_child
->parent
= old_child
->parent
;
559 old_child
->parent
= NULL
;
561 xmldoc_add_orphan(old_child
->node
->doc
, old_child
->node
);
565 IXMLDOMNode_AddRef(oldChild
);
572 HRESULT
node_remove_child(xmlnode
*This
, IXMLDOMNode
* child
, IXMLDOMNode
** oldChild
)
576 if(!child
) return E_INVALIDARG
;
581 child_node
= get_node_obj(child
);
582 if(!child_node
) return E_FAIL
;
584 if(child_node
->node
->parent
!= This
->node
)
586 WARN("childNode %p is not a child of %p\n", child
, This
);
590 xmlUnlinkNode(child_node
->node
);
591 child_node
->parent
= NULL
;
592 xmldoc_add_orphan(child_node
->node
->doc
, child_node
->node
);
596 IXMLDOMNode_AddRef(child
);
603 HRESULT
node_append_child(xmlnode
*This
, IXMLDOMNode
*child
, IXMLDOMNode
**outChild
)
612 hr
= IXMLDOMNode_get_nodeType(child
, &type
);
613 if(FAILED(hr
) || type
== NODE_ATTRIBUTE
) {
614 if (outChild
) *outChild
= NULL
;
619 return IXMLDOMNode_insertBefore(This
->iface
, child
, var
, outChild
);
622 HRESULT
node_has_childnodes(const xmlnode
*This
, VARIANT_BOOL
*ret
)
624 if (!ret
) return E_INVALIDARG
;
626 if (!This
->node
->children
)
628 *ret
= VARIANT_FALSE
;
636 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 ERR_(winediag
)("libxslt headers were not found at compile time. Expect problems.\n");
1298 HRESULT
node_transform_node(const xmlnode
*node
, IXMLDOMNode
*stylesheet
, BSTR
*p
)
1300 return node_transform_node_params(node
, stylesheet
, p
, NULL
, NULL
);
1303 HRESULT
node_select_nodes(const xmlnode
*This
, BSTR query
, IXMLDOMNodeList
**nodes
)
1308 if (!query
|| !nodes
) return E_INVALIDARG
;
1310 str
= xmlchar_from_wchar(query
);
1311 hr
= create_selection(This
->node
, str
, nodes
);
1317 HRESULT
node_select_singlenode(const xmlnode
*This
, BSTR query
, IXMLDOMNode
**node
)
1319 IXMLDOMNodeList
*list
;
1322 hr
= node_select_nodes(This
, query
, &list
);
1325 hr
= IXMLDOMNodeList_nextNode(list
, node
);
1326 IXMLDOMNodeList_Release(list
);
1331 HRESULT
node_get_namespaceURI(xmlnode
*This
, BSTR
*namespaceURI
)
1333 xmlNsPtr ns
= This
->node
->ns
;
1336 return E_INVALIDARG
;
1338 *namespaceURI
= NULL
;
1341 *namespaceURI
= bstr_from_xmlChar(ns
->href
);
1343 TRACE("uri: %s\n", debugstr_w(*namespaceURI
));
1345 return *namespaceURI
? S_OK
: S_FALSE
;
1348 HRESULT
node_get_prefix(xmlnode
*This
, BSTR
*prefix
)
1350 xmlNsPtr ns
= This
->node
->ns
;
1352 if (!prefix
) return E_INVALIDARG
;
1356 if (ns
&& ns
->prefix
)
1357 *prefix
= bstr_from_xmlChar(ns
->prefix
);
1359 TRACE("prefix: %s\n", debugstr_w(*prefix
));
1361 return *prefix
? S_OK
: S_FALSE
;
1364 HRESULT
node_get_base_name(xmlnode
*This
, BSTR
*name
)
1366 if (!name
) return E_INVALIDARG
;
1368 *name
= bstr_from_xmlChar(This
->node
->name
);
1369 if (!*name
) return E_OUTOFMEMORY
;
1371 TRACE("returning %s\n", debugstr_w(*name
));
1376 /* _private field holds a number of COM instances spawned from this libxml2 node */
1377 static void xmlnode_add_ref(xmlNodePtr node
)
1379 if (node
->type
== XML_DOCUMENT_NODE
) return;
1380 InterlockedIncrement((LONG
*)&node
->_private
);
1383 static void xmlnode_release(xmlNodePtr node
)
1385 if (node
->type
== XML_DOCUMENT_NODE
) return;
1386 InterlockedDecrement((LONG
*)&node
->_private
);
1389 void destroy_xmlnode(xmlnode
*This
)
1393 xmlnode_release(This
->node
);
1394 xmldoc_release(This
->node
->doc
);
1398 void init_xmlnode(xmlnode
*This
, xmlNodePtr node
, IXMLDOMNode
*node_iface
, dispex_static_data_t
*dispex_data
)
1402 xmlnode_add_ref(node
);
1403 xmldoc_add_ref(node
->doc
);
1407 This
->iface
= node_iface
;
1408 This
->parent
= NULL
;
1410 init_dispex(&This
->dispex
, (IUnknown
*)This
->iface
, dispex_data
);
1415 IXMLDOMNode IXMLDOMNode_iface
;
1419 static inline unknode
*unknode_from_IXMLDOMNode(IXMLDOMNode
*iface
)
1421 return CONTAINING_RECORD(iface
, unknode
, IXMLDOMNode_iface
);
1424 static HRESULT WINAPI
unknode_QueryInterface(
1429 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1431 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppvObject
);
1433 if (IsEqualGUID(riid
, &IID_IUnknown
)) {
1435 }else if (IsEqualGUID( riid
, &IID_IDispatch
) ||
1436 IsEqualGUID( riid
, &IID_IXMLDOMNode
)) {
1437 *ppvObject
= &This
->IXMLDOMNode_iface
;
1438 }else if(node_query_interface(&This
->node
, riid
, ppvObject
)) {
1439 return *ppvObject
? S_OK
: E_NOINTERFACE
;
1441 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
1443 return E_NOINTERFACE
;
1446 IUnknown_AddRef((IUnknown
*)*ppvObject
);
1450 static ULONG WINAPI
unknode_AddRef(
1451 IXMLDOMNode
*iface
)
1453 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1455 return InterlockedIncrement(&This
->ref
);
1458 static ULONG WINAPI
unknode_Release(
1459 IXMLDOMNode
*iface
)
1461 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1464 ref
= InterlockedDecrement( &This
->ref
);
1466 destroy_xmlnode(&This
->node
);
1473 static HRESULT WINAPI
unknode_GetTypeInfoCount(
1477 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1479 TRACE("(%p)->(%p)\n", This
, pctinfo
);
1486 static HRESULT WINAPI
unknode_GetTypeInfo(
1490 ITypeInfo
** ppTInfo
)
1492 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1495 TRACE("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
1497 hr
= get_typeinfo(IXMLDOMNode_tid
, ppTInfo
);
1502 static HRESULT WINAPI
unknode_GetIDsOfNames(
1505 LPOLESTR
* rgszNames
,
1510 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1512 ITypeInfo
*typeinfo
;
1515 TRACE("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
1518 if(!rgszNames
|| cNames
== 0 || !rgDispId
)
1519 return E_INVALIDARG
;
1521 hr
= get_typeinfo(IXMLDOMNode_tid
, &typeinfo
);
1524 hr
= ITypeInfo_GetIDsOfNames(typeinfo
, rgszNames
, cNames
, rgDispId
);
1525 ITypeInfo_Release(typeinfo
);
1531 static HRESULT WINAPI
unknode_Invoke(
1533 DISPID dispIdMember
,
1537 DISPPARAMS
* pDispParams
,
1538 VARIANT
* pVarResult
,
1539 EXCEPINFO
* pExcepInfo
,
1542 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1543 ITypeInfo
*typeinfo
;
1546 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
1547 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
1549 hr
= get_typeinfo(IXMLDOMNode_tid
, &typeinfo
);
1552 hr
= ITypeInfo_Invoke(typeinfo
, &This
->IXMLDOMNode_iface
, dispIdMember
, wFlags
, pDispParams
,
1553 pVarResult
, pExcepInfo
, puArgErr
);
1554 ITypeInfo_Release(typeinfo
);
1560 static HRESULT WINAPI
unknode_get_nodeName(
1564 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1566 FIXME("(%p)->(%p)\n", This
, p
);
1568 return node_get_nodeName(&This
->node
, p
);
1571 static HRESULT WINAPI
unknode_get_nodeValue(
1575 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1577 FIXME("(%p)->(%p)\n", This
, value
);
1580 return E_INVALIDARG
;
1582 V_VT(value
) = VT_NULL
;
1586 static HRESULT WINAPI
unknode_put_nodeValue(
1590 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1591 FIXME("(%p)->(v%d)\n", This
, V_VT(&value
));
1595 static HRESULT WINAPI
unknode_get_nodeType(
1597 DOMNodeType
* domNodeType
)
1599 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1601 FIXME("(%p)->(%p)\n", This
, domNodeType
);
1603 switch (This
->node
.node
->type
)
1605 case XML_ELEMENT_NODE
:
1606 case XML_ATTRIBUTE_NODE
:
1608 case XML_CDATA_SECTION_NODE
:
1609 case XML_ENTITY_REF_NODE
:
1610 case XML_ENTITY_NODE
:
1612 case XML_COMMENT_NODE
:
1613 case XML_DOCUMENT_NODE
:
1614 case XML_DOCUMENT_TYPE_NODE
:
1615 case XML_DOCUMENT_FRAG_NODE
:
1616 case XML_NOTATION_NODE
:
1617 /* we only care about this set of types, libxml2 type values are
1618 exactly what we need */
1619 *domNodeType
= (DOMNodeType
)This
->node
.node
->type
;
1622 *domNodeType
= NODE_INVALID
;
1629 static HRESULT WINAPI
unknode_get_parentNode(
1631 IXMLDOMNode
** parent
)
1633 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1634 FIXME("(%p)->(%p)\n", This
, parent
);
1635 if (!parent
) return E_INVALIDARG
;
1640 static HRESULT WINAPI
unknode_get_childNodes(
1642 IXMLDOMNodeList
** outList
)
1644 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1646 TRACE("(%p)->(%p)\n", This
, outList
);
1648 return node_get_child_nodes(&This
->node
, outList
);
1651 static HRESULT WINAPI
unknode_get_firstChild(
1653 IXMLDOMNode
** domNode
)
1655 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1657 TRACE("(%p)->(%p)\n", This
, domNode
);
1659 return node_get_first_child(&This
->node
, domNode
);
1662 static HRESULT WINAPI
unknode_get_lastChild(
1664 IXMLDOMNode
** domNode
)
1666 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1668 TRACE("(%p)->(%p)\n", This
, domNode
);
1670 return node_get_last_child(&This
->node
, domNode
);
1673 static HRESULT WINAPI
unknode_get_previousSibling(
1675 IXMLDOMNode
** domNode
)
1677 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1679 TRACE("(%p)->(%p)\n", This
, domNode
);
1681 return node_get_previous_sibling(&This
->node
, domNode
);
1684 static HRESULT WINAPI
unknode_get_nextSibling(
1686 IXMLDOMNode
** domNode
)
1688 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1690 TRACE("(%p)->(%p)\n", This
, domNode
);
1692 return node_get_next_sibling(&This
->node
, domNode
);
1695 static HRESULT WINAPI
unknode_get_attributes(
1697 IXMLDOMNamedNodeMap
** attributeMap
)
1699 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1701 FIXME("(%p)->(%p)\n", This
, attributeMap
);
1703 return return_null_ptr((void**)attributeMap
);
1706 static HRESULT WINAPI
unknode_insertBefore(
1708 IXMLDOMNode
* newNode
, VARIANT refChild
,
1709 IXMLDOMNode
** outOldNode
)
1711 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1713 FIXME("(%p)->(%p x%d %p)\n", This
, newNode
, V_VT(&refChild
), outOldNode
);
1715 return node_insert_before(&This
->node
, newNode
, &refChild
, outOldNode
);
1718 static HRESULT WINAPI
unknode_replaceChild(
1720 IXMLDOMNode
* newNode
,
1721 IXMLDOMNode
* oldNode
,
1722 IXMLDOMNode
** outOldNode
)
1724 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1726 FIXME("(%p)->(%p %p %p)\n", This
, newNode
, oldNode
, outOldNode
);
1728 return node_replace_child(&This
->node
, newNode
, oldNode
, outOldNode
);
1731 static HRESULT WINAPI
unknode_removeChild(
1733 IXMLDOMNode
* domNode
, IXMLDOMNode
** oldNode
)
1735 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1736 return node_remove_child(&This
->node
, domNode
, oldNode
);
1739 static HRESULT WINAPI
unknode_appendChild(
1741 IXMLDOMNode
* newNode
, IXMLDOMNode
** outNewNode
)
1743 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1744 return node_append_child(&This
->node
, newNode
, outNewNode
);
1747 static HRESULT WINAPI
unknode_hasChildNodes(
1749 VARIANT_BOOL
* pbool
)
1751 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1752 return node_has_childnodes(&This
->node
, pbool
);
1755 static HRESULT WINAPI
unknode_get_ownerDocument(
1757 IXMLDOMDocument
** domDocument
)
1759 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1760 return node_get_owner_doc(&This
->node
, domDocument
);
1763 static HRESULT WINAPI
unknode_cloneNode(
1765 VARIANT_BOOL pbool
, IXMLDOMNode
** outNode
)
1767 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1768 return node_clone(&This
->node
, pbool
, outNode
);
1771 static HRESULT WINAPI
unknode_get_nodeTypeString(
1775 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1777 FIXME("(%p)->(%p)\n", This
, p
);
1779 return node_get_nodeName(&This
->node
, p
);
1782 static HRESULT WINAPI
unknode_get_text(
1786 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1787 return node_get_text(&This
->node
, p
);
1790 static HRESULT WINAPI
unknode_put_text(
1794 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1795 return node_put_text(&This
->node
, p
);
1798 static HRESULT WINAPI
unknode_get_specified(
1800 VARIANT_BOOL
* isSpecified
)
1802 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1803 FIXME("(%p)->(%p) stub!\n", This
, isSpecified
);
1804 *isSpecified
= VARIANT_TRUE
;
1808 static HRESULT WINAPI
unknode_get_definition(
1810 IXMLDOMNode
** definitionNode
)
1812 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1813 FIXME("(%p)->(%p)\n", This
, definitionNode
);
1817 static HRESULT WINAPI
unknode_get_nodeTypedValue(
1821 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1822 FIXME("(%p)->(%p)\n", This
, var1
);
1823 return return_null_var(var1
);
1826 static HRESULT WINAPI
unknode_put_nodeTypedValue(
1830 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1831 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&typedValue
));
1835 static HRESULT WINAPI
unknode_get_dataType(
1839 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1840 TRACE("(%p)->(%p)\n", This
, var1
);
1841 return return_null_var(var1
);
1844 static HRESULT WINAPI
unknode_put_dataType(
1848 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1850 FIXME("(%p)->(%s)\n", This
, debugstr_w(p
));
1853 return E_INVALIDARG
;
1858 static HRESULT WINAPI
unknode_get_xml(
1862 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1864 FIXME("(%p)->(%p)\n", This
, p
);
1866 return node_get_xml(&This
->node
, FALSE
, p
);
1869 static HRESULT WINAPI
unknode_transformNode(
1871 IXMLDOMNode
* domNode
, BSTR
* p
)
1873 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1874 return node_transform_node(&This
->node
, domNode
, p
);
1877 static HRESULT WINAPI
unknode_selectNodes(
1879 BSTR p
, IXMLDOMNodeList
** outList
)
1881 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1882 return node_select_nodes(&This
->node
, p
, outList
);
1885 static HRESULT WINAPI
unknode_selectSingleNode(
1887 BSTR p
, IXMLDOMNode
** outNode
)
1889 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1890 return node_select_singlenode(&This
->node
, p
, outNode
);
1893 static HRESULT WINAPI
unknode_get_parsed(
1895 VARIANT_BOOL
* isParsed
)
1897 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1898 FIXME("(%p)->(%p) stub!\n", This
, isParsed
);
1899 *isParsed
= VARIANT_TRUE
;
1903 static HRESULT WINAPI
unknode_get_namespaceURI(
1907 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1908 TRACE("(%p)->(%p)\n", This
, p
);
1909 return node_get_namespaceURI(&This
->node
, p
);
1912 static HRESULT WINAPI
unknode_get_prefix(
1916 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1917 return node_get_prefix(&This
->node
, p
);
1920 static HRESULT WINAPI
unknode_get_baseName(
1924 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1925 return node_get_base_name(&This
->node
, p
);
1928 static HRESULT WINAPI
unknode_transformNodeToObject(
1930 IXMLDOMNode
* domNode
, VARIANT var1
)
1932 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1933 FIXME("(%p)->(%p %s)\n", This
, domNode
, debugstr_variant(&var1
));
1937 static const struct IXMLDOMNodeVtbl unknode_vtbl
=
1939 unknode_QueryInterface
,
1942 unknode_GetTypeInfoCount
,
1943 unknode_GetTypeInfo
,
1944 unknode_GetIDsOfNames
,
1946 unknode_get_nodeName
,
1947 unknode_get_nodeValue
,
1948 unknode_put_nodeValue
,
1949 unknode_get_nodeType
,
1950 unknode_get_parentNode
,
1951 unknode_get_childNodes
,
1952 unknode_get_firstChild
,
1953 unknode_get_lastChild
,
1954 unknode_get_previousSibling
,
1955 unknode_get_nextSibling
,
1956 unknode_get_attributes
,
1957 unknode_insertBefore
,
1958 unknode_replaceChild
,
1959 unknode_removeChild
,
1960 unknode_appendChild
,
1961 unknode_hasChildNodes
,
1962 unknode_get_ownerDocument
,
1964 unknode_get_nodeTypeString
,
1967 unknode_get_specified
,
1968 unknode_get_definition
,
1969 unknode_get_nodeTypedValue
,
1970 unknode_put_nodeTypedValue
,
1971 unknode_get_dataType
,
1972 unknode_put_dataType
,
1974 unknode_transformNode
,
1975 unknode_selectNodes
,
1976 unknode_selectSingleNode
,
1978 unknode_get_namespaceURI
,
1980 unknode_get_baseName
,
1981 unknode_transformNodeToObject
1984 IXMLDOMNode
*create_node( xmlNodePtr node
)
1993 TRACE("type %d\n", node
->type
);
1996 case XML_ELEMENT_NODE
:
1997 pUnk
= create_element( node
);
1999 case XML_ATTRIBUTE_NODE
:
2000 pUnk
= create_attribute( node
);
2003 pUnk
= create_text( node
);
2005 case XML_CDATA_SECTION_NODE
:
2006 pUnk
= create_cdata( node
);
2008 case XML_ENTITY_REF_NODE
:
2009 pUnk
= create_doc_entity_ref( node
);
2012 pUnk
= create_pi( node
);
2014 case XML_COMMENT_NODE
:
2015 pUnk
= create_comment( node
);
2017 case XML_DOCUMENT_NODE
:
2018 pUnk
= create_domdoc( node
);
2020 case XML_DOCUMENT_FRAG_NODE
:
2021 pUnk
= create_doc_fragment( node
);
2024 case XML_DOCUMENT_TYPE_NODE
:
2025 pUnk
= create_doc_type( node
);
2027 case XML_ENTITY_NODE
:
2028 case XML_NOTATION_NODE
: {
2031 FIXME("only creating basic node for type %d\n", node
->type
);
2033 new_node
= heap_alloc(sizeof(unknode
));
2037 new_node
->IXMLDOMNode_iface
.lpVtbl
= &unknode_vtbl
;
2039 init_xmlnode(&new_node
->node
, node
, &new_node
->IXMLDOMNode_iface
, NULL
);
2040 pUnk
= (IUnknown
*)&new_node
->IXMLDOMNode_iface
;
2044 ERR("Called for unsupported node type %d\n", node
->type
);
2048 hr
= IUnknown_QueryInterface(pUnk
, &IID_IXMLDOMNode
, (LPVOID
*)&ret
);
2049 IUnknown_Release(pUnk
);
2050 if(FAILED(hr
)) return NULL
;