2 * DOM processing instruction node implementation
4 * Copyright 2006 Huw Davies
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
27 # include <libxml/parser.h>
28 # include <libxml/xmlerror.h>
37 #include "msxml_private.h"
39 #include "wine/debug.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
45 typedef struct _dom_pi
48 IXMLDOMProcessingInstruction IXMLDOMProcessingInstruction_iface;
52 static inline dom_pi *impl_from_IXMLDOMProcessingInstruction( IXMLDOMProcessingInstruction *iface )
54 return CONTAINING_RECORD(iface, dom_pi, IXMLDOMProcessingInstruction_iface);
57 static HRESULT WINAPI dom_pi_QueryInterface(
58 IXMLDOMProcessingInstruction *iface,
62 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
63 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject);
65 if ( IsEqualGUID( riid, &IID_IXMLDOMProcessingInstruction ) ||
66 IsEqualGUID( riid, &IID_IXMLDOMNode ) ||
67 IsEqualGUID( riid, &IID_IDispatch ) ||
68 IsEqualGUID( riid, &IID_IUnknown ) )
72 else if(node_query_interface(&This->node, riid, ppvObject))
74 return *ppvObject ? S_OK : E_NOINTERFACE;
78 FIXME("Unsupported interface %s\n", debugstr_guid(riid));
82 IUnknown_AddRef((IUnknown*)*ppvObject);
86 static ULONG WINAPI dom_pi_AddRef(
87 IXMLDOMProcessingInstruction *iface )
89 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
90 return InterlockedIncrement( &This->ref );
93 static ULONG WINAPI dom_pi_Release(
94 IXMLDOMProcessingInstruction *iface )
96 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
99 ref = InterlockedDecrement( &This->ref );
102 destroy_xmlnode(&This->node);
109 static HRESULT WINAPI dom_pi_GetTypeInfoCount(
110 IXMLDOMProcessingInstruction *iface,
113 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
115 TRACE("(%p)->(%p)\n", This, pctinfo);
122 static HRESULT WINAPI dom_pi_GetTypeInfo(
123 IXMLDOMProcessingInstruction *iface,
124 UINT iTInfo, LCID lcid,
125 ITypeInfo** ppTInfo )
127 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
130 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
132 hr = get_typeinfo(IXMLDOMProcessingInstruction_tid, ppTInfo);
137 static HRESULT WINAPI dom_pi_GetIDsOfNames(
138 IXMLDOMProcessingInstruction *iface,
139 REFIID riid, LPOLESTR* rgszNames,
140 UINT cNames, LCID lcid, DISPID* rgDispId )
142 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
146 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
149 if(!rgszNames || cNames == 0 || !rgDispId)
152 hr = get_typeinfo(IXMLDOMProcessingInstruction_tid, &typeinfo);
155 hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
156 ITypeInfo_Release(typeinfo);
162 static HRESULT WINAPI dom_pi_Invoke(
163 IXMLDOMProcessingInstruction *iface,
164 DISPID dispIdMember, REFIID riid, LCID lcid,
165 WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult,
166 EXCEPINFO* pExcepInfo, UINT* puArgErr )
168 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
172 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
173 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
175 hr = get_typeinfo(IXMLDOMProcessingInstruction_tid, &typeinfo);
178 hr = ITypeInfo_Invoke(typeinfo, &This->IXMLDOMProcessingInstruction_iface, dispIdMember,
179 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
180 ITypeInfo_Release(typeinfo);
186 static HRESULT WINAPI dom_pi_get_nodeName(
187 IXMLDOMProcessingInstruction *iface,
190 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
192 TRACE("(%p)->(%p)\n", This, p);
194 return node_get_nodeName(&This->node, p);
197 static HRESULT WINAPI dom_pi_get_nodeValue(
198 IXMLDOMProcessingInstruction *iface,
201 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
203 TRACE("(%p)->(%p)\n", This, value);
205 return node_get_content(&This->node, value);
208 static HRESULT WINAPI dom_pi_put_nodeValue(
209 IXMLDOMProcessingInstruction *iface,
212 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
216 TRACE("(%p)->(%s)\n", This, debugstr_variant(&value));
218 /* Cannot set data to a PI node whose target is 'xml' */
219 hr = dom_pi_get_nodeName(iface, &sTarget);
222 static const WCHAR xmlW[] = {'x','m','l',0};
223 if(lstrcmpW( sTarget, xmlW) == 0)
225 SysFreeString(sTarget);
229 SysFreeString(sTarget);
232 return node_put_value(&This->node, &value);
235 static HRESULT WINAPI dom_pi_get_nodeType(
236 IXMLDOMProcessingInstruction *iface,
237 DOMNodeType* domNodeType )
239 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
241 TRACE("(%p)->(%p)\n", This, domNodeType);
243 *domNodeType = NODE_PROCESSING_INSTRUCTION;
247 static HRESULT WINAPI dom_pi_get_parentNode(
248 IXMLDOMProcessingInstruction *iface,
249 IXMLDOMNode** parent )
251 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
253 TRACE("(%p)->(%p)\n", This, parent);
255 return node_get_parent(&This->node, parent);
258 static HRESULT WINAPI dom_pi_get_childNodes(
259 IXMLDOMProcessingInstruction *iface,
260 IXMLDOMNodeList** outList)
262 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
264 TRACE("(%p)->(%p)\n", This, outList);
266 return node_get_child_nodes(&This->node, outList);
269 static HRESULT WINAPI dom_pi_get_firstChild(
270 IXMLDOMProcessingInstruction *iface,
271 IXMLDOMNode** domNode)
273 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
275 TRACE("(%p)->(%p)\n", This, domNode);
277 return return_null_node(domNode);
280 static HRESULT WINAPI dom_pi_get_lastChild(
281 IXMLDOMProcessingInstruction *iface,
282 IXMLDOMNode** domNode)
284 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
286 TRACE("(%p)->(%p)\n", This, domNode);
288 return return_null_node(domNode);
291 static HRESULT WINAPI dom_pi_get_previousSibling(
292 IXMLDOMProcessingInstruction *iface,
293 IXMLDOMNode** domNode)
295 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
297 TRACE("(%p)->(%p)\n", This, domNode);
299 return node_get_previous_sibling(&This->node, domNode);
302 static HRESULT WINAPI dom_pi_get_nextSibling(
303 IXMLDOMProcessingInstruction *iface,
304 IXMLDOMNode** domNode)
306 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
308 TRACE("(%p)->(%p)\n", This, domNode);
310 return node_get_next_sibling(&This->node, domNode);
313 static HRESULT WINAPI dom_pi_get_attributes(
314 IXMLDOMProcessingInstruction *iface,
315 IXMLDOMNamedNodeMap** attributeMap)
317 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
319 TRACE("(%p)->(%p)\n", This, attributeMap);
321 *attributeMap = create_nodemap((IXMLDOMNode*)&This->IXMLDOMProcessingInstruction_iface);
325 static HRESULT WINAPI dom_pi_insertBefore(
326 IXMLDOMProcessingInstruction *iface,
327 IXMLDOMNode* newNode, VARIANT refChild,
328 IXMLDOMNode** outOldNode)
330 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
332 FIXME("(%p)->(%p %s %p) needs test\n", This, newNode, debugstr_variant(&refChild), outOldNode);
334 return node_insert_before(&This->node, newNode, &refChild, outOldNode);
337 static HRESULT WINAPI dom_pi_replaceChild(
338 IXMLDOMProcessingInstruction *iface,
339 IXMLDOMNode* newNode,
340 IXMLDOMNode* oldNode,
341 IXMLDOMNode** outOldNode)
343 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
345 FIXME("(%p)->(%p %p %p) needs test\n", This, newNode, oldNode, outOldNode);
347 return node_replace_child(&This->node, newNode, oldNode, outOldNode);
350 static HRESULT WINAPI dom_pi_removeChild(
351 IXMLDOMProcessingInstruction *iface,
352 IXMLDOMNode *child, IXMLDOMNode **oldChild)
354 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
355 TRACE("(%p)->(%p %p)\n", This, child, oldChild);
356 return node_remove_child(&This->node, child, oldChild);
359 static HRESULT WINAPI dom_pi_appendChild(
360 IXMLDOMProcessingInstruction *iface,
361 IXMLDOMNode *child, IXMLDOMNode **outChild)
363 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
364 TRACE("(%p)->(%p %p)\n", This, child, outChild);
365 return node_append_child(&This->node, child, outChild);
368 static HRESULT WINAPI dom_pi_hasChildNodes(
369 IXMLDOMProcessingInstruction *iface,
372 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
373 TRACE("(%p)->(%p)\n", This, ret);
374 return node_has_childnodes(&This->node, ret);
377 static HRESULT WINAPI dom_pi_get_ownerDocument(
378 IXMLDOMProcessingInstruction *iface,
379 IXMLDOMDocument **doc)
381 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
382 TRACE("(%p)->(%p)\n", This, doc);
383 return node_get_owner_doc(&This->node, doc);
386 static HRESULT WINAPI dom_pi_cloneNode(
387 IXMLDOMProcessingInstruction *iface,
388 VARIANT_BOOL deep, IXMLDOMNode** outNode)
390 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
391 TRACE("(%p)->(%d %p)\n", This, deep, outNode);
392 return node_clone( &This->node, deep, outNode );
395 static HRESULT WINAPI dom_pi_get_nodeTypeString(
396 IXMLDOMProcessingInstruction *iface,
399 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
400 static const WCHAR processinginstructionW[] =
401 {'p','r','o','c','e','s','s','i','n','g','i','n','s','t','r','u','c','t','i','o','n',0};
403 TRACE("(%p)->(%p)\n", This, p);
405 return return_bstr(processinginstructionW, p);
408 static HRESULT WINAPI dom_pi_get_text(
409 IXMLDOMProcessingInstruction *iface,
412 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
413 TRACE("(%p)->(%p)\n", This, p);
414 return node_get_text(&This->node, p);
417 static HRESULT WINAPI dom_pi_put_text(
418 IXMLDOMProcessingInstruction *iface,
421 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
422 TRACE("(%p)->(%s)\n", This, debugstr_w(p));
423 return node_put_text( &This->node, p );
426 static HRESULT WINAPI dom_pi_get_specified(
427 IXMLDOMProcessingInstruction *iface,
428 VARIANT_BOOL* isSpecified)
430 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
431 FIXME("(%p)->(%p) stub!\n", This, isSpecified);
432 *isSpecified = VARIANT_TRUE;
436 static HRESULT WINAPI dom_pi_get_definition(
437 IXMLDOMProcessingInstruction *iface,
438 IXMLDOMNode** definitionNode)
440 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
441 FIXME("(%p)->(%p)\n", This, definitionNode);
445 static HRESULT WINAPI dom_pi_get_nodeTypedValue(
446 IXMLDOMProcessingInstruction *iface,
449 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
450 FIXME("(%p)->(%p)\n", This, var1);
451 return return_null_var(var1);
454 static HRESULT WINAPI dom_pi_put_nodeTypedValue(
455 IXMLDOMProcessingInstruction *iface,
458 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
459 FIXME("(%p)->(%s)\n", This, debugstr_variant(&typedValue));
463 static HRESULT WINAPI dom_pi_get_dataType(
464 IXMLDOMProcessingInstruction *iface,
467 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
468 TRACE("(%p)->(%p)\n", This, typename);
469 return return_null_var( typename );
472 static HRESULT WINAPI dom_pi_put_dataType(
473 IXMLDOMProcessingInstruction *iface,
476 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
478 FIXME("(%p)->(%s)\n", This, debugstr_w(p));
486 static HRESULT WINAPI dom_pi_get_xml(
487 IXMLDOMProcessingInstruction *iface,
490 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
492 TRACE("(%p)->(%p)\n", This, p);
494 return node_get_xml(&This->node, FALSE, FALSE, p);
497 static HRESULT WINAPI dom_pi_transformNode(
498 IXMLDOMProcessingInstruction *iface,
499 IXMLDOMNode *node, BSTR *p)
501 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
502 TRACE("(%p)->(%p %p)\n", This, node, p);
503 return node_transform_node(&This->node, node, p);
506 static HRESULT WINAPI dom_pi_selectNodes(
507 IXMLDOMProcessingInstruction *iface,
508 BSTR p, IXMLDOMNodeList** outList)
510 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
511 TRACE("(%p)->(%s %p)\n", This, debugstr_w(p), outList);
512 return node_select_nodes(&This->node, p, outList);
515 static HRESULT WINAPI dom_pi_selectSingleNode(
516 IXMLDOMProcessingInstruction *iface,
517 BSTR p, IXMLDOMNode** outNode)
519 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
520 TRACE("(%p)->(%s %p)\n", This, debugstr_w(p), outNode);
521 return node_select_singlenode(&This->node, p, outNode);
524 static HRESULT WINAPI dom_pi_get_parsed(
525 IXMLDOMProcessingInstruction *iface,
526 VARIANT_BOOL* isParsed)
528 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
529 FIXME("(%p)->(%p) stub!\n", This, isParsed);
530 *isParsed = VARIANT_TRUE;
534 static HRESULT WINAPI dom_pi_get_namespaceURI(
535 IXMLDOMProcessingInstruction *iface,
538 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
539 TRACE("(%p)->(%p)\n", This, p);
540 return node_get_namespaceURI(&This->node, p);
543 static HRESULT WINAPI dom_pi_get_prefix(
544 IXMLDOMProcessingInstruction *iface,
547 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
548 TRACE("(%p)->(%p)\n", This, prefix);
549 return return_null_bstr( prefix );
552 static HRESULT WINAPI dom_pi_get_baseName(
553 IXMLDOMProcessingInstruction *iface,
556 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
557 TRACE("(%p)->(%p)\n", This, name);
558 return node_get_base_name( &This->node, name );
561 static HRESULT WINAPI dom_pi_transformNodeToObject(
562 IXMLDOMProcessingInstruction *iface,
563 IXMLDOMNode* domNode, VARIANT var1)
565 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
566 FIXME("(%p)->(%p %s)\n", This, domNode, debugstr_variant(&var1));
570 static HRESULT WINAPI dom_pi_get_target(
571 IXMLDOMProcessingInstruction *iface,
574 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
576 TRACE("(%p)->(%p)\n", This, p);
578 /* target returns the same value as nodeName property */
579 return node_get_nodeName(&This->node, p);
582 static HRESULT WINAPI dom_pi_get_data(
583 IXMLDOMProcessingInstruction *iface,
586 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
590 TRACE("(%p)->(%p)\n", This, p);
595 hr = IXMLDOMProcessingInstruction_get_nodeValue( iface, &ret );
604 static HRESULT WINAPI dom_pi_put_data(
605 IXMLDOMProcessingInstruction *iface,
608 dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface );
613 TRACE("(%p)->(%s)\n", This, debugstr_w(data) );
615 /* Cannot set data to a PI node whose target is 'xml' */
616 hr = dom_pi_get_nodeName(iface, &sTarget);
619 static const WCHAR xmlW[] = {'x','m','l',0};
620 if(lstrcmpW( sTarget, xmlW) == 0)
622 SysFreeString(sTarget);
626 SysFreeString(sTarget);
629 V_VT(&val) = VT_BSTR;
632 return IXMLDOMProcessingInstruction_put_nodeValue( iface, val );
635 static const struct IXMLDOMProcessingInstructionVtbl dom_pi_vtbl =
637 dom_pi_QueryInterface,
640 dom_pi_GetTypeInfoCount,
642 dom_pi_GetIDsOfNames,
645 dom_pi_get_nodeValue,
646 dom_pi_put_nodeValue,
648 dom_pi_get_parentNode,
649 dom_pi_get_childNodes,
650 dom_pi_get_firstChild,
651 dom_pi_get_lastChild,
652 dom_pi_get_previousSibling,
653 dom_pi_get_nextSibling,
654 dom_pi_get_attributes,
659 dom_pi_hasChildNodes,
660 dom_pi_get_ownerDocument,
662 dom_pi_get_nodeTypeString,
665 dom_pi_get_specified,
666 dom_pi_get_definition,
667 dom_pi_get_nodeTypedValue,
668 dom_pi_put_nodeTypedValue,
672 dom_pi_transformNode,
674 dom_pi_selectSingleNode,
676 dom_pi_get_namespaceURI,
679 dom_pi_transformNodeToObject,
686 IUnknown* create_pi( xmlNodePtr pi )
690 This = heap_alloc( sizeof *This );
694 This->IXMLDOMProcessingInstruction_iface.lpVtbl = &dom_pi_vtbl;
697 init_xmlnode(&This->node, pi, (IXMLDOMNode*)&This->IXMLDOMProcessingInstruction_iface, NULL);
699 return (IUnknown*)&This->IXMLDOMProcessingInstruction_iface;