Commit ff847e8c authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

msxml3: Pass XSL processor parameters to libxml2.

parent 9ca4f9b6
......@@ -38,7 +38,6 @@
#include "shlwapi.h"
#include "wine/debug.h"
#include "wine/list.h"
#include "wine/unicode.h"
#include "msxml_private.h"
......
......@@ -49,7 +49,6 @@
#include "objsafe.h"
#include "wine/debug.h"
#include "wine/list.h"
#include "msxml_private.h"
......
......@@ -47,7 +47,6 @@
#include "msxml_private.h"
#include "wine/debug.h"
#include "wine/list.h"
WINE_DEFAULT_DEBUG_CHANNEL(msxml);
......
......@@ -36,6 +36,7 @@
# include <libxslt/transform.h>
# endif
# include <libxslt/xsltutils.h>
# include <libxslt/variables.h>
# include <libxslt/xsltInternals.h>
# endif
#endif
......@@ -165,9 +166,13 @@ void* libxslt_handle = NULL;
#ifdef SONAME_LIBXSLT
# define DECL_FUNCPTR(f) typeof(f) * p##f = NULL
DECL_FUNCPTR(xsltApplyStylesheet);
DECL_FUNCPTR(xsltApplyStylesheetUser);
DECL_FUNCPTR(xsltCleanupGlobals);
DECL_FUNCPTR(xsltFreeStylesheet);
DECL_FUNCPTR(xsltFreeTransformContext);
DECL_FUNCPTR(xsltNewTransformContext);
DECL_FUNCPTR(xsltParseStylesheetDoc);
DECL_FUNCPTR(xsltQuoteUserParams);
# undef DECL_FUNCPTR
#endif
......@@ -185,9 +190,13 @@ static void init_libxslt(void)
if (needed) { WARN("Can't find symbol %s\n", #f); goto sym_not_found; }
LOAD_FUNCPTR(xsltInit, 0);
LOAD_FUNCPTR(xsltApplyStylesheet, 1);
LOAD_FUNCPTR(xsltApplyStylesheetUser, 1);
LOAD_FUNCPTR(xsltCleanupGlobals, 1);
LOAD_FUNCPTR(xsltFreeStylesheet, 1);
LOAD_FUNCPTR(xsltFreeTransformContext, 1);
LOAD_FUNCPTR(xsltNewTransformContext, 1);
LOAD_FUNCPTR(xsltParseStylesheetDoc, 1);
LOAD_FUNCPTR(xsltQuoteUserParams, 1);
#undef LOAD_FUNCPTR
if (pxsltInit)
......
......@@ -24,6 +24,7 @@
#include "dispex.h"
#include "wine/unicode.h"
#include "wine/list.h"
#ifndef __WINE_CONFIG_H
# error You must include config.h to use this header
......@@ -217,6 +218,20 @@ static inline LPSTR heap_strdupWtoA(LPCWSTR str)
return ret;
}
/* XSLProcessor parameter list */
struct xslprocessor_par
{
struct list entry;
BSTR name;
BSTR value;
};
struct xslprocessor_params
{
struct list list;
unsigned int count;
};
#ifdef HAVE_LIBXML2
extern void schemasInit(void) DECLSPEC_HIDDEN;
......@@ -354,6 +369,7 @@ extern HRESULT node_get_text(const xmlnode*,BSTR*) DECLSPEC_HIDDEN;
extern HRESULT node_select_nodes(const xmlnode*,BSTR,IXMLDOMNodeList**) DECLSPEC_HIDDEN;
extern HRESULT node_select_singlenode(const xmlnode*,BSTR,IXMLDOMNode**) DECLSPEC_HIDDEN;
extern HRESULT node_transform_node(const xmlnode*,IXMLDOMNode*,BSTR*) DECLSPEC_HIDDEN;
extern HRESULT node_transform_node_params(const xmlnode*,IXMLDOMNode*,BSTR*,const struct xslprocessor_params*) DECLSPEC_HIDDEN;
extern HRESULT node_create_supporterrorinfo(const tid_t*,void**) DECLSPEC_HIDDEN;
extern HRESULT get_domdoc_from_xmldoc(xmlDocPtr xmldoc, IXMLDOMDocument3 **document) DECLSPEC_HIDDEN;
......
......@@ -39,7 +39,6 @@
#include "msxml_private.h"
#include "wine/debug.h"
#include "wine/list.h"
WINE_DEFAULT_DEBUG_CHANNEL(msxml);
......
......@@ -35,6 +35,7 @@
# ifdef HAVE_LIBXSLT_TRANSFORM_H
# include <libxslt/transform.h>
# endif
# include <libxslt/variables.h>
# include <libxslt/xsltutils.h>
# include <libxslt/xsltInternals.h>
# endif
......@@ -59,9 +60,13 @@ WINE_DEFAULT_DEBUG_CHANNEL(msxml);
extern void* libxslt_handle;
# define MAKE_FUNCPTR(f) extern typeof(f) * p##f
MAKE_FUNCPTR(xsltApplyStylesheet);
MAKE_FUNCPTR(xsltApplyStylesheetUser);
MAKE_FUNCPTR(xsltCleanupGlobals);
MAKE_FUNCPTR(xsltFreeStylesheet);
MAKE_FUNCPTR(xsltFreeTransformContext);
MAKE_FUNCPTR(xsltNewTransformContext);
MAKE_FUNCPTR(xsltParseStylesheetDoc);
MAKE_FUNCPTR(xsltQuoteUserParams);
# undef MAKE_FUNCPTR
#endif
......@@ -996,7 +1001,8 @@ static const xmlChar *get_output_buffer_content(xmlOutputBufferPtr output)
#endif
}
HRESULT node_transform_node(const xmlnode *This, IXMLDOMNode *stylesheet, BSTR *p)
HRESULT node_transform_node_params(const xmlnode *This, IXMLDOMNode *stylesheet, BSTR *p,
const struct xslprocessor_params *params)
{
#ifdef SONAME_LIBXSLT
xsltStylesheetPtr xsltSS;
......@@ -1013,7 +1019,41 @@ HRESULT node_transform_node(const xmlnode *This, IXMLDOMNode *stylesheet, BSTR *
xsltSS = pxsltParseStylesheetDoc(sheet->node->doc);
if(xsltSS)
{
xmlDocPtr result = pxsltApplyStylesheet(xsltSS, This->node->doc, NULL);
const char **xslparams = NULL;
xmlDocPtr result;
unsigned int i;
/* convert our parameter list to libxml2 format */
if (params && params->count)
{
struct xslprocessor_par *par;
i = 0;
xslparams = heap_alloc((params->count*2 + 1)*sizeof(char*));
LIST_FOR_EACH_ENTRY(par, &params->list, struct xslprocessor_par, entry)
{
xslparams[i++] = (char*)xmlchar_from_wchar(par->name);
xslparams[i++] = (char*)xmlchar_from_wchar(par->value);
}
xslparams[i] = NULL;
}
if (xslparams)
{
xsltTransformContextPtr ctxt = pxsltNewTransformContext(xsltSS, This->node->doc);
/* push parameters to user context */
pxsltQuoteUserParams(ctxt, xslparams);
result = pxsltApplyStylesheetUser(xsltSS, This->node->doc, NULL, NULL, NULL, ctxt);
pxsltFreeTransformContext(ctxt);
for (i = 0; i < params->count*2; i++)
heap_free((char*)xslparams[i]);
heap_free(xslparams);
}
else
result = pxsltApplyStylesheet(xsltSS, This->node->doc, NULL);
if(result)
{
const xmlChar *content;
......@@ -1060,6 +1100,11 @@ HRESULT node_transform_node(const xmlnode *This, IXMLDOMNode *stylesheet, BSTR *
#endif
}
HRESULT node_transform_node(const xmlnode *node, IXMLDOMNode *stylesheet, BSTR *p)
{
return node_transform_node_params(node, stylesheet, p, NULL);
}
HRESULT node_select_nodes(const xmlnode *This, BSTR query, IXMLDOMNodeList **nodes)
{
xmlChar* str;
......
......@@ -42,7 +42,6 @@
#include "shlwapi.h"
#include "wine/debug.h"
#include "wine/list.h"
#include "msxml_private.h"
......
......@@ -37,7 +37,6 @@
#include "msxml_private.h"
#include "wine/debug.h"
#include "wine/list.h"
WINE_DEFAULT_DEBUG_CHANNEL(msxml);
......@@ -50,19 +49,6 @@ typedef struct
IXMLDOMNode *node;
} xsltemplate;
struct xslprocessor_par
{
struct list entry;
BSTR name;
BSTR value;
};
struct xslprocessor_params
{
struct list list;
unsigned int count;
};
typedef struct
{
DispatchEx dispex;
......@@ -534,6 +520,7 @@ static HRESULT WINAPI xslprocessor_transform(
IXSLProcessor *iface,
VARIANT_BOOL *ret)
{
#ifdef HAVE_LIBXML2
xslprocessor *This = impl_from_IXSLProcessor( iface );
HRESULT hr;
......@@ -542,7 +529,8 @@ static HRESULT WINAPI xslprocessor_transform(
if (!ret) return E_INVALIDARG;
SysFreeString(This->outstr);
hr = IXMLDOMNode_transformNode(This->input, This->stylesheet->node, &This->outstr);
hr = node_transform_node_params(get_node_obj(This->input), This->stylesheet->node, &This->outstr, &This->params);
if (hr == S_OK)
{
if (This->output)
......@@ -558,6 +546,10 @@ static HRESULT WINAPI xslprocessor_transform(
*ret = VARIANT_FALSE;
return hr;
#else
FIXME("libxml2 is required but wasn't present at compile time\n");
return E_NOTIMPL;
#endif
}
static HRESULT WINAPI xslprocessor_reset( IXSLProcessor *iface )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment