diff --git a/mozilla/extensions/transformiix/source/xslt/ProcessorState.cpp b/mozilla/extensions/transformiix/source/xslt/ProcessorState.cpp
index 84c48800538..5bb481e675f 100644
--- a/mozilla/extensions/transformiix/source/xslt/ProcessorState.cpp
+++ b/mozilla/extensions/transformiix/source/xslt/ProcessorState.cpp
@@ -25,16 +25,17 @@
* -- added code in ::resolveFunctionCall to support the
* document() function.
*
- * $Id: ProcessorState.cpp,v 1.17 2001-01-24 14:44:02 axel%pike.org Exp $
+ * $Id: ProcessorState.cpp,v 1.18 2001-01-27 15:05:39 axel%pike.org Exp $
*/
/**
* Implementation of ProcessorState
* Much of this code was ported from XSL:P
- * @version $Revision: 1.17 $ $Date: 2001-01-24 14:44:02 $
+ * @version $Revision: 1.18 $ $Date: 2001-01-27 15:05:39 $
**/
#include "ProcessorState.h"
+#include "XSLTFunctions.h"
//-------------/
//- Constants -/
@@ -72,7 +73,7 @@ ProcessorState::~ProcessorState() {
delete dfWildCardTemplate;
if (dfTextTemplate)
delete dfTextTemplate;
- delete nodeStack;
+ delete resultNodeStack;
while ( ! variableSets.empty() ) {
delete (NamedMap*) variableSets.pop();
@@ -190,7 +191,7 @@ void ProcessorState::addTemplate(Element* xslTemplate) {
**/
MBool ProcessorState::addToResultTree(Node* node) {
- Node* current = nodeStack->peek();
+ Node* current = resultNodeStack->peek();
#ifdef MOZ_XSL
String nameSpaceURI, name, localName;
#endif
@@ -225,7 +226,7 @@ MBool ProcessorState::addToResultTree(Node* node) {
if ( docElement ) {
String nodeName(wrapperName);
Element* wrapper = resultDocument->createElement(nodeName);
- nodeStack->push(wrapper);
+ resultNodeStack->push(wrapper);
current->appendChild(wrapper);
current = wrapper;
}
@@ -250,7 +251,7 @@ MBool ProcessorState::addToResultTree(Node* node) {
if ( current == resultDocument ) {
String nodeName(wrapperName);
Element* wrapper = resultDocument->createElement(nodeName);
- nodeStack->push(wrapper);
+ resultNodeStack->push(wrapper);
current->appendChild(wrapper);
current = wrapper;
}
@@ -363,6 +364,13 @@ NodeSet* ProcessorState::getAttributeSet(const String& name) {
return (NodeSet*)namedAttributeSets.get(name);
} //-- getAttributeSet
+/**
+ * Returns the source node currently being processed
+**/
+Node* ProcessorState::getCurrentNode() {
+ return currentNodeStack.peek();
+} //-- setCurrentNode
+
/**
* Gets the default Namespace URI stack.
**/
@@ -483,7 +491,7 @@ void ProcessorState::getNameSpaceURIFromPrefix(const String& prefix, String& nam
* result tree
**/
NodeStack* ProcessorState::getNodeStack() {
- return nodeStack;
+ return resultNodeStack;
} //-- getNodeStack
/**
@@ -570,20 +578,12 @@ Node* ProcessorState::popAction() {
} //-- popAction
/**
- * Adds the given XSLT action to the top of the action stack
+ * Removes and returns the current source node being processed, from the stack
+ * @return the current source node
**/
-void ProcessorState::pushAction(Node* xsltAction) {
- if (currentAction) {
- XSLTAction* newAction = new XSLTAction;
- newAction->prev = currentAction;
- currentAction = newAction;
- }
- else {
- currentAction = new XSLTAction;
- currentAction->prev = 0;
- }
- currentAction->node = xsltAction;
-} //-- pushAction
+Node* ProcessorState::popCurrentNode() {
+ return currentNodeStack.pop();
+} //-- popCurrentNode
/**
* Adds the set of names to the Whitespace preserving element set
@@ -601,6 +601,30 @@ void ProcessorState::preserveSpace(String& names) {
} //-- preserveSpace
+/**
+ * Adds the given XSLT action to the top of the action stack
+**/
+void ProcessorState::pushAction(Node* xsltAction) {
+ if (currentAction) {
+ XSLTAction* newAction = new XSLTAction;
+ newAction->prev = currentAction;
+ currentAction = newAction;
+ }
+ else {
+ currentAction = new XSLTAction;
+ currentAction->prev = 0;
+ }
+ currentAction->node = xsltAction;
+} //-- pushAction
+
+/**
+ * Sets the source node currently being processed
+ * @param node the source node to set as the "current" node
+**/
+void ProcessorState::pushCurrentNode(Node* node) {
+ currentNodeStack.push(node);
+} //-- setCurrentNode
+
/**
* Sets a new default Namespace URI.
**/
@@ -777,7 +801,7 @@ FunctionCall* ProcessorState::resolveFunctionCall(const String& name) {
err.append(name);
}
else if (CURRENT_FN.isEqual(name)) {
- return new CurrentFunctionCall();
+ return new CurrentFunctionCall(this);
}
else if (UNPARSED_ENTITY_URI_FN.isEqual(name)) {
err = "function not yet implemented: ";
@@ -903,8 +927,8 @@ void ProcessorState::initialize() {
//-- handles the cleanup
//-- create NodeStack
- nodeStack = new NodeStack();
- nodeStack->push(this->resultDocument);
+ resultNodeStack = new NodeStack();
+ resultNodeStack->push(this->resultDocument);
setDefaultNameSpaceURIForResult("");
diff --git a/mozilla/extensions/transformiix/source/xslt/ProcessorState.h b/mozilla/extensions/transformiix/source/xslt/ProcessorState.h
index eab17ad9673..a63eba131d4 100644
--- a/mozilla/extensions/transformiix/source/xslt/ProcessorState.h
+++ b/mozilla/extensions/transformiix/source/xslt/ProcessorState.h
@@ -21,7 +21,7 @@
* Keith Visco, kvisco@ziplink.net
* -- original author.
*
- * $Id: ProcessorState.h,v 1.9 2001-01-22 09:39:55 kvisco%ziplink.net Exp $
+ * $Id: ProcessorState.h,v 1.10 2001-01-27 15:05:39 axel%pike.org Exp $
*/
@@ -45,12 +45,11 @@
#include "Tokenizer.h"
#include "VariableBinding.h"
#include "OutputFormat.h"
-#include "XSLTFunctions.h"
/**
* Class used for keeping the current state of the XSL Processor
* @author Keith Visco
- * @version $Revision: 1.9 $ $Date: 2001-01-22 09:39:55 $
+ * @version $Revision: 1.10 $ $Date: 2001-01-27 15:05:39 $
**/
class ProcessorState : public ContextState {
@@ -124,6 +123,11 @@ public:
**/
NodeSet* getAttributeSet(const String& name);
+ /**
+ * Returns the source node currently being processed
+ **/
+ Node* getCurrentNode();
+
/**
* Gets the default Namespace URI stack.
**/
@@ -221,11 +225,23 @@ public:
**/
Node* popAction();
+ /**
+ * Removes and returns the current node being processed from the stack
+ * @return the current node
+ **/
+ Node* popCurrentNode();
+
/**
* Adds the given XSLT action to the top of the action stack
**/
void pushAction(Node* xsltAction);
+ /**
+ * Sets the given source node as the "current node" being processed
+ * @param node the source node currently being processed
+ **/
+ void pushCurrentNode(Node* node);
+
/**
* Sets a new default Namespace URI. This is used for the Result Tree
@@ -333,6 +349,8 @@ private:
XSLTAction* prev;
};
+ NodeStack currentNodeStack;
+
/**
* Allows us to overcome some DOM deficiencies
**/
@@ -362,7 +380,7 @@ private:
/**
* Current stack of nodes, where we are in the result document tree
**/
- NodeStack* nodeStack;
+ NodeStack* resultNodeStack;
/**
diff --git a/mozilla/extensions/transformiix/source/xslt/XSLTProcessor.cpp b/mozilla/extensions/transformiix/source/xslt/XSLTProcessor.cpp
index 1b1381afa94..ec8cf5b6cae 100644
--- a/mozilla/extensions/transformiix/source/xslt/XSLTProcessor.cpp
+++ b/mozilla/extensions/transformiix/source/xslt/XSLTProcessor.cpp
@@ -38,7 +38,7 @@
* Olivier Gerardin
* -- Changed behavior of passing parameters to templates
*
- * $Id: XSLTProcessor.cpp,v 1.32 2001-01-24 14:44:03 axel%pike.org Exp $
+ * $Id: XSLTProcessor.cpp,v 1.33 2001-01-27 15:05:39 axel%pike.org Exp $
*/
#include "XSLTProcessor.h"
@@ -53,7 +53,7 @@
/**
* XSLTProcessor is a class for Processing XSL stylesheets
* @author Keith Visco
- * @version $Revision: 1.32 $ $Date: 2001-01-24 14:44:03 $
+ * @version $Revision: 1.33 $ $Date: 2001-01-27 15:05:39 $
**/
/**
@@ -866,6 +866,7 @@ void XSLTProcessor::processAction
Element* actionElement = (Element*)xslAction;
ps->pushAction(actionElement);
+ ps->pushCurrentNode(node);
switch ( getElementType(nodeName, ps) ) {
@@ -1378,6 +1379,7 @@ void XSLTProcessor::processAction
break;
} //-- switch
ps->popAction();
+ ps->popCurrentNode();
} //-- end if (element)
//cout << "XSLTProcessor#processAction [exit]\n";
diff --git a/mozilla/extensions/transformiix/source/xslt/XSLTProcessor.h b/mozilla/extensions/transformiix/source/xslt/XSLTProcessor.h
index e28a2eb4f8e..53c396610d5 100644
--- a/mozilla/extensions/transformiix/source/xslt/XSLTProcessor.h
+++ b/mozilla/extensions/transformiix/source/xslt/XSLTProcessor.h
@@ -21,7 +21,7 @@
* Keith Visco, kvisco@ziplink.net
* -- original author.
*
- * $Id: XSLTProcessor.h,v 1.12 2000-09-13 23:51:15 rayw%netscape.com Exp $
+ * $Id: XSLTProcessor.h,v 1.13 2001-01-27 15:05:40 axel%pike.org Exp $
*/
@@ -75,7 +75,7 @@
/**
* A class for Processing XSL Stylesheets
* @author Keith Visco
- * @version $Revision: 1.12 $ $Date: 2000-09-13 23:51:15 $
+ * @version $Revision: 1.13 $ $Date: 2001-01-27 15:05:40 $
**/
class XSLTProcessor
#ifdef MOZ_XSL
@@ -258,6 +258,7 @@ private:
MBool allowShadowing,
ProcessorState* ps);
+
#ifndef MOZ_XSL
/**
diff --git a/mozilla/extensions/transformiix/source/xslt/functions/CurrentFunctionCall.cpp b/mozilla/extensions/transformiix/source/xslt/functions/CurrentFunctionCall.cpp
index f979b8f7221..e32c0ea1214 100644
--- a/mozilla/extensions/transformiix/source/xslt/functions/CurrentFunctionCall.cpp
+++ b/mozilla/extensions/transformiix/source/xslt/functions/CurrentFunctionCall.cpp
@@ -7,9 +7,10 @@
/**
* Creates a new current function call
**/
-CurrentFunctionCall::CurrentFunctionCall() :
+CurrentFunctionCall::CurrentFunctionCall(ProcessorState* ps) :
FunctionCall(CURRENT_FN)
{
+ this->processorState = ps;
}
/**
@@ -23,7 +24,7 @@ CurrentFunctionCall::CurrentFunctionCall() :
ExprResult* CurrentFunctionCall::evaluate(Node* context, ContextState* cs) {
NodeSet* result = new NodeSet(1);
- result->add(context);
+ result->add(processorState->getCurrentNode());
return result;
} //-- evaluate
diff --git a/mozilla/extensions/transformiix/source/xslt/functions/Makefile b/mozilla/extensions/transformiix/source/xslt/functions/Makefile
index fd9075cbff0..10ded2f3162 100644
--- a/mozilla/extensions/transformiix/source/xslt/functions/Makefile
+++ b/mozilla/extensions/transformiix/source/xslt/functions/Makefile
@@ -18,16 +18,16 @@ ALL_OBJS = \
SystemPropertyFunctionCall.o
INCLUDE_PATH = -I. \
- -I$(BASE) \
- -I$(NET) \
- -I$(XPATH) \
- -I$(XML) \
- -I$(XML)/parser \
- -I$(XML_UTIL) \
- -I$(DOM) \
- -I$(XSLT) \
- -I$(XSLT)/util \
- -I$(EXPAT_PARSER_PATH)
+ -I$(BASE) \
+ -I$(NET) \
+ -I$(XPATH) \
+ -I$(XML) \
+ -I$(XML)/parser \
+ -I$(XML_UTIL) \
+ -I$(DOM) \
+ -I$(XSLT) \
+ -I$(XSLT)/util \
+ -I$(EXPAT_PARSER_PATH)
target: $(ALL_OBJS)
diff --git a/mozilla/extensions/transformiix/source/xslt/functions/Makefile.in b/mozilla/extensions/transformiix/source/xslt/functions/Makefile.in
index c0c8c493e5f..350e904d37e 100644
--- a/mozilla/extensions/transformiix/source/xslt/functions/Makefile.in
+++ b/mozilla/extensions/transformiix/source/xslt/functions/Makefile.in
@@ -39,6 +39,6 @@ INCLUDES += -I$(srcdir)/../../base -I$(srcdir)/../../net \
-I$(srcdir)/../../xpath -I$(srcdir)/../../xml \
-I$(srcdir)/../../xml/parser -I$(srcdir)/../../xml/parser/xmlparse \
-I$(srcdir)/../../xml/util -I$(srcdir)/../../xml/dom \
- -I$(srcdir)/../../xslt
+ -I$(srcdir)/.. -I$(srcdir)/../util
install:: $(OBJS)
diff --git a/mozilla/extensions/transformiix/source/xslt/functions/XSLTFunctions.h b/mozilla/extensions/transformiix/source/xslt/functions/XSLTFunctions.h
index 6d1932b004b..b0ec4af932c 100644
--- a/mozilla/extensions/transformiix/source/xslt/functions/XSLTFunctions.h
+++ b/mozilla/extensions/transformiix/source/xslt/functions/XSLTFunctions.h
@@ -23,7 +23,7 @@
* Olivier Gerardin,
* -- added document() function definition
*
- * $Id: XSLTFunctions.h,v 1.3 2001-01-12 20:06:46 axel%pike.org Exp $
+ * $Id: XSLTFunctions.h,v 1.4 2001-01-27 15:05:41 axel%pike.org Exp $
*/
#include "dom.h"
@@ -32,6 +32,7 @@
#include "Names.h"
#include "DOMHelper.h"
#include "TxString.h"
+#include "ProcessorState.h"
#ifndef TRANSFRMX_XSLT_FUNCTIONS_H
#define TRANSFRMX_XSLT_FUNCTIONS_H
@@ -123,7 +124,7 @@ public:
/**
* Creates a new current() function call
**/
- CurrentFunctionCall();
+ CurrentFunctionCall(ProcessorState* ps);
/**
* Evaluates this Expr based on the given context node and processor state
@@ -136,6 +137,7 @@ public:
virtual ExprResult* evaluate(Node* context, ContextState* cs);
private:
+ ProcessorState* processorState;
};
/**
diff --git a/mozilla/extensions/transformiix/source/xslt/functions/makefile.win b/mozilla/extensions/transformiix/source/xslt/functions/makefile.win
index 1d2a101ba9c..53cb05ac073 100644
--- a/mozilla/extensions/transformiix/source/xslt/functions/makefile.win
+++ b/mozilla/extensions/transformiix/source/xslt/functions/makefile.win
@@ -46,9 +46,9 @@ CPP_OBJS= \
EXPORTS = \
$(NULL)
-LINCS= $(LINCS) -I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor -I..\..\base -I..\..\xml\dom \
- -I..\..\xpath -I..\..\xml -I..\ -I..\..\xml\util \
- -I..\..\net -I$(DEPTH)\expat -I..\..\xml\parser
+LINCS= $(LINCS) -I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor -I..\..\base \
+ -I..\..\xml\dom -I..\..\xpath -I..\..\xml -I..\ -I..\..\xml\util \
+ -I..\..\net -I$(DEPTH)\expat -I..\..\xml\parser -I..\util
LCFLAGS = \
$(LCFLAGS) \