2 * DOM Document implementation
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/parser.h>
25 #include <libxml/xmlerror.h>
34 #include "msxml_private.h"
36 #include "wine/debug.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(msxml
);
40 static const xmlChar DT_prefix
[] = "dt";
41 static const xmlChar DT_nsURI
[] = "urn:schemas-microsoft-com:datatypes";
43 typedef struct _domelem
46 IXMLDOMElement IXMLDOMElement_iface
;
50 static const struct nodemap_funcs domelem_attr_map
;
52 static const tid_t domelem_se_tids
[] = {
58 static inline domelem
*impl_from_IXMLDOMElement( IXMLDOMElement
*iface
)
60 return CONTAINING_RECORD(iface
, domelem
, IXMLDOMElement_iface
);
63 static inline xmlNodePtr
get_element( const domelem
*This
)
65 return This
->node
.node
;
68 static HRESULT WINAPI
domelem_QueryInterface(
69 IXMLDOMElement
*iface
,
73 domelem
*This
= impl_from_IXMLDOMElement( iface
);
75 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppvObject
);
77 if ( IsEqualGUID( riid
, &IID_IXMLDOMElement
) ||
78 IsEqualGUID( riid
, &IID_IXMLDOMNode
) ||
79 IsEqualGUID( riid
, &IID_IDispatch
) ||
80 IsEqualGUID( riid
, &IID_IUnknown
) )
82 *ppvObject
= &This
->IXMLDOMElement_iface
;
84 else if(node_query_interface(&This
->node
, riid
, ppvObject
))
86 return *ppvObject
? S_OK
: E_NOINTERFACE
;
88 else if(IsEqualGUID( riid
, &IID_ISupportErrorInfo
))
90 return node_create_supporterrorinfo(domelem_se_tids
, ppvObject
);
94 TRACE("interface %s not implemented\n", debugstr_guid(riid
));
99 IUnknown_AddRef( (IUnknown
*)*ppvObject
);
103 static ULONG WINAPI
domelem_AddRef(IXMLDOMElement
*iface
)
105 domelem
*element
= impl_from_IXMLDOMElement(iface
);
106 LONG ref
= InterlockedIncrement(&element
->ref
);
108 TRACE("%p, refcount %ld.\n", iface
, ref
);
113 static ULONG WINAPI
domelem_Release(IXMLDOMElement
*iface
)
115 domelem
*element
= impl_from_IXMLDOMElement(iface
);
116 ULONG ref
= InterlockedDecrement(&element
->ref
);
118 TRACE("%p, refcount %lu.\n", iface
, ref
);
122 destroy_xmlnode(&element
->node
);
129 static HRESULT WINAPI
domelem_GetTypeInfoCount(
130 IXMLDOMElement
*iface
,
133 domelem
*This
= impl_from_IXMLDOMElement( iface
);
134 return IDispatchEx_GetTypeInfoCount(&This
->node
.dispex
.IDispatchEx_iface
, pctinfo
);
137 static HRESULT WINAPI
domelem_GetTypeInfo(
138 IXMLDOMElement
*iface
,
139 UINT iTInfo
, LCID lcid
,
140 ITypeInfo
** ppTInfo
)
142 domelem
*This
= impl_from_IXMLDOMElement( iface
);
143 return IDispatchEx_GetTypeInfo(&This
->node
.dispex
.IDispatchEx_iface
,
144 iTInfo
, lcid
, ppTInfo
);
147 static HRESULT WINAPI
domelem_GetIDsOfNames(
148 IXMLDOMElement
*iface
,
149 REFIID riid
, LPOLESTR
* rgszNames
,
150 UINT cNames
, LCID lcid
, DISPID
* rgDispId
)
152 domelem
*This
= impl_from_IXMLDOMElement( iface
);
153 return IDispatchEx_GetIDsOfNames(&This
->node
.dispex
.IDispatchEx_iface
,
154 riid
, rgszNames
, cNames
, lcid
, rgDispId
);
157 static HRESULT WINAPI
domelem_Invoke(
158 IXMLDOMElement
*iface
,
159 DISPID dispIdMember
, REFIID riid
, LCID lcid
,
160 WORD wFlags
, DISPPARAMS
* pDispParams
, VARIANT
* pVarResult
,
161 EXCEPINFO
* pExcepInfo
, UINT
* puArgErr
)
163 domelem
*This
= impl_from_IXMLDOMElement( iface
);
164 return IDispatchEx_Invoke(&This
->node
.dispex
.IDispatchEx_iface
,
165 dispIdMember
, riid
, lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
168 static HRESULT WINAPI
domelem_get_nodeName(
169 IXMLDOMElement
*iface
,
172 domelem
*This
= impl_from_IXMLDOMElement( iface
);
174 TRACE("(%p)->(%p)\n", This
, p
);
176 return node_get_nodeName(&This
->node
, p
);
179 static HRESULT WINAPI
domelem_get_nodeValue(
180 IXMLDOMElement
*iface
,
183 domelem
*This
= impl_from_IXMLDOMElement( iface
);
185 TRACE("(%p)->(%p)\n", This
, value
);
190 V_VT(value
) = VT_NULL
;
191 V_BSTR(value
) = NULL
; /* tests show that we should do this */
195 static HRESULT WINAPI
domelem_put_nodeValue(
196 IXMLDOMElement
*iface
,
199 domelem
*This
= impl_from_IXMLDOMElement( iface
);
200 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&value
));
204 static HRESULT WINAPI
domelem_get_nodeType(
205 IXMLDOMElement
*iface
,
206 DOMNodeType
* domNodeType
)
208 domelem
*This
= impl_from_IXMLDOMElement( iface
);
210 TRACE("(%p)->(%p)\n", This
, domNodeType
);
212 *domNodeType
= NODE_ELEMENT
;
216 static HRESULT WINAPI
domelem_get_parentNode(
217 IXMLDOMElement
*iface
,
218 IXMLDOMNode
** parent
)
220 domelem
*This
= impl_from_IXMLDOMElement( iface
);
222 TRACE("(%p)->(%p)\n", This
, parent
);
224 return node_get_parent(&This
->node
, parent
);
227 static HRESULT WINAPI
domelem_get_childNodes(
228 IXMLDOMElement
*iface
,
229 IXMLDOMNodeList
** outList
)
231 domelem
*This
= impl_from_IXMLDOMElement( iface
);
233 TRACE("(%p)->(%p)\n", This
, outList
);
235 return node_get_child_nodes(&This
->node
, outList
);
238 static HRESULT WINAPI
domelem_get_firstChild(
239 IXMLDOMElement
*iface
,
240 IXMLDOMNode
** domNode
)
242 domelem
*This
= impl_from_IXMLDOMElement( iface
);
244 TRACE("(%p)->(%p)\n", This
, domNode
);
246 return node_get_first_child(&This
->node
, domNode
);
249 static HRESULT WINAPI
domelem_get_lastChild(
250 IXMLDOMElement
*iface
,
251 IXMLDOMNode
** domNode
)
253 domelem
*This
= impl_from_IXMLDOMElement( iface
);
255 TRACE("(%p)->(%p)\n", This
, domNode
);
257 return node_get_last_child(&This
->node
, domNode
);
260 static HRESULT WINAPI
domelem_get_previousSibling(
261 IXMLDOMElement
*iface
,
262 IXMLDOMNode
** domNode
)
264 domelem
*This
= impl_from_IXMLDOMElement( iface
);
266 TRACE("(%p)->(%p)\n", This
, domNode
);
268 return node_get_previous_sibling(&This
->node
, domNode
);
271 static HRESULT WINAPI
domelem_get_nextSibling(
272 IXMLDOMElement
*iface
,
273 IXMLDOMNode
** domNode
)
275 domelem
*This
= impl_from_IXMLDOMElement( iface
);
277 TRACE("(%p)->(%p)\n", This
, domNode
);
279 return node_get_next_sibling(&This
->node
, domNode
);
282 static HRESULT WINAPI
domelem_get_attributes(
283 IXMLDOMElement
*iface
,
284 IXMLDOMNamedNodeMap
** map
)
286 domelem
*This
= impl_from_IXMLDOMElement( iface
);
288 TRACE("(%p)->(%p)\n", This
, map
);
290 *map
= create_nodemap(This
->node
.node
, &domelem_attr_map
);
294 static HRESULT WINAPI
domelem_insertBefore(
295 IXMLDOMElement
*iface
,
296 IXMLDOMNode
* newNode
, VARIANT refChild
,
297 IXMLDOMNode
** old_node
)
299 domelem
*This
= impl_from_IXMLDOMElement( iface
);
303 TRACE("(%p)->(%p %s %p)\n", This
, newNode
, debugstr_variant(&refChild
), old_node
);
305 if (!newNode
) return E_INVALIDARG
;
307 hr
= IXMLDOMNode_get_nodeType(newNode
, &type
);
308 if (hr
!= S_OK
) return hr
;
310 TRACE("new node type %d\n", type
);
314 case NODE_DOCUMENT_TYPE
:
317 if (old_node
) *old_node
= NULL
;
320 return node_insert_before(&This
->node
, newNode
, &refChild
, old_node
);
324 static HRESULT WINAPI
domelem_replaceChild(
325 IXMLDOMElement
*iface
,
326 IXMLDOMNode
* newNode
,
327 IXMLDOMNode
* oldNode
,
328 IXMLDOMNode
** outOldNode
)
330 domelem
*This
= impl_from_IXMLDOMElement( iface
);
332 TRACE("(%p)->(%p %p %p)\n", This
, newNode
, oldNode
, outOldNode
);
334 return node_replace_child(&This
->node
, newNode
, oldNode
, outOldNode
);
337 static HRESULT WINAPI
domelem_removeChild(
338 IXMLDOMElement
*iface
,
339 IXMLDOMNode
*child
, IXMLDOMNode
**oldChild
)
341 domelem
*This
= impl_from_IXMLDOMElement( iface
);
342 TRACE("(%p)->(%p %p)\n", This
, child
, oldChild
);
343 return node_remove_child(&This
->node
, child
, oldChild
);
346 static HRESULT WINAPI
domelem_appendChild(
347 IXMLDOMElement
*iface
,
348 IXMLDOMNode
*child
, IXMLDOMNode
**outChild
)
350 domelem
*This
= impl_from_IXMLDOMElement( iface
);
351 TRACE("(%p)->(%p %p)\n", This
, child
, outChild
);
352 return node_append_child(&This
->node
, child
, outChild
);
355 static HRESULT WINAPI
domelem_hasChildNodes(
356 IXMLDOMElement
*iface
,
359 domelem
*This
= impl_from_IXMLDOMElement( iface
);
360 TRACE("(%p)->(%p)\n", This
, ret
);
361 return node_has_childnodes(&This
->node
, ret
);
364 static HRESULT WINAPI
domelem_get_ownerDocument(
365 IXMLDOMElement
*iface
,
366 IXMLDOMDocument
**doc
)
368 domelem
*This
= impl_from_IXMLDOMElement( iface
);
369 TRACE("(%p)->(%p)\n", This
, doc
);
370 return node_get_owner_doc(&This
->node
, doc
);
373 static HRESULT WINAPI
domelem_cloneNode(
374 IXMLDOMElement
*iface
,
375 VARIANT_BOOL deep
, IXMLDOMNode
** outNode
)
377 domelem
*This
= impl_from_IXMLDOMElement( iface
);
378 TRACE("(%p)->(%d %p)\n", This
, deep
, outNode
);
379 return node_clone( &This
->node
, deep
, outNode
);
382 static HRESULT WINAPI
domelem_get_nodeTypeString(
383 IXMLDOMElement
*iface
,
386 domelem
*This
= impl_from_IXMLDOMElement( iface
);
387 static const WCHAR elementW
[] = {'e','l','e','m','e','n','t',0};
389 TRACE("(%p)->(%p)\n", This
, p
);
391 return return_bstr(elementW
, p
);
394 static HRESULT WINAPI
domelem_get_text(
395 IXMLDOMElement
*iface
,
398 domelem
*This
= impl_from_IXMLDOMElement( iface
);
399 TRACE("(%p)->(%p)\n", This
, p
);
400 return node_get_text(&This
->node
, p
);
403 static HRESULT WINAPI
domelem_put_text(
404 IXMLDOMElement
*iface
,
407 domelem
*This
= impl_from_IXMLDOMElement( iface
);
408 TRACE("(%p)->(%s)\n", This
, debugstr_w(p
));
409 return node_put_text( &This
->node
, p
);
412 static HRESULT WINAPI
domelem_get_specified(
413 IXMLDOMElement
*iface
,
414 VARIANT_BOOL
* isSpecified
)
416 domelem
*This
= impl_from_IXMLDOMElement( iface
);
417 FIXME("(%p)->(%p) stub!\n", This
, isSpecified
);
418 *isSpecified
= VARIANT_TRUE
;
422 static HRESULT WINAPI
domelem_get_definition(
423 IXMLDOMElement
*iface
,
424 IXMLDOMNode
** definitionNode
)
426 domelem
*This
= impl_from_IXMLDOMElement( iface
);
427 FIXME("(%p)->(%p)\n", This
, definitionNode
);
431 static inline BYTE
hex_to_byte(xmlChar c
)
433 if(c
<= '9') return c
-'0';
434 if(c
<= 'F') return c
-'A'+10;
438 static inline BYTE
base64_to_byte(xmlChar c
)
440 if(c
== '+') return 62;
441 if(c
== '/') return 63;
442 if(c
<= '9') return c
-'0'+52;
443 if(c
<= 'Z') return c
-'A';
447 static inline HRESULT
variant_from_dt(XDR_DT dt
, xmlChar
* str
, VARIANT
* v
)
451 BOOL handled
= FALSE
;
466 V_BSTR(v
) = bstr_from_xmlChar(str
);
469 return E_OUTOFMEMORY
;
487 st
.wDayOfWeek
= st
.wHour
= st
.wMinute
= st
.wSecond
= st
.wMilliseconds
= 0;
489 V_VT(&src
) = VT_BSTR
;
490 V_BSTR(&src
) = bstr_from_xmlChar(str
);
493 return E_OUTOFMEMORY
;
496 e
= p
+ SysStringLen(V_BSTR(&src
));
498 if(p
+4<e
&& *(p
+4)=='-') /* parse date (yyyy-mm-dd) */
500 st
.wYear
= wcstol(p
, NULL
, 10);
501 st
.wMonth
= wcstol(p
+5, NULL
, 10);
502 st
.wDay
= wcstol(p
+8, NULL
, 10);
508 if(p
+2<e
&& *(p
+2)==':') /* parse time (hh:mm:ss.?) */
510 st
.wHour
= wcstol(p
, NULL
, 10);
511 st
.wMinute
= wcstol(p
+3, NULL
, 10);
512 st
.wSecond
= wcstol(p
+6, NULL
, 10);
518 while (*p
>= '0' && *p
<= '9') p
++;
522 SystemTimeToVariantTime(&st
, &date
);
526 if(*p
== '+') /* parse timezone offset (+hh:mm) */
527 V_DATE(v
) += (DOUBLE
)wcstol(p
+1, NULL
, 10)/24 + (DOUBLE
)wcstol(p
+4, NULL
, 10)/1440;
528 else if(*p
== '-') /* parse timezone offset (-hh:mm) */
529 V_DATE(v
) -= (DOUBLE
)wcstol(p
+1, NULL
, 10)/24 + (DOUBLE
)wcstol(p
+4, NULL
, 10)/1440;
540 len
= xmlStrlen(str
)/2;
544 V_VT(v
) = (VT_ARRAY
|VT_UI1
);
545 V_ARRAY(v
) = SafeArrayCreate(VT_UI1
, 1, &sab
);
548 return E_OUTOFMEMORY
;
551 ((BYTE
*)V_ARRAY(v
)->pvData
)[i
] = (hex_to_byte(str
[2*i
])<<4)
552 + hex_to_byte(str
[2*i
+1]);
562 /* remove all formatting chars */
567 if ( *c2
== ' ' || *c2
== '\t' ||
568 *c2
== '\n' || *c2
== '\r' )
578 if(str
[len
-2] == '=') i
= 2;
579 else if(str
[len
-1] == '=') i
= 1;
583 sab
.cElements
= len
/4*3-i
;
585 V_VT(v
) = (VT_ARRAY
|VT_UI1
);
586 V_ARRAY(v
) = SafeArrayCreate(VT_UI1
, 1, &sab
);
589 return E_OUTOFMEMORY
;
591 for(i
=0; i
<len
/4; i
++)
593 ((BYTE
*)V_ARRAY(v
)->pvData
)[3*i
] = (base64_to_byte(str
[4*i
])<<2)
594 + (base64_to_byte(str
[4*i
+1])>>4);
595 if(3*i
+1 < sab
.cElements
)
596 ((BYTE
*)V_ARRAY(v
)->pvData
)[3*i
+1] = (base64_to_byte(str
[4*i
+1])<<4)
597 + (base64_to_byte(str
[4*i
+2])>>2);
598 if(3*i
+2 < sab
.cElements
)
599 ((BYTE
*)V_ARRAY(v
)->pvData
)[3*i
+2] = (base64_to_byte(str
[4*i
+2])<<6)
600 + base64_to_byte(str
[4*i
+3]);
651 FIXME("need to handle dt:%s\n", debugstr_dt(dt
));
653 V_BSTR(v
) = bstr_from_xmlChar(str
);
655 return E_OUTOFMEMORY
;
659 WARN("unknown type %d\n", dt
);
664 V_VT(&src
) = VT_BSTR
;
665 V_BSTR(&src
) = bstr_from_xmlChar(str
);
668 return E_OUTOFMEMORY
;
670 hr
= VariantChangeTypeEx(v
, &src
,
671 MAKELCID(MAKELANGID(LANG_ENGLISH
,SUBLANG_ENGLISH_US
),SORT_DEFAULT
),0, V_VT(v
));
677 static XDR_DT
element_get_dt(xmlNodePtr node
)
679 XDR_DT dt
= DT_INVALID
;
681 TRACE("(%p)\n", node
);
682 if(node
->type
!= XML_ELEMENT_NODE
)
684 FIXME("invalid element node\n");
688 if (node
->ns
&& xmlStrEqual(node
->ns
->href
, DT_nsURI
))
690 dt
= str_to_dt(node
->name
, -1);
694 xmlChar
* pVal
= xmlGetNsProp(node
, BAD_CAST
"dt", DT_nsURI
);
697 dt
= str_to_dt(pVal
, -1);
702 IXMLDOMDocument3
* doc
= (IXMLDOMDocument3
*)create_domdoc((xmlNodePtr
)node
->doc
);
708 if (IXMLDOMDocument3_get_schemas(doc
, &v
) == S_OK
&&
709 V_VT(&v
) == VT_DISPATCH
)
711 dt
= SchemaCache_get_node_dt((IXMLDOMSchemaCollection2
*)V_DISPATCH(&v
), node
);
714 IXMLDOMDocument3_Release(doc
);
719 TRACE("=> dt:%s\n", debugstr_dt(dt
));
723 static HRESULT WINAPI
domelem_get_nodeTypedValue(
724 IXMLDOMElement
*iface
,
727 domelem
*This
= impl_from_IXMLDOMElement( iface
);
732 TRACE("(%p)->(%p)\n", This
, v
);
734 if(!v
) return E_INVALIDARG
;
738 dt
= element_get_dt(get_element(This
));
739 content
= xmlNodeGetContent(get_element(This
));
740 hr
= variant_from_dt(dt
, content
, v
);
746 static HRESULT
encode_base64(const BYTE
*buf
, int len
, BSTR
*ret
)
748 static const char b64
[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
750 int bytes
, pad_bytes
, div
;
754 bytes
= (len
*8 + 5)/6;
755 pad_bytes
= (bytes
% 4) ? 4 - (bytes
% 4) : 0;
757 TRACE("%d, bytes is %d, pad bytes is %d\n", len
, bytes
, pad_bytes
);
758 needed
= bytes
+ pad_bytes
+ 1;
760 *ret
= SysAllocStringLen(NULL
, needed
);
761 if (!*ret
) return E_OUTOFMEMORY
;
763 /* Three bytes of input give 4 chars of output */
769 /* first char is the first 6 bits of the first byte*/
770 *ptr
++ = b64
[ ( d
[0] >> 2) & 0x3f ];
771 /* second char is the last 2 bits of the first byte and the first 4
772 * bits of the second byte */
773 *ptr
++ = b64
[ ((d
[0] << 4) & 0x30) | (d
[1] >> 4 & 0x0f)];
774 /* third char is the last 4 bits of the second byte and the first 2
775 * bits of the third byte */
776 *ptr
++ = b64
[ ((d
[1] << 2) & 0x3c) | (d
[2] >> 6 & 0x03)];
777 /* fourth char is the remaining 6 bits of the third byte */
778 *ptr
++ = b64
[ d
[2] & 0x3f];
786 /* first char is the first 6 bits of the first byte*/
787 *ptr
++ = b64
[ ( d
[0] >> 2) & 0x3f ];
788 /* second char is the last 2 bits of the first byte and the first 4
789 * bits of the second byte */
790 *ptr
++ = b64
[ ((d
[0] << 4) & 0x30) | (d
[1] >> 4 & 0x0f)];
791 /* third char is the last 4 bits of the second byte padded with
793 *ptr
++ = b64
[ ((d
[1] << 2) & 0x3c) ];
794 /* fourth char is a = to indicate one byte of padding */
798 /* first char is the first 6 bits of the first byte*/
799 *ptr
++ = b64
[ ( d
[0] >> 2) & 0x3f ];
800 /* second char is the last 2 bits of the first byte padded with
802 *ptr
++ = b64
[ ((d
[0] << 4) & 0x30)];
803 /* third char is = to indicate padding */
805 /* fourth char is = to indicate padding */
813 static HRESULT
encode_binhex(const BYTE
*buf
, int len
, BSTR
*ret
)
815 static const char byte_to_hex
[16] = "0123456789abcdef";
818 *ret
= SysAllocStringLen(NULL
, len
*2);
819 if (!*ret
) return E_OUTOFMEMORY
;
821 for (i
= 0; i
< len
; i
++)
823 (*ret
)[2*i
] = byte_to_hex
[buf
[i
] >> 4];
824 (*ret
)[2*i
+1] = byte_to_hex
[0x0f & buf
[i
]];
830 static HRESULT WINAPI
domelem_put_nodeTypedValue(
831 IXMLDOMElement
*iface
,
834 domelem
*This
= impl_from_IXMLDOMElement( iface
);
838 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&value
));
840 dt
= element_get_dt(get_element(This
));
843 /* for untyped node coerce to BSTR and set */
846 if (V_VT(&value
) != VT_BSTR
)
849 VariantInit(&content
);
850 hr
= VariantChangeType(&content
, &value
, 0, VT_BSTR
);
853 hr
= node_set_content(&This
->node
, V_BSTR(&content
));
854 VariantClear(&content
);
858 hr
= node_set_content(&This
->node
, V_BSTR(&value
));
861 if (V_VT(&value
) == VT_BSTR
)
862 hr
= node_set_content(&This
->node
, V_BSTR(&value
));
863 else if (V_VT(&value
) == (VT_UI1
|VT_ARRAY
))
865 UINT dim
= SafeArrayGetDim(V_ARRAY(&value
));
872 FIXME("unexpected array dimension count %u\n", dim
);
874 SafeArrayGetUBound(V_ARRAY(&value
), 1, &ubound
);
875 SafeArrayGetLBound(V_ARRAY(&value
), 1, &lbound
);
877 len
= (ubound
- lbound
+ 1)*SafeArrayGetElemsize(V_ARRAY(&value
));
879 hr
= SafeArrayAccessData(V_ARRAY(&value
), (void*)&ptr
);
880 if (FAILED(hr
)) return hr
;
882 hr
= encode_base64(ptr
, len
, &encoded
);
883 SafeArrayUnaccessData(V_ARRAY(&value
));
884 if (FAILED(hr
)) return hr
;
886 hr
= node_set_content(&This
->node
, encoded
);
887 SysFreeString(encoded
);
891 FIXME("unhandled variant type %d for dt:%s\n", V_VT(&value
), debugstr_dt(dt
));
896 if (V_VT(&value
) == (VT_UI1
|VT_ARRAY
))
898 UINT dim
= SafeArrayGetDim(V_ARRAY(&value
));
905 FIXME("unexpected array dimension count %u\n", dim
);
907 SafeArrayGetUBound(V_ARRAY(&value
), 1, &ubound
);
908 SafeArrayGetLBound(V_ARRAY(&value
), 1, &lbound
);
910 len
= (ubound
- lbound
+ 1)*SafeArrayGetElemsize(V_ARRAY(&value
));
912 hr
= SafeArrayAccessData(V_ARRAY(&value
), (void*)&ptr
);
913 if (FAILED(hr
)) return hr
;
915 hr
= encode_binhex(ptr
, len
, &encoded
);
916 SafeArrayUnaccessData(V_ARRAY(&value
));
917 if (FAILED(hr
)) return hr
;
919 hr
= node_set_content(&This
->node
, encoded
);
920 SysFreeString(encoded
);
924 FIXME("unhandled variant type %d for dt:%s\n", V_VT(&value
), debugstr_dt(dt
));
929 FIXME("not implemented for dt:%s\n", debugstr_dt(dt
));
936 static HRESULT WINAPI
domelem_get_dataType(
937 IXMLDOMElement
*iface
,
940 domelem
*This
= impl_from_IXMLDOMElement( iface
);
943 TRACE("(%p)->(%p)\n", This
, typename
);
948 dt
= element_get_dt(get_element(This
));
977 V_VT(typename
) = VT_BSTR
;
978 V_BSTR(typename
) = SysAllocString(dt_to_bstr(dt
));
980 if (!V_BSTR(typename
))
981 return E_OUTOFMEMORY
;
984 /* Other types (DTD equivalents) do not return anything here,
985 * but the pointer part of the VARIANT is set to NULL */
986 V_VT(typename
) = VT_NULL
;
987 V_BSTR(typename
) = NULL
;
990 return (V_VT(typename
) != VT_NULL
) ? S_OK
: S_FALSE
;
993 static HRESULT WINAPI
domelem_put_dataType(
994 IXMLDOMElement
*iface
,
997 domelem
*This
= impl_from_IXMLDOMElement( iface
);
1002 TRACE("(%p)->(%s)\n", This
, debugstr_w(dtName
));
1005 return E_INVALIDARG
;
1007 dt
= bstr_to_dt(dtName
, -1);
1009 /* An example of this is. The Text in the node needs to be a 0 or 1 for a boolean type.
1010 This applies to changing types (string->bool) or setting a new one
1012 str
= xmlNodeGetContent(get_element(This
));
1013 hr
= dt_validate(dt
, str
);
1016 /* Check all supported types. */
1028 case DT_DATETIME_TZ
:
1051 xmlAttrPtr attr
= xmlHasNsProp(get_element(This
), DT_prefix
, DT_nsURI
);
1054 attr
= xmlSetNsProp(get_element(This
), attr
->ns
, DT_prefix
, dt_to_str(dt
));
1059 xmlNsPtr ns
= xmlNewNs(get_element(This
), DT_nsURI
, DT_prefix
);
1062 attr
= xmlNewNsProp(get_element(This
), ns
, DT_prefix
, dt_to_str(dt
));
1065 xmlAddChild(get_element(This
), (xmlNodePtr
)attr
);
1069 ERR("Failed to create Attribute\n");
1072 ERR("Failed to create Namespace\n");
1077 FIXME("need to handle dt:%s\n", debugstr_dt(dt
));
1085 static HRESULT WINAPI
domelem_get_xml(
1086 IXMLDOMElement
*iface
,
1089 domelem
*This
= impl_from_IXMLDOMElement( iface
);
1091 TRACE("(%p)->(%p)\n", This
, p
);
1093 return node_get_xml(&This
->node
, TRUE
, p
);
1096 static HRESULT WINAPI
domelem_transformNode(
1097 IXMLDOMElement
*iface
,
1098 IXMLDOMNode
*node
, BSTR
*p
)
1100 domelem
*This
= impl_from_IXMLDOMElement( iface
);
1101 TRACE("(%p)->(%p %p)\n", This
, node
, p
);
1102 return node_transform_node(&This
->node
, node
, p
);
1105 static HRESULT WINAPI
domelem_selectNodes(
1106 IXMLDOMElement
*iface
,
1107 BSTR p
, IXMLDOMNodeList
** outList
)
1109 domelem
*This
= impl_from_IXMLDOMElement( iface
);
1110 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(p
), outList
);
1111 return node_select_nodes(&This
->node
, p
, outList
);
1114 static HRESULT WINAPI
domelem_selectSingleNode(
1115 IXMLDOMElement
*iface
,
1116 BSTR p
, IXMLDOMNode
** outNode
)
1118 domelem
*This
= impl_from_IXMLDOMElement( iface
);
1119 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(p
), outNode
);
1120 return node_select_singlenode(&This
->node
, p
, outNode
);
1123 static HRESULT WINAPI
domelem_get_parsed(
1124 IXMLDOMElement
*iface
,
1125 VARIANT_BOOL
* isParsed
)
1127 domelem
*This
= impl_from_IXMLDOMElement( iface
);
1128 FIXME("(%p)->(%p) stub!\n", This
, isParsed
);
1129 *isParsed
= VARIANT_TRUE
;
1133 static HRESULT WINAPI
domelem_get_namespaceURI(
1134 IXMLDOMElement
*iface
,
1137 domelem
*This
= impl_from_IXMLDOMElement( iface
);
1138 TRACE("(%p)->(%p)\n", This
, p
);
1139 return node_get_namespaceURI(&This
->node
, p
);
1142 static HRESULT WINAPI
domelem_get_prefix(
1143 IXMLDOMElement
*iface
,
1146 domelem
*This
= impl_from_IXMLDOMElement( iface
);
1147 TRACE("(%p)->(%p)\n", This
, prefix
);
1148 return node_get_prefix( &This
->node
, prefix
);
1151 static HRESULT WINAPI
domelem_get_baseName(
1152 IXMLDOMElement
*iface
,
1155 domelem
*This
= impl_from_IXMLDOMElement( iface
);
1156 TRACE("(%p)->(%p)\n", This
, name
);
1157 return node_get_base_name( &This
->node
, name
);
1160 static HRESULT WINAPI
domelem_transformNodeToObject(
1161 IXMLDOMElement
*iface
,
1162 IXMLDOMNode
* domNode
, VARIANT var1
)
1164 domelem
*This
= impl_from_IXMLDOMElement( iface
);
1165 FIXME("(%p)->(%p %s)\n", This
, domNode
, debugstr_variant(&var1
));
1169 static HRESULT WINAPI
domelem_get_tagName(
1170 IXMLDOMElement
*iface
,
1173 domelem
*This
= impl_from_IXMLDOMElement( iface
);
1175 const xmlChar
*prefix
;
1178 TRACE("(%p)->(%p)\n", This
, p
);
1180 if (!p
) return E_INVALIDARG
;
1182 element
= get_element( This
);
1186 prefix
= element
->ns
? element
->ns
->prefix
: NULL
;
1187 qname
= xmlBuildQName(element
->name
, prefix
, NULL
, 0);
1189 *p
= bstr_from_xmlChar(qname
);
1190 if (qname
!= element
->name
) xmlFree(qname
);
1192 return *p
? S_OK
: E_OUTOFMEMORY
;
1195 static HRESULT WINAPI
domelem_getAttribute(
1196 IXMLDOMElement
*iface
,
1197 BSTR name
, VARIANT
* value
)
1199 domelem
*This
= impl_from_IXMLDOMElement( iface
);
1201 xmlChar
*xml_name
, *xml_value
= NULL
;
1202 xmlChar
*local
, *prefix
;
1203 HRESULT hr
= S_FALSE
;
1206 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(name
), value
);
1209 return E_INVALIDARG
;
1211 element
= get_element( This
);
1215 V_BSTR(value
) = NULL
;
1216 V_VT(value
) = VT_NULL
;
1218 xml_name
= xmlchar_from_wchar( name
);
1220 if(!xmlValidateNameValue(xml_name
))
1224 if ((local
= xmlSplitQName2(xml_name
, &prefix
)))
1226 if (xmlStrEqual(prefix
, BAD_CAST
"xmlns"))
1228 ns
= xmlSearchNs(element
->doc
, element
, local
);
1230 xml_value
= xmlStrdup(ns
->href
);
1234 ns
= xmlSearchNs(element
->doc
, element
, prefix
);
1236 xml_value
= xmlGetNsProp(element
, local
, ns
->href
);
1243 xml_value
= xmlGetNsProp(element
, xml_name
, NULL
);
1246 heap_free(xml_name
);
1249 V_VT(value
) = VT_BSTR
;
1250 V_BSTR(value
) = bstr_from_xmlChar( xml_value
);
1258 static HRESULT WINAPI
domelem_setAttribute(
1259 IXMLDOMElement
*iface
,
1260 BSTR name
, VARIANT value
)
1262 domelem
*This
= impl_from_IXMLDOMElement( iface
);
1263 xmlChar
*xml_name
, *xml_value
, *local
, *prefix
;
1267 TRACE("(%p)->(%s %s)\n", This
, debugstr_w(name
), debugstr_variant(&value
));
1269 element
= get_element( This
);
1273 if (V_VT(&value
) != VT_BSTR
)
1278 hr
= VariantChangeType(&var
, &value
, 0, VT_BSTR
);
1281 FIXME("VariantChangeType failed\n");
1285 xml_value
= xmlchar_from_wchar(V_BSTR(&var
));
1289 xml_value
= xmlchar_from_wchar(V_BSTR(&value
));
1291 xml_name
= xmlchar_from_wchar( name
);
1293 if ((local
= xmlSplitQName2(xml_name
, &prefix
)))
1295 static const xmlChar
* xmlnsA
= (const xmlChar
*)"xmlns";
1298 /* it's not allowed to modify existing namespace definition */
1299 if (xmlStrEqual(prefix
, xmlnsA
))
1300 ns
= xmlSearchNs(element
->doc
, element
, local
);
1307 int cmp
= xmlStrEqual(ns
->href
, xml_value
);
1308 heap_free(xml_value
);
1309 heap_free(xml_name
);
1310 return cmp
? S_OK
: E_INVALIDARG
;
1314 if (!xmlSetNsProp(element
, NULL
, xml_name
, xml_value
))
1317 heap_free(xml_value
);
1318 heap_free(xml_name
);
1323 static HRESULT WINAPI
domelem_removeAttribute(
1324 IXMLDOMElement
*iface
,
1327 domelem
*This
= impl_from_IXMLDOMElement( iface
);
1328 IXMLDOMNamedNodeMap
*attr
;
1331 TRACE("(%p)->(%s)\n", This
, debugstr_w(p
));
1333 hr
= IXMLDOMElement_get_attributes(iface
, &attr
);
1334 if (hr
!= S_OK
) return hr
;
1336 hr
= IXMLDOMNamedNodeMap_removeNamedItem(attr
, p
, NULL
);
1337 IXMLDOMNamedNodeMap_Release(attr
);
1342 static HRESULT WINAPI
domelem_getAttributeNode(
1343 IXMLDOMElement
*iface
,
1344 BSTR p
, IXMLDOMAttribute
** attributeNode
)
1346 domelem
*This
= impl_from_IXMLDOMElement( iface
);
1347 xmlChar
*local
, *prefix
, *nameA
;
1348 HRESULT hr
= S_FALSE
;
1352 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(p
), attributeNode
);
1354 element
= get_element( This
);
1355 if (!element
) return E_FAIL
;
1357 if (attributeNode
) *attributeNode
= NULL
;
1359 nameA
= xmlchar_from_wchar(p
);
1360 if (!xmlValidateNameValue(nameA
))
1372 *attributeNode
= NULL
;
1374 local
= xmlSplitQName2(nameA
, &prefix
);
1378 /* try to get namespace for supplied qualified name */
1379 xmlNsPtr ns
= xmlSearchNs(element
->doc
, element
, prefix
);
1382 attr
= xmlHasNsProp(element
, local
, ns
? ns
->href
: NULL
);
1387 attr
= xmlHasProp(element
, nameA
);
1388 /* attribute has attached namespace and we requested non-qualified
1389 name - it's a failure case */
1390 if (attr
&& attr
->ns
) attr
= NULL
;
1397 IUnknown
*unk
= create_attribute((xmlNodePtr
)attr
, FALSE
);
1398 hr
= IUnknown_QueryInterface(unk
, &IID_IXMLDOMAttribute
, (void**)attributeNode
);
1399 IUnknown_Release(unk
);
1405 static HRESULT WINAPI
domelem_setAttributeNode(
1406 IXMLDOMElement
*iface
,
1407 IXMLDOMAttribute
* attribute
,
1408 IXMLDOMAttribute
** old
)
1410 domelem
*This
= impl_from_IXMLDOMElement( iface
);
1411 static const WCHAR xmlnsW
[] = {'x','m','l','n','s',0};
1412 xmlChar
*name
, *value
;
1419 FIXME("(%p)->(%p %p): semi-stub\n", This
, attribute
, old
);
1421 if (!attribute
) return E_INVALIDARG
;
1423 attr_node
= get_node_obj((IXMLDOMNode
*)attribute
);
1424 if (!attr_node
) return E_FAIL
;
1426 if (attr_node
->parent
)
1428 WARN("attempt to add already used attribute\n");
1432 hr
= IXMLDOMAttribute_get_nodeName(attribute
, &nameW
);
1433 if (hr
!= S_OK
) return hr
;
1435 /* adding xmlns attribute doesn't change a tree or existing namespace definition */
1436 if (!wcscmp(nameW
, xmlnsW
))
1438 SysFreeString(nameW
);
1439 return DISP_E_UNKNOWNNAME
;
1442 hr
= IXMLDOMAttribute_get_nodeValue(attribute
, &valueW
);
1445 SysFreeString(nameW
);
1449 if (old
) *old
= NULL
;
1451 TRACE("attribute: %s=%s\n", debugstr_w(nameW
), debugstr_w(V_BSTR(&valueW
)));
1453 hr
= IXMLDOMAttribute_get_prefix(attribute
, &prefix
);
1456 FIXME("namespaces not supported: %s\n", debugstr_w(prefix
));
1457 SysFreeString(prefix
);
1460 name
= xmlchar_from_wchar(nameW
);
1461 value
= xmlchar_from_wchar(V_BSTR(&valueW
));
1463 if (!name
|| !value
)
1465 SysFreeString(nameW
);
1466 VariantClear(&valueW
);
1469 return E_OUTOFMEMORY
;
1472 attr
= xmlSetNsProp(get_element(This
), NULL
, name
, value
);
1474 attr_node
->parent
= (IXMLDOMNode
*)iface
;
1476 SysFreeString(nameW
);
1477 VariantClear(&valueW
);
1481 return attr
? S_OK
: E_FAIL
;
1484 static HRESULT WINAPI
domelem_removeAttributeNode(
1485 IXMLDOMElement
*iface
,
1486 IXMLDOMAttribute
* domAttribute
,
1487 IXMLDOMAttribute
** attributeNode
)
1489 domelem
*This
= impl_from_IXMLDOMElement( iface
);
1490 FIXME("(%p)->(%p %p)\n", This
, domAttribute
, attributeNode
);
1494 static HRESULT WINAPI
domelem_getElementsByTagName(
1495 IXMLDOMElement
*iface
,
1496 BSTR tagName
, IXMLDOMNodeList
** resultList
)
1498 domelem
*This
= impl_from_IXMLDOMElement( iface
);
1503 TRACE("(%p)->(%s, %p)\n", This
, debugstr_w(tagName
), resultList
);
1505 if (!tagName
|| !resultList
) return E_INVALIDARG
;
1507 XPath
= is_xpathmode(get_element(This
)->doc
);
1508 set_xpathmode(get_element(This
)->doc
, TRUE
);
1509 query
= tagName_to_XPath(tagName
);
1510 hr
= create_selection(get_element(This
), query
, resultList
);
1512 set_xpathmode(get_element(This
)->doc
, XPath
);
1517 static HRESULT WINAPI
domelem_normalize(
1518 IXMLDOMElement
*iface
)
1520 domelem
*This
= impl_from_IXMLDOMElement( iface
);
1521 FIXME("%p\n", This
);
1525 static const struct IXMLDOMElementVtbl domelem_vtbl
=
1527 domelem_QueryInterface
,
1530 domelem_GetTypeInfoCount
,
1531 domelem_GetTypeInfo
,
1532 domelem_GetIDsOfNames
,
1534 domelem_get_nodeName
,
1535 domelem_get_nodeValue
,
1536 domelem_put_nodeValue
,
1537 domelem_get_nodeType
,
1538 domelem_get_parentNode
,
1539 domelem_get_childNodes
,
1540 domelem_get_firstChild
,
1541 domelem_get_lastChild
,
1542 domelem_get_previousSibling
,
1543 domelem_get_nextSibling
,
1544 domelem_get_attributes
,
1545 domelem_insertBefore
,
1546 domelem_replaceChild
,
1547 domelem_removeChild
,
1548 domelem_appendChild
,
1549 domelem_hasChildNodes
,
1550 domelem_get_ownerDocument
,
1552 domelem_get_nodeTypeString
,
1555 domelem_get_specified
,
1556 domelem_get_definition
,
1557 domelem_get_nodeTypedValue
,
1558 domelem_put_nodeTypedValue
,
1559 domelem_get_dataType
,
1560 domelem_put_dataType
,
1562 domelem_transformNode
,
1563 domelem_selectNodes
,
1564 domelem_selectSingleNode
,
1566 domelem_get_namespaceURI
,
1568 domelem_get_baseName
,
1569 domelem_transformNodeToObject
,
1570 domelem_get_tagName
,
1571 domelem_getAttribute
,
1572 domelem_setAttribute
,
1573 domelem_removeAttribute
,
1574 domelem_getAttributeNode
,
1575 domelem_setAttributeNode
,
1576 domelem_removeAttributeNode
,
1577 domelem_getElementsByTagName
,
1581 static HRESULT
domelem_get_qualified_item(const xmlNodePtr node
, BSTR name
, BSTR uri
,
1588 TRACE("(%p)->(%s %s %p)\n", node
, debugstr_w(name
), debugstr_w(uri
), item
);
1590 if (!name
|| !item
) return E_INVALIDARG
;
1594 href
= xmlchar_from_wchar(uri
);
1595 if (!href
) return E_OUTOFMEMORY
;
1600 nameA
= xmlchar_from_wchar(name
);
1604 return E_OUTOFMEMORY
;
1607 attr
= xmlHasNsProp(node
, nameA
, href
);
1618 *item
= create_node((xmlNodePtr
)attr
);
1623 static HRESULT
domelem_get_named_item(const xmlNodePtr node
, BSTR name
, IXMLDOMNode
**item
)
1625 xmlChar
*nameA
, *local
, *prefix
;
1630 TRACE("(%p)->(%s %p)\n", node
, debugstr_w(name
), item
);
1632 nameA
= xmlchar_from_wchar(name
);
1633 local
= xmlSplitQName2(nameA
, &prefix
);
1637 return domelem_get_qualified_item(node
, name
, NULL
, item
);
1639 /* try to get namespace uri for supplied qualified name */
1640 ns
= xmlSearchNs(node
->doc
, node
, prefix
);
1647 if (item
) *item
= NULL
;
1648 return item
? S_FALSE
: E_INVALIDARG
;
1651 uriW
= bstr_from_xmlChar(ns
->href
);
1652 localW
= bstr_from_xmlChar(local
);
1655 TRACE("got qualified node %s, uri=%s\n", debugstr_w(localW
), debugstr_w(uriW
));
1657 hr
= domelem_get_qualified_item(node
, localW
, uriW
, item
);
1659 SysFreeString(localW
);
1660 SysFreeString(uriW
);
1665 static HRESULT
domelem_set_named_item(xmlNodePtr node
, IXMLDOMNode
*newItem
, IXMLDOMNode
**namedItem
)
1670 TRACE("(%p)->(%p %p)\n", node
, newItem
, namedItem
);
1673 return E_INVALIDARG
;
1675 if(namedItem
) *namedItem
= NULL
;
1677 /* Must be an Attribute */
1678 ThisNew
= get_node_obj( newItem
);
1679 if(!ThisNew
) return E_FAIL
;
1681 if(ThisNew
->node
->type
!= XML_ATTRIBUTE_NODE
)
1684 if(!ThisNew
->node
->parent
)
1685 if(xmldoc_remove_orphan(ThisNew
->node
->doc
, ThisNew
->node
) != S_OK
)
1686 WARN("%p is not an orphan of %p\n", ThisNew
->node
, ThisNew
->node
->doc
);
1688 nodeNew
= xmlAddChild(node
, ThisNew
->node
);
1691 *namedItem
= create_node( nodeNew
);
1695 static HRESULT
domelem_remove_qualified_item(xmlNodePtr node
, BSTR name
, BSTR uri
, IXMLDOMNode
**item
)
1697 xmlChar
*nameA
, *href
;
1700 TRACE("(%p)->(%s %s %p)\n", node
, debugstr_w(name
), debugstr_w(uri
), item
);
1702 if (!name
) return E_INVALIDARG
;
1706 href
= xmlchar_from_wchar(uri
);
1707 if (!href
) return E_OUTOFMEMORY
;
1712 nameA
= xmlchar_from_wchar(name
);
1716 return E_OUTOFMEMORY
;
1719 attr
= xmlHasNsProp(node
, nameA
, href
);
1726 if (item
) *item
= NULL
;
1732 xmlUnlinkNode( (xmlNodePtr
) attr
);
1733 xmldoc_add_orphan( attr
->doc
, (xmlNodePtr
) attr
);
1734 *item
= create_node( (xmlNodePtr
) attr
);
1738 if (xmlRemoveProp(attr
) == -1)
1739 ERR("xmlRemoveProp failed\n");
1745 static HRESULT
domelem_remove_named_item(xmlNodePtr node
, BSTR name
, IXMLDOMNode
**item
)
1747 xmlChar
*nameA
, *local
, *prefix
;
1752 TRACE("(%p)->(%s %p)\n", node
, debugstr_w(name
), item
);
1754 nameA
= xmlchar_from_wchar(name
);
1755 local
= xmlSplitQName2(nameA
, &prefix
);
1759 return domelem_remove_qualified_item(node
, name
, NULL
, item
);
1761 ns
= xmlSearchNs(node
->doc
, node
, prefix
);
1768 if (item
) *item
= NULL
;
1769 return item
? S_FALSE
: E_INVALIDARG
;
1772 uriW
= bstr_from_xmlChar(ns
->href
);
1773 localW
= bstr_from_xmlChar(local
);
1776 TRACE("removing qualified node %s, uri=%s\n", debugstr_w(localW
), debugstr_w(uriW
));
1778 hr
= domelem_remove_qualified_item(node
, localW
, uriW
, item
);
1780 SysFreeString(localW
);
1781 SysFreeString(uriW
);
1786 static HRESULT
domelem_get_item(const xmlNodePtr node
, LONG index
, IXMLDOMNode
**item
)
1794 TRACE("%p, %ld, %p.\n", node
, index
, item
);
1802 curr
= node
->properties
;
1804 for (; attrIndex
< index
&& curr
->next
!= NULL
; attrIndex
++)
1807 if (attrIndex
== index
) {
1808 *item
= create_node( (xmlNodePtr
) curr
);
1818 for (; attrIndex
< index
&& ns
->next
!= NULL
; attrIndex
++)
1821 if (attrIndex
< index
)
1824 xmlns
= xmlNewNs(NULL
, BAD_CAST
"http://www.w3.org/2000/xmlns/", BAD_CAST
"xmlns");
1826 return E_OUTOFMEMORY
;
1828 curr
= xmlNewNsProp(NULL
, xmlns
, ns
->prefix
, ns
->href
);
1831 return E_OUTOFMEMORY
;
1833 curr
->doc
= node
->doc
;
1835 unk
= create_attribute((xmlNodePtr
)curr
, TRUE
);
1839 return E_OUTOFMEMORY
;
1842 hr
= IUnknown_QueryInterface(unk
, &IID_IXMLDOMNode
, (void**)item
);
1843 IUnknown_Release(unk
);
1848 static HRESULT
domelem_get_length(const xmlNodePtr node
, LONG
*length
)
1854 TRACE("(%p)->(%p)\n", node
, length
);
1857 return E_INVALIDARG
;
1860 curr
= node
->properties
;
1871 *length
= attrCount
;
1876 static HRESULT
domelem_next_node(const xmlNodePtr node
, LONG
*iter
, IXMLDOMNode
**nextNode
)
1881 TRACE("%p, %ld, %p.\n", node
, *iter
, nextNode
);
1885 curr
= node
->properties
;
1889 for (i
= 0; i
< *iter
; i
++) {
1890 if (curr
->next
== NULL
)
1897 *nextNode
= create_node((xmlNodePtr
)curr
);
1902 static const struct nodemap_funcs domelem_attr_map
= {
1903 domelem_get_named_item
,
1904 domelem_set_named_item
,
1905 domelem_remove_named_item
,
1908 domelem_get_qualified_item
,
1909 domelem_remove_qualified_item
,
1913 static const tid_t domelem_iface_tids
[] = {
1918 static dispex_static_data_t domelem_dispex
= {
1925 IUnknown
* create_element( xmlNodePtr element
)
1929 This
= heap_alloc( sizeof *This
);
1933 This
->IXMLDOMElement_iface
.lpVtbl
= &domelem_vtbl
;
1936 init_xmlnode(&This
->node
, element
, (IXMLDOMNode
*)&This
->IXMLDOMElement_iface
, &domelem_dispex
);
1938 return (IUnknown
*)&This
->IXMLDOMElement_iface
;