dbertoni 02/04/15 22:45:50
Modified: c/src/XSLT ElemApplyImport.cpp ElemChoose.cpp
ElemForEach.cpp ElemOtherwise.cpp ElemOtherwise.hpp
ElemTemplate.cpp ElemTemplate.hpp
ElemTemplateElement.hpp ElemWhen.cpp ElemWhen.hpp
StylesheetExecutionContext.hpp
StylesheetExecutionContextDefault.cpp
StylesheetExecutionContextDefault.hpp
Log:
Make sure the current template is maintained correctly. Added option for
pre-instance factories for result tree fragments.
Revision Changes Path
1.16 +8 -3 xml-xalan/c/src/XSLT/ElemApplyImport.cpp
Index: ElemApplyImport.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemApplyImport.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- ElemApplyImport.cpp 23 Feb 2002 04:23:16 -0000 1.15
+++ ElemApplyImport.cpp 16 Apr 2002 05:45:50 -0000 1.16
@@ -119,12 +119,17 @@
void
-ElemApplyImport::execute(StylesheetExecutionContext&
executionContext) const
+ElemApplyImport::execute(StylesheetExecutionContext& executionContext) const
{
- ElemTemplateElement::execute(executionContext);
-
XalanNode* const sourceNode = executionContext.getCurrentNode();
assert(sourceNode != 0);
+
+ if (executionContext.getCurrentTemplate() == 0)
+ {
+ executionContext.error("There is no current template",
sourceNode, this);
+ }
+
+ ElemTemplateElement::execute(executionContext);
transformChild(
executionContext,
1.18 +2 -2 xml-xalan/c/src/XSLT/ElemChoose.cpp
Index: ElemChoose.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemChoose.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- ElemChoose.cpp 23 Feb 2002 04:23:16 -0000 1.17
+++ ElemChoose.cpp 16 Apr 2002 05:45:50 -0000 1.18
@@ -157,7 +157,7 @@
if(test->boolean() == true)
{
- node->executeChildren(executionContext);
+ node->execute(executionContext);
break;
}
@@ -165,7 +165,7 @@
else
{
// xsl:otherwise
- node->executeChildren(executionContext);
+ node->execute(executionContext);
}
}
}
1.22 +2 -0 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.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- ElemForEach.cpp 23 Feb 2002 04:23:16 -0000 1.21
+++ ElemForEach.cpp 16 Apr 2002 05:45:50 -0000 1.22
@@ -169,6 +169,8 @@
{
assert(m_selectPattern != 0);
+ StylesheetExecutionContext::SetAndRestoreCurrentTemplate
theSetAndRestore(executionContext, 0);
+
if (hasChildren() == true)
{
XalanNode* const sourceNode =
executionContext.getCurrentNode();
1.9 +10 -0 xml-xalan/c/src/XSLT/ElemOtherwise.cpp
Index: ElemOtherwise.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemOtherwise.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- ElemOtherwise.cpp 23 Feb 2002 04:23:16 -0000 1.8
+++ ElemOtherwise.cpp 16 Apr 2002 05:45:50 -0000 1.9
@@ -107,3 +107,13 @@
{
return Constants::ELEMNAME_OTHERWISE_WITH_PREFIX_STRING;
}
+
+
+
+void
+ElemOtherwise::execute(StylesheetExecutionContext& executionContext) const
+{
+ ElemTemplateElement::execute(executionContext);
+
+ executeChildren(executionContext);
+}
1.7 +3 -0 xml-xalan/c/src/XSLT/ElemOtherwise.hpp
Index: ElemOtherwise.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemOtherwise.hpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ElemOtherwise.hpp 12 Feb 2001 02:34:53 -0000 1.6
+++ ElemOtherwise.hpp 16 Apr 2002 05:45:50 -0000 1.7
@@ -91,6 +91,9 @@
virtual const XalanDOMString&
getElementName() const;
+
+ virtual void
+ execute(StylesheetExecutionContext& executionContext) const;
};
1.22 +23 -1 xml-xalan/c/src/XSLT/ElemTemplate.cpp
Index: ElemTemplate.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemTemplate.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- ElemTemplate.cpp 23 Feb 2002 04:23:16 -0000 1.21
+++ ElemTemplate.cpp 16 Apr 2002 05:45:50 -0000 1.22
@@ -174,9 +174,31 @@
void
-ElemTemplate::execute(StylesheetExecutionContext&
executionContext) const
+ElemTemplate::execute(StylesheetExecutionContext& executionContext) const
{
ElemTemplateElement::execute(executionContext);
executeChildren(executionContext);
+}
+
+
+
+void
+ElemTemplate::executeChildren(StylesheetExecutionContext&
executionContext) const
+{
+ StylesheetExecutionContext::SetAndRestoreCurrentTemplate
theSetAndRestore(executionContext, this);
+
+ ElemTemplateElement::executeChildren(executionContext);
+}
+
+
+
+void
+ElemTemplate::executeChildren(
+ StylesheetExecutionContext& executionContext,
+ XalanNode*
sourceNode) const
+{
+ StylesheetExecutionContext::SetAndRestoreCurrentTemplate
theSetAndRestore(executionContext, this);
+
+ ElemTemplateElement::executeChildren(executionContext, sourceNode);
}
1.13 +8 -0 xml-xalan/c/src/XSLT/ElemTemplate.hpp
Index: ElemTemplate.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemTemplate.hpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- ElemTemplate.hpp 13 Aug 2001 17:08:53 -0000 1.12
+++ ElemTemplate.hpp 16 Apr 2002 05:45:50 -0000 1.13
@@ -153,6 +153,14 @@
virtual void
execute(StylesheetExecutionContext& executionContext) const;
+ virtual void
+ executeChildren(StylesheetExecutionContext& executionContext) const;
+
+ virtual void
+ executeChildren(
+ StylesheetExecutionContext& executionContext,
+ XalanNode*
sourceNode) const;
+
private:
// not implemented
1.41 +2 -2 xml-xalan/c/src/XSLT/ElemTemplateElement.hpp
Index: ElemTemplateElement.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemTemplateElement.hpp,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -r1.40 -r1.41
--- ElemTemplateElement.hpp 12 Apr 2002 04:47:32 -0000 1.40
+++ ElemTemplateElement.hpp 16 Apr 2002 05:45:50 -0000 1.41
@@ -223,7 +223,7 @@
*
* @param processor XSLT processor instance
*/
- void
+ virtual void
executeChildren(StylesheetExecutionContext& executionContext) const;
/**
@@ -232,7 +232,7 @@
* @param processor XSLT processor instance
* @param sourceNode current node
*/
- void
+ virtual void
executeChildren(
StylesheetExecutionContext& executionContext,
XalanNode*
sourceNode) const;
1.12 +10 -0 xml-xalan/c/src/XSLT/ElemWhen.cpp
Index: ElemWhen.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemWhen.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- ElemWhen.cpp 23 Feb 2002 04:23:16 -0000 1.11
+++ ElemWhen.cpp 16 Apr 2002 05:45:50 -0000 1.12
@@ -130,3 +130,13 @@
{
return Constants::ELEMNAME_WHEN_WITH_PREFIX_STRING;
}
+
+
+
+void
+ElemWhen::execute(StylesheetExecutionContext& executionContext) const
+{
+ ElemTemplateElement::execute(executionContext);
+
+ executeChildren(executionContext);
+}
1.7 +3 -0 xml-xalan/c/src/XSLT/ElemWhen.hpp
Index: ElemWhen.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemWhen.hpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ElemWhen.hpp 12 Feb 2001 02:34:53 -0000 1.6
+++ ElemWhen.hpp 16 Apr 2002 05:45:50 -0000 1.7
@@ -107,6 +107,9 @@
virtual const XalanDOMString&
getElementName() const;
+ virtual void
+ execute(StylesheetExecutionContext& executionContext) const;
+
private:
const XPath* m_pTest;
1.72 +56 -3 xml-xalan/c/src/XSLT/StylesheetExecutionContext.hpp
Index: StylesheetExecutionContext.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetExecutionContext.hpp,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -r1.71 -r1.72
--- StylesheetExecutionContext.hpp 3 Apr 2002 05:13:38 -0000 1.71
+++ StylesheetExecutionContext.hpp 16 Apr 2002 05:45:50 -0000 1.72
@@ -113,6 +113,7 @@
class CountersTable;
+class ElemTemplate;
class ElemTemplateElement;
class ElemVariable;
class FormatterListener;
@@ -207,7 +208,7 @@
setStylesheetRoot(const StylesheetRoot* theStylesheet) = 0;
/**
- * Retrieve the current mode of the element
+ * Retrieve the current mode.
*
* @return QName for mode
*/
@@ -215,12 +216,64 @@
getCurrentMode() const = 0;
/**
- * Set the current mode of the element
+ * Set the current mode.
*
- * @param QName for mode
+ * @param theMode QName for mode
*/
virtual void
setCurrentMode(const XalanQName* theMode) = 0;
+
+ /**
+ * Retrieve the current template
+ *
+ * @return The current template instance or null if there is no current
template
+ */
+ virtual const ElemTemplate*
+ getCurrentTemplate() const = 0;
+
+ /**
+ * Set the current template
+ *
+ * @param theTemplate The current template instance
+ */
+ virtual void
+ setCurrentTemplate(const ElemTemplate* theTemplate) = 0;
+
+ /*
+ * A class to manage setting and restoring the current
+ * template instance.
+ */
+ class SetAndRestoreCurrentTemplate
+ {
+ public:
+
+ SetAndRestoreCurrentTemplate(
+ StylesheetExecutionContext&
executionContext,
+ const ElemTemplate*
theTemplate) :
+ m_executionContext(executionContext),
+ m_template(executionContext.getCurrentTemplate())
+ {
+ executionContext.setCurrentTemplate(theTemplate);
+ }
+
+ ~SetAndRestoreCurrentTemplate()
+ {
+ m_executionContext.setCurrentTemplate(m_template);
+ }
+
+ private:
+
+ // Not implemented...
+ SetAndRestoreCurrentTemplate(const
SetAndRestoreCurrentTemplate&);
+
+ SetAndRestoreCurrentTemplate&
+ operator=(const SetAndRestoreCurrentTemplate&);
+
+ // Data members...
+ StylesheetExecutionContext& m_executionContext;
+
+ const ElemTemplate* const m_template;
+ };
/**
* Whether diagnostic output is to be generated
1.87 +48 -7
xml-xalan/c/src/XSLT/StylesheetExecutionContextDefault.cpp
Index: StylesheetExecutionContextDefault.cpp
===================================================================
RCS file:
/home/cvs/xml-xalan/c/src/XSLT/StylesheetExecutionContextDefault.cpp,v
retrieving revision 1.86
retrieving revision 1.87
diff -u -r1.86 -r1.87
--- StylesheetExecutionContextDefault.cpp 11 Apr 2002 05:54:50 -0000
1.86
+++ StylesheetExecutionContextDefault.cpp 16 Apr 2002 05:45:50 -0000
1.87
@@ -151,13 +151,16 @@
m_ignoreHTMLElementNamespaces(false),
m_sourceTreeResultTreeFactory(),
m_mode(0),
+ m_currentTemplate(0),
m_formatterToTextCache(),
m_formatterToSourceTreeCache(),
m_nodeSorterCache(),
m_indentAmount(-1),
m_xresultTreeFragAllocator(eXResultTreeFragAllocatorBlockSize),
m_resultTreeFragAllocator(eResultTreeFragAllocatorBlockSize),
- m_documentFragmentAllocator(eDocumentFragmentAllocatorBlockSize)
+ m_documentFragmentAllocator(eDocumentFragmentAllocatorBlockSize),
+ m_documentAllocator(eDocumentAllocatorBlockSize),
+ m_usePerInstanceDocumentFactory(true)
{
}
@@ -188,13 +191,16 @@
m_ignoreHTMLElementNamespaces(false),
m_sourceTreeResultTreeFactory(),
m_mode(0),
+ m_currentTemplate(0),
m_formatterToTextCache(),
m_formatterToSourceTreeCache(),
m_nodeSorterCache(),
m_indentAmount(-1),
m_xresultTreeFragAllocator(eXResultTreeFragAllocatorBlockSize),
m_resultTreeFragAllocator(eResultTreeFragAllocatorBlockSize),
- m_documentFragmentAllocator(eDocumentFragmentAllocatorBlockSize)
+ m_documentFragmentAllocator(eDocumentFragmentAllocatorBlockSize),
+ m_documentAllocator(eDocumentAllocatorBlockSize),
+ m_usePerInstanceDocumentFactory(true)
{
}
@@ -281,6 +287,22 @@
+const ElemTemplate*
+StylesheetExecutionContextDefault::getCurrentTemplate() const
+{
+ return m_currentTemplate;
+}
+
+
+
+void
+StylesheetExecutionContextDefault::setCurrentTemplate(const ElemTemplate*
theTemplate)
+{
+ m_currentTemplate = theTemplate;
+}
+
+
+
bool
StylesheetExecutionContextDefault::doDiagnosticsOutput() const
{
@@ -937,8 +959,13 @@
{
assert(m_xsltProcessor != 0);
+ XalanSourceTreeDocument* const theDocument =
m_usePerInstanceDocumentFactory == true ?
+ m_documentAllocator.create() :
+ getSourceTreeFactory();
+ assert(theDocument != 0);
+
XalanSourceTreeDocumentFragment* const theDocumentFragment =
- m_documentFragmentAllocator.create(*getSourceTreeFactory());
+ m_documentFragmentAllocator.create(*theDocument);
assert(theDocumentFragment != 0);
ResultTreeFragBase* const theResultTreeFrag =
@@ -950,8 +977,6 @@
FormatterToSourceTree* const theFormatter = theGuard.get();
assert(theFormatter != 0);
- XalanSourceTreeDocument* const theDocument = getSourceTreeFactory();
-
theFormatter->setDocument(theDocument);
theFormatter->setDocumentFragment(theDocumentFragment);
@@ -1103,7 +1128,7 @@
}
else
{
- ResultTreeFrag* const theResultTreeFrag =
+ ResultTreeFrag* const theResultTreeFrag =
#if defined(XALAN_OLD_STYLE_CASTS)
(ResultTreeFrag*)theResultTreeFragBase;
#else
@@ -1115,9 +1140,23 @@
assert(theDocumentFragment != 0);
m_resultTreeFragAllocator.destroy(theResultTreeFrag);
+
+ if (m_usePerInstanceDocumentFactory == true)
+ {
+#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
+#if defined(XALAN_OLD_STYLE_CASTS)
+ m_documentAllocator.destroy((const
XalanSourceTreeDocument*)theDocumentFragment->getOwnerDocument());
+#else
+
m_documentAllocator.destroy(static_cast<XalanSourceTreeDocument*>(theDocumentFragment->getOwnerDocument()));
+#endif
+#else
+
m_documentAllocator.destroy(theDocumentFragment->getOwnerDocument());
+#endif
+ }
+
m_documentFragmentAllocator.destroy(theDocumentFragment);
- return true;
+ return true;
}
}
@@ -1502,10 +1541,12 @@
}
m_mode = 0;
+ m_currentTemplate = 0;
m_formatterToTextCache.reset();
m_formatterToSourceTreeCache.reset();
m_nodeSorterCache.reset();
+ m_documentAllocator.reset();
m_documentFragmentAllocator.reset();
m_resultTreeFragAllocator.reset();
m_xresultTreeFragAllocator.reset();
1.76 +28 -1
xml-xalan/c/src/XSLT/StylesheetExecutionContextDefault.hpp
Index: StylesheetExecutionContextDefault.hpp
===================================================================
RCS file:
/home/cvs/xml-xalan/c/src/XSLT/StylesheetExecutionContextDefault.hpp,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -r1.75 -r1.76
--- StylesheetExecutionContextDefault.hpp 11 Apr 2002 05:54:50 -0000
1.75
+++ StylesheetExecutionContextDefault.hpp 16 Apr 2002 05:45:50 -0000
1.76
@@ -101,6 +101,7 @@
#include <XSLT/Stylesheet.hpp>
#include <XSLT/VariablesStack.hpp>
#include <XSLT/XResultTreeFragAllocator.hpp>
+#include <XSLT/XalanSourceTreeDocumentAllocator.hpp>
#include <XSLT/XalanSourceTreeDocumentFragmentAllocator.hpp>
@@ -264,6 +265,18 @@
m_xsltProcessor = theProcessor;
}
+ bool
+ getUsePerInstanceDocumentFactory() const
+ {
+ return m_usePerInstanceDocumentFactory;
+ }
+
+ void
+ setUsePerInstanceDocumentFactory(bool fValue)
+ {
+ m_usePerInstanceDocumentFactory = fValue;
+ }
+
// These interfaces are inherited from StylesheetExecutionContext...
@@ -288,6 +301,12 @@
virtual void
setCurrentMode(const XalanQName* theMode);
+ virtual const ElemTemplate*
+ getCurrentTemplate() const;
+
+ virtual void
+ setCurrentTemplate(const ElemTemplate* theTemplate);
+
virtual bool
doDiagnosticsOutput() const;
@@ -1018,7 +1037,6 @@
XPathExecutionContextDefault m_xpathExecutionContextDefault;
- // $$ ToDo: Try to remove this dependency, and rely only on
XSLTProcessor...
XSLTEngineImpl* m_xsltProcessor;
XalanNode* m_rootDocument;
@@ -1027,6 +1045,7 @@
eDefaultParamsVectorSize = 10,
eXResultTreeFragAllocatorBlockSize = 10,
eResultTreeFragAllocatorBlockSize = 10,
+ eDocumentAllocatorBlockSize = 10,
eDocumentFragmentAllocatorBlockSize = 10 };
ElementRecursionStackType m_elementRecursionStack;
@@ -1072,6 +1091,8 @@
// Holds the current mode.
const XalanQName* m_mode;
+ const ElemTemplate*
m_currentTemplate;
+
typedef XalanObjectCacheDefault<FormatterToText>
FormatterToTextCacheType;
typedef XalanObjectCacheDefault<FormatterToSourceTree>
FormatterToSourceTreeCacheType;
typedef XalanObjectCacheDefault<NodeSorter>
NodeSorterCacheType;
@@ -1089,6 +1110,12 @@
ResultTreeFragAllocator
m_resultTreeFragAllocator;
XalanSourceTreeDocumentFragmentAllocator
m_documentFragmentAllocator;
+
+ XalanSourceTreeDocumentAllocator m_documentAllocator;
+
+ // If true, we will use a separate document factory for
+ // result tree fragments.
+ bool
m_usePerInstanceDocumentFactory;
static XalanNumberFormatFactory
s_defaultXalanNumberFormatFactory;
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]