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/heap.h"
27 #include "wine/list.h"
29 #include "msxml_dispex.h"
31 extern const CLSID
* DOMDocument_version(MSXML_VERSION v
) DECLSPEC_HIDDEN
;
34 /* The XDR datatypes (urn:schemas-microsoft-com:datatypes)
35 * These are actually valid for XSD schemas as well
38 typedef enum _XDR_DT
{
79 extern HINSTANCE MSXML_hInstance DECLSPEC_HIDDEN
;
81 /* memory allocation functions */
83 static inline void* __WINE_ALLOC_SIZE(2) heap_realloc_zero(void *mem
, size_t size
)
85 return HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, mem
, size
);
88 static inline LPWSTR
heap_strdupW(LPCWSTR str
)
95 size
= (lstrlenW(str
)+1)*sizeof(WCHAR
);
96 ret
= heap_alloc(size
);
98 memcpy(ret
, str
, size
);
104 /* XSLProcessor parameter list */
105 struct xslprocessor_par
112 struct xslprocessor_params
118 extern void schemasInit(void) DECLSPEC_HIDDEN
;
119 extern void schemasCleanup(void) DECLSPEC_HIDDEN
;
121 /* IXMLDOMNode Internal Structure */
122 typedef struct _xmlnode
130 /* IXMLDOMNamedNodeMap custom function table */
133 HRESULT (*get_named_item
)(const xmlNodePtr
,BSTR
,IXMLDOMNode
**);
134 HRESULT (*set_named_item
)(xmlNodePtr
,IXMLDOMNode
*,IXMLDOMNode
**);
135 HRESULT (*remove_named_item
)(xmlNodePtr
,BSTR
,IXMLDOMNode
**);
136 HRESULT (*get_item
)(xmlNodePtr
,LONG
,IXMLDOMNode
**);
137 HRESULT (*get_length
)(xmlNodePtr
,LONG
*);
138 HRESULT (*get_qualified_item
)(const xmlNodePtr
,BSTR
,BSTR
,IXMLDOMNode
**);
139 HRESULT (*remove_qualified_item
)(xmlNodePtr
,BSTR
,BSTR
,IXMLDOMNode
**);
140 HRESULT (*next_node
)(const xmlNodePtr
,LONG
*,IXMLDOMNode
**);
143 /* used by IEnumVARIANT to access outer object items */
144 struct enumvariant_funcs
146 HRESULT (*get_item
)(IUnknown
*, LONG
, VARIANT
*);
147 HRESULT (*next
)(IUnknown
*);
151 extern IUnknown
*create_domdoc( xmlNodePtr
) DECLSPEC_HIDDEN
;
152 extern IUnknown
*create_xmldoc( void ) DECLSPEC_HIDDEN
;
153 extern IXMLDOMNode
*create_node( xmlNodePtr
) DECLSPEC_HIDDEN
;
154 extern IUnknown
*create_element( xmlNodePtr
) DECLSPEC_HIDDEN
;
155 extern IUnknown
*create_attribute( xmlNodePtr
, BOOL
) DECLSPEC_HIDDEN
;
156 extern IUnknown
*create_text( xmlNodePtr
) DECLSPEC_HIDDEN
;
157 extern IUnknown
*create_pi( xmlNodePtr
) DECLSPEC_HIDDEN
;
158 extern IUnknown
*create_comment( xmlNodePtr
) DECLSPEC_HIDDEN
;
159 extern IUnknown
*create_cdata( xmlNodePtr
) DECLSPEC_HIDDEN
;
160 extern IXMLDOMNodeList
*create_children_nodelist( xmlNodePtr
) DECLSPEC_HIDDEN
;
161 extern IXMLDOMNamedNodeMap
*create_nodemap( xmlNodePtr
, const struct nodemap_funcs
* ) DECLSPEC_HIDDEN
;
162 extern IUnknown
*create_doc_fragment( xmlNodePtr
) DECLSPEC_HIDDEN
;
163 extern IUnknown
*create_doc_entity_ref( xmlNodePtr
) DECLSPEC_HIDDEN
;
164 extern IUnknown
*create_doc_type( xmlNodePtr
) DECLSPEC_HIDDEN
;
165 extern HRESULT
create_selection( xmlNodePtr
, xmlChar
*, IXMLDOMNodeList
** ) DECLSPEC_HIDDEN
;
166 extern HRESULT
create_enumvariant( IUnknown
*, BOOL
, const struct enumvariant_funcs
*, IEnumVARIANT
**) DECLSPEC_HIDDEN
;
167 extern HRESULT
create_dom_implementation(IXMLDOMImplementation
**obj
) DECLSPEC_HIDDEN
;
170 xmlNodePtr
xmlNodePtr_from_domnode( IXMLDOMNode
*iface
, xmlElementType type
) DECLSPEC_HIDDEN
;
173 extern xmlChar
*xmlChar_from_wchar( LPCWSTR str
) DECLSPEC_HIDDEN
;
175 extern void xmldoc_init( xmlDocPtr doc
, MSXML_VERSION version
) DECLSPEC_HIDDEN
;
176 extern LONG
xmldoc_add_ref( xmlDocPtr doc
) DECLSPEC_HIDDEN
;
177 extern LONG
xmldoc_release( xmlDocPtr doc
) DECLSPEC_HIDDEN
;
178 extern LONG
xmldoc_add_refs( xmlDocPtr doc
, LONG refs
) DECLSPEC_HIDDEN
;
179 extern LONG
xmldoc_release_refs ( xmlDocPtr doc
, LONG refs
) DECLSPEC_HIDDEN
;
180 extern void xmlnode_add_ref(xmlNodePtr node
) DECLSPEC_HIDDEN
;
181 extern void xmlnode_release(xmlNodePtr node
) DECLSPEC_HIDDEN
;
182 extern int xmlnode_get_inst_cnt( xmlnode
*node
) DECLSPEC_HIDDEN
;
183 extern HRESULT
xmldoc_add_orphan( xmlDocPtr doc
, xmlNodePtr node
) DECLSPEC_HIDDEN
;
184 extern HRESULT
xmldoc_remove_orphan( xmlDocPtr doc
, xmlNodePtr node
) DECLSPEC_HIDDEN
;
185 extern void xmldoc_link_xmldecl(xmlDocPtr doc
, xmlNodePtr node
) DECLSPEC_HIDDEN
;
186 extern xmlNodePtr
xmldoc_unlink_xmldecl(xmlDocPtr doc
) DECLSPEC_HIDDEN
;
187 extern MSXML_VERSION
xmldoc_version( xmlDocPtr doc
) DECLSPEC_HIDDEN
;
189 extern HRESULT
XMLElement_create( xmlNodePtr node
, LPVOID
*ppObj
, BOOL own
) DECLSPEC_HIDDEN
;
191 extern void wineXmlCallbackLog(char const* caller
, xmlErrorLevel lvl
, char const* msg
, va_list ap
) DECLSPEC_HIDDEN
;
192 extern void wineXmlCallbackError(char const* caller
, xmlErrorPtr err
) DECLSPEC_HIDDEN
;
194 #define LIBXML2_LOG_CALLBACK WINAPIV __WINE_PRINTF_ATTR(2,3)
196 #define LIBXML2_CALLBACK_TRACE(caller, msg, ap) \
197 wineXmlCallbackLog(#caller, XML_ERR_NONE, msg, ap)
199 #define LIBXML2_CALLBACK_WARN(caller, msg, ap) \
200 wineXmlCallbackLog(#caller, XML_ERR_WARNING, msg, ap)
202 #define LIBXML2_CALLBACK_ERR(caller, msg, ap) \
203 wineXmlCallbackLog(#caller, XML_ERR_ERROR, msg, ap)
205 #define LIBXML2_CALLBACK_SERROR(caller, err) wineXmlCallbackError(#caller, err)
207 extern BOOL
is_preserving_whitespace(xmlNodePtr node
) DECLSPEC_HIDDEN
;
208 extern BOOL
is_xpathmode(const xmlDocPtr doc
) DECLSPEC_HIDDEN
;
209 extern void set_xpathmode(xmlDocPtr doc
, BOOL xpath
) DECLSPEC_HIDDEN
;
211 extern void init_xmlnode(xmlnode
*,xmlNodePtr
,IXMLDOMNode
*,dispex_static_data_t
*) DECLSPEC_HIDDEN
;
212 extern void destroy_xmlnode(xmlnode
*) DECLSPEC_HIDDEN
;
213 extern BOOL
node_query_interface(xmlnode
*,REFIID
,void**) DECLSPEC_HIDDEN
;
214 extern xmlnode
*get_node_obj(IXMLDOMNode
*) DECLSPEC_HIDDEN
;
216 extern HRESULT
node_append_child(xmlnode
*,IXMLDOMNode
*,IXMLDOMNode
**) DECLSPEC_HIDDEN
;
217 extern HRESULT
node_get_nodeName(xmlnode
*,BSTR
*) DECLSPEC_HIDDEN
;
218 extern HRESULT
node_get_content(xmlnode
*,VARIANT
*) DECLSPEC_HIDDEN
;
219 extern HRESULT
node_set_content(xmlnode
*,LPCWSTR
) DECLSPEC_HIDDEN
;
220 extern HRESULT
node_put_value(xmlnode
*,VARIANT
*) DECLSPEC_HIDDEN
;
221 extern HRESULT
node_put_value_escaped(xmlnode
*,VARIANT
*) DECLSPEC_HIDDEN
;
222 extern HRESULT
node_get_parent(xmlnode
*,IXMLDOMNode
**) DECLSPEC_HIDDEN
;
223 extern HRESULT
node_get_child_nodes(xmlnode
*,IXMLDOMNodeList
**) DECLSPEC_HIDDEN
;
224 extern HRESULT
node_get_first_child(xmlnode
*,IXMLDOMNode
**) DECLSPEC_HIDDEN
;
225 extern HRESULT
node_get_last_child(xmlnode
*,IXMLDOMNode
**) DECLSPEC_HIDDEN
;
226 extern HRESULT
node_get_previous_sibling(xmlnode
*,IXMLDOMNode
**) DECLSPEC_HIDDEN
;
227 extern HRESULT
node_get_next_sibling(xmlnode
*,IXMLDOMNode
**) DECLSPEC_HIDDEN
;
228 extern HRESULT
node_insert_before(xmlnode
*,IXMLDOMNode
*,const VARIANT
*,IXMLDOMNode
**) DECLSPEC_HIDDEN
;
229 extern HRESULT
node_replace_child(xmlnode
*,IXMLDOMNode
*,IXMLDOMNode
*,IXMLDOMNode
**) DECLSPEC_HIDDEN
;
230 extern HRESULT
node_put_text(xmlnode
*,BSTR
) DECLSPEC_HIDDEN
;
231 extern HRESULT
node_get_xml(xmlnode
*,BOOL
,BSTR
*) DECLSPEC_HIDDEN
;
232 extern HRESULT
node_clone(xmlnode
*,VARIANT_BOOL
,IXMLDOMNode
**) DECLSPEC_HIDDEN
;
233 extern HRESULT
node_get_prefix(xmlnode
*,BSTR
*) DECLSPEC_HIDDEN
;
234 extern HRESULT
node_get_base_name(xmlnode
*,BSTR
*) DECLSPEC_HIDDEN
;
235 extern HRESULT
node_get_namespaceURI(xmlnode
*,BSTR
*) DECLSPEC_HIDDEN
;
236 extern HRESULT
node_remove_child(xmlnode
*,IXMLDOMNode
*,IXMLDOMNode
**) DECLSPEC_HIDDEN
;
237 extern HRESULT
node_has_childnodes(const xmlnode
*,VARIANT_BOOL
*) DECLSPEC_HIDDEN
;
238 extern HRESULT
node_get_owner_doc(const xmlnode
*,IXMLDOMDocument
**) DECLSPEC_HIDDEN
;
239 extern HRESULT
node_get_text(const xmlnode
*,BSTR
*) DECLSPEC_HIDDEN
;
240 extern HRESULT
node_select_nodes(const xmlnode
*,BSTR
,IXMLDOMNodeList
**) DECLSPEC_HIDDEN
;
241 extern HRESULT
node_select_singlenode(const xmlnode
*,BSTR
,IXMLDOMNode
**) DECLSPEC_HIDDEN
;
242 extern HRESULT
node_transform_node(const xmlnode
*,IXMLDOMNode
*,BSTR
*) DECLSPEC_HIDDEN
;
243 extern HRESULT
node_transform_node_params(const xmlnode
*,IXMLDOMNode
*,BSTR
*,ISequentialStream
*,
244 const struct xslprocessor_params
*) DECLSPEC_HIDDEN
;
245 extern HRESULT
node_create_supporterrorinfo(const tid_t
*,void**) DECLSPEC_HIDDEN
;
247 extern HRESULT
get_domdoc_from_xmldoc(xmlDocPtr xmldoc
, IXMLDOMDocument3
**document
) DECLSPEC_HIDDEN
;
249 extern HRESULT
SchemaCache_validate_tree(IXMLDOMSchemaCollection2
*, xmlNodePtr
) DECLSPEC_HIDDEN
;
250 extern XDR_DT
SchemaCache_get_node_dt(IXMLDOMSchemaCollection2
*, xmlNodePtr
) DECLSPEC_HIDDEN
;
251 extern HRESULT
cache_from_doc_ns(IXMLDOMSchemaCollection2
*, xmlnode
*) DECLSPEC_HIDDEN
;
253 extern XDR_DT
str_to_dt(xmlChar
const* str
, int len
/* calculated if -1 */) DECLSPEC_HIDDEN
;
254 extern XDR_DT
bstr_to_dt(OLECHAR
const* bstr
, int len
/* calculated if -1 */) DECLSPEC_HIDDEN
;
255 extern xmlChar
const* dt_to_str(XDR_DT dt
) DECLSPEC_HIDDEN
;
256 extern const char* debugstr_dt(XDR_DT dt
) DECLSPEC_HIDDEN
;
257 extern OLECHAR
const* dt_to_bstr(XDR_DT dt
) DECLSPEC_HIDDEN
;
258 extern HRESULT
dt_validate(XDR_DT dt
, xmlChar
const* content
) DECLSPEC_HIDDEN
;
260 extern BSTR
EnsureCorrectEOL(BSTR
) DECLSPEC_HIDDEN
;
262 extern xmlChar
* tagName_to_XPath(const BSTR tagName
) DECLSPEC_HIDDEN
;
264 extern HRESULT
dom_pi_put_xml_decl(IXMLDOMNode
*node
, BSTR data
) DECLSPEC_HIDDEN
;
266 #include <libxslt/documents.h>
267 extern xmlDocPtr
xslt_doc_default_loader(const xmlChar
*uri
, xmlDictPtr dict
, int options
,
268 void *_ctxt
, xsltLoadType type
) DECLSPEC_HIDDEN
;
270 static inline BSTR
bstr_from_xmlChar(const xmlChar
*str
)
275 DWORD len
= MultiByteToWideChar(CP_UTF8
, 0, (LPCSTR
)str
, -1, NULL
, 0);
276 ret
= SysAllocStringLen(NULL
, len
-1);
278 MultiByteToWideChar( CP_UTF8
, 0, (LPCSTR
)str
, -1, ret
, len
);
281 ret
= SysAllocStringLen(NULL
, 0);
286 static inline xmlChar
*xmlchar_from_wcharn(const WCHAR
*str
, int nchars
, BOOL use_xml_alloc
)
289 DWORD len
= WideCharToMultiByte( CP_UTF8
, 0, str
, nchars
, NULL
, 0, NULL
, NULL
);
291 xmlstr
= use_xml_alloc
? xmlMalloc( len
+ 1 ) : heap_alloc( len
+ 1 );
294 WideCharToMultiByte( CP_UTF8
, 0, str
, nchars
, (LPSTR
) xmlstr
, len
+1, NULL
, NULL
);
300 static inline xmlChar
*xmlchar_from_wchar( const WCHAR
*str
)
302 return xmlchar_from_wcharn(str
, -1, FALSE
);
305 static inline xmlChar
*heap_strdupxmlChar(const xmlChar
*str
)
312 size
= (xmlStrlen(str
)+1)*sizeof(xmlChar
);
313 ret
= heap_alloc(size
);
314 memcpy(ret
, str
, size
);
320 static inline HRESULT
return_null_node(IXMLDOMNode
**p
)
328 static inline HRESULT
return_null_ptr(void **p
)
336 static inline HRESULT
return_null_var(VARIANT
*p
)
345 static inline HRESULT
return_null_bstr(BSTR
*p
)
354 static inline HRESULT
return_var_false(VARIANT_BOOL
*p
)
363 extern IXMLDOMParseError
*create_parseError( LONG code
, BSTR url
, BSTR reason
, BSTR srcText
,
364 LONG line
, LONG linepos
, LONG filepos
) DECLSPEC_HIDDEN
;
365 extern HRESULT
SchemaCache_create(MSXML_VERSION
, void**) DECLSPEC_HIDDEN
;
366 extern HRESULT
XMLDocument_create(void**) DECLSPEC_HIDDEN
;
367 extern HRESULT
SAXXMLReader_create(MSXML_VERSION
, void**) DECLSPEC_HIDDEN
;
368 extern HRESULT
SAXAttributes_create(MSXML_VERSION
, void**) DECLSPEC_HIDDEN
;
369 extern HRESULT
XMLHTTPRequest_create(void **) DECLSPEC_HIDDEN
;
370 extern HRESULT
ServerXMLHTTP_create(void **) DECLSPEC_HIDDEN
;
371 extern HRESULT
XSLTemplate_create(void**) DECLSPEC_HIDDEN
;
372 extern HRESULT
MXWriter_create(MSXML_VERSION
, void**) DECLSPEC_HIDDEN
;
373 extern HRESULT
MXNamespaceManager_create(void**) DECLSPEC_HIDDEN
;
374 extern HRESULT
XMLParser_create(void**) DECLSPEC_HIDDEN
;
375 extern HRESULT
XMLView_create(void**) DECLSPEC_HIDDEN
;
377 /* Error Codes - not defined anywhere in the public headers */
378 #define E_XML_ELEMENT_UNDECLARED 0xC00CE00D
379 #define E_XML_ELEMENT_ID_NOT_FOUND 0xC00CE00E
381 #define E_XML_EMPTY_NOT_ALLOWED 0xC00CE011
382 #define E_XML_ELEMENT_NOT_COMPLETE 0xC00CE012
383 #define E_XML_ROOT_NAME_MISMATCH 0xC00CE013
384 #define E_XML_INVALID_CONTENT 0xC00CE014
385 #define E_XML_ATTRIBUTE_NOT_DEFINED 0xC00CE015
386 #define E_XML_ATTRIBUTE_FIXED 0xC00CE016
387 #define E_XML_ATTRIBUTE_VALUE 0xC00CE017
388 #define E_XML_ILLEGAL_TEXT 0xC00CE018
390 #define E_XML_REQUIRED_ATTRIBUTE_MISSING 0xC00CE020
392 #define NODE_PRIV_TRAILING_IGNORABLE_WS 0x40000000
393 #define NODE_PRIV_CHILD_IGNORABLE_WS 0x80000000
394 #define NODE_PRIV_REFCOUNT_MASK ~(NODE_PRIV_TRAILING_IGNORABLE_WS|NODE_PRIV_CHILD_IGNORABLE_WS)
395 #endif /* __MSXML_PRIVATE__ */