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"
28 #ifndef __WINE_CONFIG_H
29 # error You must include config.h to use this header
42 IXMLDOMCDATASection_tid,
46 IXMLDOMDocumentFragment_tid,
47 IXMLDOMDocumentType_tid,
49 IXMLDOMEntityReference_tid,
50 IXMLDOMImplementation_tid,
51 IXMLDOMNamedNodeMap_tid,
54 IXMLDOMParseError_tid,
55 IXMLDOMProcessingInstruction_tid,
56 IXMLDOMSchemaCollection_tid,
65 IVBSAXContentHandler_tid,
66 IVBSAXDeclHandler_tid,
68 IVBSAXEntityResolver_tid,
69 IVBSAXErrorHandler_tid,
70 IVBSAXLexicalHandler_tid,
80 /* The XDR datatypes (urn:schemas-microsoft-com:datatypes)
81 * These are actually valid for XSD schemas as well
84 typedef enum _XDR_DT {
123 #define DT__N_TYPES (DT_UUID+1)
125 extern HRESULT get_typeinfo(tid_t tid, ITypeInfo **typeinfo);
126 extern void release_typelib(void);
128 typedef struct dispex_data_t dispex_data_t;
129 typedef struct dispex_dynamic_data_t dispex_dynamic_data_t;
131 #define MSXML_DISPID_CUSTOM_MIN 0x60000000
132 #define MSXML_DISPID_CUSTOM_MAX 0x6fffffff
135 HRESULT (*get_dispid)(IUnknown*,BSTR,DWORD,DISPID*);
136 HRESULT (*invoke)(IUnknown*,DISPID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*);
137 } dispex_static_data_vtbl_t;
140 const dispex_static_data_vtbl_t *vtbl;
141 const tid_t disp_tid;
143 const tid_t* const iface_tids;
144 } dispex_static_data_t;
147 const IDispatchExVtbl *lpIDispatchExVtbl;
151 dispex_static_data_t *data;
152 dispex_dynamic_data_t *dynamic_data;
155 extern HINSTANCE MSXML_hInstance;
157 void init_dispex(DispatchEx*,IUnknown*,dispex_static_data_t*);
158 BOOL dispex_query_interface(DispatchEx*,REFIID,void**);
162 #ifdef HAVE_LIBXML_PARSER_H
163 #include <libxml/parser.h>
168 #include <libxml/xmlerror.h>
170 extern void schemasInit(void);
171 extern void schemasCleanup(void);
173 #ifndef HAVE_XMLFIRSTELEMENTCHILD
174 static inline xmlNodePtr wine_xmlFirstElementChild(xmlNodePtr parent)
177 for (child = parent->children; child != NULL; child = child->next)
178 if (child->type == XML_ELEMENT_NODE)
183 #define xmlFirstElementChild wine_xmlFirstElementChild
187 extern IUnknown *create_domdoc( xmlNodePtr document );
188 extern IUnknown *create_xmldoc( void );
189 extern IXMLDOMNode *create_node( xmlNodePtr node );
190 extern IUnknown *create_element( xmlNodePtr element );
191 extern IUnknown *create_attribute( xmlNodePtr attribute );
192 extern IUnknown *create_text( xmlNodePtr text );
193 extern IUnknown *create_pi( xmlNodePtr pi );
194 extern IUnknown *create_comment( xmlNodePtr comment );
195 extern IUnknown *create_cdata( xmlNodePtr text );
196 extern IXMLDOMNodeList *create_children_nodelist( xmlNodePtr );
197 extern IXMLDOMNamedNodeMap *create_nodemap( IXMLDOMNode *node );
198 extern IUnknown *create_doc_Implementation(void);
199 extern IUnknown *create_doc_fragment( xmlNodePtr fragment );
200 extern IUnknown *create_doc_entity_ref( xmlNodePtr entity );
201 extern IUnknown *create_doc_type( xmlNodePtr doctype );
203 extern HRESULT queryresult_create( xmlNodePtr node, xmlChar* szQuery, IXMLDOMNodeList** out );
206 xmlNodePtr xmlNodePtr_from_domnode( IXMLDOMNode *iface, xmlElementType type );
209 extern xmlChar *xmlChar_from_wchar( LPCWSTR str );
211 extern void xmldoc_init( xmlDocPtr doc, const GUID *clsid );
212 extern LONG xmldoc_add_ref( xmlDocPtr doc );
213 extern LONG xmldoc_release( xmlDocPtr doc );
214 extern HRESULT xmldoc_add_orphan( xmlDocPtr doc, xmlNodePtr node );
215 extern HRESULT xmldoc_remove_orphan( xmlDocPtr doc, xmlNodePtr node );
216 extern void xmldoc_link_xmldecl(xmlDocPtr doc, xmlNodePtr node);
217 extern xmlNodePtr xmldoc_unlink_xmldecl(xmlDocPtr doc);
219 extern HRESULT XMLElement_create( IUnknown *pUnkOuter, xmlNodePtr node, LPVOID *ppObj, BOOL own );
221 extern void wineXmlCallbackLog(char const* caller, xmlErrorLevel lvl, char const* msg, va_list ap);
222 extern void wineXmlCallbackError(char const* caller, xmlErrorPtr err);
224 #define LIBXML2_LOG_CALLBACK __WINE_PRINTF_ATTR(2,3)
226 #define LIBXML2_CALLBACK_TRACE(caller, msg, ap) \
227 wineXmlCallbackLog(#caller, XML_ERR_NONE, msg, ap)
229 #define LIBXML2_CALLBACK_WARN(caller, msg, ap) \
230 wineXmlCallbackLog(#caller, XML_ERR_WARNING, msg, ap)
232 #define LIBXML2_CALLBACK_ERR(caller, msg, ap) \
233 wineXmlCallbackLog(#caller, XML_ERR_ERROR, msg, ap)
235 #define LIBXML2_CALLBACK_SERROR(caller, err) wineXmlCallbackError(#caller, err)
237 extern BOOL is_preserving_whitespace(xmlNodePtr node);
238 extern BOOL is_xpathmode(const xmlDocPtr doc);
239 extern void set_xpathmode(xmlDocPtr doc, BOOL xpath);
241 /* IXMLDOMNode Internal Structure */
242 typedef struct _xmlnode
245 IXMLDOMNode IXMLDOMNode_iface;
250 extern void init_xmlnode(xmlnode*,xmlNodePtr,IXMLDOMNode*,dispex_static_data_t*);
251 extern void destroy_xmlnode(xmlnode*);
252 extern BOOL node_query_interface(xmlnode*,REFIID,void**);
253 extern xmlnode *get_node_obj(IXMLDOMNode*);
255 extern HRESULT node_append_child(xmlnode*,IXMLDOMNode*,IXMLDOMNode**);
256 extern HRESULT node_get_nodeName(xmlnode*,BSTR*);
257 extern HRESULT node_get_content(xmlnode*,VARIANT*);
258 extern HRESULT node_set_content(xmlnode*,LPCWSTR);
259 extern HRESULT node_put_value(xmlnode*,VARIANT*);
260 extern HRESULT node_put_value_escaped(xmlnode*,VARIANT*);
261 extern HRESULT node_get_parent(xmlnode*,IXMLDOMNode**);
262 extern HRESULT node_get_child_nodes(xmlnode*,IXMLDOMNodeList**);
263 extern HRESULT node_get_first_child(xmlnode*,IXMLDOMNode**);
264 extern HRESULT node_get_last_child(xmlnode*,IXMLDOMNode**);
265 extern HRESULT node_get_previous_sibling(xmlnode*,IXMLDOMNode**);
266 extern HRESULT node_get_next_sibling(xmlnode*,IXMLDOMNode**);
267 extern HRESULT node_insert_before(xmlnode*,IXMLDOMNode*,const VARIANT*,IXMLDOMNode**);
268 extern HRESULT node_replace_child(xmlnode*,IXMLDOMNode*,IXMLDOMNode*,IXMLDOMNode**);
269 extern HRESULT node_put_text(xmlnode*,BSTR);
270 extern HRESULT node_get_xml(xmlnode*,BOOL,BOOL,BSTR*);
271 extern HRESULT node_clone(xmlnode*,VARIANT_BOOL,IXMLDOMNode**);
272 extern HRESULT node_get_prefix(xmlnode*,BSTR*);
273 extern HRESULT node_get_base_name(xmlnode*,BSTR*);
274 extern HRESULT node_get_namespaceURI(xmlnode*,BSTR*);
275 extern HRESULT node_remove_child(xmlnode*,IXMLDOMNode*,IXMLDOMNode**);
276 extern HRESULT node_has_childnodes(const xmlnode*,VARIANT_BOOL*);
277 extern HRESULT node_get_owner_doc(const xmlnode*,IXMLDOMDocument**);
278 extern HRESULT node_get_text(const xmlnode*,BSTR*);
280 extern HRESULT get_domdoc_from_xmldoc(xmlDocPtr xmldoc, IXMLDOMDocument3 **document);
282 extern HRESULT SchemaCache_validate_tree(IXMLDOMSchemaCollection2* iface, xmlNodePtr tree);
283 extern XDR_DT SchemaCache_get_node_dt(IXMLDOMSchemaCollection2* iface, xmlNodePtr node);
285 extern XDR_DT str_to_dt(xmlChar const* str, int len /* calculated if -1 */);
286 extern XDR_DT bstr_to_dt(OLECHAR const* bstr, int len /* calculated if -1 */);
287 extern xmlChar const* dt_to_str(XDR_DT dt);
288 extern OLECHAR const* dt_to_bstr(XDR_DT dt);
289 extern XDR_DT element_get_dt(xmlNodePtr node);
290 extern HRESULT dt_validate(XDR_DT dt, xmlChar const* content);
292 extern BSTR EnsureCorrectEOL(BSTR);
294 extern xmlChar* tagName_to_XPath(const BSTR tagName);
296 static inline BSTR bstr_from_xmlChar(const xmlChar *str)
301 DWORD len = MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)str, -1, NULL, 0);
302 ret = SysAllocStringLen(NULL, len-1);
304 MultiByteToWideChar( CP_UTF8, 0, (LPCSTR)str, -1, ret, len);
307 ret = SysAllocStringLen(NULL, 0);
312 static inline HRESULT return_bstr(const WCHAR *value, BSTR *p)
318 *p = SysAllocString(value);
320 return E_OUTOFMEMORY;
328 static inline HRESULT return_null_node(IXMLDOMNode **p)
336 static inline HRESULT return_null_ptr(void **p)
344 static inline HRESULT return_null_var(VARIANT *p)
353 static inline HRESULT return_null_bstr(BSTR *p)
364 extern void* libxslt_handle;
365 #ifdef SONAME_LIBXSLT
366 # ifdef HAVE_LIBXSLT_PATTERN_H
367 # include <libxslt/pattern.h>
369 # ifdef HAVE_LIBXSLT_TRANSFORM_H
370 # include <libxslt/transform.h>
372 # include <libxslt/xsltutils.h>
373 # include <libxslt/xsltInternals.h>
375 # define MAKE_FUNCPTR(f) extern typeof(f) * p##f
376 MAKE_FUNCPTR(xsltApplyStylesheet);
377 MAKE_FUNCPTR(xsltCleanupGlobals);
378 MAKE_FUNCPTR(xsltFreeStylesheet);
379 MAKE_FUNCPTR(xsltParseStylesheetDoc);
383 extern IXMLDOMParseError *create_parseError( LONG code, BSTR url, BSTR reason, BSTR srcText,
384 LONG line, LONG linepos, LONG filepos );
385 extern HRESULT DOMDocument_create(const GUID*, IUnknown*, void**);
386 extern HRESULT SchemaCache_create(const GUID*, IUnknown*, void**);
387 extern HRESULT XMLDocument_create(IUnknown*, void**);
388 extern HRESULT SAXXMLReader_create(IUnknown*, void**);
389 extern HRESULT XMLHTTPRequest_create(IUnknown*, void **);
390 extern HRESULT XSLTemplate_create(IUnknown*, void**);
392 static inline const CLSID* DOMDocument_version(MSXML_VERSION v)
397 case MSXML_DEFAULT: return &CLSID_DOMDocument;
398 case MSXML3: return &CLSID_DOMDocument30;
399 case MSXML4: return &CLSID_DOMDocument40;
400 case MSXML6: return &CLSID_DOMDocument60;
404 static inline const CLSID* SchemaCache_version(MSXML_VERSION v)
409 case MSXML_DEFAULT: return &CLSID_XMLSchemaCache;
410 case MSXML3: return &CLSID_XMLSchemaCache30;
411 case MSXML4: return &CLSID_XMLSchemaCache40;
412 case MSXML6: return &CLSID_XMLSchemaCache60;
416 typedef struct bsc_t bsc_t;
418 HRESULT bind_url(LPCWSTR, HRESULT (*onDataAvailable)(void*,char*,DWORD), void*, bsc_t**);
419 void detach_bsc(bsc_t*);
421 const char *debugstr_variant(const VARIANT*);
423 /* memory allocation functions */
425 static inline void *heap_alloc(size_t len)
427 return HeapAlloc(GetProcessHeap(), 0, len);
430 static inline void *heap_alloc_zero(size_t len)
432 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
435 static inline void *heap_realloc(void *mem, size_t len)
437 return HeapReAlloc(GetProcessHeap(), 0, mem, len);
440 static inline BOOL heap_free(void *mem)
442 return HeapFree(GetProcessHeap(), 0, mem);
445 static inline LPWSTR heap_strdupW(LPCWSTR str)
452 size = (strlenW(str)+1)*sizeof(WCHAR);
453 ret = heap_alloc(size);
454 memcpy(ret, str, size);
460 /* Error Codes - not defined anywhere in the public headers */
461 #define E_XML_ELEMENT_UNDECLARED 0xC00CE00D
462 #define E_XML_ELEMENT_ID_NOT_FOUND 0xC00CE00E
464 #define E_XML_EMPTY_NOT_ALLOWED 0xC00CE011
465 #define E_XML_ELEMENT_NOT_COMPLETE 0xC00CE012
466 #define E_XML_ROOT_NAME_MISMATCH 0xC00CE013
467 #define E_XML_INVALID_CONTENT 0xC00CE014
468 #define E_XML_ATTRIBUTE_NOT_DEFINED 0xC00CE015
469 #define E_XML_ATTRIBUTE_FIXED 0xC00CE016
470 #define E_XML_ATTRIBUTE_VALUE 0xC00CE017
471 #define E_XML_ILLEGAL_TEXT 0xC00CE018
473 #define E_XML_REQUIRED_ATTRIBUTE_MISSING 0xC00CE020
475 #endif /* __MSXML_PRIVATE__ */