[xml] Is the handling of "fake node libxslt" element nodes in xpath.c still needed?



Hi,

Can somebody recall and clarify the nature of the
"fake node libxslt" in xpath.c?

Example from xmlXPathNextParent():

if ((ctxt->context->node->parent->type == XML_ELEMENT_NODE) &&
  ((ctxt->context->node->parent->name[0] == ' ') ||
   (xmlStrEqual(ctxt->context->node->parent->name,
    BAD_CAST "fake node libxslt"))))

Since this tests for an element node, I wonder if this usage is
obsolete, since, although in Libxslt a Result Tree Fragment (xmlDoc)
is always named " fake node libxslt" (in xsltCreateRVT(), but with a
space at first position), it is a document node; the XPath code
tests for an element node.
Such string comparisons are performed in the axis-iterator functions
for the parent and ancestor axes.

In XSieve I came across this code:

// Before running XSLT:
// 1) create temporary output document (~ "variables.c:500")
// 2) remember old data and set new common data
//
container = xsltCreateRVT(ctxt);
ASSERT_RET_UNSPEC(container, "xsltCreateRVT() failed");
fakeroot = xmlNewNode(NULL, " fake node libxslt");
ASSERT_RET_UNSPEC(fakeroot, "xmlNewNode failed");
xmlDocSetRootElement(container, fakeroot);

Since the comment indicates that this was copied from variables.c,
one could assume that the original Result Tree Fragments had
an extra dummy document element in the past.

There's also a TODO in xpath.c:

/*
* TODO: when compatibility allows remove all "fake node libxslt" strings
*       the test should just be name[0] = ' '
*/

Does someone know if we can safely remove the test for
"fake node libxslt" and only leave the name[0] = ' ' test?
Traversing the affected axes without the need for a string comparison
would be more efficient.

Regards,

Kasimier






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