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
;
465 V_BSTR(v
) = bstr_from_xmlChar(str
);
468 return E_OUTOFMEMORY
;
486 st
.wDayOfWeek
= st
.wHour
= st
.wMinute
= st
.wSecond
= st
.wMilliseconds
= 0;
488 V_VT(&src
) = VT_BSTR
;
489 V_BSTR(&src
) = bstr_from_xmlChar(str
);
492 return E_OUTOFMEMORY
;
495 e
= p
+ SysStringLen(V_BSTR(&src
));
497 if(p
+4<e
&& *(p
+4)=='-') /* parse date (yyyy-mm-dd) */
499 st
.wYear
= wcstol(p
, NULL
, 10);
500 st
.wMonth
= wcstol(p
+5, NULL
, 10);
501 st
.wDay
= wcstol(p
+8, NULL
, 10);
507 if(p
+2<e
&& *(p
+2)==':') /* parse time (hh:mm:ss.?) */
509 st
.wHour
= wcstol(p
, NULL
, 10);
510 st
.wMinute
= wcstol(p
+3, NULL
, 10);
511 st
.wSecond
= wcstol(p
+6, NULL
, 10);
517 while (*p
>= '0' && *p
<= '9') p
++;
521 SystemTimeToVariantTime(&st
, &date
);
525 if(*p
== '+') /* parse timezone offset (+hh:mm) */
526 V_DATE(v
) += (DOUBLE
)wcstol(p
+1, NULL
, 10)/24 + (DOUBLE
)wcstol(p
+4, NULL
, 10)/1440;
527 else if(*p
== '-') /* parse timezone offset (-hh:mm) */
528 V_DATE(v
) -= (DOUBLE
)wcstol(p
+1, NULL
, 10)/24 + (DOUBLE
)wcstol(p
+4, NULL
, 10)/1440;
539 len
= xmlStrlen(str
)/2;
543 V_VT(v
) = (VT_ARRAY
|VT_UI1
);
544 V_ARRAY(v
) = SafeArrayCreate(VT_UI1
, 1, &sab
);
547 return E_OUTOFMEMORY
;
550 ((BYTE
*)V_ARRAY(v
)->pvData
)[i
] = (hex_to_byte(str
[2*i
])<<4)
551 + hex_to_byte(str
[2*i
+1]);
561 /* remove all formatting chars */
566 if ( *c2
== ' ' || *c2
== '\t' ||
567 *c2
== '\n' || *c2
== '\r' )
577 if(str
[len
-2] == '=') i
= 2;
578 else if(str
[len
-1] == '=') i
= 1;
582 sab
.cElements
= len
/4*3-i
;
584 V_VT(v
) = (VT_ARRAY
|VT_UI1
);
585 V_ARRAY(v
) = SafeArrayCreate(VT_UI1
, 1, &sab
);
588 return E_OUTOFMEMORY
;
590 for(i
=0; i
<len
/4; i
++)
592 ((BYTE
*)V_ARRAY(v
)->pvData
)[3*i
] = (base64_to_byte(str
[4*i
])<<2)
593 + (base64_to_byte(str
[4*i
+1])>>4);
594 if(3*i
+1 < sab
.cElements
)
595 ((BYTE
*)V_ARRAY(v
)->pvData
)[3*i
+1] = (base64_to_byte(str
[4*i
+1])<<4)
596 + (base64_to_byte(str
[4*i
+2])>>2);
597 if(3*i
+2 < sab
.cElements
)
598 ((BYTE
*)V_ARRAY(v
)->pvData
)[3*i
+2] = (base64_to_byte(str
[4*i
+2])<<6)
599 + base64_to_byte(str
[4*i
+3]);
650 FIXME("need to handle dt:%s\n", debugstr_dt(dt
));
652 V_BSTR(v
) = bstr_from_xmlChar(str
);
654 return E_OUTOFMEMORY
;
658 WARN("unknown type %d\n", dt
);
663 V_VT(&src
) = VT_BSTR
;
664 V_BSTR(&src
) = bstr_from_xmlChar(str
);
667 return E_OUTOFMEMORY
;
669 hr
= VariantChangeTypeEx(v
, &src
,
670 MAKELCID(MAKELANGID(LANG_ENGLISH
,SUBLANG_ENGLISH_US
),SORT_DEFAULT
),0, V_VT(v
));
676 static XDR_DT
element_get_dt(xmlNodePtr node
)
678 XDR_DT dt
= DT_INVALID
;
680 TRACE("(%p)\n", node
);
681 if(node
->type
!= XML_ELEMENT_NODE
)
683 FIXME("invalid element node\n");
687 if (node
->ns
&& xmlStrEqual(node
->ns
->href
, DT_nsURI
))
689 dt
= str_to_dt(node
->name
, -1);
693 xmlChar
* pVal
= xmlGetNsProp(node
, BAD_CAST
"dt", DT_nsURI
);
696 dt
= str_to_dt(pVal
, -1);
701 IXMLDOMDocument3
* doc
= (IXMLDOMDocument3
*)create_domdoc((xmlNodePtr
)node
->doc
);
707 if (IXMLDOMDocument3_get_schemas(doc
, &v
) == S_OK
&&
708 V_VT(&v
) == VT_DISPATCH
)
710 dt
= SchemaCache_get_node_dt((IXMLDOMSchemaCollection2
*)V_DISPATCH(&v
), node
);
713 IXMLDOMDocument3_Release(doc
);
718 TRACE("=> dt:%s\n", debugstr_dt(dt
));
722 static HRESULT WINAPI
domelem_get_nodeTypedValue(
723 IXMLDOMElement
*iface
,
726 domelem
*This
= impl_from_IXMLDOMElement( iface
);
731 TRACE("(%p)->(%p)\n", This
, v
);
733 if(!v
) return E_INVALIDARG
;
737 dt
= element_get_dt(get_element(This
));
739 if (dt
== DT_INVALID
)
741 if (SUCCEEDED(hr
= node_get_text(&This
->node
, &V_BSTR(v
))))
745 content
= xmlNodeGetContent(get_element(This
));
746 hr
= variant_from_dt(dt
, content
, v
);
752 static HRESULT
encode_base64(const BYTE
*buf
, int len
, BSTR
*ret
)
754 static const char b64
[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
756 int bytes
, pad_bytes
, div
;
760 bytes
= (len
*8 + 5)/6;
761 pad_bytes
= (bytes
% 4) ? 4 - (bytes
% 4) : 0;
763 TRACE("%d, bytes is %d, pad bytes is %d\n", len
, bytes
, pad_bytes
);
764 needed
= bytes
+ pad_bytes
+ 1;
766 *ret
= SysAllocStringLen(NULL
, needed
);
767 if (!*ret
) return E_OUTOFMEMORY
;
769 /* Three bytes of input give 4 chars of output */
775 /* first char is the first 6 bits of the first byte*/
776 *ptr
++ = b64
[ ( d
[0] >> 2) & 0x3f ];
777 /* second char is the last 2 bits of the first byte and the first 4
778 * bits of the second byte */
779 *ptr
++ = b64
[ ((d
[0] << 4) & 0x30) | (d
[1] >> 4 & 0x0f)];
780 /* third char is the last 4 bits of the second byte and the first 2
781 * bits of the third byte */
782 *ptr
++ = b64
[ ((d
[1] << 2) & 0x3c) | (d
[2] >> 6 & 0x03)];
783 /* fourth char is the remaining 6 bits of the third byte */
784 *ptr
++ = b64
[ d
[2] & 0x3f];
792 /* first char is the first 6 bits of the first byte*/
793 *ptr
++ = b64
[ ( d
[0] >> 2) & 0x3f ];
794 /* second char is the last 2 bits of the first byte and the first 4
795 * bits of the second byte */
796 *ptr
++ = b64
[ ((d
[0] << 4) & 0x30) | (d
[1] >> 4 & 0x0f)];
797 /* third char is the last 4 bits of the second byte padded with
799 *ptr
++ = b64
[ ((d
[1] << 2) & 0x3c) ];
800 /* fourth char is a = to indicate one byte of padding */
804 /* first char is the first 6 bits of the first byte*/
805 *ptr
++ = b64
[ ( d
[0] >> 2) & 0x3f ];
806 /* second char is the last 2 bits of the first byte padded with
808 *ptr
++ = b64
[ ((d
[0] << 4) & 0x30)];
809 /* third char is = to indicate padding */
811 /* fourth char is = to indicate padding */
819 static HRESULT
encode_binhex(const BYTE
*buf
, int len
, BSTR
*ret
)
821 static const char byte_to_hex
[16] = "0123456789abcdef";
824 *ret
= SysAllocStringLen(NULL
, len
*2);
825 if (!*ret
) return E_OUTOFMEMORY
;
827 for (i
= 0; i
< len
; i
++)
829 (*ret
)[2*i
] = byte_to_hex
[buf
[i
] >> 4];
830 (*ret
)[2*i
+1] = byte_to_hex
[0x0f & buf
[i
]];
836 static HRESULT WINAPI
domelem_put_nodeTypedValue(
837 IXMLDOMElement
*iface
,
840 domelem
*This
= impl_from_IXMLDOMElement( iface
);
844 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&value
));
846 dt
= element_get_dt(get_element(This
));
849 /* for untyped node coerce to BSTR and set */
852 if (V_VT(&value
) != VT_BSTR
)
855 VariantInit(&content
);
856 hr
= VariantChangeType(&content
, &value
, 0, VT_BSTR
);
859 hr
= node_set_content(&This
->node
, V_BSTR(&content
));
860 VariantClear(&content
);
864 hr
= node_set_content(&This
->node
, V_BSTR(&value
));
867 if (V_VT(&value
) == VT_BSTR
)
868 hr
= node_set_content(&This
->node
, V_BSTR(&value
));
869 else if (V_VT(&value
) == (VT_UI1
|VT_ARRAY
))
871 UINT dim
= SafeArrayGetDim(V_ARRAY(&value
));
878 FIXME("unexpected array dimension count %u\n", dim
);
880 SafeArrayGetUBound(V_ARRAY(&value
), 1, &ubound
);
881 SafeArrayGetLBound(V_ARRAY(&value
), 1, &lbound
);
883 len
= (ubound
- lbound
+ 1)*SafeArrayGetElemsize(V_ARRAY(&value
));
885 hr
= SafeArrayAccessData(V_ARRAY(&value
), (void*)&ptr
);
886 if (FAILED(hr
)) return hr
;
888 hr
= encode_base64(ptr
, len
, &encoded
);
889 SafeArrayUnaccessData(V_ARRAY(&value
));
890 if (FAILED(hr
)) return hr
;
892 hr
= node_set_content(&This
->node
, encoded
);
893 SysFreeString(encoded
);
897 FIXME("unhandled variant type %d for dt:%s\n", V_VT(&value
), debugstr_dt(dt
));
902 if (V_VT(&value
) == (VT_UI1
|VT_ARRAY
))
904 UINT dim
= SafeArrayGetDim(V_ARRAY(&value
));
911 FIXME("unexpected array dimension count %u\n", dim
);
913 SafeArrayGetUBound(V_ARRAY(&value
), 1, &ubound
);
914 SafeArrayGetLBound(V_ARRAY(&value
), 1, &lbound
);
916 len
= (ubound
- lbound
+ 1)*SafeArrayGetElemsize(V_ARRAY(&value
));
918 hr
= SafeArrayAccessData(V_ARRAY(&value
), (void*)&ptr
);
919 if (FAILED(hr
)) return hr
;
921 hr
= encode_binhex(ptr
, len
, &encoded
);
922 SafeArrayUnaccessData(V_ARRAY(&value
));
923 if (FAILED(hr
)) return hr
;
925 hr
= node_set_content(&This
->node
, encoded
);
926 SysFreeString(encoded
);
930 FIXME("unhandled variant type %d for dt:%s\n", V_VT(&value
), debugstr_dt(dt
));
935 FIXME("not implemented for dt:%s\n", debugstr_dt(dt
));
942 static HRESULT WINAPI
domelem_get_dataType(
943 IXMLDOMElement
*iface
,
946 domelem
*This
= impl_from_IXMLDOMElement( iface
);
949 TRACE("(%p)->(%p)\n", This
, typename
);
954 dt
= element_get_dt(get_element(This
));
983 V_VT(typename
) = VT_BSTR
;
984 V_BSTR(typename
) = SysAllocString(dt_to_bstr(dt
));
986 if (!V_BSTR(typename
))
987 return E_OUTOFMEMORY
;
990 /* Other types (DTD equivalents) do not return anything here,
991 * but the pointer part of the VARIANT is set to NULL */
992 V_VT(typename
) = VT_NULL
;
993 V_BSTR(typename
) = NULL
;
996 return (V_VT(typename
) != VT_NULL
) ? S_OK
: S_FALSE
;
999 static HRESULT WINAPI
domelem_put_dataType(
1000 IXMLDOMElement
*iface
,
1003 domelem
*This
= impl_from_IXMLDOMElement( iface
);
1004 HRESULT hr
= E_FAIL
;
1008 TRACE("(%p)->(%s)\n", This
, debugstr_w(dtName
));
1011 return E_INVALIDARG
;
1013 dt
= bstr_to_dt(dtName
, -1);
1015 /* An example of this is. The Text in the node needs to be a 0 or 1 for a boolean type.
1016 This applies to changing types (string->bool) or setting a new one
1018 str
= xmlNodeGetContent(get_element(This
));
1019 hr
= dt_validate(dt
, str
);
1022 /* Check all supported types. */
1034 case DT_DATETIME_TZ
:
1057 xmlAttrPtr attr
= xmlHasNsProp(get_element(This
), DT_prefix
, DT_nsURI
);
1060 attr
= xmlSetNsProp(get_element(This
), attr
->ns
, DT_prefix
, dt_to_str(dt
));
1065 xmlNsPtr ns
= xmlNewNs(get_element(This
), DT_nsURI
, DT_prefix
);
1068 attr
= xmlNewNsProp(get_element(This
), ns
, DT_prefix
, dt_to_str(dt
));
1071 xmlAddChild(get_element(This
), (xmlNodePtr
)attr
);
1075 ERR("Failed to create Attribute\n");
1078 ERR("Failed to create Namespace\n");
1083 FIXME("need to handle dt:%s\n", debugstr_dt(dt
));
1091 static HRESULT WINAPI
domelem_get_xml(
1092 IXMLDOMElement
*iface
,
1095 domelem
*This
= impl_from_IXMLDOMElement( iface
);
1097 TRACE("(%p)->(%p)\n", This
, p
);
1099 return node_get_xml(&This
->node
, TRUE
, p
);
1102 static HRESULT WINAPI
domelem_transformNode(
1103 IXMLDOMElement
*iface
,
1104 IXMLDOMNode
*node
, BSTR
*p
)
1106 domelem
*This
= impl_from_IXMLDOMElement( iface
);
1107 TRACE("(%p)->(%p %p)\n", This
, node
, p
);
1108 return node_transform_node(&This
->node
, node
, p
);
1111 static HRESULT WINAPI
domelem_selectNodes(
1112 IXMLDOMElement
*iface
,
1113 BSTR p
, IXMLDOMNodeList
** outList
)
1115 domelem
*This
= impl_from_IXMLDOMElement( iface
);
1116 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(p
), outList
);
1117 return node_select_nodes(&This
->node
, p
, outList
);
1120 static HRESULT WINAPI
domelem_selectSingleNode(
1121 IXMLDOMElement
*iface
,
1122 BSTR p
, IXMLDOMNode
** outNode
)
1124 domelem
*This
= impl_from_IXMLDOMElement( iface
);
1125 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(p
), outNode
);
1126 return node_select_singlenode(&This
->node
, p
, outNode
);
1129 static HRESULT WINAPI
domelem_get_parsed(
1130 IXMLDOMElement
*iface
,
1131 VARIANT_BOOL
* isParsed
)
1133 domelem
*This
= impl_from_IXMLDOMElement( iface
);
1134 FIXME("(%p)->(%p) stub!\n", This
, isParsed
);
1135 *isParsed
= VARIANT_TRUE
;
1139 static HRESULT WINAPI
domelem_get_namespaceURI(
1140 IXMLDOMElement
*iface
,
1143 domelem
*This
= impl_from_IXMLDOMElement( iface
);
1144 TRACE("(%p)->(%p)\n", This
, p
);
1145 return node_get_namespaceURI(&This
->node
, p
);
1148 static HRESULT WINAPI
domelem_get_prefix(
1149 IXMLDOMElement
*iface
,
1152 domelem
*This
= impl_from_IXMLDOMElement( iface
);
1153 TRACE("(%p)->(%p)\n", This
, prefix
);
1154 return node_get_prefix( &This
->node
, prefix
);
1157 static HRESULT WINAPI
domelem_get_baseName(
1158 IXMLDOMElement
*iface
,
1161 domelem
*This
= impl_from_IXMLDOMElement( iface
);
1162 TRACE("(%p)->(%p)\n", This
, name
);
1163 return node_get_base_name( &This
->node
, name
);
1166 static HRESULT WINAPI
domelem_transformNodeToObject(
1167 IXMLDOMElement
*iface
,
1168 IXMLDOMNode
* domNode
, VARIANT var1
)
1170 domelem
*This
= impl_from_IXMLDOMElement( iface
);
1171 FIXME("(%p)->(%p %s)\n", This
, domNode
, debugstr_variant(&var1
));
1175 static HRESULT WINAPI
domelem_get_tagName(
1176 IXMLDOMElement
*iface
,
1179 domelem
*This
= impl_from_IXMLDOMElement( iface
);
1181 const xmlChar
*prefix
;
1184 TRACE("(%p)->(%p)\n", This
, p
);
1186 if (!p
) return E_INVALIDARG
;
1188 element
= get_element( This
);
1192 prefix
= element
->ns
? element
->ns
->prefix
: NULL
;
1193 qname
= xmlBuildQName(element
->name
, prefix
, NULL
, 0);
1195 *p
= bstr_from_xmlChar(qname
);
1196 if (qname
!= element
->name
) xmlFree(qname
);
1198 return *p
? S_OK
: E_OUTOFMEMORY
;
1201 static HRESULT WINAPI
domelem_getAttribute(
1202 IXMLDOMElement
*iface
,
1203 BSTR name
, VARIANT
* value
)
1205 domelem
*This
= impl_from_IXMLDOMElement( iface
);
1207 xmlChar
*xml_name
, *xml_value
= NULL
;
1208 xmlChar
*local
, *prefix
;
1209 HRESULT hr
= S_FALSE
;
1212 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(name
), value
);
1215 return E_INVALIDARG
;
1217 element
= get_element( This
);
1221 V_BSTR(value
) = NULL
;
1222 V_VT(value
) = VT_NULL
;
1224 xml_name
= xmlchar_from_wchar( name
);
1226 if(!xmlValidateNameValue(xml_name
))
1230 if ((local
= xmlSplitQName2(xml_name
, &prefix
)))
1232 if (xmlStrEqual(prefix
, BAD_CAST
"xmlns"))
1234 ns
= xmlSearchNs(element
->doc
, element
, local
);
1236 xml_value
= xmlStrdup(ns
->href
);
1240 ns
= xmlSearchNs(element
->doc
, element
, prefix
);
1242 xml_value
= xmlGetNsProp(element
, local
, ns
->href
);
1249 xml_value
= xmlGetNsProp(element
, xml_name
, NULL
);
1252 heap_free(xml_name
);
1255 V_VT(value
) = VT_BSTR
;
1256 V_BSTR(value
) = bstr_from_xmlChar( xml_value
);
1264 static HRESULT WINAPI
domelem_setAttribute(
1265 IXMLDOMElement
*iface
,
1266 BSTR name
, VARIANT value
)
1268 domelem
*This
= impl_from_IXMLDOMElement( iface
);
1269 xmlChar
*xml_name
, *xml_value
, *local
, *prefix
;
1273 TRACE("(%p)->(%s %s)\n", This
, debugstr_w(name
), debugstr_variant(&value
));
1275 element
= get_element( This
);
1279 if (V_VT(&value
) != VT_BSTR
)
1284 hr
= VariantChangeType(&var
, &value
, 0, VT_BSTR
);
1287 FIXME("VariantChangeType failed\n");
1291 xml_value
= xmlchar_from_wchar(V_BSTR(&var
));
1295 xml_value
= xmlchar_from_wchar(V_BSTR(&value
));
1297 xml_name
= xmlchar_from_wchar( name
);
1299 if ((local
= xmlSplitQName2(xml_name
, &prefix
)))
1301 static const xmlChar
* xmlnsA
= (const xmlChar
*)"xmlns";
1304 /* it's not allowed to modify existing namespace definition */
1305 if (xmlStrEqual(prefix
, xmlnsA
))
1306 ns
= xmlSearchNs(element
->doc
, element
, local
);
1313 int cmp
= xmlStrEqual(ns
->href
, xml_value
);
1314 heap_free(xml_value
);
1315 heap_free(xml_name
);
1316 return cmp
? S_OK
: E_INVALIDARG
;
1320 if (!xmlSetNsProp(element
, NULL
, xml_name
, xml_value
))
1323 heap_free(xml_value
);
1324 heap_free(xml_name
);
1329 static HRESULT WINAPI
domelem_removeAttribute(
1330 IXMLDOMElement
*iface
,
1333 domelem
*This
= impl_from_IXMLDOMElement( iface
);
1334 IXMLDOMNamedNodeMap
*attr
;
1337 TRACE("(%p)->(%s)\n", This
, debugstr_w(p
));
1339 hr
= IXMLDOMElement_get_attributes(iface
, &attr
);
1340 if (hr
!= S_OK
) return hr
;
1342 hr
= IXMLDOMNamedNodeMap_removeNamedItem(attr
, p
, NULL
);
1343 IXMLDOMNamedNodeMap_Release(attr
);
1348 static HRESULT WINAPI
domelem_getAttributeNode(
1349 IXMLDOMElement
*iface
,
1350 BSTR p
, IXMLDOMAttribute
** attributeNode
)
1352 domelem
*This
= impl_from_IXMLDOMElement( iface
);
1353 xmlChar
*local
, *prefix
, *nameA
;
1354 HRESULT hr
= S_FALSE
;
1358 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(p
), attributeNode
);
1360 element
= get_element( This
);
1361 if (!element
) return E_FAIL
;
1363 if (attributeNode
) *attributeNode
= NULL
;
1365 nameA
= xmlchar_from_wchar(p
);
1366 if (!xmlValidateNameValue(nameA
))
1378 *attributeNode
= NULL
;
1380 local
= xmlSplitQName2(nameA
, &prefix
);
1384 /* try to get namespace for supplied qualified name */
1385 xmlNsPtr ns
= xmlSearchNs(element
->doc
, element
, prefix
);
1388 attr
= xmlHasNsProp(element
, local
, ns
? ns
->href
: NULL
);
1393 attr
= xmlHasProp(element
, nameA
);
1394 /* attribute has attached namespace and we requested non-qualified
1395 name - it's a failure case */
1396 if (attr
&& attr
->ns
) attr
= NULL
;
1403 IUnknown
*unk
= create_attribute((xmlNodePtr
)attr
, FALSE
);
1404 hr
= IUnknown_QueryInterface(unk
, &IID_IXMLDOMAttribute
, (void**)attributeNode
);
1405 IUnknown_Release(unk
);
1411 static HRESULT WINAPI
domelem_setAttributeNode(
1412 IXMLDOMElement
*iface
,
1413 IXMLDOMAttribute
* attribute
,
1414 IXMLDOMAttribute
** old
)
1416 domelem
*This
= impl_from_IXMLDOMElement( iface
);
1417 static const WCHAR xmlnsW
[] = {'x','m','l','n','s',0};
1418 xmlChar
*name
, *value
;
1425 FIXME("(%p)->(%p %p): semi-stub\n", This
, attribute
, old
);
1427 if (!attribute
) return E_INVALIDARG
;
1429 attr_node
= get_node_obj((IXMLDOMNode
*)attribute
);
1430 if (!attr_node
) return E_FAIL
;
1432 if (attr_node
->parent
)
1434 WARN("attempt to add already used attribute\n");
1438 hr
= IXMLDOMAttribute_get_nodeName(attribute
, &nameW
);
1439 if (hr
!= S_OK
) return hr
;
1441 /* adding xmlns attribute doesn't change a tree or existing namespace definition */
1442 if (!wcscmp(nameW
, xmlnsW
))
1444 SysFreeString(nameW
);
1445 return DISP_E_UNKNOWNNAME
;
1448 hr
= IXMLDOMAttribute_get_nodeValue(attribute
, &valueW
);
1451 SysFreeString(nameW
);
1455 if (old
) *old
= NULL
;
1457 TRACE("attribute: %s=%s\n", debugstr_w(nameW
), debugstr_w(V_BSTR(&valueW
)));
1459 hr
= IXMLDOMAttribute_get_prefix(attribute
, &prefix
);
1462 FIXME("namespaces not supported: %s\n", debugstr_w(prefix
));
1463 SysFreeString(prefix
);
1466 name
= xmlchar_from_wchar(nameW
);
1467 value
= xmlchar_from_wchar(V_BSTR(&valueW
));
1469 if (!name
|| !value
)
1471 SysFreeString(nameW
);
1472 VariantClear(&valueW
);
1475 return E_OUTOFMEMORY
;
1478 attr
= xmlSetNsProp(get_element(This
), NULL
, name
, value
);
1480 attr_node
->parent
= (IXMLDOMNode
*)iface
;
1482 SysFreeString(nameW
);
1483 VariantClear(&valueW
);
1487 return attr
? S_OK
: E_FAIL
;
1490 static HRESULT WINAPI
domelem_removeAttributeNode(
1491 IXMLDOMElement
*iface
,
1492 IXMLDOMAttribute
* domAttribute
,
1493 IXMLDOMAttribute
** attributeNode
)
1495 domelem
*This
= impl_from_IXMLDOMElement( iface
);
1496 FIXME("(%p)->(%p %p)\n", This
, domAttribute
, attributeNode
);
1500 static HRESULT WINAPI
domelem_getElementsByTagName(
1501 IXMLDOMElement
*iface
,
1502 BSTR tagName
, IXMLDOMNodeList
** resultList
)
1504 domelem
*This
= impl_from_IXMLDOMElement( iface
);
1509 TRACE("(%p)->(%s, %p)\n", This
, debugstr_w(tagName
), resultList
);
1511 if (!tagName
|| !resultList
) return E_INVALIDARG
;
1513 XPath
= is_xpathmode(get_element(This
)->doc
);
1514 set_xpathmode(get_element(This
)->doc
, TRUE
);
1515 query
= tagName_to_XPath(tagName
);
1516 hr
= create_selection(get_element(This
), query
, resultList
);
1518 set_xpathmode(get_element(This
)->doc
, XPath
);
1523 static HRESULT WINAPI
domelem_normalize(
1524 IXMLDOMElement
*iface
)
1526 domelem
*This
= impl_from_IXMLDOMElement( iface
);
1527 FIXME("%p\n", This
);
1531 static const struct IXMLDOMElementVtbl domelem_vtbl
=
1533 domelem_QueryInterface
,
1536 domelem_GetTypeInfoCount
,
1537 domelem_GetTypeInfo
,
1538 domelem_GetIDsOfNames
,
1540 domelem_get_nodeName
,
1541 domelem_get_nodeValue
,
1542 domelem_put_nodeValue
,
1543 domelem_get_nodeType
,
1544 domelem_get_parentNode
,
1545 domelem_get_childNodes
,
1546 domelem_get_firstChild
,
1547 domelem_get_lastChild
,
1548 domelem_get_previousSibling
,
1549 domelem_get_nextSibling
,
1550 domelem_get_attributes
,
1551 domelem_insertBefore
,
1552 domelem_replaceChild
,
1553 domelem_removeChild
,
1554 domelem_appendChild
,
1555 domelem_hasChildNodes
,
1556 domelem_get_ownerDocument
,
1558 domelem_get_nodeTypeString
,
1561 domelem_get_specified
,
1562 domelem_get_definition
,
1563 domelem_get_nodeTypedValue
,
1564 domelem_put_nodeTypedValue
,
1565 domelem_get_dataType
,
1566 domelem_put_dataType
,
1568 domelem_transformNode
,
1569 domelem_selectNodes
,
1570 domelem_selectSingleNode
,
1572 domelem_get_namespaceURI
,
1574 domelem_get_baseName
,
1575 domelem_transformNodeToObject
,
1576 domelem_get_tagName
,
1577 domelem_getAttribute
,
1578 domelem_setAttribute
,
1579 domelem_removeAttribute
,
1580 domelem_getAttributeNode
,
1581 domelem_setAttributeNode
,
1582 domelem_removeAttributeNode
,
1583 domelem_getElementsByTagName
,
1587 static HRESULT
domelem_get_qualified_item(const xmlNodePtr node
, BSTR name
, BSTR uri
,
1594 TRACE("(%p)->(%s %s %p)\n", node
, debugstr_w(name
), debugstr_w(uri
), item
);
1596 if (!name
|| !item
) return E_INVALIDARG
;
1600 href
= xmlchar_from_wchar(uri
);
1601 if (!href
) return E_OUTOFMEMORY
;
1606 nameA
= xmlchar_from_wchar(name
);
1610 return E_OUTOFMEMORY
;
1613 attr
= xmlHasNsProp(node
, nameA
, href
);
1624 *item
= create_node((xmlNodePtr
)attr
);
1629 static HRESULT
domelem_get_named_item(const xmlNodePtr node
, BSTR name
, IXMLDOMNode
**item
)
1631 xmlChar
*nameA
, *local
, *prefix
;
1636 TRACE("(%p)->(%s %p)\n", node
, debugstr_w(name
), item
);
1638 nameA
= xmlchar_from_wchar(name
);
1639 local
= xmlSplitQName2(nameA
, &prefix
);
1643 return domelem_get_qualified_item(node
, name
, NULL
, item
);
1645 /* try to get namespace uri for supplied qualified name */
1646 ns
= xmlSearchNs(node
->doc
, node
, prefix
);
1653 if (item
) *item
= NULL
;
1654 return item
? S_FALSE
: E_INVALIDARG
;
1657 uriW
= bstr_from_xmlChar(ns
->href
);
1658 localW
= bstr_from_xmlChar(local
);
1661 TRACE("got qualified node %s, uri=%s\n", debugstr_w(localW
), debugstr_w(uriW
));
1663 hr
= domelem_get_qualified_item(node
, localW
, uriW
, item
);
1665 SysFreeString(localW
);
1666 SysFreeString(uriW
);
1671 static HRESULT
domelem_set_named_item(xmlNodePtr node
, IXMLDOMNode
*newItem
, IXMLDOMNode
**namedItem
)
1676 TRACE("(%p)->(%p %p)\n", node
, newItem
, namedItem
);
1679 return E_INVALIDARG
;
1681 if(namedItem
) *namedItem
= NULL
;
1683 /* Must be an Attribute */
1684 ThisNew
= get_node_obj( newItem
);
1685 if(!ThisNew
) return E_FAIL
;
1687 if(ThisNew
->node
->type
!= XML_ATTRIBUTE_NODE
)
1690 if(!ThisNew
->node
->parent
)
1691 if(xmldoc_remove_orphan(ThisNew
->node
->doc
, ThisNew
->node
) != S_OK
)
1692 WARN("%p is not an orphan of %p\n", ThisNew
->node
, ThisNew
->node
->doc
);
1694 nodeNew
= xmlAddChild(node
, ThisNew
->node
);
1697 *namedItem
= create_node( nodeNew
);
1701 static HRESULT
domelem_remove_qualified_item(xmlNodePtr node
, BSTR name
, BSTR uri
, IXMLDOMNode
**item
)
1703 xmlChar
*nameA
, *href
;
1706 TRACE("(%p)->(%s %s %p)\n", node
, debugstr_w(name
), debugstr_w(uri
), item
);
1708 if (!name
) return E_INVALIDARG
;
1712 href
= xmlchar_from_wchar(uri
);
1713 if (!href
) return E_OUTOFMEMORY
;
1718 nameA
= xmlchar_from_wchar(name
);
1722 return E_OUTOFMEMORY
;
1725 attr
= xmlHasNsProp(node
, nameA
, href
);
1732 if (item
) *item
= NULL
;
1738 xmlUnlinkNode( (xmlNodePtr
) attr
);
1739 xmldoc_add_orphan( attr
->doc
, (xmlNodePtr
) attr
);
1740 *item
= create_node( (xmlNodePtr
) attr
);
1744 if (xmlRemoveProp(attr
) == -1)
1745 ERR("xmlRemoveProp failed\n");
1751 static HRESULT
domelem_remove_named_item(xmlNodePtr node
, BSTR name
, IXMLDOMNode
**item
)
1753 xmlChar
*nameA
, *local
, *prefix
;
1758 TRACE("(%p)->(%s %p)\n", node
, debugstr_w(name
), item
);
1760 nameA
= xmlchar_from_wchar(name
);
1761 local
= xmlSplitQName2(nameA
, &prefix
);
1765 return domelem_remove_qualified_item(node
, name
, NULL
, item
);
1767 ns
= xmlSearchNs(node
->doc
, node
, prefix
);
1774 if (item
) *item
= NULL
;
1775 return item
? S_FALSE
: E_INVALIDARG
;
1778 uriW
= bstr_from_xmlChar(ns
->href
);
1779 localW
= bstr_from_xmlChar(local
);
1782 TRACE("removing qualified node %s, uri=%s\n", debugstr_w(localW
), debugstr_w(uriW
));
1784 hr
= domelem_remove_qualified_item(node
, localW
, uriW
, item
);
1786 SysFreeString(localW
);
1787 SysFreeString(uriW
);
1792 static HRESULT
domelem_get_item(const xmlNodePtr node
, LONG index
, IXMLDOMNode
**item
)
1800 TRACE("%p, %ld, %p.\n", node
, index
, item
);
1808 curr
= node
->properties
;
1810 for (; attrIndex
< index
&& curr
->next
!= NULL
; attrIndex
++)
1813 if (attrIndex
== index
) {
1814 *item
= create_node( (xmlNodePtr
) curr
);
1824 for (; attrIndex
< index
&& ns
->next
!= NULL
; attrIndex
++)
1827 if (attrIndex
< index
)
1830 xmlns
= xmlNewNs(NULL
, BAD_CAST
"http://www.w3.org/2000/xmlns/", BAD_CAST
"xmlns");
1832 return E_OUTOFMEMORY
;
1834 curr
= xmlNewNsProp(NULL
, xmlns
, ns
->prefix
, ns
->href
);
1837 return E_OUTOFMEMORY
;
1839 curr
->doc
= node
->doc
;
1841 unk
= create_attribute((xmlNodePtr
)curr
, TRUE
);
1845 return E_OUTOFMEMORY
;
1848 hr
= IUnknown_QueryInterface(unk
, &IID_IXMLDOMNode
, (void**)item
);
1849 IUnknown_Release(unk
);
1854 static HRESULT
domelem_get_length(const xmlNodePtr node
, LONG
*length
)
1860 TRACE("(%p)->(%p)\n", node
, length
);
1863 return E_INVALIDARG
;
1866 curr
= node
->properties
;
1877 *length
= attrCount
;
1882 static HRESULT
domelem_next_node(const xmlNodePtr node
, LONG
*iter
, IXMLDOMNode
**nextNode
)
1887 TRACE("%p, %ld, %p.\n", node
, *iter
, nextNode
);
1891 curr
= node
->properties
;
1895 for (i
= 0; i
< *iter
; i
++) {
1896 if (curr
->next
== NULL
)
1903 *nextNode
= create_node((xmlNodePtr
)curr
);
1908 static const struct nodemap_funcs domelem_attr_map
= {
1909 domelem_get_named_item
,
1910 domelem_set_named_item
,
1911 domelem_remove_named_item
,
1914 domelem_get_qualified_item
,
1915 domelem_remove_qualified_item
,
1919 static const tid_t domelem_iface_tids
[] = {
1924 static dispex_static_data_t domelem_dispex
= {
1931 IUnknown
* create_element( xmlNodePtr element
)
1935 This
= heap_alloc( sizeof *This
);
1939 This
->IXMLDOMElement_iface
.lpVtbl
= &domelem_vtbl
;
1942 init_xmlnode(&This
->node
, element
, (IXMLDOMNode
*)&This
->IXMLDOMElement_iface
, &domelem_dispex
);
1944 return (IUnknown
*)&This
->IXMLDOMElement_iface
;