dbertoni 2003/01/31 16:24:32
Modified: c/src/XSLT ElemApplyTemplates.cpp ElemApplyTemplates.hpp
ElemForEach.cpp ElemForEach.hpp
Log:
Don't push params and set up stack frame until after evaluating xsl:sort
children. Fixes Bugzilla 16654.
Revision Changes Path
1.31 +53 -0 xml-xalan/c/src/XSLT/ElemApplyTemplates.cpp
Index: ElemApplyTemplates.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemApplyTemplates.cpp,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- ElemApplyTemplates.cpp 8 Jan 2003 06:59:56 -0000 1.30
+++ ElemApplyTemplates.cpp 1 Feb 2003 00:24:31 -0000 1.31
@@ -170,6 +170,11 @@
executionContext, *this));
}
+#if 1
+ ParentType::transformSelectedChildren(
+ executionContext,
+ 0);
+#else
XalanNode* const sourceNode = executionContext.getCurrentNode();
assert(sourceNode != 0);
@@ -202,6 +207,54 @@
transformSelectedChildren(
executionContext,
0,
+ thePushPop.getStackFrameIndex());
+ }
+#endif
+}
+
+
+
+void
+ElemApplyTemplates::selectAndSortChildren(
+ StylesheetExecutionContext&
executionContext,
+ const ElemTemplateElement* theTemplate,
+ NodeSorter*
sorter,
+ int
/* selectStackFrameIndex */) const
+{
+ XalanNode* const sourceNode = executionContext.getCurrentNode();
+ assert(sourceNode != 0);
+
+ // Push the params & stack frame, but then execute the select
+ // expression inside transformSelectedChildren, which must be
+ // executed in the stack frame before the new stack frame.
+ StylesheetExecutionContext::ParamsPushPop thePushPop(
+ executionContext,
+ *this,
+ sourceNode,
+ this);
+
+ const XalanQName* const currentMode =
executionContext.getCurrentMode();
+ assert(currentMode != 0);
+
+ if (isDefaultTemplate() == false &&
+ !m_mode->equals(*currentMode))
+ {
+ executionContext.setCurrentMode(m_mode);
+
+ ParentType::selectAndSortChildren(
+ executionContext,
+ theTemplate,
+ sorter,
+ thePushPop.getStackFrameIndex());
+
+ executionContext.setCurrentMode(currentMode);
+ }
+ else
+ {
+ ParentType::selectAndSortChildren(
+ executionContext,
+ theTemplate,
+ sorter,
thePushPop.getStackFrameIndex());
}
}
1.16 +7 -0 xml-xalan/c/src/XSLT/ElemApplyTemplates.hpp
Index: ElemApplyTemplates.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemApplyTemplates.hpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- ElemApplyTemplates.hpp 25 Nov 2002 18:11:52 -0000 1.15
+++ ElemApplyTemplates.hpp 1 Feb 2003 00:24:31 -0000 1.16
@@ -113,6 +113,13 @@
virtual bool
childTypeAllowed(int xslToken) const;
+ virtual void
+ selectAndSortChildren(
+ StylesheetExecutionContext&
executionContext,
+ const ElemTemplateElement* theTemplate,
+ NodeSorter*
sorter,
+ int
selectStackFrameIndex) const;
+
private:
const XalanQName* m_mode;
1.34 +7 -9 xml-xalan/c/src/XSLT/ElemForEach.cpp
Index: ElemForEach.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemForEach.cpp,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- ElemForEach.cpp 8 Jan 2003 06:59:56 -0000 1.33
+++ ElemForEach.cpp 1 Feb 2003 00:24:31 -0000 1.34
@@ -223,8 +223,7 @@
{
transformSelectedChildren(
executionContext,
- this,
- executionContext.getCurrentStackFrameIndex());
+ this);
}
}
@@ -233,19 +232,18 @@
void
ElemForEach::transformSelectedChildren(
StylesheetExecutionContext&
executionContext,
- const ElemTemplateElement* theTemplate,
- int
selectStackFrameIndex) const
+ const ElemTemplateElement* theTemplate)
const
{
assert(m_selectPattern != 0);
assert(m_sortElemsCount == m_sortElems.size());
if (m_sortElemsCount == 0)
{
- transformSelectedChildren(
+ selectAndSortChildren(
executionContext,
theTemplate,
0,
- selectStackFrameIndex);
+
executionContext.getCurrentStackFrameIndex());
}
else
{
@@ -392,18 +390,18 @@
*this));
}
- transformSelectedChildren(
+ selectAndSortChildren(
executionContext,
theTemplate,
sorter.get(),
- selectStackFrameIndex);
+
executionContext.getCurrentStackFrameIndex());
}
}
void
-ElemForEach::transformSelectedChildren(
+ElemForEach::selectAndSortChildren(
StylesheetExecutionContext&
executionContext,
const ElemTemplateElement* theTemplate,
NodeSorter*
sorter,
1.18 +16 -19 xml-xalan/c/src/XSLT/ElemForEach.hpp
Index: ElemForEach.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemForEach.hpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- ElemForEach.hpp 8 Jan 2003 06:59:56 -0000 1.17
+++ ElemForEach.hpp 1 Feb 2003 00:24:32 -0000 1.18
@@ -166,45 +166,42 @@
* @param executionContext The current execution context
* @param template The owning template context.
* @param sourceNodeContext The current source node context.
- * @param selectStackFrameIndex stack frame context for executing the
- * select statement
*/
void
transformSelectedChildren(
StylesheetExecutionContext&
executionContext,
- const ElemTemplateElement* theTemplate,
- int
selectStackFrameIndex) const;
+ const ElemTemplateElement* theTemplate)
const;
/**
* Perform a query if needed, and call transformChild for each child.
*
- * @param executionContext The current execution context
- * @param template The owning template context.
- * @param sorter The NodeSorter instance, if any.
- * @param selectStackFrameIndex stack frame context for executing the
- * select
statement
+ * @param executionContext The current execution context
+ * @param theTemplate The owning template context.
+ * @param sourceNodes The source nodes to transform.
+ * @param sourceNodesCount The count of source nodes to transform.
*/
void
transformSelectedChildren(
StylesheetExecutionContext& executionContext,
const ElemTemplateElement* theTemplate,
- NodeSorter* sorter,
- int
selectStackFrameIndex) const;
+ const NodeRefListBase& sourceNodes,
+ NodeRefListBase::size_type
sourceNodesCount) const;
/**
* Perform a query if needed, and call transformChild for each child.
*
- * @param executionContext The current execution context
- * @param theTemplate The owning template context.
- * @param sourceNodes The source nodes to transform.
- * @param sourceNodesCount The count of source nodes to transform.
+ * @param executionContext The current execution context
+ * @param template The owning template context.
+ * @param sorter The NodeSorter instance, if any.
+ * @param selectStackFrameIndex stack frame context for executing the
+ * select
statement
*/
- void
- transformSelectedChildren(
+ virtual void
+ selectAndSortChildren(
StylesheetExecutionContext& executionContext,
const ElemTemplateElement* theTemplate,
- const NodeRefListBase& sourceNodes,
- NodeRefListBase::size_type
sourceNodesCount) const;
+ NodeSorter* sorter,
+ int
selectStackFrameIndex) const;
const XPath* m_selectPattern;
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]