Re: [xslt] extending xsltproc with plugins
- From: Tony Graham <Tony Graham MenteithConsulting com>
- To: xslt gnome org
- Subject: Re: [xslt] extending xsltproc with plugins
- Date: Tue, 15 Jan 2008 13:04:48 +0000
On Tue, Jan 15 2008 11:24:14 +0000, gr active-media-group com wrote:
> First of all, thanks for your help Tony
Not a problem.
> 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.
Declaring the function looks okay to me, though I'm not so sure about
the internals of the function.
Have you tried a version of getDataDetailValue() that just does the same
as xsltExtFunctionTest (though maybe with popping more function
arguments)?
> 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);
If you want the string value, you can use xmlXPathPopString() [1]
> msg = concat(msg, ",");
> msg = concat(msg, (char*) obj);
> xmlXPathFreeObject(obj);
> }
>
> concat(msg,"\n");
Previously you used the return value of this function.
> parameters[0] = msg;
>
> char* result = sendDataBySocket(parameters);
>
> valuePush(ctxt, xmlXPathNewString(result));
Don't you need to free one or more of the versions of msg?
> }
>
> 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);
> }
Regards,
Tony Graham.
======================================================================
Tony Graham MenteithConsulting com http://www.menteithconsulting.com
Menteith Consulting Ltd Registered in Ireland - No. 428599
Registered Office: 13 Kelly's Bay Beach, Skerries, Co. Dublin, Ireland
----------------------------------------------------------------------
Menteith Consulting -- Understanding how markup works
======================================================================
[1] http://xmlsoft.org/html/libxml-xpathInternals.html#xmlXPathPopString
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]