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
21 #ifndef __MSXML_PRIVATE__
22 #define __MSXML_PRIVATE__
26 #include "wine/unicode.h"
27 #include "wine/list.h"
29 #ifndef __WINE_CONFIG_H
30 # error You must include config.h to use this header
46 IXMLDOMCDATASection_tid
,
51 IXMLDOMDocumentFragment_tid
,
52 IXMLDOMDocumentType_tid
,
54 IXMLDOMEntityReference_tid
,
55 IXMLDOMImplementation_tid
,
56 IXMLDOMNamedNodeMap_tid
,
59 IXMLDOMParseError2_tid
,
60 IXMLDOMProcessingInstruction_tid
,
61 IXMLDOMSchemaCollection_tid
,
62 IXMLDOMSchemaCollection2_tid
,
71 IVBSAXContentHandler_tid
,
72 IVBSAXDeclHandler_tid
,
74 IVBSAXEntityResolver_tid
,
75 IVBSAXErrorHandler_tid
,
76 IVBSAXLexicalHandler_tid
,
83 IVBMXNamespaceManager_tid
,
84 IServerXMLHTTPRequest_tid
,
88 /* The XDR datatypes (urn:schemas-microsoft-com:datatypes)
89 * These are actually valid for XSD schemas as well
92 typedef enum _XDR_DT
{
133 extern HRESULT
get_typeinfo(tid_t tid
, ITypeInfo
**typeinfo
) DECLSPEC_HIDDEN
;
134 extern void release_typelib(void) DECLSPEC_HIDDEN
;
136 typedef struct dispex_data_t dispex_data_t
;
139 HRESULT (*get_dispid
)(IUnknown
*,BSTR
,DWORD
,DISPID
*);
140 HRESULT (*invoke
)(IUnknown
*,DISPID
,LCID
,WORD
,DISPPARAMS
*,VARIANT
*,EXCEPINFO
*);
141 } dispex_static_data_vtbl_t
;
144 const dispex_static_data_vtbl_t
*vtbl
;
145 const tid_t disp_tid
;
147 const tid_t
* const iface_tids
;
148 } dispex_static_data_t
;
151 IDispatchEx IDispatchEx_iface
;
155 dispex_static_data_t
*data
;
158 extern HINSTANCE MSXML_hInstance DECLSPEC_HIDDEN
;
160 void init_dispex(DispatchEx
*,IUnknown
*,dispex_static_data_t
*) DECLSPEC_HIDDEN
;
161 void release_dispex(DispatchEx
*) DECLSPEC_HIDDEN
;
162 BOOL
dispex_query_interface(DispatchEx
*,REFIID
,void**) DECLSPEC_HIDDEN
;
163 const IID
*get_riid_from_tid(enum tid_t tid
) DECLSPEC_HIDDEN
;
165 /* memory allocation functions */
167 static inline void *heap_alloc(size_t len
)
169 return HeapAlloc(GetProcessHeap(), 0, len
);
172 static inline void *heap_alloc_zero(size_t len
)
174 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, len
);
177 static inline void *heap_realloc(void *mem
, size_t len
)
179 return HeapReAlloc(GetProcessHeap(), 0, mem
, len
);
182 static inline void *heap_realloc_zero(void *mem
, size_t len
)
184 return HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, mem
, len
);
187 static inline BOOL
heap_free(void *mem
)
189 return HeapFree(GetProcessHeap(), 0, mem
);
192 static inline LPWSTR
heap_strdupW(LPCWSTR str
)
199 size
= (strlenW(str
)+1)*sizeof(WCHAR
);
200 ret
= heap_alloc(size
);
202 memcpy(ret
, str
, size
);
208 static inline LPSTR
heap_strdupWtoA(LPCWSTR str
)
213 DWORD len
= WideCharToMultiByte(CP_ACP
, 0, str
, -1, NULL
, 0, NULL
, NULL
);
214 ret
= heap_alloc(len
+1);
218 WideCharToMultiByte(CP_ACP
, 0, str
, -1, ret
, len
+1, NULL
, NULL
);
224 /* XSLProcessor parameter list */
225 struct xslprocessor_par
232 struct xslprocessor_params
240 extern void schemasInit(void) DECLSPEC_HIDDEN
;
241 extern void schemasCleanup(void) DECLSPEC_HIDDEN
;
243 #ifndef HAVE_XMLFIRSTELEMENTCHILD
244 static inline xmlNodePtr
wine_xmlFirstElementChild(xmlNodePtr parent
)
247 for (child
= parent
->children
; child
!= NULL
; child
= child
->next
)
248 if (child
->type
== XML_ELEMENT_NODE
)
253 #define xmlFirstElementChild wine_xmlFirstElementChild
256 /* IXMLDOMNode Internal Structure */
257 typedef struct _xmlnode
265 /* IXMLDOMNamedNodeMap custom function table */
268 HRESULT (*get_named_item
)(const xmlNodePtr
,BSTR
,IXMLDOMNode
**);
269 HRESULT (*set_named_item
)(xmlNodePtr
,IXMLDOMNode
*,IXMLDOMNode
**);
270 HRESULT (*remove_named_item
)(xmlNodePtr
,BSTR
,IXMLDOMNode
**);
271 HRESULT (*get_item
)(xmlNodePtr
,LONG
,IXMLDOMNode
**);
272 HRESULT (*get_length
)(xmlNodePtr
,LONG
*);
273 HRESULT (*get_qualified_item
)(const xmlNodePtr
,BSTR
,BSTR
,IXMLDOMNode
**);
274 HRESULT (*remove_qualified_item
)(xmlNodePtr
,BSTR
,BSTR
,IXMLDOMNode
**);
275 HRESULT (*next_node
)(const xmlNodePtr
,LONG
*,IXMLDOMNode
**);
278 /* used by IEnumVARIANT to access outer object items */
279 struct enumvariant_funcs
281 HRESULT (*get_item
)(IUnknown
*, LONG
, VARIANT
*);
282 HRESULT (*next
)(IUnknown
*);
286 extern IUnknown
*create_domdoc( xmlNodePtr
) DECLSPEC_HIDDEN
;
287 extern IUnknown
*create_xmldoc( void ) DECLSPEC_HIDDEN
;
288 extern IXMLDOMNode
*create_node( xmlNodePtr
) DECLSPEC_HIDDEN
;
289 extern IUnknown
*create_element( xmlNodePtr
) DECLSPEC_HIDDEN
;
290 extern IUnknown
*create_attribute( xmlNodePtr
) DECLSPEC_HIDDEN
;
291 extern IUnknown
*create_text( xmlNodePtr
) DECLSPEC_HIDDEN
;
292 extern IUnknown
*create_pi( xmlNodePtr
) DECLSPEC_HIDDEN
;
293 extern IUnknown
*create_comment( xmlNodePtr
) DECLSPEC_HIDDEN
;
294 extern IUnknown
*create_cdata( xmlNodePtr
) DECLSPEC_HIDDEN
;
295 extern IXMLDOMNodeList
*create_children_nodelist( xmlNodePtr
) DECLSPEC_HIDDEN
;
296 extern IXMLDOMNamedNodeMap
*create_nodemap( xmlNodePtr
, const struct nodemap_funcs
* ) DECLSPEC_HIDDEN
;
297 extern IUnknown
*create_doc_Implementation(void) DECLSPEC_HIDDEN
;
298 extern IUnknown
*create_doc_fragment( xmlNodePtr
) DECLSPEC_HIDDEN
;
299 extern IUnknown
*create_doc_entity_ref( xmlNodePtr
) DECLSPEC_HIDDEN
;
300 extern IUnknown
*create_doc_type( xmlNodePtr
) DECLSPEC_HIDDEN
;
301 extern HRESULT
create_selection( xmlNodePtr
, xmlChar
*, IXMLDOMNodeList
** ) DECLSPEC_HIDDEN
;
302 extern HRESULT
create_enumvariant( IUnknown
*, BOOL
, const struct enumvariant_funcs
*, IEnumVARIANT
**) DECLSPEC_HIDDEN
;
305 xmlNodePtr
xmlNodePtr_from_domnode( IXMLDOMNode
*iface
, xmlElementType type
) DECLSPEC_HIDDEN
;
308 extern xmlChar
*xmlChar_from_wchar( LPCWSTR str
) DECLSPEC_HIDDEN
;
310 extern void xmldoc_init( xmlDocPtr doc
, MSXML_VERSION version
) DECLSPEC_HIDDEN
;
311 extern LONG
xmldoc_add_ref( xmlDocPtr doc
) DECLSPEC_HIDDEN
;
312 extern LONG
xmldoc_release( xmlDocPtr doc
) DECLSPEC_HIDDEN
;
313 extern LONG
xmldoc_add_refs( xmlDocPtr doc
, LONG refs
) DECLSPEC_HIDDEN
;
314 extern LONG
xmldoc_release_refs ( xmlDocPtr doc
, LONG refs
) DECLSPEC_HIDDEN
;
315 extern int xmlnode_get_inst_cnt( xmlnode
*node
) DECLSPEC_HIDDEN
;
316 extern HRESULT
xmldoc_add_orphan( xmlDocPtr doc
, xmlNodePtr node
) DECLSPEC_HIDDEN
;
317 extern HRESULT
xmldoc_remove_orphan( xmlDocPtr doc
, xmlNodePtr node
) DECLSPEC_HIDDEN
;
318 extern void xmldoc_link_xmldecl(xmlDocPtr doc
, xmlNodePtr node
) DECLSPEC_HIDDEN
;
319 extern xmlNodePtr
xmldoc_unlink_xmldecl(xmlDocPtr doc
) DECLSPEC_HIDDEN
;
321 extern HRESULT
XMLElement_create( xmlNodePtr node
, LPVOID
*ppObj
, BOOL own
) DECLSPEC_HIDDEN
;
323 extern void wineXmlCallbackLog(char const* caller
, xmlErrorLevel lvl
, char const* msg
, va_list ap
) DECLSPEC_HIDDEN
;
324 extern void wineXmlCallbackError(char const* caller
, xmlErrorPtr err
) DECLSPEC_HIDDEN
;
326 #define LIBXML2_LOG_CALLBACK __WINE_PRINTF_ATTR(2,3)
328 #define LIBXML2_CALLBACK_TRACE(caller, msg, ap) \
329 wineXmlCallbackLog(#caller, XML_ERR_NONE, msg, ap)
331 #define LIBXML2_CALLBACK_WARN(caller, msg, ap) \
332 wineXmlCallbackLog(#caller, XML_ERR_WARNING, msg, ap)
334 #define LIBXML2_CALLBACK_ERR(caller, msg, ap) \
335 wineXmlCallbackLog(#caller, XML_ERR_ERROR, msg, ap)
337 #define LIBXML2_CALLBACK_SERROR(caller, err) wineXmlCallbackError(#caller, err)
339 extern BOOL
is_preserving_whitespace(xmlNodePtr node
) DECLSPEC_HIDDEN
;
340 extern BOOL
is_xpathmode(const xmlDocPtr doc
) DECLSPEC_HIDDEN
;
341 extern void set_xpathmode(xmlDocPtr doc
, BOOL xpath
) DECLSPEC_HIDDEN
;
343 extern void init_xmlnode(xmlnode
*,xmlNodePtr
,IXMLDOMNode
*,dispex_static_data_t
*) DECLSPEC_HIDDEN
;
344 extern void destroy_xmlnode(xmlnode
*) DECLSPEC_HIDDEN
;
345 extern BOOL
node_query_interface(xmlnode
*,REFIID
,void**) DECLSPEC_HIDDEN
;
346 extern xmlnode
*get_node_obj(IXMLDOMNode
*) DECLSPEC_HIDDEN
;
348 extern HRESULT
node_append_child(xmlnode
*,IXMLDOMNode
*,IXMLDOMNode
**) DECLSPEC_HIDDEN
;
349 extern HRESULT
node_get_nodeName(xmlnode
*,BSTR
*) DECLSPEC_HIDDEN
;
350 extern HRESULT
node_get_content(xmlnode
*,VARIANT
*) DECLSPEC_HIDDEN
;
351 extern HRESULT
node_set_content(xmlnode
*,LPCWSTR
) DECLSPEC_HIDDEN
;
352 extern HRESULT
node_put_value(xmlnode
*,VARIANT
*) DECLSPEC_HIDDEN
;
353 extern HRESULT
node_put_value_escaped(xmlnode
*,VARIANT
*) DECLSPEC_HIDDEN
;
354 extern HRESULT
node_get_parent(xmlnode
*,IXMLDOMNode
**) DECLSPEC_HIDDEN
;
355 extern HRESULT
node_get_child_nodes(xmlnode
*,IXMLDOMNodeList
**) DECLSPEC_HIDDEN
;
356 extern HRESULT
node_get_first_child(xmlnode
*,IXMLDOMNode
**) DECLSPEC_HIDDEN
;
357 extern HRESULT
node_get_last_child(xmlnode
*,IXMLDOMNode
**) DECLSPEC_HIDDEN
;
358 extern HRESULT
node_get_previous_sibling(xmlnode
*,IXMLDOMNode
**) DECLSPEC_HIDDEN
;
359 extern HRESULT
node_get_next_sibling(xmlnode
*,IXMLDOMNode
**) DECLSPEC_HIDDEN
;
360 extern HRESULT
node_insert_before(xmlnode
*,IXMLDOMNode
*,const VARIANT
*,IXMLDOMNode
**) DECLSPEC_HIDDEN
;
361 extern HRESULT
node_replace_child(xmlnode
*,IXMLDOMNode
*,IXMLDOMNode
*,IXMLDOMNode
**) DECLSPEC_HIDDEN
;
362 extern HRESULT
node_put_text(xmlnode
*,BSTR
) DECLSPEC_HIDDEN
;
363 extern HRESULT
node_get_xml(xmlnode
*,BOOL
,BSTR
*) DECLSPEC_HIDDEN
;
364 extern HRESULT
node_clone(xmlnode
*,VARIANT_BOOL
,IXMLDOMNode
**) DECLSPEC_HIDDEN
;
365 extern HRESULT
node_get_prefix(xmlnode
*,BSTR
*) DECLSPEC_HIDDEN
;
366 extern HRESULT
node_get_base_name(xmlnode
*,BSTR
*) DECLSPEC_HIDDEN
;
367 extern HRESULT
node_get_namespaceURI(xmlnode
*,BSTR
*) DECLSPEC_HIDDEN
;
368 extern HRESULT
node_remove_child(xmlnode
*,IXMLDOMNode
*,IXMLDOMNode
**) DECLSPEC_HIDDEN
;
369 extern HRESULT
node_has_childnodes(const xmlnode
*,VARIANT_BOOL
*) DECLSPEC_HIDDEN
;
370 extern HRESULT
node_get_owner_doc(const xmlnode
*,IXMLDOMDocument
**) DECLSPEC_HIDDEN
;
371 extern HRESULT
node_get_text(const xmlnode
*,BSTR
*) DECLSPEC_HIDDEN
;
372 extern HRESULT
node_select_nodes(const xmlnode
*,BSTR
,IXMLDOMNodeList
**) DECLSPEC_HIDDEN
;
373 extern HRESULT
node_select_singlenode(const xmlnode
*,BSTR
,IXMLDOMNode
**) DECLSPEC_HIDDEN
;
374 extern HRESULT
node_transform_node(const xmlnode
*,IXMLDOMNode
*,BSTR
*) DECLSPEC_HIDDEN
;
375 extern HRESULT
node_transform_node_params(const xmlnode
*,IXMLDOMNode
*,BSTR
*,IStream
*,const struct xslprocessor_params
*) DECLSPEC_HIDDEN
;
376 extern HRESULT
node_create_supporterrorinfo(const tid_t
*,void**) DECLSPEC_HIDDEN
;
378 extern HRESULT
get_domdoc_from_xmldoc(xmlDocPtr xmldoc
, IXMLDOMDocument3
**document
) DECLSPEC_HIDDEN
;
380 extern HRESULT
SchemaCache_validate_tree(IXMLDOMSchemaCollection2
*, xmlNodePtr
) DECLSPEC_HIDDEN
;
381 extern XDR_DT
SchemaCache_get_node_dt(IXMLDOMSchemaCollection2
*, xmlNodePtr
) DECLSPEC_HIDDEN
;
382 extern HRESULT
cache_from_doc_ns(IXMLDOMSchemaCollection2
*, xmlnode
*) DECLSPEC_HIDDEN
;
384 extern XDR_DT
str_to_dt(xmlChar
const* str
, int len
/* calculated if -1 */) DECLSPEC_HIDDEN
;
385 extern XDR_DT
bstr_to_dt(OLECHAR
const* bstr
, int len
/* calculated if -1 */) DECLSPEC_HIDDEN
;
386 extern xmlChar
const* dt_to_str(XDR_DT dt
) DECLSPEC_HIDDEN
;
387 extern const char* debugstr_dt(XDR_DT dt
) DECLSPEC_HIDDEN
;
388 extern OLECHAR
const* dt_to_bstr(XDR_DT dt
) DECLSPEC_HIDDEN
;
389 extern HRESULT
dt_validate(XDR_DT dt
, xmlChar
const* content
) DECLSPEC_HIDDEN
;
391 extern BSTR
EnsureCorrectEOL(BSTR
) DECLSPEC_HIDDEN
;
393 extern xmlChar
* tagName_to_XPath(const BSTR tagName
) DECLSPEC_HIDDEN
;
395 static inline BSTR
bstr_from_xmlChar(const xmlChar
*str
)
400 DWORD len
= MultiByteToWideChar(CP_UTF8
, 0, (LPCSTR
)str
, -1, NULL
, 0);
401 ret
= SysAllocStringLen(NULL
, len
-1);
403 MultiByteToWideChar( CP_UTF8
, 0, (LPCSTR
)str
, -1, ret
, len
);
406 ret
= SysAllocStringLen(NULL
, 0);
411 static inline xmlChar
*xmlchar_from_wcharn(const WCHAR
*str
, int nchars
)
414 DWORD len
= WideCharToMultiByte( CP_UTF8
, 0, str
, nchars
, NULL
, 0, NULL
, NULL
);
416 xmlstr
= heap_alloc( len
+1 );
419 WideCharToMultiByte( CP_UTF8
, 0, str
, nchars
, (LPSTR
) xmlstr
, len
+1, NULL
, NULL
);
425 static inline xmlChar
*xmlchar_from_wchar( const WCHAR
*str
)
427 return xmlchar_from_wcharn(str
, -1);
430 static inline xmlChar
*heap_strdupxmlChar(const xmlChar
*str
)
437 size
= (xmlStrlen(str
)+1)*sizeof(xmlChar
);
438 ret
= heap_alloc(size
);
439 memcpy(ret
, str
, size
);
447 static inline HRESULT
return_bstr(const WCHAR
*value
, BSTR
*p
)
453 *p
= SysAllocString(value
);
455 return E_OUTOFMEMORY
;
463 static inline HRESULT
return_bstrn(const WCHAR
*value
, int len
, BSTR
*p
)
466 *p
= SysAllocStringLen(value
, len
);
468 return E_OUTOFMEMORY
;
475 static inline HRESULT
return_null_node(IXMLDOMNode
**p
)
483 static inline HRESULT
return_null_ptr(void **p
)
491 static inline HRESULT
return_null_var(VARIANT
*p
)
500 static inline HRESULT
return_null_bstr(BSTR
*p
)
509 static inline HRESULT
return_var_false(VARIANT_BOOL
*p
)
518 extern IXMLDOMParseError
*create_parseError( LONG code
, BSTR url
, BSTR reason
, BSTR srcText
,
519 LONG line
, LONG linepos
, LONG filepos
) DECLSPEC_HIDDEN
;
520 extern HRESULT
DOMDocument_create(MSXML_VERSION
, void**) DECLSPEC_HIDDEN
;
521 extern HRESULT
SchemaCache_create(MSXML_VERSION
, void**) DECLSPEC_HIDDEN
;
522 extern HRESULT
XMLDocument_create(void**) DECLSPEC_HIDDEN
;
523 extern HRESULT
SAXXMLReader_create(MSXML_VERSION
, void**) DECLSPEC_HIDDEN
;
524 extern HRESULT
SAXAttributes_create(MSXML_VERSION
, void**) DECLSPEC_HIDDEN
;
525 extern HRESULT
XMLHTTPRequest_create(void **) DECLSPEC_HIDDEN
;
526 extern HRESULT
ServerXMLHTTP_create(void **) DECLSPEC_HIDDEN
;
527 extern HRESULT
XSLTemplate_create(void**) DECLSPEC_HIDDEN
;
528 extern HRESULT
MXWriter_create(MSXML_VERSION
, void**) DECLSPEC_HIDDEN
;
529 extern HRESULT
MXNamespaceManager_create(void**) DECLSPEC_HIDDEN
;
530 extern HRESULT
XMLParser_create(void**) DECLSPEC_HIDDEN
;
531 extern HRESULT
XMLView_create(void**) DECLSPEC_HIDDEN
;
533 static inline const CLSID
* DOMDocument_version(MSXML_VERSION v
)
538 case MSXML_DEFAULT
: return &CLSID_DOMDocument
;
539 case MSXML3
: return &CLSID_DOMDocument30
;
540 case MSXML4
: return &CLSID_DOMDocument40
;
541 case MSXML6
: return &CLSID_DOMDocument60
;
545 static inline const CLSID
* SchemaCache_version(MSXML_VERSION v
)
550 case MSXML_DEFAULT
: return &CLSID_XMLSchemaCache
;
551 case MSXML3
: return &CLSID_XMLSchemaCache30
;
552 case MSXML4
: return &CLSID_XMLSchemaCache40
;
553 case MSXML6
: return &CLSID_XMLSchemaCache60
;
557 typedef struct bsc_t bsc_t
;
559 HRESULT
create_moniker_from_url(LPCWSTR
, IMoniker
**) DECLSPEC_HIDDEN
;
560 HRESULT
bind_url(IMoniker
*, HRESULT (*onDataAvailable
)(void*,char*,DWORD
), void*, bsc_t
**) DECLSPEC_HIDDEN
;
561 HRESULT
detach_bsc(bsc_t
*) DECLSPEC_HIDDEN
;
563 const char *debugstr_variant(const VARIANT
*) DECLSPEC_HIDDEN
;
565 /* Error Codes - not defined anywhere in the public headers */
566 #define E_XML_ELEMENT_UNDECLARED 0xC00CE00D
567 #define E_XML_ELEMENT_ID_NOT_FOUND 0xC00CE00E
569 #define E_XML_EMPTY_NOT_ALLOWED 0xC00CE011
570 #define E_XML_ELEMENT_NOT_COMPLETE 0xC00CE012
571 #define E_XML_ROOT_NAME_MISMATCH 0xC00CE013
572 #define E_XML_INVALID_CONTENT 0xC00CE014
573 #define E_XML_ATTRIBUTE_NOT_DEFINED 0xC00CE015
574 #define E_XML_ATTRIBUTE_FIXED 0xC00CE016
575 #define E_XML_ATTRIBUTE_VALUE 0xC00CE017
576 #define E_XML_ILLEGAL_TEXT 0xC00CE018
578 #define E_XML_REQUIRED_ATTRIBUTE_MISSING 0xC00CE020
580 #endif /* __MSXML_PRIVATE__ */