dbertoni 00/05/29 15:45:25
Modified: c/src/XSLT XSLTEngineImpl.cpp XSLTEngineImpl.hpp
Log:
Added support for marking an element's stack frame.
Revision Changes Path
1.42 +64 -7 xml-xalan/c/src/XSLT/XSLTEngineImpl.cpp
Index: XSLTEngineImpl.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/XSLTEngineImpl.cpp,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -r1.41 -r1.42
--- XSLTEngineImpl.cpp 2000/05/26 19:25:36 1.41
+++ XSLTEngineImpl.cpp 2000/05/29 22:45:24 1.42
@@ -125,6 +125,7 @@
#include "Constants.hpp"
#include "ContextMarker.hpp"
#include "ElemWithParam.hpp"
+#include "ElementFrameMarker.hpp"
#include "ElementMarker.hpp"
#include "FunctionCurrent.hpp"
#include "FunctionDocument.hpp"
@@ -576,7 +577,7 @@
{
theStylesheet = constructionContext.create(stylesheetSource);
- StylesheetHandler stylesheetProcessor(*this,
*theStylesheet, constructionContext);
+ StylesheetHandler stylesheetProcessor(*theStylesheet,
constructionContext);
if(0 != stylesheetSource.getNode())
{
@@ -858,7 +859,7 @@
stylesheet = new
Stylesheet(*const_cast<StylesheetRoot*>(m_stylesheetRoot), stringHolder,
constructionContext);
}
- StylesheetHandler stylesheetProcessor(*this,
*stylesheet, constructionContext);
+ StylesheetHandler stylesheetProcessor(*stylesheet,
constructionContext);
FormatterTreeWalker tw(stylesheetProcessor);
@@ -897,7 +898,7 @@
stylesheet = new
Stylesheet(*const_cast<StylesheetRoot*>(m_stylesheetRoot), localXSLURLString,
constructionContext);
}
- StylesheetHandler stylesheetProcessor(*this, *stylesheet,
constructionContext);
+ StylesheetHandler stylesheetProcessor(*stylesheet,
constructionContext);
typedef StylesheetConstructionContext::URLAutoPtrType
URLAutoPtrType;
@@ -3844,10 +3845,10 @@
for(int i = (nElems - 1); i >= 0 && fFound == false; i--)
{
const StackEntry* const theEntry = m_stack[i];
- assert(theEntry != 0);
+ assert(theEntry != 0 && theEntry == back());
const StackEntry::eStackEntryType type =
theEntry->getType();
- assert(type < 4 && type >= 0);
+ assert(type < StackEntry::eNextValue && type >= 0);
fFound = type == StackEntry::eContextMarker ? true : false;
@@ -4078,7 +4079,7 @@
const int nElems = getCurrentStackFrameIndex();
// Sub 1 extra for the context marker.
- for(int i = (nElems - 1); i >= 0; i--)
+ for(int i = nElems - 1; i >= 0; --i)
{
const StackEntry* const theEntry =
m_stack[i];
@@ -4104,10 +4105,11 @@
if(0 == theResult && true == fSearchGlobalSpace)
{
// Look in the global space
- for(int i = (m_globalStackFrameIndex-1); i >= 2; i--)
+ for(int i = m_globalStackFrameIndex - 1; i >= 2; i--)
{
const StackEntry* const theEntry = m_stack[i];
assert(theEntry != 0);
+
if(theEntry->getType() == StackEntry::eArgument)
{
const Arg* const theArg =
@@ -4127,6 +4129,61 @@
}
return theResult;
+}
+
+
+
+void
+XSLTEngineImpl::VariableStack::pushElementFrame(const ElemTemplateElement*
elem)
+{
+ StackEntry* const theEntry = new ElementFrameMarker(elem);
+
+ m_stackEntries.insert(theEntry);
+
+ push(theEntry);
+}
+
+
+
+void
+XSLTEngineImpl::VariableStack::popElementFrame(const ElemTemplateElement*
elem)
+{
+ const int nElems = getCurrentStackFrameIndex();
+
+ bool fFound = false;
+
+ // Sub 1 extra for the context marker.
+ for(int i = nElems - 1; i >= 0 && fFound == false; --i)
+ {
+ const StackEntry* const theEntry =
+ m_stack[i];
+ assert(theEntry != 0 && theEntry == back());
+
+ // Pop it off the stack...
+ pop();
+
+ if(theEntry->getType() == StackEntry::eContextMarker)
+ {
+ // Didn't really find it, but quit anyway...
+ // $$$ ToDo: Isn't this really a bad stack context???
+ fFound = true;
+ }
+ else if (theEntry->getType() == StackEntry::eElementFrameMarker)
+ {
+ const ElementFrameMarker* const theMarker =
+ static_cast<const
ElementFrameMarker*>(theEntry);
+
+ const ElemTemplateElement* const theElement =
+ theMarker->getElement();
+
+ fFound = true;
+
+ if (theElement != elem)
+ {
+ throw InvalidStackContextException();
+ }
+ }
+ }
}
1.34 +42 -4 xml-xalan/c/src/XSLT/XSLTEngineImpl.hpp
Index: XSLTEngineImpl.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/XSLTEngineImpl.hpp,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- XSLTEngineImpl.hpp 2000/05/25 16:51:37 1.33
+++ XSLTEngineImpl.hpp 2000/05/29 22:45:25 1.34
@@ -668,11 +668,12 @@
}
/**
- * Retieve the latest XSLT version currently supported.
+ * Get the latest XSLT version currently supported.
*
* @return XSLT version number
*/
- static double getXSLTVerSupported();
+ static double
+ getXSLTVerSupported();
/**
* Accessor method for hash table of XSLT IDs for attribute names.
@@ -698,13 +699,30 @@
/**
* Given an XSL tag name, return an integer token that corresponds to
- * ELEMNAME_XXX constants defined in Constants.java.
+ * ELEMNAME_XXX constants defined in Constants.hpp
*
* @param name a probable xsl:xxx element
* @return Constants.ELEMNAME_XXX token, -1 if in XSL or Xalan
namespace,
* or -2 if not in known namespace
*/
int
+ getElementToken(const XalanDOMString& name) const
+ {
+ AttributeKeysMapType::const_iterator iter=
+ s_elementKeys.find(name);
+
+ return iter == s_elementKeys.end() ? -2 : (*iter).second;
+ }
+
+ /**
+ * Given an XSL tag name, return an integer token that corresponds to
+ * ELEMNAME_XXX constants defined in Constants.hpp.
+ *
+ * @param name a probable xsl:xxx element
+ * @return Constants.ELEMNAME_XXX token, -1 if in XSL or Xalan
namespace,
+ * or -2 if not in known namespace
+ */
+ int
getAttrTok(const XalanDOMString& name) const
{
AttributeKeysMapType::const_iterator iter=
@@ -1590,7 +1608,7 @@
push(StackEntry* theEntry)
{
assert(theEntry != 0);
- assert(theEntry->getType() < 4 && theEntry->getType()
>= 0);
+ assert(theEntry->getType() < StackEntry::eNextValue &&
theEntry->getType() >= 0);
if(m_currentStackFrameIndex == m_stack.size())
{
@@ -1616,6 +1634,9 @@
--m_currentStackFrameIndex;
}
+ // We can't really delete anything here, since
+ // the caller may still be referring to the
+ // stack entry...
m_stack.pop_back();
}
@@ -1626,6 +1647,23 @@
return m_stack.back();
}
+
+ /**
+ * Push a frame marker for an element.
+ *
+ * @param elem the element
+ */
+ void
+ pushElementFrame(const ElemTemplateElement* elem);
+
+ /**
+ * Pop a frame marker for an element.
+ *
+ * @param elem the element
+ */
+ void
+ popElementFrame(const ElemTemplateElement* elem);
+
class InvalidStackContextException : public
XSLTProcessorException
{