if ((xsltTopLevelsHash == NULL) || (name == NULL) || (URI == NULL))
return(NULL);
- return xmlHashLookup2(xsltTopLevelsHash, name, URI);
+ return((xsltPreComputeFunction)
+ xmlHashLookup2(xsltTopLevelsHash, name, URI));
}
/**
* function libxslt:test() for testing the extensions support.
*/
static void
-xsltExtFunctionTest(xmlXPathParserContextPtr ctxt, int nargs)
+xsltExtFunctionTest(xmlXPathParserContextPtr ctxt, int nargs ATTRIBUTE_UNUSED)
{
xsltTransformContextPtr tctxt;
- void *data;
+ void *data = NULL;
tctxt = xsltXPathGetTransformContext(ctxt);
* Returns a pointer to the module specific data for this transformation
*/
static void *
-xsltExtStyleInitTest(xsltStylesheetPtr style, const xmlChar * URI)
+xsltExtStyleInitTest(xsltStylesheetPtr style ATTRIBUTE_UNUSED,
+ const xmlChar * URI)
{
if (testStyleData != NULL) {
xsltPrintErrorContext(NULL, NULL, NULL);
* A function called at shutdown time of an XSLT extension module
*/
static void
-xsltExtStyleShutdownTest(xsltStylesheetPtr style,
+xsltExtStyleShutdownTest(xsltStylesheetPtr style ATTRIBUTE_UNUSED,
const xmlChar * URI, void *data) {
if (testStyleData == NULL) {
xsltGenericError(xsltGenericErrorContext,
*
* Returns the newly allocated xsltTransformContextPtr or NULL in case of error
*/
-static xsltTransformContextPtr
+xsltTransformContextPtr
xsltNewTransformContext(xsltStylesheetPtr style, xmlDocPtr doc) {
xsltTransformContextPtr cur;
xsltDocumentPtr docu;
*
* Free up the memory allocated by @ctxt
*/
-static void
+void
xsltFreeTransformContext(xsltTransformContextPtr ctxt) {
if (ctxt == NULL)
return;
* @params: a NULL terminated arry of parameters names/values tuples
* @output: the targetted output
* @profile: profile FILE * output or NULL
+ * @user: user provided parameter
*
* Apply the stylesheet to the document
* NOTE: This may lead to a non-wellformed output XML wise !
static xmlDocPtr
xsltApplyStylesheetInternal(xsltStylesheetPtr style, xmlDocPtr doc,
const char **params, const char *output,
- FILE * profile)
+ FILE * profile, xsltTransformContextPtr userCtxt)
{
xmlDocPtr res = NULL;
xsltTransformContextPtr ctxt = NULL;
if ((style == NULL) || (doc == NULL))
return (NULL);
- ctxt = xsltNewTransformContext(style, doc);
+
+ if (userCtxt != NULL)
+ ctxt = userCtxt;
+ else
+ ctxt = xsltNewTransformContext(style, doc);
+
if (ctxt == NULL)
return (NULL);
if (profile != NULL) {
xsltSaveProfiling(ctxt, profile);
}
- xsltFreeTransformContext(ctxt);
+ if (userCtxt == NULL)
+ xsltFreeTransformContext(ctxt);
+
return (res);
error:
xsltApplyStylesheet(xsltStylesheetPtr style, xmlDocPtr doc,
const char **params)
{
- return (xsltApplyStylesheetInternal(style, doc, params, NULL, NULL));
+ return (xsltApplyStylesheetInternal(style, doc, params, NULL, NULL, NULL));
}
/**
{
xmlDocPtr res;
- res = xsltApplyStylesheetInternal(style, doc, params, NULL, output);
+ res = xsltApplyStylesheetInternal(style, doc, params, NULL, output, NULL);
+ return (res);
+}
+
+/**
+ * xsltApplyStylesheetUser:
+ * @style: a parsed XSLT stylesheet
+ * @doc: a parsed XML document
+ * @params: a NULL terminated arry of parameters names/values tuples
+ * @output: the targetted output
+ * @profile: profile FILE * output or NULL
+ * @userCtxt: user provided transform context
+ *
+ * Apply the stylesheet to the document and allow the user to provide
+ * its own transformation context.
+ *
+ * Returns the result document or NULL in case of error
+ */
+xmlDocPtr
+xsltApplyStylesheetUser(xsltStylesheetPtr style, xmlDocPtr doc,
+ const char **params, const char *output,
+ FILE * profile, xsltTransformContextPtr userCtxt)
+{
+ xmlDocPtr res;
+
+ res = xsltApplyStylesheetInternal(style, doc, params, output,
+ profile, userCtxt);
return (res);
}
return (-1);
}
- tmp = xsltApplyStylesheetInternal(style, doc, params, output, NULL);
+ tmp = xsltApplyStylesheetInternal(style, doc, params, output, NULL, NULL);
if (tmp == NULL) {
xsltPrintErrorContext(NULL, NULL, (xmlNodePtr) doc);
xsltGenericError(xsltGenericErrorContext,