Extension Function Implementation

Андрей Олешкевич via xslt <[email protected]> Tue, 5 Oct 2021 13:30:00 +0300
Newsgroups gmane.comp.gnome.lib.xslt
Message-ID <CAF25rrKbEoqcfyGCq8dr+6dStC=d5J5cd5vEDfyZ6UUb3=DgWg@mail.gmail.com>
--===============2341731675467244582==
Content-Type: multipart/alternative; boundary="000000000000a74fd905cd98834f"

--000000000000a74fd905cd98834f
Content-Type: text/plain; charset="UTF-8"

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?

--000000000000a74fd905cd98834f
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><span style=3D"font-family:&quot;Source Sans Pro&quot;,Can=
tarell,&quot;Droid Sans&quot;,Ubuntu,&quot;DejaVu Sans&quot;,Arial,sans-ser=
if;font-size:15.008px">I am trying to create an xslt extension function for=
 libxslt (c++). My extension function takes a string as input, then this st=
ring is parsed by xml parser, and the function returns this parsed xml. I r=
eturn value by this expression:</span><br><div><span style=3D"font-family:C=
onsolas,Menlo,Monaco,&quot;Lucida Console&quot;,&quot;Liberation Mono&quot;=
,&quot;DejaVu Sans Mono&quot;,&quot;Bitstream Vera Sans Mono&quot;,&quot;Co=
urier New&quot;,monospace;font-size:15.008px;white-space:pre;background-col=
or:rgb(249,249,249)"><br></span></div><div><span style=3D"font-family:Conso=
las,Menlo,Monaco,&quot;Lucida Console&quot;,&quot;Liberation Mono&quot;,&qu=
ot;DejaVu Sans Mono&quot;,&quot;Bitstream Vera Sans Mono&quot;,&quot;Courie=
r New&quot;,monospace;font-size:15.008px;white-space:pre;background-color:r=
gb(249,249,249)">void fnParse(xmlXPathParserContextPtr ctx, int nargs)
{
    ...
    xmlXPathReturnNodeSet(ctx, xmlXPathNodeSetCreate(node));
}</span><span style=3D"font-family:&quot;Source Sans Pro&quot;,Cantarell,&q=
uot;Droid Sans&quot;,Ubuntu,&quot;DejaVu Sans&quot;,Arial,sans-serif;font-s=
ize:15.008px"><br></span></div><div><span style=3D"font-family:Consolas,Men=
lo,Monaco,&quot;Lucida Console&quot;,&quot;Liberation Mono&quot;,&quot;Deja=
Vu Sans Mono&quot;,&quot;Bitstream Vera Sans Mono&quot;,&quot;Courier New&q=
uot;,monospace;font-size:15.008px;white-space:pre;background-color:rgb(249,=
249,249)"><br></span></div><div><span style=3D"font-family:&quot;Source San=
s Pro&quot;,Cantarell,&quot;Droid Sans&quot;,Ubuntu,&quot;DejaVu Sans&quot;=
,Arial,sans-serif;font-size:15.008px">But I have found that libxslt does no=
t free node memory after use. It free xmlNodeSet, but not free the node whi=
ch is stored in this nodeset. Perhaps I missed something important. What is=
 the correct way to return an XML node in the extension function?</span>=C2=
=A0=C2=A0<span style=3D"font-family:Consolas,Menlo,Monaco,&quot;Lucida Cons=
ole&quot;,&quot;Liberation Mono&quot;,&quot;DejaVu Sans Mono&quot;,&quot;Bi=
tstream Vera Sans Mono&quot;,&quot;Courier New&quot;,monospace;font-size:15=
.008px;white-space:pre;background-color:rgb(249,249,249)"><br></span></div>=
</div>

--000000000000a74fd905cd98834f--

--===============2341731675467244582==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
xslt mailing list, project page http://xmlsoft.org/XSLT/
[email protected]
https://mail.gnome.org/mailman/listinfo/xslt

--===============2341731675467244582==--