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
;
462 /* unlink from current parent first */
465 hr
= IXMLDOMNode_removeChild(node_obj
->parent
, node_obj
->iface
, NULL
);
466 if (hr
== S_OK
) xmldoc_remove_orphan(node_obj
->node
->doc
, node_obj
->node
);
469 doc
= node_obj
->node
->doc
;
471 /* refs count including subtree */
472 if (doc
!= before_node_obj
->node
->doc
)
473 refcount
= xmlnode_get_inst_cnt(node_obj
);
475 if (refcount
) xmldoc_add_refs(before_node_obj
->node
->doc
, refcount
);
476 xmlAddPrevSibling(before_node_obj
->node
, node_obj
->node
);
477 if (refcount
) xmldoc_release_refs(doc
, refcount
);
478 node_obj
->parent
= This
->parent
;
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
;
490 if (doc
!= This
->node
->doc
)
491 refcount
= xmlnode_get_inst_cnt(node_obj
);
493 if (refcount
) xmldoc_add_refs(This
->node
->doc
, refcount
);
494 /* xmlAddChild doesn't unlink node from previous parent */
495 xmlUnlinkNode(node_obj
->node
);
496 xmlAddChild(This
->node
, node_obj
->node
);
497 if (refcount
) xmldoc_release_refs(doc
, refcount
);
498 node_obj
->parent
= This
->iface
;
503 IXMLDOMNode_AddRef(new_child
);
511 HRESULT
node_replace_child(xmlnode
*This
, IXMLDOMNode
*newChild
, IXMLDOMNode
*oldChild
,
514 xmlnode
*old_child
, *new_child
;
515 xmlDocPtr leaving_doc
;
516 xmlNode
*my_ancestor
;
519 /* Do not believe any documentation telling that newChild == NULL
520 means removal. It does certainly *not* apply to msxml3! */
521 if(!newChild
|| !oldChild
)
527 old_child
= get_node_obj(oldChild
);
528 if(!old_child
) return E_FAIL
;
530 if(old_child
->node
->parent
!= This
->node
)
532 WARN("childNode %p is not a child of %p\n", oldChild
, This
);
536 new_child
= get_node_obj(newChild
);
537 if(!new_child
) return E_FAIL
;
539 my_ancestor
= This
->node
;
542 if(my_ancestor
== new_child
->node
)
544 WARN("tried to create loop\n");
547 my_ancestor
= my_ancestor
->parent
;
550 if(!new_child
->node
->parent
)
551 if(xmldoc_remove_orphan(new_child
->node
->doc
, new_child
->node
) != S_OK
)
552 WARN("%p is not an orphan of %p\n", new_child
->node
, new_child
->node
->doc
);
554 leaving_doc
= new_child
->node
->doc
;
556 if (leaving_doc
!= old_child
->node
->doc
)
557 refcount
= xmlnode_get_inst_cnt(new_child
);
559 if (refcount
) xmldoc_add_refs(old_child
->node
->doc
, refcount
);
560 xmlReplaceNode(old_child
->node
, new_child
->node
);
561 if (refcount
) xmldoc_release_refs(leaving_doc
, refcount
);
562 new_child
->parent
= old_child
->parent
;
563 old_child
->parent
= NULL
;
565 xmldoc_add_orphan(old_child
->node
->doc
, old_child
->node
);
569 IXMLDOMNode_AddRef(oldChild
);
576 HRESULT
node_remove_child(xmlnode
*This
, IXMLDOMNode
* child
, IXMLDOMNode
** oldChild
)
580 if(!child
) return E_INVALIDARG
;
585 child_node
= get_node_obj(child
);
586 if(!child_node
) return E_FAIL
;
588 if(child_node
->node
->parent
!= This
->node
)
590 WARN("childNode %p is not a child of %p\n", child
, This
);
594 xmlUnlinkNode(child_node
->node
);
595 child_node
->parent
= NULL
;
596 xmldoc_add_orphan(child_node
->node
->doc
, child_node
->node
);
600 IXMLDOMNode_AddRef(child
);
607 HRESULT
node_append_child(xmlnode
*This
, IXMLDOMNode
*child
, IXMLDOMNode
**outChild
)
616 hr
= IXMLDOMNode_get_nodeType(child
, &type
);
617 if(FAILED(hr
) || type
== NODE_ATTRIBUTE
) {
618 if (outChild
) *outChild
= NULL
;
623 return IXMLDOMNode_insertBefore(This
->iface
, child
, var
, outChild
);
626 HRESULT
node_has_childnodes(const xmlnode
*This
, VARIANT_BOOL
*ret
)
628 if (!ret
) return E_INVALIDARG
;
630 if (!This
->node
->children
)
632 *ret
= VARIANT_FALSE
;
640 HRESULT
node_get_owner_doc(const xmlnode
*This
, IXMLDOMDocument
**doc
)
642 return get_domdoc_from_xmldoc(This
->node
->doc
, (IXMLDOMDocument3
**)doc
);
645 HRESULT
node_clone(xmlnode
*This
, VARIANT_BOOL deep
, IXMLDOMNode
**cloneNode
)
650 if(!cloneNode
) return E_INVALIDARG
;
652 clone
= xmlCopyNode(This
->node
, deep
? 1 : 2);
655 xmlSetTreeDoc(clone
, This
->node
->doc
);
656 xmldoc_add_orphan(clone
->doc
, clone
);
658 node
= create_node(clone
);
661 ERR("Copy failed\n");
662 xmldoc_remove_orphan(clone
->doc
, clone
);
671 ERR("Copy failed\n");
678 static inline xmlChar
* trim_whitespace(xmlChar
* str
)
686 while (*ret
&& isspace(*ret
))
688 len
= xmlStrlen(ret
);
690 while (isspace(ret
[len
-1])) --len
;
692 ret
= xmlStrndup(ret
, len
);
697 static xmlChar
* do_get_text(xmlNodePtr node
)
701 BOOL preserving
= is_preserving_whitespace(node
);
705 str
= xmlNodeGetContent(node
);
709 xmlElementType prev_type
= XML_TEXT_NODE
;
711 str
= xmlStrdup(BAD_CAST
"");
712 for (child
= node
->children
; child
!= NULL
; child
= child
->next
)
716 case XML_ELEMENT_NODE
:
717 tmp
= do_get_text(child
);
720 case XML_CDATA_SECTION_NODE
:
721 case XML_ENTITY_REF_NODE
:
722 case XML_ENTITY_NODE
:
723 tmp
= xmlNodeGetContent(child
);
734 if (prev_type
== XML_ELEMENT_NODE
&& child
->type
== XML_ELEMENT_NODE
)
735 str
= xmlStrcat(str
, BAD_CAST
" ");
736 str
= xmlStrcat(str
, tmp
);
737 prev_type
= child
->type
;
746 case XML_ELEMENT_NODE
:
748 case XML_ENTITY_REF_NODE
:
749 case XML_ENTITY_NODE
:
750 case XML_DOCUMENT_NODE
:
751 case XML_DOCUMENT_FRAG_NODE
:
753 str
= trim_whitespace(str
);
762 HRESULT
node_get_text(const xmlnode
*This
, BSTR
*text
)
767 if (!text
) return E_INVALIDARG
;
769 content
= do_get_text(This
->node
);
772 str
= bstr_from_xmlChar(content
);
776 /* Always return a string. */
777 if (!str
) str
= SysAllocStringLen( NULL
, 0 );
779 TRACE("%p %s\n", This
, debugstr_w(str
) );
785 HRESULT
node_put_text(xmlnode
*This
, BSTR text
)
789 TRACE("(%p)->(%s)\n", This
, debugstr_w(text
));
791 str
= xmlchar_from_wchar(text
);
793 /* Escape the string. */
794 str2
= xmlEncodeEntitiesReentrant(This
->node
->doc
, str
);
797 xmlNodeSetContent(This
->node
, str2
);
803 BSTR
EnsureCorrectEOL(BSTR sInput
)
810 nLen
= SysStringLen(sInput
);
811 /* Count line endings */
812 for(i
=0; i
< nLen
; i
++)
814 if(sInput
[i
] == '\n')
818 TRACE("len=%d, num=%d\n", nLen
, nNum
);
820 /* Add linefeed as needed */
824 sNew
= SysAllocStringLen(NULL
, nLen
+ nNum
);
825 for(i
=0; i
< nLen
; i
++)
827 if(sInput
[i
] == '\n')
829 sNew
[i
+nPlace
] = '\r';
832 sNew
[i
+nPlace
] = sInput
[i
];
835 SysFreeString(sInput
);
842 TRACE("len %d\n", SysStringLen(sNew
));
848 * We are trying to replicate the same behaviour as msxml by converting
849 * line endings to \r\n and using indents as \t. The problem is that msxml
850 * only formats nodes that have a line ending. Using libxml we cannot
851 * reproduce behaviour exactly.
854 HRESULT
node_get_xml(xmlnode
*This
, BOOL ensure_eol
, BSTR
*ret
)
856 xmlBufferPtr xml_buf
;
865 xml_buf
= xmlBufferCreate();
867 return E_OUTOFMEMORY
;
869 xmldecl
= xmldoc_unlink_xmldecl( This
->node
->doc
);
871 size
= xmlNodeDump(xml_buf
, This
->node
->doc
, This
->node
, 0, 1);
873 const xmlChar
*buf_content
;
876 /* Attribute Nodes return a space in front of their name */
877 buf_content
= xmlBufferContent(xml_buf
);
879 content
= bstr_from_xmlChar(buf_content
+ (buf_content
[0] == ' ' ? 1 : 0));
881 content
= EnsureCorrectEOL(content
);
885 *ret
= SysAllocStringLen(NULL
, 0);
888 xmlBufferFree(xml_buf
);
889 xmldoc_link_xmldecl( This
->node
->doc
, xmldecl
);
890 return *ret
? S_OK
: E_OUTOFMEMORY
;
893 #ifdef SONAME_LIBXSLT
895 /* duplicates xmlBufferWriteQuotedString() logic */
896 static void xml_write_quotedstring(xmlOutputBufferPtr buf
, const xmlChar
*string
)
898 const xmlChar
*cur
, *base
;
900 if (xmlStrchr(string
, '\"'))
902 if (xmlStrchr(string
, '\''))
904 xmlOutputBufferWrite(buf
, 1, "\"");
912 xmlOutputBufferWrite(buf
, cur
-base
, (const char*)base
);
913 xmlOutputBufferWrite(buf
, 6, """);
921 xmlOutputBufferWrite(buf
, cur
-base
, (const char*)base
);
922 xmlOutputBufferWrite(buf
, 1, "\"");
926 xmlOutputBufferWrite(buf
, 1, "\'");
927 xmlOutputBufferWriteString(buf
, (const char*)string
);
928 xmlOutputBufferWrite(buf
, 1, "\'");
933 xmlOutputBufferWrite(buf
, 1, "\"");
934 xmlOutputBufferWriteString(buf
, (const char*)string
);
935 xmlOutputBufferWrite(buf
, 1, "\"");
939 static int XMLCALL
transform_to_stream_write(void *context
, const char *buffer
, int len
)
942 HRESULT hr
= IStream_Write((IStream
*)context
, buffer
, len
, &written
);
943 return hr
== S_OK
? written
: -1;
946 /* Output for method "text" */
947 static void transform_write_text(xmlDocPtr result
, xsltStylesheetPtr style
, xmlOutputBufferPtr output
)
949 xmlNodePtr cur
= result
->children
;
952 if (cur
->type
== XML_TEXT_NODE
)
953 xmlOutputBufferWriteString(output
, (const char*)cur
->content
);
955 /* skip to next node */
958 if ((cur
->children
->type
!= XML_ENTITY_DECL
) &&
959 (cur
->children
->type
!= XML_ENTITY_REF_NODE
) &&
960 (cur
->children
->type
!= XML_ENTITY_NODE
))
977 if (cur
== (xmlNodePtr
) style
->doc
) {
989 #undef XSLT_GET_IMPORT_PTR
990 #define XSLT_GET_IMPORT_PTR(res, style, name) { \
991 xsltStylesheetPtr st = style; \
993 while (st != NULL) { \
994 if (st->name != NULL) { res = st->name; break; } \
995 st = pxsltNextImport(st); \
998 #undef XSLT_GET_IMPORT_INT
999 #define XSLT_GET_IMPORT_INT(res, style, name) { \
1000 xsltStylesheetPtr st = style; \
1002 while (st != NULL) { \
1003 if (st->name != -1) { res = st->name; break; } \
1004 st = pxsltNextImport(st); \
1007 static void transform_write_xmldecl(xmlDocPtr result
, xsltStylesheetPtr style
, BOOL omit_encoding
, xmlOutputBufferPtr output
)
1009 int omit_xmldecl
, standalone
;
1011 XSLT_GET_IMPORT_INT(omit_xmldecl
, style
, omitXmlDeclaration
);
1012 if (omit_xmldecl
== 1) return;
1014 XSLT_GET_IMPORT_INT(standalone
, style
, standalone
);
1016 xmlOutputBufferWriteString(output
, "<?xml version=");
1017 if (result
->version
)
1019 xmlOutputBufferWriteString(output
, "\"");
1020 xmlOutputBufferWriteString(output
, (const char *)result
->version
);
1021 xmlOutputBufferWriteString(output
, "\"");
1024 xmlOutputBufferWriteString(output
, "\"1.0\"");
1028 const xmlChar
*encoding
;
1030 /* default encoding is UTF-16 */
1031 XSLT_GET_IMPORT_PTR(encoding
, style
, encoding
);
1032 xmlOutputBufferWriteString(output
, " encoding=");
1033 xmlOutputBufferWriteString(output
, "\"");
1034 xmlOutputBufferWriteString(output
, encoding
? (const char *)encoding
: "UTF-16");
1035 xmlOutputBufferWriteString(output
, "\"");
1038 /* standalone attribute */
1039 if (standalone
!= -1)
1040 xmlOutputBufferWriteString(output
, standalone
== 0 ? " standalone=\"no\"" : " standalone=\"yes\"");
1042 xmlOutputBufferWriteString(output
, "?>");
1045 static void htmldtd_dumpcontent(xmlOutputBufferPtr buf
, xmlDocPtr doc
)
1047 xmlDtdPtr cur
= doc
->intSubset
;
1049 xmlOutputBufferWriteString(buf
, "<!DOCTYPE ");
1050 xmlOutputBufferWriteString(buf
, (const char *)cur
->name
);
1051 if (cur
->ExternalID
)
1053 xmlOutputBufferWriteString(buf
, " PUBLIC ");
1054 xml_write_quotedstring(buf
, cur
->ExternalID
);
1057 xmlOutputBufferWriteString(buf
, " ");
1058 xml_write_quotedstring(buf
, cur
->SystemID
);
1061 else if (cur
->SystemID
)
1063 xmlOutputBufferWriteString(buf
, " SYSTEM ");
1064 xml_write_quotedstring(buf
, cur
->SystemID
);
1066 xmlOutputBufferWriteString(buf
, ">\n");
1069 /* Duplicates htmlDocContentDumpFormatOutput() the way we need it - doesn't add trailing newline. */
1070 static void htmldoc_dumpcontent(xmlOutputBufferPtr buf
, xmlDocPtr doc
, const char *encoding
, int format
)
1072 xmlElementType type
;
1074 /* force HTML output */
1076 doc
->type
= XML_HTML_DOCUMENT_NODE
;
1078 htmldtd_dumpcontent(buf
, doc
);
1079 if (doc
->children
) {
1080 xmlNodePtr cur
= doc
->children
;
1082 htmlNodeDumpFormatOutput(buf
, doc
, cur
, encoding
, format
);
1089 static inline BOOL
transform_is_empty_resultdoc(xmlDocPtr result
)
1091 return !result
->children
|| ((result
->children
->type
== XML_DTD_NODE
) && !result
->children
->next
);
1094 static inline BOOL
transform_is_valid_method(xsltStylesheetPtr style
)
1096 return !style
->methodURI
|| !(style
->method
&& xmlStrEqual(style
->method
, (const xmlChar
*)"xhtml"));
1099 /* Helper to write transformation result to specified output buffer. */
1100 static HRESULT
node_transform_write(xsltStylesheetPtr style
, xmlDocPtr result
, BOOL omit_encoding
, const char *encoding
, xmlOutputBufferPtr output
)
1102 const xmlChar
*method
;
1105 if (!transform_is_valid_method(style
))
1107 ERR("unknown output method\n");
1111 XSLT_GET_IMPORT_PTR(method
, style
, method
)
1112 XSLT_GET_IMPORT_INT(indent
, style
, indent
);
1114 if (!method
&& (result
->type
== XML_HTML_DOCUMENT_NODE
))
1115 method
= (const xmlChar
*) "html";
1117 if (method
&& xmlStrEqual(method
, (const xmlChar
*)"html"))
1119 htmlSetMetaEncoding(result
, (const xmlChar
*)encoding
);
1122 htmldoc_dumpcontent(output
, result
, (const char*)encoding
, indent
);
1124 else if (method
&& xmlStrEqual(method
, (const xmlChar
*)"xhtml"))
1126 htmlSetMetaEncoding(result
, (const xmlChar
*) encoding
);
1127 htmlDocContentDumpOutput(output
, result
, encoding
);
1129 else if (method
&& xmlStrEqual(method
, (const xmlChar
*)"text"))
1130 transform_write_text(result
, style
, output
);
1133 transform_write_xmldecl(result
, style
, omit_encoding
, output
);
1135 if (result
->children
)
1137 xmlNodePtr child
= result
->children
;
1141 xmlNodeDumpOutput(output
, result
, child
, 0, indent
== 1, encoding
);
1142 if (indent
&& ((child
->type
== XML_DTD_NODE
) || ((child
->type
== XML_COMMENT_NODE
) && child
->next
)))
1143 xmlOutputBufferWriteString(output
, "\r\n");
1144 child
= child
->next
;
1149 xmlOutputBufferFlush(output
);
1153 /* For BSTR output is always UTF-16, without 'encoding' attribute */
1154 static HRESULT
node_transform_write_to_bstr(xsltStylesheetPtr style
, xmlDocPtr result
, BSTR
*str
)
1158 if (transform_is_empty_resultdoc(result
))
1159 *str
= SysAllocStringLen(NULL
, 0);
1162 xmlOutputBufferPtr output
= xmlAllocOutputBuffer(xmlFindCharEncodingHandler("UTF-16"));
1163 const xmlChar
*content
;
1168 return E_OUTOFMEMORY
;
1170 hr
= node_transform_write(style
, result
, TRUE
, "UTF-16", output
);
1171 #ifdef LIBXML2_NEW_BUFFER
1172 content
= xmlBufContent(output
->conv
);
1173 len
= xmlBufUse(output
->conv
);
1175 content
= xmlBufferContent(output
->conv
);
1176 len
= xmlBufferLength(output
->conv
);
1178 /* UTF-16 encoder places UTF-16 bom, we don't need it for BSTR */
1179 content
+= sizeof(WCHAR
);
1180 *str
= SysAllocStringLen((WCHAR
*)content
, len
/sizeof(WCHAR
) - 1);
1181 xmlOutputBufferClose(output
);
1184 return *str
? hr
: E_OUTOFMEMORY
;
1187 static HRESULT
node_transform_write_to_stream(xsltStylesheetPtr style
, xmlDocPtr result
, IStream
*stream
)
1189 static const xmlChar
*utf16
= (const xmlChar
*)"UTF-16";
1190 xmlOutputBufferPtr output
;
1191 const xmlChar
*encoding
;
1194 if (transform_is_empty_resultdoc(result
))
1196 WARN("empty result document\n");
1200 if (style
->methodURI
&& (!style
->method
|| !xmlStrEqual(style
->method
, (const xmlChar
*) "xhtml")))
1202 ERR("unknown output method\n");
1206 /* default encoding is UTF-16 */
1207 XSLT_GET_IMPORT_PTR(encoding
, style
, encoding
);
1211 output
= xmlOutputBufferCreateIO(transform_to_stream_write
, NULL
, stream
, xmlFindCharEncodingHandler((const char*)encoding
));
1213 return E_OUTOFMEMORY
;
1215 hr
= node_transform_write(style
, result
, FALSE
, (const char*)encoding
, output
);
1216 xmlOutputBufferClose(output
);
1222 HRESULT
node_transform_node_params(const xmlnode
*This
, IXMLDOMNode
*stylesheet
, BSTR
*p
,
1223 IStream
*stream
, const struct xslprocessor_params
*params
)
1225 #ifdef SONAME_LIBXSLT
1226 xsltStylesheetPtr xsltSS
;
1230 if (!libxslt_handle
) return E_NOTIMPL
;
1231 if (!stylesheet
|| !p
) return E_INVALIDARG
;
1235 sheet
= get_node_obj(stylesheet
);
1236 if(!sheet
) return E_FAIL
;
1238 xsltSS
= pxsltParseStylesheetDoc(sheet
->node
->doc
);
1241 const char **xslparams
= NULL
;
1245 /* convert our parameter list to libxml2 format */
1246 if (params
&& params
->count
)
1248 struct xslprocessor_par
*par
;
1251 xslparams
= heap_alloc((params
->count
*2 + 1)*sizeof(char*));
1252 LIST_FOR_EACH_ENTRY(par
, ¶ms
->list
, struct xslprocessor_par
, entry
)
1254 xslparams
[i
++] = (char*)xmlchar_from_wchar(par
->name
);
1255 xslparams
[i
++] = (char*)xmlchar_from_wchar(par
->value
);
1257 xslparams
[i
] = NULL
;
1262 xsltTransformContextPtr ctxt
= pxsltNewTransformContext(xsltSS
, This
->node
->doc
);
1264 /* push parameters to user context */
1265 pxsltQuoteUserParams(ctxt
, xslparams
);
1266 result
= pxsltApplyStylesheetUser(xsltSS
, This
->node
->doc
, NULL
, NULL
, NULL
, ctxt
);
1267 pxsltFreeTransformContext(ctxt
);
1269 for (i
= 0; i
< params
->count
*2; i
++)
1270 heap_free((char*)xslparams
[i
]);
1271 heap_free(xslparams
);
1274 result
= pxsltApplyStylesheet(xsltSS
, This
->node
->doc
, NULL
);
1279 hr
= node_transform_write_to_stream(xsltSS
, result
, stream
);
1281 hr
= node_transform_write_to_bstr(xsltSS
, result
, p
);
1284 /* libxslt "helpfully" frees the XML document the stylesheet was
1285 generated from, too */
1287 pxsltFreeStylesheet(xsltSS
);
1290 if(!*p
) *p
= SysAllocStringLen(NULL
, 0);
1294 ERR_(winediag
)("libxslt headers were not found at compile time. Expect problems.\n");
1300 HRESULT
node_transform_node(const xmlnode
*node
, IXMLDOMNode
*stylesheet
, BSTR
*p
)
1302 return node_transform_node_params(node
, stylesheet
, p
, NULL
, NULL
);
1305 HRESULT
node_select_nodes(const xmlnode
*This
, BSTR query
, IXMLDOMNodeList
**nodes
)
1310 if (!query
|| !nodes
) return E_INVALIDARG
;
1312 str
= xmlchar_from_wchar(query
);
1313 hr
= create_selection(This
->node
, str
, nodes
);
1319 HRESULT
node_select_singlenode(const xmlnode
*This
, BSTR query
, IXMLDOMNode
**node
)
1321 IXMLDOMNodeList
*list
;
1324 hr
= node_select_nodes(This
, query
, &list
);
1327 hr
= IXMLDOMNodeList_nextNode(list
, node
);
1328 IXMLDOMNodeList_Release(list
);
1333 HRESULT
node_get_namespaceURI(xmlnode
*This
, BSTR
*namespaceURI
)
1335 xmlNsPtr ns
= This
->node
->ns
;
1338 return E_INVALIDARG
;
1340 *namespaceURI
= NULL
;
1343 *namespaceURI
= bstr_from_xmlChar(ns
->href
);
1345 TRACE("uri: %s\n", debugstr_w(*namespaceURI
));
1347 return *namespaceURI
? S_OK
: S_FALSE
;
1350 HRESULT
node_get_prefix(xmlnode
*This
, BSTR
*prefix
)
1352 xmlNsPtr ns
= This
->node
->ns
;
1354 if (!prefix
) return E_INVALIDARG
;
1358 if (ns
&& ns
->prefix
)
1359 *prefix
= bstr_from_xmlChar(ns
->prefix
);
1361 TRACE("prefix: %s\n", debugstr_w(*prefix
));
1363 return *prefix
? S_OK
: S_FALSE
;
1366 HRESULT
node_get_base_name(xmlnode
*This
, BSTR
*name
)
1368 if (!name
) return E_INVALIDARG
;
1370 *name
= bstr_from_xmlChar(This
->node
->name
);
1371 if (!*name
) return E_OUTOFMEMORY
;
1373 TRACE("returning %s\n", debugstr_w(*name
));
1378 /* _private field holds a number of COM instances spawned from this libxml2 node */
1379 static void xmlnode_add_ref(xmlNodePtr node
)
1381 if (node
->type
== XML_DOCUMENT_NODE
) return;
1382 InterlockedIncrement((LONG
*)&node
->_private
);
1385 static void xmlnode_release(xmlNodePtr node
)
1387 if (node
->type
== XML_DOCUMENT_NODE
) return;
1388 InterlockedDecrement((LONG
*)&node
->_private
);
1391 void destroy_xmlnode(xmlnode
*This
)
1395 xmlnode_release(This
->node
);
1396 xmldoc_release(This
->node
->doc
);
1400 void init_xmlnode(xmlnode
*This
, xmlNodePtr node
, IXMLDOMNode
*node_iface
, dispex_static_data_t
*dispex_data
)
1404 xmlnode_add_ref(node
);
1405 xmldoc_add_ref(node
->doc
);
1409 This
->iface
= node_iface
;
1410 This
->parent
= NULL
;
1412 init_dispex(&This
->dispex
, (IUnknown
*)This
->iface
, dispex_data
);
1417 IXMLDOMNode IXMLDOMNode_iface
;
1421 static inline unknode
*unknode_from_IXMLDOMNode(IXMLDOMNode
*iface
)
1423 return CONTAINING_RECORD(iface
, unknode
, IXMLDOMNode_iface
);
1426 static HRESULT WINAPI
unknode_QueryInterface(
1431 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1433 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppvObject
);
1435 if (IsEqualGUID(riid
, &IID_IUnknown
)) {
1437 }else if (IsEqualGUID( riid
, &IID_IDispatch
) ||
1438 IsEqualGUID( riid
, &IID_IXMLDOMNode
)) {
1439 *ppvObject
= &This
->IXMLDOMNode_iface
;
1440 }else if(node_query_interface(&This
->node
, riid
, ppvObject
)) {
1441 return *ppvObject
? S_OK
: E_NOINTERFACE
;
1443 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
1445 return E_NOINTERFACE
;
1448 IUnknown_AddRef((IUnknown
*)*ppvObject
);
1452 static ULONG WINAPI
unknode_AddRef(
1453 IXMLDOMNode
*iface
)
1455 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1457 return InterlockedIncrement(&This
->ref
);
1460 static ULONG WINAPI
unknode_Release(
1461 IXMLDOMNode
*iface
)
1463 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1466 ref
= InterlockedDecrement( &This
->ref
);
1468 destroy_xmlnode(&This
->node
);
1475 static HRESULT WINAPI
unknode_GetTypeInfoCount(
1479 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1481 TRACE("(%p)->(%p)\n", This
, pctinfo
);
1488 static HRESULT WINAPI
unknode_GetTypeInfo(
1492 ITypeInfo
** ppTInfo
)
1494 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1497 TRACE("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
1499 hr
= get_typeinfo(IXMLDOMNode_tid
, ppTInfo
);
1504 static HRESULT WINAPI
unknode_GetIDsOfNames(
1507 LPOLESTR
* rgszNames
,
1512 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1514 ITypeInfo
*typeinfo
;
1517 TRACE("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
1520 if(!rgszNames
|| cNames
== 0 || !rgDispId
)
1521 return E_INVALIDARG
;
1523 hr
= get_typeinfo(IXMLDOMNode_tid
, &typeinfo
);
1526 hr
= ITypeInfo_GetIDsOfNames(typeinfo
, rgszNames
, cNames
, rgDispId
);
1527 ITypeInfo_Release(typeinfo
);
1533 static HRESULT WINAPI
unknode_Invoke(
1535 DISPID dispIdMember
,
1539 DISPPARAMS
* pDispParams
,
1540 VARIANT
* pVarResult
,
1541 EXCEPINFO
* pExcepInfo
,
1544 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1545 ITypeInfo
*typeinfo
;
1548 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
1549 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
1551 hr
= get_typeinfo(IXMLDOMNode_tid
, &typeinfo
);
1554 hr
= ITypeInfo_Invoke(typeinfo
, &This
->IXMLDOMNode_iface
, dispIdMember
, wFlags
, pDispParams
,
1555 pVarResult
, pExcepInfo
, puArgErr
);
1556 ITypeInfo_Release(typeinfo
);
1562 static HRESULT WINAPI
unknode_get_nodeName(
1566 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1568 FIXME("(%p)->(%p)\n", This
, p
);
1570 return node_get_nodeName(&This
->node
, p
);
1573 static HRESULT WINAPI
unknode_get_nodeValue(
1577 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1579 FIXME("(%p)->(%p)\n", This
, value
);
1582 return E_INVALIDARG
;
1584 V_VT(value
) = VT_NULL
;
1588 static HRESULT WINAPI
unknode_put_nodeValue(
1592 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1593 FIXME("(%p)->(v%d)\n", This
, V_VT(&value
));
1597 static HRESULT WINAPI
unknode_get_nodeType(
1599 DOMNodeType
* domNodeType
)
1601 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1603 FIXME("(%p)->(%p)\n", This
, domNodeType
);
1605 *domNodeType
= This
->node
.node
->type
;
1609 static HRESULT WINAPI
unknode_get_parentNode(
1611 IXMLDOMNode
** parent
)
1613 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1614 FIXME("(%p)->(%p)\n", This
, parent
);
1615 if (!parent
) return E_INVALIDARG
;
1620 static HRESULT WINAPI
unknode_get_childNodes(
1622 IXMLDOMNodeList
** outList
)
1624 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1626 TRACE("(%p)->(%p)\n", This
, outList
);
1628 return node_get_child_nodes(&This
->node
, outList
);
1631 static HRESULT WINAPI
unknode_get_firstChild(
1633 IXMLDOMNode
** domNode
)
1635 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1637 TRACE("(%p)->(%p)\n", This
, domNode
);
1639 return node_get_first_child(&This
->node
, domNode
);
1642 static HRESULT WINAPI
unknode_get_lastChild(
1644 IXMLDOMNode
** domNode
)
1646 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1648 TRACE("(%p)->(%p)\n", This
, domNode
);
1650 return node_get_last_child(&This
->node
, domNode
);
1653 static HRESULT WINAPI
unknode_get_previousSibling(
1655 IXMLDOMNode
** domNode
)
1657 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1659 TRACE("(%p)->(%p)\n", This
, domNode
);
1661 return node_get_previous_sibling(&This
->node
, domNode
);
1664 static HRESULT WINAPI
unknode_get_nextSibling(
1666 IXMLDOMNode
** domNode
)
1668 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1670 TRACE("(%p)->(%p)\n", This
, domNode
);
1672 return node_get_next_sibling(&This
->node
, domNode
);
1675 static HRESULT WINAPI
unknode_get_attributes(
1677 IXMLDOMNamedNodeMap
** attributeMap
)
1679 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1681 FIXME("(%p)->(%p)\n", This
, attributeMap
);
1683 return return_null_ptr((void**)attributeMap
);
1686 static HRESULT WINAPI
unknode_insertBefore(
1688 IXMLDOMNode
* newNode
, VARIANT refChild
,
1689 IXMLDOMNode
** outOldNode
)
1691 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1693 FIXME("(%p)->(%p x%d %p)\n", This
, newNode
, V_VT(&refChild
), outOldNode
);
1695 return node_insert_before(&This
->node
, newNode
, &refChild
, outOldNode
);
1698 static HRESULT WINAPI
unknode_replaceChild(
1700 IXMLDOMNode
* newNode
,
1701 IXMLDOMNode
* oldNode
,
1702 IXMLDOMNode
** outOldNode
)
1704 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1706 FIXME("(%p)->(%p %p %p)\n", This
, newNode
, oldNode
, outOldNode
);
1708 return node_replace_child(&This
->node
, newNode
, oldNode
, outOldNode
);
1711 static HRESULT WINAPI
unknode_removeChild(
1713 IXMLDOMNode
* domNode
, IXMLDOMNode
** oldNode
)
1715 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1716 return node_remove_child(&This
->node
, domNode
, oldNode
);
1719 static HRESULT WINAPI
unknode_appendChild(
1721 IXMLDOMNode
* newNode
, IXMLDOMNode
** outNewNode
)
1723 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1724 return node_append_child(&This
->node
, newNode
, outNewNode
);
1727 static HRESULT WINAPI
unknode_hasChildNodes(
1729 VARIANT_BOOL
* pbool
)
1731 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1732 return node_has_childnodes(&This
->node
, pbool
);
1735 static HRESULT WINAPI
unknode_get_ownerDocument(
1737 IXMLDOMDocument
** domDocument
)
1739 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1740 return node_get_owner_doc(&This
->node
, domDocument
);
1743 static HRESULT WINAPI
unknode_cloneNode(
1745 VARIANT_BOOL pbool
, IXMLDOMNode
** outNode
)
1747 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1748 return node_clone(&This
->node
, pbool
, outNode
);
1751 static HRESULT WINAPI
unknode_get_nodeTypeString(
1755 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1757 FIXME("(%p)->(%p)\n", This
, p
);
1759 return node_get_nodeName(&This
->node
, p
);
1762 static HRESULT WINAPI
unknode_get_text(
1766 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1767 return node_get_text(&This
->node
, p
);
1770 static HRESULT WINAPI
unknode_put_text(
1774 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1775 return node_put_text(&This
->node
, p
);
1778 static HRESULT WINAPI
unknode_get_specified(
1780 VARIANT_BOOL
* isSpecified
)
1782 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1783 FIXME("(%p)->(%p) stub!\n", This
, isSpecified
);
1784 *isSpecified
= VARIANT_TRUE
;
1788 static HRESULT WINAPI
unknode_get_definition(
1790 IXMLDOMNode
** definitionNode
)
1792 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1793 FIXME("(%p)->(%p)\n", This
, definitionNode
);
1797 static HRESULT WINAPI
unknode_get_nodeTypedValue(
1801 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1802 FIXME("(%p)->(%p)\n", This
, var1
);
1803 return return_null_var(var1
);
1806 static HRESULT WINAPI
unknode_put_nodeTypedValue(
1810 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1811 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&typedValue
));
1815 static HRESULT WINAPI
unknode_get_dataType(
1819 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1820 TRACE("(%p)->(%p)\n", This
, var1
);
1821 return return_null_var(var1
);
1824 static HRESULT WINAPI
unknode_put_dataType(
1828 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1830 FIXME("(%p)->(%s)\n", This
, debugstr_w(p
));
1833 return E_INVALIDARG
;
1838 static HRESULT WINAPI
unknode_get_xml(
1842 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1844 FIXME("(%p)->(%p)\n", This
, p
);
1846 return node_get_xml(&This
->node
, FALSE
, p
);
1849 static HRESULT WINAPI
unknode_transformNode(
1851 IXMLDOMNode
* domNode
, BSTR
* p
)
1853 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1854 return node_transform_node(&This
->node
, domNode
, p
);
1857 static HRESULT WINAPI
unknode_selectNodes(
1859 BSTR p
, IXMLDOMNodeList
** outList
)
1861 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1862 return node_select_nodes(&This
->node
, p
, outList
);
1865 static HRESULT WINAPI
unknode_selectSingleNode(
1867 BSTR p
, IXMLDOMNode
** outNode
)
1869 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1870 return node_select_singlenode(&This
->node
, p
, outNode
);
1873 static HRESULT WINAPI
unknode_get_parsed(
1875 VARIANT_BOOL
* isParsed
)
1877 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1878 FIXME("(%p)->(%p) stub!\n", This
, isParsed
);
1879 *isParsed
= VARIANT_TRUE
;
1883 static HRESULT WINAPI
unknode_get_namespaceURI(
1887 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1888 TRACE("(%p)->(%p)\n", This
, p
);
1889 return node_get_namespaceURI(&This
->node
, p
);
1892 static HRESULT WINAPI
unknode_get_prefix(
1896 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1897 return node_get_prefix(&This
->node
, p
);
1900 static HRESULT WINAPI
unknode_get_baseName(
1904 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1905 return node_get_base_name(&This
->node
, p
);
1908 static HRESULT WINAPI
unknode_transformNodeToObject(
1910 IXMLDOMNode
* domNode
, VARIANT var1
)
1912 unknode
*This
= unknode_from_IXMLDOMNode( iface
);
1913 FIXME("(%p)->(%p %s)\n", This
, domNode
, debugstr_variant(&var1
));
1917 static const struct IXMLDOMNodeVtbl unknode_vtbl
=
1919 unknode_QueryInterface
,
1922 unknode_GetTypeInfoCount
,
1923 unknode_GetTypeInfo
,
1924 unknode_GetIDsOfNames
,
1926 unknode_get_nodeName
,
1927 unknode_get_nodeValue
,
1928 unknode_put_nodeValue
,
1929 unknode_get_nodeType
,
1930 unknode_get_parentNode
,
1931 unknode_get_childNodes
,
1932 unknode_get_firstChild
,
1933 unknode_get_lastChild
,
1934 unknode_get_previousSibling
,
1935 unknode_get_nextSibling
,
1936 unknode_get_attributes
,
1937 unknode_insertBefore
,
1938 unknode_replaceChild
,
1939 unknode_removeChild
,
1940 unknode_appendChild
,
1941 unknode_hasChildNodes
,
1942 unknode_get_ownerDocument
,
1944 unknode_get_nodeTypeString
,
1947 unknode_get_specified
,
1948 unknode_get_definition
,
1949 unknode_get_nodeTypedValue
,
1950 unknode_put_nodeTypedValue
,
1951 unknode_get_dataType
,
1952 unknode_put_dataType
,
1954 unknode_transformNode
,
1955 unknode_selectNodes
,
1956 unknode_selectSingleNode
,
1958 unknode_get_namespaceURI
,
1960 unknode_get_baseName
,
1961 unknode_transformNodeToObject
1964 IXMLDOMNode
*create_node( xmlNodePtr node
)
1973 TRACE("type %d\n", node
->type
);
1976 case XML_ELEMENT_NODE
:
1977 pUnk
= create_element( node
);
1979 case XML_ATTRIBUTE_NODE
:
1980 pUnk
= create_attribute( node
);
1983 pUnk
= create_text( node
);
1985 case XML_CDATA_SECTION_NODE
:
1986 pUnk
= create_cdata( node
);
1988 case XML_ENTITY_REF_NODE
:
1989 pUnk
= create_doc_entity_ref( node
);
1992 pUnk
= create_pi( node
);
1994 case XML_COMMENT_NODE
:
1995 pUnk
= create_comment( node
);
1997 case XML_DOCUMENT_NODE
:
1998 pUnk
= create_domdoc( node
);
2000 case XML_DOCUMENT_FRAG_NODE
:
2001 pUnk
= create_doc_fragment( node
);
2004 pUnk
= create_doc_type( node
);
2009 FIXME("only creating basic node for type %d\n", node
->type
);
2011 new_node
= heap_alloc(sizeof(unknode
));
2015 new_node
->IXMLDOMNode_iface
.lpVtbl
= &unknode_vtbl
;
2017 init_xmlnode(&new_node
->node
, node
, &new_node
->IXMLDOMNode_iface
, NULL
);
2018 pUnk
= (IUnknown
*)&new_node
->IXMLDOMNode_iface
;
2022 hr
= IUnknown_QueryInterface(pUnk
, &IID_IXMLDOMNode
, (LPVOID
*)&ret
);
2023 IUnknown_Release(pUnk
);
2024 if(FAILED(hr
)) return NULL
;