int nbsorts = 0;
xmlNodePtr sorts[XSLT_MAX_SORT];
xmlDocPtr oldXDocPtr;
- xsltDocumentPtr oldCDocPtr, newDocPtr = NULL;
- xmlNodePtr newDocPtrPtr = NULL;
+ xsltDocumentPtr oldCDocPtr;
int oldNsNr;
xmlNsPtr *oldNamespaces;
In order to take care of potential keys we need to
do some extra work in the case of an RVT converted
into a nodeset (e.g. exslt:node-set())
+ We create a "pseudo-doc" (if not already created) and
+ store it's pointer into _private. This doc, together
+ with the keyset, will be freed when the RVT is freed.
*/
if ((list != NULL) && (ctxt->document->keys != NULL)) {
if ((list->nodeNr != 0) &&
(list->nodeTab[0]->doc != NULL) &&
(xmlStrEqual((xmlChar *)list->nodeTab[0]->doc->name,
(const xmlChar *) " fake node libxslt")) &&
- (list->nodeTab[0]->doc->psvi == NULL)) {
- newDocPtr = xsltNewDocument(ctxt,
- list->nodeTab[0]->doc);
- if (newDocPtr == NULL) {
+ (list->nodeTab[0]->doc->_private == NULL)) {
+ list->nodeTab[0]->doc->_private = xsltNewDocument(
+ ctxt, list->nodeTab[0]->doc);
+ if (list->nodeTab[0]->doc->_private == NULL) {
xsltTransformError(ctxt, NULL, inst,
"xsltApplyTemplates : failed to allocate subdoc\n");
}
- if (list->nodeTab[0]->type == XML_ELEMENT_NODE) {
- list->nodeTab[0]->psvi = (xmlNodePtr)newDocPtr;
- } else
- if ((list->nodeTab[0]->type == XML_ELEMENT_NODE) ||
- (list->nodeTab[0]->type == XML_DOCUMENT_NODE)) {
- list->nodeTab[0]->psvi = (xmlNodePtr)newDocPtr;
- newDocPtrPtr = list->nodeTab[0];
- }
- ctxt->document = newDocPtr;
+
+ ctxt->document = list->nodeTab[0]->doc->_private;
}
+
}
} else {
list = NULL;
error:
if (params != NULL)
xsltFreeStackElemList(params); /* free the parameter list */
- if (list != NULL) {
- /*
- If we created a "pseudo-document" we must free it now
- */
- if (newDocPtr != NULL) {
- newDocPtr->doc->parent = NULL;
- xsltFreeDocumentKeys(newDocPtr);
- xmlFree(newDocPtr);
- if (newDocPtrPtr != NULL)
- newDocPtrPtr->psvi = NULL;
- }
+ if (list != NULL)
xmlXPathFreeNodeSet(list);
- }
/*
* res must be deallocated after list
*/
--- /dev/null
+<?xml version="1.0"?>
+
+<xsl:transform
+ version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:exsl="http://exslt.org/common"
+ extension-element-prefixes="exsl">
+
+ <xsl:template match="@*|node()" mode="copy">
+ <xsl:copy>
+ <xsl:apply-templates select="@*|node()" mode="copy"/>
+ </xsl:copy>
+ </xsl:template>
+
+ <xsl:template match="/">
+ <xsl:variable name="v">
+ <xsl:apply-templates mode="copy"/>
+ </xsl:variable>
+ <xsl:apply-templates select="exsl:node-set($v)" mode="copy"/>
+<!-- replacing the above line with the following one increases speed -->
+<!-- <xsl:apply-templates select="." mode="copy"/> -->
+ </xsl:template>
+
+<!-- removing the following line increases the speed -->
+ <xsl:key name="tree-by-subject_id" match="tree" use="@subject_id"/>
+
+</xsl:transform>
+
+
+