RE: [xslt] Result Tree Fragments



Perhaps an answer to my own question:

Daniel, can you verify that the attached patch for str:tokenize() is the
correct method for returning Result Tree Fragments from extension functions.

This also fixes what appeared to be a memory leak in that 'str' and
'delimiters' were never freed if the operation was successful.

I've also attached the patch to the bug.


-----Original Message-----
From: Vakoc, Mark 
Sent: Tuesday, April 08, 2003 1:50 PM
To: xslt@gnome.org
Subject: [xslt] Result Tree Fragments



Hi Daniel, all,

I'm trying to debug the bug I entered:
http://bugzilla.gnome.org/show_bug.cgi?id=110023

It appears that you have changed the method for managing result tree
fragments.  It appears that any extension functions that return a result
tree fragment need to be modified, including str:tokenize() and such.

Before the container node for the result tree fragment (rtf) nodes was a
child of the source document so the nodes would get free'd when the document
is free'd.  Under the new system when would the nodes contained in the RTF
ever get freed?  Do I need to modify all my extension functions that return
a RTF to use this new method?  If so str:tokenize and any other extensions
that return a RTF need to be modified as well?

	} else {
	    /*
	     * This is a result tree fragment.
	     */
	    xmlDocPtr container;
	    xmlNodePtr oldInsert;
	    xmlDocPtr  oldoutput;

	    container = xmlNewDoc(NULL);
	    if (container == NULL)
		return(NULL);
	    container->name = (char *) xmlStrdup(BAD_CAST " fake node
libxslt");
	    container->doc = container;
	    container->parent = NULL;

	    oldoutput = ctxt->output;
	    ctxt->output = container;
	    oldInsert = ctxt->insert;
	    ctxt->insert = (xmlNodePtr) container;
	    xsltApplyOneTemplate(ctxt, ctxt->node, elem->tree, NULL, NULL);
	    ctxt->insert = oldInsert;
	    ctxt->output = oldoutput;

	    result = xmlXPathNewValueTree((xmlNodePtr) container);
	    if (result == NULL) {
		result = xmlXPathNewCString("");
	    } else {
		/*
		 * Tag the subtree for removal once consumed
		 */
		result->boolval = 1;
	    }
#ifdef WITH_XSLT_DEBUG_VARIABLE
#ifdef LIBXML_DEBUG_ENABLED
	    if ((xsltGenericDebugContext == stdout) ||
		(xsltGenericDebugContext == stderr))
		xmlXPathDebugDumpObject((FILE *)xsltGenericDebugContext,
					result, 0);
#endif
#endif
	}
_______________________________________________
xslt mailing list, project page http://xmlsoft.org/XSLT/
xslt@gnome.org
http://mail.gnome.org/mailman/listinfo/xslt

strings.diff



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