msxml3: libxml2 error/warning callback functions.
This commit is contained in:
parent
62f9966fdc
commit
fec2199f4f
|
@ -356,6 +356,27 @@ static void sax_characters(void *ctx, const xmlChar *ch, int len)
|
|||
xmlSAX2Characters(ctx, ch, len);
|
||||
}
|
||||
|
||||
static void LIBXML2_LOG_CALLBACK sax_error(void* ctx, char const* msg, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, msg);
|
||||
LIBXML2_CALLBACK_ERR(doparse, msg, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
static void LIBXML2_LOG_CALLBACK sax_warning(void* ctx, char const* msg, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, msg);
|
||||
LIBXML2_CALLBACK_WARN(doparse, msg, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
static void sax_serror(void* ctx, xmlErrorPtr err)
|
||||
{
|
||||
LIBXML2_CALLBACK_SERROR(doparse, err);
|
||||
}
|
||||
|
||||
static xmlDocPtr doparse(domdoc* This, char *ptr, int len, xmlChar const* encoding)
|
||||
{
|
||||
xmlDocPtr doc = NULL;
|
||||
|
@ -382,9 +403,9 @@ static xmlDocPtr doparse(domdoc* This, char *ptr, int len, xmlChar const* encodi
|
|||
sax_characters, /* ignorableWhitespace */
|
||||
xmlSAX2ProcessingInstruction, /* processingInstruction */
|
||||
xmlSAX2Comment, /* comment */
|
||||
NULL, /* TODO: warning */
|
||||
NULL, /* TODO: error */
|
||||
NULL, /* TODO: fatalError */
|
||||
sax_warning, /* warning */
|
||||
sax_error, /* error */
|
||||
sax_error, /* fatalError */
|
||||
xmlSAX2GetParameterEntity, /* getParameterEntity */
|
||||
xmlSAX2CDataBlock, /* cdataBlock */
|
||||
xmlSAX2ExternalSubset, /* externalSubset */
|
||||
|
@ -392,7 +413,7 @@ static xmlDocPtr doparse(domdoc* This, char *ptr, int len, xmlChar const* encodi
|
|||
NULL, /* _private */
|
||||
xmlSAX2StartElementNs, /* startElementNs */
|
||||
xmlSAX2EndElementNs, /* endElementNs */
|
||||
NULL /* TODO: serror */
|
||||
sax_serror /* serror */
|
||||
};
|
||||
xmlInitParser();
|
||||
|
||||
|
@ -403,9 +424,9 @@ static xmlDocPtr doparse(domdoc* This, char *ptr, int len, xmlChar const* encodi
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (pctx->sax) xmlFree(pctx->sax);
|
||||
if (pctx->sax) xmlFree(pctx->sax);
|
||||
pctx->sax = &sax_handler;
|
||||
pctx->_private = This;
|
||||
pctx->_private = This;
|
||||
pctx->recovery = 0;
|
||||
pctx->encoding = xmlStrdup(encoding);
|
||||
xmlParseDocument(pctx);
|
||||
|
@ -2417,6 +2438,22 @@ static HRESULT WINAPI domdoc_putref_schemas(
|
|||
return hr;
|
||||
}
|
||||
|
||||
static void LIBXML2_LOG_CALLBACK validate_error(void* ctx, char const* msg, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, msg);
|
||||
LIBXML2_CALLBACK_ERR(domdoc_validate, msg, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
static void LIBXML2_LOG_CALLBACK validate_warning(void* ctx, char const* msg, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, msg);
|
||||
LIBXML2_CALLBACK_WARN(domdoc_validate, msg, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI domdoc_validate(
|
||||
IXMLDOMDocument3* iface,
|
||||
IXMLDOMParseError** err)
|
||||
|
@ -2435,8 +2472,8 @@ static HRESULT WINAPI domdoc_validate(
|
|||
}
|
||||
|
||||
vctx = xmlNewValidCtxt();
|
||||
vctx->error = NULL; /* TODO: error callback */
|
||||
vctx->warning = NULL; /* TODO: warning callback */
|
||||
vctx->error = validate_error;
|
||||
vctx->warning = validate_warning;
|
||||
|
||||
if (xmlValidateDocument(vctx, get_doc(This)))
|
||||
{
|
||||
|
|
|
@ -42,6 +42,48 @@ WINE_DEFAULT_DEBUG_CHANNEL(msxml);
|
|||
|
||||
#ifdef HAVE_LIBXML2
|
||||
|
||||
void wineXmlCallbackLog(char const* caller, xmlErrorLevel lvl, char const* msg, va_list ap)
|
||||
{
|
||||
char* buf = NULL;
|
||||
int len = 32, needed;
|
||||
enum __wine_debug_class dbcl = __WINE_DBCL_ERR;
|
||||
switch (lvl)
|
||||
{
|
||||
case XML_ERR_NONE:
|
||||
dbcl = __WINE_DBCL_TRACE;
|
||||
break;
|
||||
case XML_ERR_WARNING:
|
||||
dbcl = __WINE_DBCL_WARN;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (ap)
|
||||
{
|
||||
do
|
||||
{
|
||||
heap_free(buf);
|
||||
buf = heap_alloc(len);
|
||||
needed = vsnprintf(buf, len, msg, ap);
|
||||
if (needed == -1)
|
||||
len *= 2;
|
||||
else if (needed >= len)
|
||||
len = needed + 1;
|
||||
else
|
||||
needed = 0;
|
||||
}
|
||||
while (needed);
|
||||
|
||||
wine_dbg_log(dbcl, &__wine_dbch_msxml, caller, buf);
|
||||
heap_free(buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
wine_dbg_log(dbcl, &__wine_dbch_msxml, caller, msg);
|
||||
}
|
||||
}
|
||||
|
||||
/* Support for loading xml files from a Wine Windows drive */
|
||||
static int wineXmlMatchCallback (char const * filename)
|
||||
{
|
||||
|
@ -115,7 +157,7 @@ DECL_FUNCPTR(xsltApplyStylesheet);
|
|||
DECL_FUNCPTR(xsltCleanupGlobals);
|
||||
DECL_FUNCPTR(xsltFreeStylesheet);
|
||||
DECL_FUNCPTR(xsltParseStylesheetDoc);
|
||||
# undef MAKE_FUNCPTR
|
||||
# undef DECL_FUNCPTR
|
||||
#endif
|
||||
|
||||
static void init_libxslt(void)
|
||||
|
|
|
@ -106,6 +106,8 @@ BOOL dispex_query_interface(DispatchEx*,REFIID,void**);
|
|||
#include <libxml/parser.h>
|
||||
#endif
|
||||
|
||||
#include <libxml/xmlerror.h>
|
||||
|
||||
/* constructors */
|
||||
extern IUnknown *create_domdoc( xmlNodePtr document );
|
||||
extern IUnknown *create_xmldoc( void );
|
||||
|
@ -140,6 +142,21 @@ extern xmlNodePtr xmldoc_unlink_xmldecl(xmlDocPtr doc);
|
|||
|
||||
extern HRESULT XMLElement_create( IUnknown *pUnkOuter, xmlNodePtr node, LPVOID *ppObj, BOOL own );
|
||||
|
||||
extern void wineXmlCallbackLog(char const* caller, xmlErrorLevel lvl, char const* msg, va_list ap);
|
||||
|
||||
#define LIBXML2_LOG_CALLBACK __WINE_PRINTF_ATTR(2,3)
|
||||
|
||||
#define LIBXML2_CALLBACK_TRACE(caller, msg, ap) \
|
||||
wineXmlCallbackLog(#caller, XML_ERR_NONE, msg, ap)
|
||||
|
||||
#define LIBXML2_CALLBACK_WARN(caller, msg, ap) \
|
||||
wineXmlCallbackLog(#caller, XML_ERR_WARNING, msg, ap)
|
||||
|
||||
#define LIBXML2_CALLBACK_ERR(caller, msg, ap) \
|
||||
wineXmlCallbackLog(#caller, XML_ERR_ERROR, msg, ap)
|
||||
|
||||
#define LIBXML2_CALLBACK_SERROR(caller, err) \
|
||||
wineXmlCallbackLog(#caller, err->level, err->message, NULL)
|
||||
|
||||
/* IXMLDOMNode Internal Structure */
|
||||
typedef struct _xmlnode
|
||||
|
|
|
@ -491,6 +491,11 @@ void XSLPattern_OP_IGEq(xmlXPathParserContextPtr pctx, int nargs)
|
|||
xmlFree(arg2);
|
||||
}
|
||||
|
||||
static void query_serror(void* ctx, xmlErrorPtr err)
|
||||
{
|
||||
LIBXML2_CALLBACK_SERROR(queryresult_create, err);
|
||||
}
|
||||
|
||||
HRESULT queryresult_create(xmlNodePtr node, LPCWSTR szQuery, IXMLDOMNodeList **out)
|
||||
{
|
||||
queryresult *This = heap_alloc_zero(sizeof(queryresult));
|
||||
|
@ -513,6 +518,7 @@ HRESULT queryresult_create(xmlNodePtr node, LPCWSTR szQuery, IXMLDOMNodeList **o
|
|||
This->node = node;
|
||||
xmldoc_add_ref(This->node->doc);
|
||||
|
||||
ctxt->error = query_serror;
|
||||
ctxt->node = node;
|
||||
registerNamespaces(ctxt);
|
||||
|
||||
|
@ -545,7 +551,7 @@ HRESULT queryresult_create(xmlNodePtr node, LPCWSTR szQuery, IXMLDOMNodeList **o
|
|||
xmlXPathRegisterFunc(ctxt, (xmlChar const*)"OP_IGEq", XSLPattern_OP_IGEq);
|
||||
}
|
||||
|
||||
This->result = xmlXPathEval(str, ctxt);
|
||||
This->result = xmlXPathEvalExpression(str, ctxt);
|
||||
if (!This->result || This->result->type != XPATH_NODESET)
|
||||
{
|
||||
hr = E_FAIL;
|
||||
|
|
Loading…
Reference in New Issue