Re: [xslt] Extension Function Implementation



You have to create and register a "result value tree" by calling xsltCreateRVT and xsltRegisterLocalRVT, then add the nodes you want to return to that tree. Have a look at functions like exsltStrTokenizeFunction to see how it works:

    https://gitlab.gnome.org/GNOME/libxslt/-/blob/master/libexslt/strings.c

Hope that helps,
Nick


On 05/10/2021 12:30, Андрей Олешкевич via xslt wrote:
I am trying to create an xslt extension function for libxslt (c++). My extension function takes a string as input, then this string is parsed by xml parser, and the function returns this parsed xml. I return value by this expression:

void fnParse(xmlXPathParserContextPtr ctx, int nargs) { ... xmlXPathReturnNodeSet(ctx, xmlXPathNodeSetCreate(node)); }

But I have found that libxslt does not free node memory after use. It free xmlNodeSet, but not free the node which is stored in this nodeset. Perhaps I missed something important. What is the correct way to return an XML node in the extension function?


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