Re: [xslt] extending xsltproc with plugins



First of all, thanks for your help Tony

I can compile and run test, with the supplied testplugin.c there's not 
problem, but when I tryed to add a function to the file i run in this error:

command:
LIBXSLT_PLUGINS_PATH=/home/gr/Plugins < "./plugin.xml" xsltproc "./plugin.xsl" 
- > result.xml

error:
xmlXPathCompOpEval: function DataDetailValue not found
XPath error : Unregistered function
runtime error: file ./plugin.xsl line 11 element value-of
XPath evaluation returned no result.

where in LIBXSLT_PLUGINS_PATH is the xmlsoft_org_xslt_testplugin.so library.

Here is the cose I added:

static void getDataDetailValue(xmlXPathParserContextPtr ctxt, int nargs){
	
	char* parameters[6] = {"novalue\n", "novalue\n", "novalue\n", 
			"novalue\n", "novalue\n", "novalue\n"};
	char* msg = ",DataDetailValue";
	
	int var;
	for (var = 0; var < nargs; ++var) {
		xmlXPathObjectPtr obj = valuePop(ctxt);
		msg = concat(msg, ",");
		msg = concat(msg, (char*) obj);
		xmlXPathFreeObject(obj);
	}
	
	concat(msg,"\n");
	
	parameters[0] = msg;
	
	char* result = sendDataBySocket(parameters);
	
	valuePush(ctxt, xmlXPathNewString(result));
}

and this is the registration of the function:

void
PLUGINPUBFUN xmlsoft_org_xslt_testplugin_init(void)
{
    xsltRegisterExtModuleFull((const xmlChar *) XSLT_TESTPLUGIN_URL,
                              xsltExtInitTest, xsltExtShutdownTest,
                              xsltExtStyleInitTest,
                              xsltExtStyleShutdownTest);
    xsltRegisterExtModuleFunction((const xmlChar *) "testplugin",
                                  (const xmlChar *) XSLT_TESTPLUGIN_URL,
                                  xsltExtFunctionTest);
    xsltRegisterExtModuleFunction((const xmlChar *) "DataDetailValue",
                                  (const xmlChar *) XSLT_TESTPLUGIN_URL,
                                  getDataDetailValue);
    xsltRegisterExtModuleElement((const xmlChar *) "testplugin",
                                 (const xmlChar *) XSLT_TESTPLUGIN_URL,
                                 xsltExtElementPreCompTest,
                                 xsltExtElementTest);
}

I can't understand why this is not working.
Thanks for helping me

best regards

Giulio




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]