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
24 #include <libxml/parser.h>
25 #include <libxml/xmlerror.h>
33 #include "xmlparser.h"
34 #include "msxml_private.h"
36 #include "wine/debug.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(msxml
);
40 typedef struct _dom_pi
43 IXMLDOMProcessingInstruction IXMLDOMProcessingInstruction_iface
;
47 static const struct nodemap_funcs dom_pi_attr_map
;
49 static const tid_t dompi_se_tids
[] = {
51 IXMLDOMProcessingInstruction_tid
,
55 static inline dom_pi
*impl_from_IXMLDOMProcessingInstruction( IXMLDOMProcessingInstruction
*iface
)
57 return CONTAINING_RECORD(iface
, dom_pi
, IXMLDOMProcessingInstruction_iface
);
60 static HRESULT WINAPI
dom_pi_QueryInterface(
61 IXMLDOMProcessingInstruction
*iface
,
65 dom_pi
*This
= impl_from_IXMLDOMProcessingInstruction( iface
);
66 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppvObject
);
68 if ( IsEqualGUID( riid
, &IID_IXMLDOMProcessingInstruction
) ||
69 IsEqualGUID( riid
, &IID_IXMLDOMNode
) ||
70 IsEqualGUID( riid
, &IID_IDispatch
) ||
71 IsEqualGUID( riid
, &IID_IUnknown
) )
75 else if(node_query_interface(&This
->node
, riid
, ppvObject
))
77 return *ppvObject
? S_OK
: E_NOINTERFACE
;
79 else if(IsEqualGUID( riid
, &IID_ISupportErrorInfo
))
81 return node_create_supporterrorinfo(dompi_se_tids
, ppvObject
);
85 TRACE("Unsupported interface %s\n", debugstr_guid(riid
));
90 IUnknown_AddRef((IUnknown
*)*ppvObject
);
94 static ULONG WINAPI
dom_pi_AddRef(
95 IXMLDOMProcessingInstruction
*iface
)
97 dom_pi
*This
= impl_from_IXMLDOMProcessingInstruction( iface
);
98 ULONG ref
= InterlockedIncrement( &This
->ref
);
99 TRACE("%p, refcount %lu.\n", iface
, ref
);
103 static ULONG WINAPI
dom_pi_Release(
104 IXMLDOMProcessingInstruction
*iface
)
106 dom_pi
*This
= impl_from_IXMLDOMProcessingInstruction( iface
);
107 ULONG ref
= InterlockedDecrement( &This
->ref
);
109 TRACE("%p, refcount %lu.\n", iface
, ref
);
112 destroy_xmlnode(&This
->node
);
119 static HRESULT WINAPI
dom_pi_GetTypeInfoCount(
120 IXMLDOMProcessingInstruction
*iface
,
123 dom_pi
*This
= impl_from_IXMLDOMProcessingInstruction( iface
);
124 return IDispatchEx_GetTypeInfoCount(&This
->node
.dispex
.IDispatchEx_iface
, pctinfo
);
127 static HRESULT WINAPI
dom_pi_GetTypeInfo(
128 IXMLDOMProcessingInstruction
*iface
,
129 UINT iTInfo
, LCID lcid
,
130 ITypeInfo
** ppTInfo
)
132 dom_pi
*This
= impl_from_IXMLDOMProcessingInstruction( iface
);
133 return IDispatchEx_GetTypeInfo(&This
->node
.dispex
.IDispatchEx_iface
,
134 iTInfo
, lcid
, 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
);
143 return IDispatchEx_GetIDsOfNames(&This
->node
.dispex
.IDispatchEx_iface
,
144 riid
, rgszNames
, cNames
, lcid
, rgDispId
);
147 static HRESULT WINAPI
dom_pi_Invoke(
148 IXMLDOMProcessingInstruction
*iface
,
149 DISPID dispIdMember
, REFIID riid
, LCID lcid
,
150 WORD wFlags
, DISPPARAMS
* pDispParams
, VARIANT
* pVarResult
,
151 EXCEPINFO
* pExcepInfo
, UINT
* puArgErr
)
153 dom_pi
*This
= impl_from_IXMLDOMProcessingInstruction( iface
);
154 return IDispatchEx_Invoke(&This
->node
.dispex
.IDispatchEx_iface
,
155 dispIdMember
, riid
, lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
158 static HRESULT WINAPI
dom_pi_get_nodeName(
159 IXMLDOMProcessingInstruction
*iface
,
162 dom_pi
*This
= impl_from_IXMLDOMProcessingInstruction( iface
);
164 TRACE("(%p)->(%p)\n", This
, p
);
166 return node_get_nodeName(&This
->node
, p
);
169 static HRESULT WINAPI
dom_pi_get_nodeValue(
170 IXMLDOMProcessingInstruction
*iface
,
173 dom_pi
*This
= impl_from_IXMLDOMProcessingInstruction( iface
);
175 TRACE("(%p)->(%p)\n", This
, value
);
177 return node_get_content(&This
->node
, value
);
180 static HRESULT WINAPI
dom_pi_put_nodeValue(
181 IXMLDOMProcessingInstruction
*iface
,
184 dom_pi
*This
= impl_from_IXMLDOMProcessingInstruction( iface
);
188 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&value
));
190 /* Cannot set data to a PI node whose target is 'xml' */
191 hr
= IXMLDOMProcessingInstruction_get_nodeName(iface
, &target
);
194 static const WCHAR xmlW
[] = {'x','m','l',0};
195 if(!wcscmp(target
, xmlW
))
197 SysFreeString(target
);
201 SysFreeString(target
);
204 return node_put_value(&This
->node
, &value
);
207 static HRESULT WINAPI
dom_pi_get_nodeType(
208 IXMLDOMProcessingInstruction
*iface
,
209 DOMNodeType
* domNodeType
)
211 dom_pi
*This
= impl_from_IXMLDOMProcessingInstruction( iface
);
213 TRACE("(%p)->(%p)\n", This
, domNodeType
);
215 *domNodeType
= NODE_PROCESSING_INSTRUCTION
;
219 static HRESULT WINAPI
dom_pi_get_parentNode(
220 IXMLDOMProcessingInstruction
*iface
,
221 IXMLDOMNode
** parent
)
223 dom_pi
*This
= impl_from_IXMLDOMProcessingInstruction( iface
);
225 TRACE("(%p)->(%p)\n", This
, parent
);
227 return node_get_parent(&This
->node
, parent
);
230 static HRESULT WINAPI
dom_pi_get_childNodes(
231 IXMLDOMProcessingInstruction
*iface
,
232 IXMLDOMNodeList
** outList
)
234 dom_pi
*This
= impl_from_IXMLDOMProcessingInstruction( iface
);
236 TRACE("(%p)->(%p)\n", This
, outList
);
238 return node_get_child_nodes(&This
->node
, outList
);
241 static HRESULT WINAPI
dom_pi_get_firstChild(
242 IXMLDOMProcessingInstruction
*iface
,
243 IXMLDOMNode
** domNode
)
245 dom_pi
*This
= impl_from_IXMLDOMProcessingInstruction( iface
);
247 TRACE("(%p)->(%p)\n", This
, domNode
);
249 return return_null_node(domNode
);
252 static HRESULT WINAPI
dom_pi_get_lastChild(
253 IXMLDOMProcessingInstruction
*iface
,
254 IXMLDOMNode
** domNode
)
256 dom_pi
*This
= impl_from_IXMLDOMProcessingInstruction( iface
);
258 TRACE("(%p)->(%p)\n", This
, domNode
);
260 return return_null_node(domNode
);
263 static HRESULT WINAPI
dom_pi_get_previousSibling(
264 IXMLDOMProcessingInstruction
*iface
,
265 IXMLDOMNode
** domNode
)
267 dom_pi
*This
= impl_from_IXMLDOMProcessingInstruction( iface
);
269 TRACE("(%p)->(%p)\n", This
, domNode
);
271 return node_get_previous_sibling(&This
->node
, domNode
);
274 static HRESULT WINAPI
dom_pi_get_nextSibling(
275 IXMLDOMProcessingInstruction
*iface
,
276 IXMLDOMNode
** domNode
)
278 dom_pi
*This
= impl_from_IXMLDOMProcessingInstruction( iface
);
280 TRACE("(%p)->(%p)\n", This
, domNode
);
282 return node_get_next_sibling(&This
->node
, domNode
);
285 static HRESULT
xml_get_value(xmlChar
**p
, xmlChar
**value
)
290 while (isspace(**p
)) *p
+= 1;
291 if (**p
!= '=') return XML_E_MISSINGEQUALS
;
294 while (isspace(**p
)) *p
+= 1;
295 if (**p
!= '"' && **p
!= '\'') return XML_E_MISSINGQUOTE
;
300 while (**p
&& **p
!= q
) *p
+= 1;
301 if (!**p
) return XML_E_BADCHARINSTRING
;
303 if (!len
) return XML_E_MISSINGNAME
;
306 *value
= heap_alloc(len
+ 1);
307 if (!*value
) return E_OUTOFMEMORY
;
308 memcpy(*value
, v
, len
);
314 static void set_prop(xmlNodePtr node
, xmlAttrPtr attr
)
318 if (!node
->properties
)
320 node
->properties
= attr
;
324 prop
= node
->properties
;
325 while (prop
->next
) prop
= prop
->next
;
330 static HRESULT
parse_xml_decl(xmlNodePtr node
)
332 xmlChar
*version
, *encoding
, *standalone
, *p
;
336 if (!node
->content
) return S_OK
;
338 version
= encoding
= standalone
= NULL
;
344 while (isspace(*p
)) p
++;
347 if (!strncmp((const char *)p
, "version", 7))
350 if ((hr
= xml_get_value(&p
, &version
)) != S_OK
) goto fail
;
352 else if (!strncmp((const char *)p
, "encoding", 8))
355 if ((hr
= xml_get_value(&p
, &encoding
)) != S_OK
) goto fail
;
357 else if (!strncmp((const char *)p
, "standalone", 10))
360 if ((hr
= xml_get_value(&p
, &standalone
)) != S_OK
) goto fail
;
364 FIXME("unexpected XML attribute %s\n", debugstr_a((const char *)p
));
365 hr
= XML_E_UNEXPECTED_ATTRIBUTE
;
370 /* xmlSetProp/xmlSetNsProp accept only nodes of type XML_ELEMENT_NODE,
371 * so we have to create and assign attributes to a node by hand.
376 attr
= xmlSetNsProp(NULL
, NULL
, (const xmlChar
*)"version", version
);
379 attr
->doc
= node
->doc
;
380 set_prop(node
, attr
);
382 else hr
= E_OUTOFMEMORY
;
386 attr
= xmlSetNsProp(NULL
, NULL
, (const xmlChar
*)"encoding", encoding
);
389 attr
->doc
= node
->doc
;
390 set_prop(node
, attr
);
392 else hr
= E_OUTOFMEMORY
;
396 attr
= xmlSetNsProp(NULL
, NULL
, (const xmlChar
*)"standalone", standalone
);
399 attr
->doc
= node
->doc
;
400 set_prop(node
, attr
);
402 else hr
= E_OUTOFMEMORY
;
408 xmlFreePropList(node
->properties
);
409 node
->properties
= NULL
;
414 heap_free(standalone
);
418 static HRESULT WINAPI
dom_pi_get_attributes(
419 IXMLDOMProcessingInstruction
*iface
,
420 IXMLDOMNamedNodeMap
** map
)
422 dom_pi
*This
= impl_from_IXMLDOMProcessingInstruction( iface
);
423 static const WCHAR xmlW
[] = {'x','m','l',0};
427 TRACE("(%p)->(%p)\n", This
, map
);
429 if (!map
) return E_INVALIDARG
;
433 hr
= node_get_nodeName(&This
->node
, &name
);
434 if (hr
!= S_OK
) return hr
;
436 if (!wcscmp(name
, xmlW
))
437 *map
= create_nodemap(This
->node
.node
, &dom_pi_attr_map
);
441 return *map
? S_OK
: S_FALSE
;
444 static HRESULT WINAPI
dom_pi_insertBefore(
445 IXMLDOMProcessingInstruction
*iface
,
446 IXMLDOMNode
* newNode
, VARIANT refChild
,
447 IXMLDOMNode
** outOldNode
)
449 dom_pi
*This
= impl_from_IXMLDOMProcessingInstruction( iface
);
451 FIXME("(%p)->(%p %s %p) needs test\n", This
, newNode
, debugstr_variant(&refChild
), outOldNode
);
453 return node_insert_before(&This
->node
, newNode
, &refChild
, outOldNode
);
456 static HRESULT WINAPI
dom_pi_replaceChild(
457 IXMLDOMProcessingInstruction
*iface
,
458 IXMLDOMNode
* newNode
,
459 IXMLDOMNode
* oldNode
,
460 IXMLDOMNode
** outOldNode
)
462 dom_pi
*This
= impl_from_IXMLDOMProcessingInstruction( iface
);
464 FIXME("(%p)->(%p %p %p) needs test\n", This
, newNode
, oldNode
, outOldNode
);
466 return node_replace_child(&This
->node
, newNode
, oldNode
, outOldNode
);
469 static HRESULT WINAPI
dom_pi_removeChild(
470 IXMLDOMProcessingInstruction
*iface
,
471 IXMLDOMNode
*child
, IXMLDOMNode
**oldChild
)
473 dom_pi
*This
= impl_from_IXMLDOMProcessingInstruction( iface
);
474 TRACE("(%p)->(%p %p)\n", This
, child
, oldChild
);
475 return node_remove_child(&This
->node
, child
, oldChild
);
478 static HRESULT WINAPI
dom_pi_appendChild(
479 IXMLDOMProcessingInstruction
*iface
,
480 IXMLDOMNode
*child
, IXMLDOMNode
**outChild
)
482 dom_pi
*This
= impl_from_IXMLDOMProcessingInstruction( iface
);
483 TRACE("(%p)->(%p %p)\n", This
, child
, outChild
);
484 return node_append_child(&This
->node
, child
, outChild
);
487 static HRESULT WINAPI
dom_pi_hasChildNodes(
488 IXMLDOMProcessingInstruction
*iface
,
491 dom_pi
*This
= impl_from_IXMLDOMProcessingInstruction( iface
);
492 TRACE("(%p)->(%p)\n", This
, ret
);
493 return node_has_childnodes(&This
->node
, ret
);
496 static HRESULT WINAPI
dom_pi_get_ownerDocument(
497 IXMLDOMProcessingInstruction
*iface
,
498 IXMLDOMDocument
**doc
)
500 dom_pi
*This
= impl_from_IXMLDOMProcessingInstruction( iface
);
501 TRACE("(%p)->(%p)\n", This
, doc
);
502 return node_get_owner_doc(&This
->node
, doc
);
505 static HRESULT WINAPI
dom_pi_cloneNode(
506 IXMLDOMProcessingInstruction
*iface
,
507 VARIANT_BOOL deep
, IXMLDOMNode
** outNode
)
509 dom_pi
*This
= impl_from_IXMLDOMProcessingInstruction( iface
);
510 TRACE("(%p)->(%d %p)\n", This
, deep
, outNode
);
511 return node_clone( &This
->node
, deep
, outNode
);
514 static HRESULT WINAPI
dom_pi_get_nodeTypeString(
515 IXMLDOMProcessingInstruction
*iface
,
518 dom_pi
*This
= impl_from_IXMLDOMProcessingInstruction( iface
);
519 static const WCHAR processinginstructionW
[] =
520 {'p','r','o','c','e','s','s','i','n','g','i','n','s','t','r','u','c','t','i','o','n',0};
522 TRACE("(%p)->(%p)\n", This
, p
);
524 return return_bstr(processinginstructionW
, p
);
527 static HRESULT WINAPI
dom_pi_get_text(
528 IXMLDOMProcessingInstruction
*iface
,
531 dom_pi
*This
= impl_from_IXMLDOMProcessingInstruction( iface
);
532 TRACE("(%p)->(%p)\n", This
, p
);
533 return node_get_text(&This
->node
, p
);
536 static HRESULT WINAPI
dom_pi_put_text(
537 IXMLDOMProcessingInstruction
*iface
,
540 dom_pi
*This
= impl_from_IXMLDOMProcessingInstruction( iface
);
541 TRACE("(%p)->(%s)\n", This
, debugstr_w(p
));
542 return node_put_text( &This
->node
, p
);
545 static HRESULT WINAPI
dom_pi_get_specified(
546 IXMLDOMProcessingInstruction
*iface
,
547 VARIANT_BOOL
* isSpecified
)
549 dom_pi
*This
= impl_from_IXMLDOMProcessingInstruction( iface
);
550 FIXME("(%p)->(%p) stub!\n", This
, isSpecified
);
551 *isSpecified
= VARIANT_TRUE
;
555 static HRESULT WINAPI
dom_pi_get_definition(
556 IXMLDOMProcessingInstruction
*iface
,
557 IXMLDOMNode
** definitionNode
)
559 dom_pi
*This
= impl_from_IXMLDOMProcessingInstruction( iface
);
560 FIXME("(%p)->(%p)\n", This
, definitionNode
);
564 static HRESULT WINAPI
dom_pi_get_nodeTypedValue(
565 IXMLDOMProcessingInstruction
*iface
,
568 dom_pi
*This
= impl_from_IXMLDOMProcessingInstruction( iface
);
569 TRACE("(%p)->(%p)\n", This
, v
);
570 return node_get_content(&This
->node
, v
);
573 static HRESULT WINAPI
dom_pi_put_nodeTypedValue(
574 IXMLDOMProcessingInstruction
*iface
,
577 dom_pi
*This
= impl_from_IXMLDOMProcessingInstruction( iface
);
578 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&typedValue
));
582 static HRESULT WINAPI
dom_pi_get_dataType(
583 IXMLDOMProcessingInstruction
*iface
,
586 dom_pi
*This
= impl_from_IXMLDOMProcessingInstruction( iface
);
587 TRACE("(%p)->(%p)\n", This
, typename
);
588 return return_null_var( typename
);
591 static HRESULT WINAPI
dom_pi_put_dataType(
592 IXMLDOMProcessingInstruction
*iface
,
595 dom_pi
*This
= impl_from_IXMLDOMProcessingInstruction( iface
);
597 TRACE("(%p)->(%s)\n", This
, debugstr_w(p
));
605 static HRESULT WINAPI
dom_pi_get_xml(
606 IXMLDOMProcessingInstruction
*iface
,
609 dom_pi
*This
= impl_from_IXMLDOMProcessingInstruction( iface
);
611 TRACE("(%p)->(%p)\n", This
, p
);
613 return node_get_xml(&This
->node
, FALSE
, p
);
616 static HRESULT WINAPI
dom_pi_transformNode(
617 IXMLDOMProcessingInstruction
*iface
,
618 IXMLDOMNode
*node
, BSTR
*p
)
620 dom_pi
*This
= impl_from_IXMLDOMProcessingInstruction( iface
);
621 TRACE("(%p)->(%p %p)\n", This
, node
, p
);
622 return node_transform_node(&This
->node
, node
, p
);
625 static HRESULT WINAPI
dom_pi_selectNodes(
626 IXMLDOMProcessingInstruction
*iface
,
627 BSTR p
, IXMLDOMNodeList
** outList
)
629 dom_pi
*This
= impl_from_IXMLDOMProcessingInstruction( iface
);
630 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(p
), outList
);
631 return node_select_nodes(&This
->node
, p
, outList
);
634 static HRESULT WINAPI
dom_pi_selectSingleNode(
635 IXMLDOMProcessingInstruction
*iface
,
636 BSTR p
, IXMLDOMNode
** outNode
)
638 dom_pi
*This
= impl_from_IXMLDOMProcessingInstruction( iface
);
639 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(p
), outNode
);
640 return node_select_singlenode(&This
->node
, p
, outNode
);
643 static HRESULT WINAPI
dom_pi_get_parsed(
644 IXMLDOMProcessingInstruction
*iface
,
645 VARIANT_BOOL
* isParsed
)
647 dom_pi
*This
= impl_from_IXMLDOMProcessingInstruction( iface
);
648 FIXME("(%p)->(%p) stub!\n", This
, isParsed
);
649 *isParsed
= VARIANT_TRUE
;
653 static HRESULT WINAPI
dom_pi_get_namespaceURI(
654 IXMLDOMProcessingInstruction
*iface
,
657 dom_pi
*This
= impl_from_IXMLDOMProcessingInstruction( iface
);
658 TRACE("(%p)->(%p)\n", This
, p
);
659 return node_get_namespaceURI(&This
->node
, p
);
662 static HRESULT WINAPI
dom_pi_get_prefix(
663 IXMLDOMProcessingInstruction
*iface
,
666 dom_pi
*This
= impl_from_IXMLDOMProcessingInstruction( iface
);
667 TRACE("(%p)->(%p)\n", This
, prefix
);
668 return return_null_bstr( prefix
);
671 static HRESULT WINAPI
dom_pi_get_baseName(
672 IXMLDOMProcessingInstruction
*iface
,
675 dom_pi
*This
= impl_from_IXMLDOMProcessingInstruction( iface
);
676 TRACE("(%p)->(%p)\n", This
, name
);
677 return node_get_base_name( &This
->node
, name
);
680 static HRESULT WINAPI
dom_pi_transformNodeToObject(
681 IXMLDOMProcessingInstruction
*iface
,
682 IXMLDOMNode
* domNode
, VARIANT var1
)
684 dom_pi
*This
= impl_from_IXMLDOMProcessingInstruction( iface
);
685 FIXME("(%p)->(%p %s)\n", This
, domNode
, debugstr_variant(&var1
));
689 static HRESULT WINAPI
dom_pi_get_target(
690 IXMLDOMProcessingInstruction
*iface
,
693 dom_pi
*This
= impl_from_IXMLDOMProcessingInstruction( iface
);
695 TRACE("(%p)->(%p)\n", This
, p
);
697 /* target returns the same value as nodeName property */
698 return node_get_nodeName(&This
->node
, p
);
701 static HRESULT WINAPI
dom_pi_get_data(
702 IXMLDOMProcessingInstruction
*iface
,
705 dom_pi
*This
= impl_from_IXMLDOMProcessingInstruction( iface
);
709 TRACE("(%p)->(%p)\n", This
, p
);
714 hr
= IXMLDOMProcessingInstruction_get_nodeValue( iface
, &ret
);
723 static HRESULT WINAPI
dom_pi_put_data(
724 IXMLDOMProcessingInstruction
*iface
,
727 dom_pi
*This
= impl_from_IXMLDOMProcessingInstruction( iface
);
731 TRACE("(%p)->(%s)\n", This
, debugstr_w(data
) );
733 /* cannot set data to a PI node whose target is 'xml' */
734 hr
= IXMLDOMProcessingInstruction_get_nodeName(iface
, &target
);
737 static const WCHAR xmlW
[] = {'x','m','l',0};
738 if(!wcscmp(target
, xmlW
))
740 SysFreeString(target
);
744 SysFreeString(target
);
747 return node_set_content(&This
->node
, data
);
750 HRESULT
dom_pi_put_xml_decl(IXMLDOMNode
*node
, BSTR data
)
752 static const WCHAR xmlW
[] = {'x','m','l',0};
758 return XML_E_XMLDECLSYNTAX
;
760 node_obj
= get_node_obj(node
);
761 hr
= node_set_content(node_obj
, data
);
765 hr
= node_get_nodeName(node_obj
, &name
);
769 if (!lstrcmpW(name
, xmlW
) && !node_obj
->node
->properties
)
770 hr
= parse_xml_decl(node_obj
->node
);
778 static const struct IXMLDOMProcessingInstructionVtbl dom_pi_vtbl
=
780 dom_pi_QueryInterface
,
783 dom_pi_GetTypeInfoCount
,
785 dom_pi_GetIDsOfNames
,
788 dom_pi_get_nodeValue
,
789 dom_pi_put_nodeValue
,
791 dom_pi_get_parentNode
,
792 dom_pi_get_childNodes
,
793 dom_pi_get_firstChild
,
794 dom_pi_get_lastChild
,
795 dom_pi_get_previousSibling
,
796 dom_pi_get_nextSibling
,
797 dom_pi_get_attributes
,
802 dom_pi_hasChildNodes
,
803 dom_pi_get_ownerDocument
,
805 dom_pi_get_nodeTypeString
,
808 dom_pi_get_specified
,
809 dom_pi_get_definition
,
810 dom_pi_get_nodeTypedValue
,
811 dom_pi_put_nodeTypedValue
,
815 dom_pi_transformNode
,
817 dom_pi_selectSingleNode
,
819 dom_pi_get_namespaceURI
,
822 dom_pi_transformNodeToObject
,
829 static xmlAttrPtr
node_has_prop(const xmlNode
*node
, const xmlChar
*name
)
833 /* xmlHasNsProp accepts only nodes of type XML_ELEMENT_NODE,
834 * so we have to look for an attribute in the node by hand.
837 prop
= node
->properties
;
841 if (xmlStrEqual(prop
->name
, name
))
850 static HRESULT
dom_pi_get_qualified_item(const xmlNodePtr node
, BSTR name
, BSTR uri
,
853 FIXME("(%p)->(%s %s %p): stub\n", node
, debugstr_w(name
), debugstr_w(uri
), item
);
857 static HRESULT
dom_pi_get_named_item(const xmlNodePtr node
, BSTR name
, IXMLDOMNode
**item
)
862 TRACE("(%p)->(%s %p)\n", node
, debugstr_w(name
), item
);
864 if (!item
) return E_POINTER
;
866 nameA
= xmlchar_from_wchar(name
);
867 if (!nameA
) return E_OUTOFMEMORY
;
869 attr
= node_has_prop(node
, nameA
);
878 *item
= create_node((xmlNodePtr
)attr
);
883 static HRESULT
dom_pi_set_named_item(xmlNodePtr node
, IXMLDOMNode
*newItem
, IXMLDOMNode
**namedItem
)
885 FIXME("(%p)->(%p %p): stub\n", node
, newItem
, namedItem
);
889 static HRESULT
dom_pi_remove_qualified_item(xmlNodePtr node
, BSTR name
, BSTR uri
, IXMLDOMNode
**item
)
891 FIXME("(%p)->(%s %s %p): stub\n", node
, debugstr_w(name
), debugstr_w(uri
), item
);
895 static HRESULT
dom_pi_remove_named_item(xmlNodePtr node
, BSTR name
, IXMLDOMNode
**item
)
897 FIXME("(%p)->(%s %p): stub\n", node
, debugstr_w(name
), item
);
901 static HRESULT
dom_pi_get_item(const xmlNodePtr node
, LONG index
, IXMLDOMNode
**item
)
903 FIXME("%p, %ld, %p: stub\n", node
, index
, item
);
907 static HRESULT
dom_pi_get_length(const xmlNodePtr node
, LONG
*length
)
909 FIXME("(%p)->(%p): stub\n", node
, length
);
915 static HRESULT
dom_pi_next_node(const xmlNodePtr node
, LONG
*iter
, IXMLDOMNode
**nextNode
)
917 FIXME("%p, %ld, %p: stub\n", node
, *iter
, nextNode
);
921 static const struct nodemap_funcs dom_pi_attr_map
= {
922 dom_pi_get_named_item
,
923 dom_pi_set_named_item
,
924 dom_pi_remove_named_item
,
927 dom_pi_get_qualified_item
,
928 dom_pi_remove_qualified_item
,
932 static const tid_t dompi_iface_tids
[] = {
933 IXMLDOMProcessingInstruction_tid
,
937 static dispex_static_data_t dompi_dispex
= {
939 IXMLDOMProcessingInstruction_tid
,
944 IUnknown
* create_pi( xmlNodePtr pi
)
948 This
= heap_alloc( sizeof *This
);
952 This
->IXMLDOMProcessingInstruction_iface
.lpVtbl
= &dom_pi_vtbl
;
955 init_xmlnode(&This
->node
, pi
, (IXMLDOMNode
*)&This
->IXMLDOMProcessingInstruction_iface
, &dompi_dispex
);
957 return (IUnknown
*)&This
->IXMLDOMProcessingInstruction_iface
;