You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by db...@locus.apache.org on 2000/12/04 21:49:08 UTC
cvs commit: xml-xalan/c/src/XSLT ElemLiteralResult.cpp ElemParam.cpp ElemVariable.cpp ElemVariable.hpp FunctionDocument.cpp FunctionElementAvailable.cpp FunctionFormatNumber.cpp FunctionFunctionAvailable.cpp FunctionGenerateID.cpp FunctionKey.cpp FunctionSystemProperty.cpp FunctionUnparsedEntityURI.cpp KeyTable.cpp KeyTable.hpp Stylesheet.cpp StylesheetExecutionContext.hpp StylesheetExecutionContextDefault.cpp StylesheetExecutionContextDefault.hpp VariablesStack.cpp VariablesStack.hpp XSLTEngineImpl.cpp
dbertoni 00/12/04 12:48:58
Modified: c/src/XMLSupport FormatterToText.cpp
c/src/XPath Function.cpp Function.hpp FunctionBoolean.cpp
FunctionCeiling.cpp FunctionConcat.cpp
FunctionContains.cpp FunctionCount.cpp
FunctionFalse.cpp FunctionFloor.cpp FunctionID.cpp
FunctionLang.cpp FunctionLast.cpp
FunctionLocalName.cpp FunctionName.cpp
FunctionNamespaceURI.cpp FunctionNamespaceURI.hpp
FunctionNormalizeSpace.cpp FunctionNot.cpp
FunctionNumber.cpp FunctionPosition.cpp
FunctionRound.cpp FunctionStartsWith.cpp
FunctionString.cpp FunctionStringLength.cpp
FunctionSubstring.cpp FunctionSubstringAfter.cpp
FunctionSubstringBefore.cpp FunctionSum.cpp
FunctionTranslate.cpp FunctionTrue.cpp XNodeSet.cpp
XPath.cpp XPathExecutionContext.hpp
XPathExecutionContextDefault.cpp
XPathExecutionContextDefault.hpp
c/src/XSLT ElemLiteralResult.cpp ElemParam.cpp
ElemVariable.cpp ElemVariable.hpp
FunctionDocument.cpp FunctionElementAvailable.cpp
FunctionFormatNumber.cpp
FunctionFunctionAvailable.cpp
FunctionGenerateID.cpp FunctionKey.cpp
FunctionSystemProperty.cpp
FunctionUnparsedEntityURI.cpp KeyTable.cpp
KeyTable.hpp Stylesheet.cpp
StylesheetExecutionContext.hpp
StylesheetExecutionContextDefault.cpp
StylesheetExecutionContextDefault.hpp
VariablesStack.cpp VariablesStack.hpp
XSLTEngineImpl.cpp
Log:
Performance tweaks and fix for lazy evaluation of top-level variables and params.
Revision Changes Path
1.13 +1 -1 xml-xalan/c/src/XMLSupport/FormatterToText.cpp
Index: FormatterToText.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XMLSupport/FormatterToText.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- FormatterToText.cpp 2000/11/20 16:18:52 1.12
+++ FormatterToText.cpp 2000/12/04 20:48:12 1.13
@@ -77,7 +77,7 @@
bool normalizeLinefeed) :
FormatterListener(OUTPUT_METHOD_TEXT),
m_writer(writer),
- m_maxCharacter(~0),
+ m_maxCharacter(XalanDOMChar(~0)),
m_encoding(),
m_haveEncoding(false),
m_normalize(normalizeLinefeed)
1.3 +4 -0 xml-xalan/c/src/XPath/Function.cpp
Index: Function.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/Function.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Function.cpp 2000/11/21 21:07:49 1.2
+++ Function.cpp 2000/12/04 20:48:12 1.3
@@ -60,6 +60,10 @@
+#include "XObjectFactory.hpp"
+
+
+
Function::Function()
{
}
1.10 +3 -6 xml-xalan/c/src/XPath/Function.hpp
Index: Function.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/Function.hpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- Function.hpp 2000/11/21 21:07:50 1.9
+++ Function.hpp 2000/12/04 20:48:13 1.10
@@ -64,19 +64,16 @@
-#include <XPath/XObject.hpp>
-#include <XPath/XObjectFactory.hpp>
-#include <XPath/XPathExecutionContext.hpp>
+#include <vector>
-#include <vector>
+#include <XPath/XObject.hpp>
+#include <XPath/XPathExecutionContext.hpp>
class XalanNode;
-class XObject;
-class XPathExecutionContext;
1.4 +5 -1 xml-xalan/c/src/XPath/FunctionBoolean.cpp
Index: FunctionBoolean.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionBoolean.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- FunctionBoolean.cpp 2000/11/21 21:07:50 1.3
+++ FunctionBoolean.cpp 2000/12/04 20:48:13 1.4
@@ -54,7 +54,11 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
-#include <XPath/FunctionBoolean.hpp>
+#include "FunctionBoolean.hpp"
+
+
+
+#include "XObjectFactory.hpp"
1.4 +4 -0 xml-xalan/c/src/XPath/FunctionCeiling.cpp
Index: FunctionCeiling.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionCeiling.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- FunctionCeiling.cpp 2000/11/21 21:07:52 1.3
+++ FunctionCeiling.cpp 2000/12/04 20:48:13 1.4
@@ -58,6 +58,10 @@
+#include "XObjectFactory.hpp"
+
+
+
FunctionCeiling::FunctionCeiling()
{
}
1.6 +5 -1 xml-xalan/c/src/XPath/FunctionConcat.cpp
Index: FunctionConcat.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionConcat.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- FunctionConcat.cpp 2000/11/21 21:07:53 1.5
+++ FunctionConcat.cpp 2000/12/04 20:48:14 1.6
@@ -54,7 +54,11 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
-#include <XPath/FunctionConcat.hpp>
+#include "FunctionConcat.hpp"
+
+
+
+#include "XObjectFactory.hpp"
1.4 +5 -1 xml-xalan/c/src/XPath/FunctionContains.cpp
Index: FunctionContains.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionContains.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- FunctionContains.cpp 2000/11/21 21:07:54 1.3
+++ FunctionContains.cpp 2000/12/04 20:48:15 1.4
@@ -54,7 +54,11 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
-#include <XPath/FunctionContains.hpp>
+#include "FunctionContains.hpp"
+
+
+
+#include "XObjectFactory.hpp"
1.4 +5 -1 xml-xalan/c/src/XPath/FunctionCount.cpp
Index: FunctionCount.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionCount.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- FunctionCount.cpp 2000/11/21 21:07:55 1.3
+++ FunctionCount.cpp 2000/12/04 20:48:15 1.4
@@ -54,7 +54,11 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
-#include <XPath/FunctionCount.hpp>
+#include "FunctionCount.hpp"
+
+
+
+#include "XObjectFactory.hpp"
1.4 +5 -1 xml-xalan/c/src/XPath/FunctionFalse.cpp
Index: FunctionFalse.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionFalse.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- FunctionFalse.cpp 2000/11/21 21:07:57 1.3
+++ FunctionFalse.cpp 2000/12/04 20:48:15 1.4
@@ -54,7 +54,11 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
-#include <XPath/FunctionFalse.hpp>
+#include "FunctionFalse.hpp"
+
+
+
+#include "XObjectFactory.hpp"
1.4 +5 -1 xml-xalan/c/src/XPath/FunctionFloor.cpp
Index: FunctionFloor.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionFloor.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- FunctionFloor.cpp 2000/11/21 21:07:58 1.3
+++ FunctionFloor.cpp 2000/12/04 20:48:15 1.4
@@ -54,7 +54,11 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
-#include <XPath/FunctionFloor.hpp>
+#include "FunctionFloor.hpp"
+
+
+
+#include "XObjectFactory.hpp"
1.4 +5 -1 xml-xalan/c/src/XPath/FunctionID.cpp
Index: FunctionID.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionID.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- FunctionID.cpp 2000/11/21 21:07:58 1.3
+++ FunctionID.cpp 2000/12/04 20:48:15 1.4
@@ -54,7 +54,11 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
-#include <XPath/FunctionID.hpp>
+#include "FunctionID.hpp"
+
+
+
+#include "XObjectFactory.hpp"
1.4 +5 -1 xml-xalan/c/src/XPath/FunctionLang.cpp
Index: FunctionLang.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionLang.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- FunctionLang.cpp 2000/11/21 21:08:00 1.3
+++ FunctionLang.cpp 2000/12/04 20:48:15 1.4
@@ -54,7 +54,11 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
-#include <XPath/FunctionLang.hpp>
+#include "FunctionLang.hpp"
+
+
+
+#include "XObjectFactory.hpp"
1.4 +5 -1 xml-xalan/c/src/XPath/FunctionLast.cpp
Index: FunctionLast.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionLast.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- FunctionLast.cpp 2000/11/21 21:08:00 1.3
+++ FunctionLast.cpp 2000/12/04 20:48:15 1.4
@@ -54,7 +54,11 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
-#include <XPath/FunctionLast.hpp>
+#include "FunctionLast.hpp"
+
+
+
+#include "XObjectFactory.hpp"
1.6 +5 -1 xml-xalan/c/src/XPath/FunctionLocalName.cpp
Index: FunctionLocalName.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionLocalName.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- FunctionLocalName.cpp 2000/11/21 21:58:13 1.5
+++ FunctionLocalName.cpp 2000/12/04 20:48:15 1.6
@@ -54,7 +54,11 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
-#include <XPath/FunctionLocalName.hpp>
+#include "FunctionLocalName.hpp"
+
+
+
+#include "XObjectFactory.hpp"
1.4 +5 -1 xml-xalan/c/src/XPath/FunctionName.cpp
Index: FunctionName.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionName.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- FunctionName.cpp 2000/11/21 21:08:02 1.3
+++ FunctionName.cpp 2000/12/04 20:48:15 1.4
@@ -54,7 +54,11 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
-#include <XPath/FunctionName.hpp>
+#include "FunctionName.hpp"
+
+
+
+#include "XObjectFactory.hpp"
1.5 +25 -47 xml-xalan/c/src/XPath/FunctionNamespaceURI.cpp
Index: FunctionNamespaceURI.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionNamespaceURI.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- FunctionNamespaceURI.cpp 2000/11/21 21:08:03 1.4
+++ FunctionNamespaceURI.cpp 2000/12/04 20:48:15 1.5
@@ -54,10 +54,14 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
-#include <XPath/FunctionNamespaceURI.hpp>
+#include "FunctionNamespaceURI.hpp"
+#include "XObjectFactory.hpp"
+
+
+
FunctionNamespaceURI::FunctionNamespaceURI()
{
}
@@ -72,72 +76,47 @@
XObjectPtr
FunctionNamespaceURI::execute(
- XPathExecutionContext& executionContext,
- XalanNode* /* context */,
- const XObjectPtr arg1)
+ XPathExecutionContext& executionContext,
+ XalanNode* /* context */,
+ const XObjectPtr arg1)
{
assert(arg1.null() == false);
- const XalanDOMString* theNamespace = 0;
+ const NodeRefListBase& theList = arg1->nodeset();
- theNamespace = getNamespaceFromNodeSet(*arg1, executionContext);
+ if (theList.getLength() == 0)
+ {
+ return executionContext.getXObjectFactory().createString(XalanDOMString());
+ }
+ else
+ {
+ assert(theList.item(0) != 0);
- return executionContext.getXObjectFactory().createString(theNamespace == 0 ? XalanDOMString() : *theNamespace);
+ return executionContext.getXObjectFactory().createString(executionContext.getNamespaceOfNode(*theList.item(0)));
+ }
}
XObjectPtr
FunctionNamespaceURI::execute(
- XPathExecutionContext& executionContext,
- XalanNode* context)
-{
- const XalanDOMString* theNamespace = 0;
-
+ XPathExecutionContext& executionContext,
+ XalanNode* context)
+{
if (context == 0)
{
executionContext.error("The namespace-uri() function requires a non-null context node!");
+
+ // Dummy return value...
+ return XObjectPtr(0);
}
else
{
// The XPath standard says that if there are no arguments,
// the argument defaults to a node set with the context node
// as the only member.
- // So we have to create an XObject with the context node as
- // the only member.
- // We shroud the temporary getNamespaceFromNodeSet( in a
- // FactoryObjectAutoPointer because it can be deleted once
- // we're done.
-
- // An XObject that contains the context node.
- XObjectPtr theXObject(executionContext.createNodeSet(*context));
-
-
- theNamespace = getNamespaceFromNodeSet(*theXObject.get(), executionContext);
+ return executionContext.getXObjectFactory().createString(executionContext.getNamespaceOfNode(*context));
}
-
- return executionContext.getXObjectFactory().createString(theNamespace == 0 ? XalanDOMString() : *theNamespace);
-}
-
-
-
-const XalanDOMString*
-FunctionNamespaceURI::getNamespaceFromNodeSet(
- const XObject& theXObject,
- XPathExecutionContext& theContext)
-{
- const NodeRefListBase& theList = theXObject.nodeset();
-
- if (theList.getLength() == 0)
- {
- return 0;
- }
- else
- {
- assert(theList.item(0) != 0);
-
- return &theContext.getNamespaceOfNode(*theList.item(0));
- }
}
@@ -160,4 +139,3 @@
return XALAN_STATIC_UCODE_STRING(
"The namespace-uri() function takes zero arguments or one argument!");
}
-
1.12 +0 -4 xml-xalan/c/src/XPath/FunctionNamespaceURI.hpp
Index: FunctionNamespaceURI.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionNamespaceURI.hpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- FunctionNamespaceURI.hpp 2000/11/30 21:36:30 1.11
+++ FunctionNamespaceURI.hpp 2000/12/04 20:48:15 1.12
@@ -110,10 +110,6 @@
private:
- static const XalanDOMString*
- getNamespaceFromNodeSet(const XObject& theXObject,
- XPathExecutionContext& theContext);
-
const XalanDOMString
getError() const;
1.8 +26 -14 xml-xalan/c/src/XPath/FunctionNormalizeSpace.cpp
Index: FunctionNormalizeSpace.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionNormalizeSpace.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- FunctionNormalizeSpace.cpp 2000/12/01 21:40:55 1.7
+++ FunctionNormalizeSpace.cpp 2000/12/04 20:48:16 1.8
@@ -59,6 +59,14 @@
+#include <DOMSupport/DOMServices.hpp>
+
+
+
+#include "XObjectFactory.hpp"
+
+
+
FunctionNormalizeSpace::FunctionNormalizeSpace()
{
}
@@ -73,9 +81,9 @@
XObjectPtr
FunctionNormalizeSpace::execute(
- XPathExecutionContext& executionContext,
- XalanNode* /* context */,
- const XObjectPtr arg1)
+ XPathExecutionContext& executionContext,
+ XalanNode* /* context */,
+ const XObjectPtr arg1)
{
assert(arg1.null() == false);
@@ -86,24 +94,29 @@
XObjectPtr
FunctionNormalizeSpace::execute(
- XPathExecutionContext& executionContext,
- XalanNode* context)
+ XPathExecutionContext& executionContext,
+ XalanNode* context)
{
if (context == 0)
{
executionContext.error("The normalize-space() function requires a non-null context node!",
context);
- return XObjectPtr();
+ // Dummy return value...
+ return XObjectPtr(0);
}
else
{
- // The XPath standard says that if there
- // are no arguments, the default is to turn the contextNode
- // into a string-value, which really means using FunctionString,
- // but we don't need to do that, since our XObject classes
- // do the real work in turning themselves into strings.
- return normalize(executionContext, executionContext.createNodeSet(*context)->str());
+ // The XPath standard says that if there are no arguments,
+ // the default is to turn the context node into a string value.
+ // DOMServices::getNodeData() will give us the data.
+
+ // Get a cached string...
+ XPathExecutionContext::GetAndReleaseCachedString theData(executionContext);
+
+ DOMServices::getNodeData(*context, theData);
+
+ return normalize(executionContext, theData);
}
}
@@ -218,8 +231,7 @@
const XalanDOMString
FunctionNormalizeSpace::getError() const
{
- return XALAN_STATIC_UCODE_STRING(
- "The normalize-space() function takes zero arguments or one argument!");
+ return XALAN_STATIC_UCODE_STRING("The normalize-space() function takes zero arguments or one argument!");
}
1.4 +5 -1 xml-xalan/c/src/XPath/FunctionNot.cpp
Index: FunctionNot.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionNot.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- FunctionNot.cpp 2000/11/21 21:08:05 1.3
+++ FunctionNot.cpp 2000/12/04 20:48:16 1.4
@@ -54,7 +54,11 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
-#include <XPath/FunctionNot.hpp>
+#include "FunctionNot.hpp"
+
+
+
+#include "XObjectFactory.hpp"
1.4 +35 -24 xml-xalan/c/src/XPath/FunctionNumber.cpp
Index: FunctionNumber.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionNumber.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- FunctionNumber.cpp 2000/11/21 21:08:06 1.3
+++ FunctionNumber.cpp 2000/12/04 20:48:16 1.4
@@ -54,10 +54,18 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
-#include <XPath/FunctionNumber.hpp>
+#include "FunctionNumber.hpp"
+#include <DOMSupport/DOMServices.hpp>
+
+
+
+#include "XObjectFactory.hpp"
+
+
+
FunctionNumber::FunctionNumber()
{
}
@@ -72,50 +80,53 @@
XObjectPtr
FunctionNumber::execute(
- XPathExecutionContext& executionContext,
- XalanNode* context,
- const XObjectPtr arg1)
+ XPathExecutionContext& executionContext,
+ XalanNode* /* context */,
+ const XObjectPtr arg1)
{
assert(arg1.null() == false);
-
- double theValue = 0.0L;
- theValue = arg1->num();
-
- return executionContext.getXObjectFactory().createNumber(theValue);
+ if (arg1->getType() == XObject::eTypeNumber)
+ {
+ // Since XObjects are reference counted, just return the
+ // argument.
+ return arg1;
+ }
+ else
+ {
+ return executionContext.getXObjectFactory().createNumber(arg1->num());
+ }
}
XObjectPtr
FunctionNumber::execute(
- XPathExecutionContext& executionContext,
- XalanNode* context)
+ XPathExecutionContext& executionContext,
+ XalanNode* context)
{
- double theValue = 0.0L;
-
if (context == 0)
{
executionContext.error("The number() function requires a non-null context node!");
+
+ // Dummy return value...
+ return XObjectPtr(0);
}
else
{
// The XPath standard says that if there are no arguments,
// the argument defaults to a node set with the context node
- // as the only member.
- // So we have to create an XNodeList with the context node as
- // the only member and call the num() function on it. We shroud
- // the temporary XNodeList in an XObjectPtr because it can be
- // deleted once we've converted the context node to a number.
+ // as the only member. The number value of a node set is the
+ // string value of the first node in the node set, converted to
+ // a number. DOMServices::getNodeData() will give us the data.
- // An XObject that contains the context node.
- XObjectPtr theXObject(executionContext.createNodeSet(*context));
+ // Get a cached string...
+ XPathExecutionContext::GetAndReleaseCachedString theData(executionContext);
- // Get the numeric value of the theXObject...
- theValue = theXObject->num();
- }
+ DOMServices::getNodeData(*context, theData);
- return executionContext.getXObjectFactory().createNumber(theValue);
+ return executionContext.getXObjectFactory().createNumber(DOMStringToDouble(theData));
+ }
}
1.4 +5 -1 xml-xalan/c/src/XPath/FunctionPosition.cpp
Index: FunctionPosition.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionPosition.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- FunctionPosition.cpp 2000/11/21 21:08:07 1.3
+++ FunctionPosition.cpp 2000/12/04 20:48:16 1.4
@@ -54,7 +54,11 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
-#include <XPath/FunctionPosition.hpp>
+#include "FunctionPosition.hpp"
+
+
+
+#include "XObjectFactory.hpp"
1.4 +5 -1 xml-xalan/c/src/XPath/FunctionRound.cpp
Index: FunctionRound.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionRound.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- FunctionRound.cpp 2000/11/21 21:08:08 1.3
+++ FunctionRound.cpp 2000/12/04 20:48:16 1.4
@@ -54,11 +54,15 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
-#include <XPath/FunctionRound.hpp>
+#include "FunctionRound.hpp"
#include <PlatformSupport/DoubleSupport.hpp>
+
+
+
+#include "XObjectFactory.hpp"
1.4 +5 -1 xml-xalan/c/src/XPath/FunctionStartsWith.cpp
Index: FunctionStartsWith.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionStartsWith.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- FunctionStartsWith.cpp 2000/11/21 21:08:10 1.3
+++ FunctionStartsWith.cpp 2000/12/04 20:48:16 1.4
@@ -54,7 +54,11 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
-#include <XPath/FunctionStartsWith.hpp>
+#include "FunctionStartsWith.hpp"
+
+
+
+#include "XObjectFactory.hpp"
1.6 +27 -13 xml-xalan/c/src/XPath/FunctionString.cpp
Index: FunctionString.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionString.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- FunctionString.cpp 2000/11/21 22:02:11 1.5
+++ FunctionString.cpp 2000/12/04 20:48:16 1.6
@@ -54,10 +54,18 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
-#include <XPath/FunctionString.hpp>
+#include "FunctionString.hpp"
+#include <DOMSupport/DOMServices.hpp>
+
+
+
+#include "XObjectFactory.hpp"
+
+
+
FunctionString::FunctionString()
{
}
@@ -72,9 +80,9 @@
XObjectPtr
FunctionString::execute(
- XPathExecutionContext& executionContext,
- XalanNode* /* context */,
- const XObjectPtr arg1)
+ XPathExecutionContext& executionContext,
+ XalanNode* /* context */,
+ const XObjectPtr arg1)
{
assert(arg1.null() == false);
@@ -85,23 +93,30 @@
XObjectPtr
FunctionString::execute(
- XPathExecutionContext& executionContext,
- XalanNode* context)
+ XPathExecutionContext& executionContext,
+ XalanNode* context)
{
if (context == 0)
{
executionContext.error("The string() function requires a non-null context node!");
- return XObjectPtr();
+ // Dummy return value...
+ return XObjectPtr(0);
}
else
{
// The XPath standard says that if there are no arguments,
// the argument defaults to a node set with the context node
- // as the only member.
- // So we have to create an XNodeList with the context node as
- // the only member and call the str() function on it.
- return executionContext.getXObjectFactory().createString(executionContext.createNodeSet(*context)->str());
+ // as the only member. The string value of a node set is the
+ // string value of the first node in the node set.
+ // DOMServices::getNodeData() will give us the data.
+
+ // Get a cached string...
+ XPathExecutionContext::GetAndReleaseCachedString theData(executionContext);
+
+ DOMServices::getNodeData(*context, theData);
+
+ return executionContext.getXObjectFactory().createString(theData);
}
}
@@ -122,7 +137,6 @@
const XalanDOMString
FunctionString::getError() const
{
- return XALAN_STATIC_UCODE_STRING(
- "The string() function takes zero or one argument!");
+ return XALAN_STATIC_UCODE_STRING("The string() function takes zero or one argument!");
}
1.4 +29 -28 xml-xalan/c/src/XPath/FunctionStringLength.cpp
Index: FunctionStringLength.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionStringLength.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- FunctionStringLength.cpp 2000/11/21 21:08:15 1.3
+++ FunctionStringLength.cpp 2000/12/04 20:48:16 1.4
@@ -54,10 +54,18 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
-#include <XPath/FunctionStringLength.hpp>
+#include "FunctionStringLength.hpp"
+#include <DOMSupport/DOMServices.hpp>
+
+
+
+#include "XObjectFactory.hpp"
+
+
+
FunctionStringLength::FunctionStringLength()
{
}
@@ -72,49 +80,44 @@
XObjectPtr
FunctionStringLength::execute(
- XPathExecutionContext& executionContext,
- XalanNode* /* context */,
- const XObjectPtr arg1)
+ XPathExecutionContext& executionContext,
+ XalanNode* /* context */,
+ const XObjectPtr arg1)
{
assert(arg1.null() == false);
- unsigned int theLength = length(arg1->str());
-
- return executionContext.getXObjectFactory().createNumber(theLength);
+ return executionContext.getXObjectFactory().createNumber(length(arg1->str()));
}
XObjectPtr
FunctionStringLength::execute(
- XPathExecutionContext& executionContext,
- XalanNode* context)
+ XPathExecutionContext& executionContext,
+ XalanNode* context)
{
- unsigned int theLength = 0;
-
if (context == 0)
{
executionContext.error("The string-length() function requires a non-null context node!");
+
+ // Dummy return value...
+ return XObjectPtr(0);
}
else
{
- XalanDOMString theValue;
-
// The XPath standard says that if there are no arguments,
// the argument defaults to a node set with the context node
- // as the only member.
- // So we have to create an XNodeList with the context node as
- // the only member and call the str() function on it.
-
- // An XObject that contains the context node.
- XObjectPtr theXObject(executionContext.createNodeSet(*context));
-
- // Get the value of the theXObject...
- theValue = theXObject->str();
- theLength = length(theValue);
- }
+ // as the only member. The string value of a node set is the
+ // string value of the first node in the node set.
+ // DOMServices::getNodeData() will give us the data.
+
+ // Get a cached string...
+ XPathExecutionContext::GetAndReleaseCachedString theData(executionContext);
- return executionContext.getXObjectFactory().createNumber(theLength);
+ DOMServices::getNodeData(*context, theData);
+
+ return executionContext.getXObjectFactory().createNumber(length(theData));
+ }
}
@@ -134,7 +137,5 @@
const XalanDOMString
FunctionStringLength::getError() const
{
- return XALAN_STATIC_UCODE_STRING(
- "The string-length() function takes zero or one argument!");
+ return XALAN_STATIC_UCODE_STRING("The string-length() function takes zero or one argument!");
}
-
1.7 +5 -1 xml-xalan/c/src/XPath/FunctionSubstring.cpp
Index: FunctionSubstring.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionSubstring.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- FunctionSubstring.cpp 2000/11/27 21:43:34 1.6
+++ FunctionSubstring.cpp 2000/12/04 20:48:17 1.7
@@ -54,7 +54,11 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
-#include <XPath/FunctionSubstring.hpp>
+#include "FunctionSubstring.hpp"
+
+
+
+#include "XObjectFactory.hpp"
1.7 +5 -1 xml-xalan/c/src/XPath/FunctionSubstringAfter.cpp
Index: FunctionSubstringAfter.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionSubstringAfter.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- FunctionSubstringAfter.cpp 2000/11/27 21:43:36 1.6
+++ FunctionSubstringAfter.cpp 2000/12/04 20:48:17 1.7
@@ -54,7 +54,11 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
-#include <XPath/FunctionSubstringAfter.hpp>
+#include "FunctionSubstringAfter.hpp"
+
+
+
+#include "XObjectFactory.hpp"
1.7 +5 -1 xml-xalan/c/src/XPath/FunctionSubstringBefore.cpp
Index: FunctionSubstringBefore.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionSubstringBefore.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- FunctionSubstringBefore.cpp 2000/11/27 21:43:37 1.6
+++ FunctionSubstringBefore.cpp 2000/12/04 20:48:17 1.7
@@ -54,7 +54,11 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
-#include <XPath/FunctionSubstringBefore.hpp>
+#include "FunctionSubstringBefore.hpp"
+
+
+
+#include "XObjectFactory.hpp"
1.4 +5 -1 xml-xalan/c/src/XPath/FunctionSum.cpp
Index: FunctionSum.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionSum.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- FunctionSum.cpp 2000/11/21 21:08:18 1.3
+++ FunctionSum.cpp 2000/12/04 20:48:17 1.4
@@ -54,7 +54,11 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
-#include <XPath/FunctionSum.hpp>
+#include "FunctionSum.hpp"
+
+
+
+#include "XObjectFactory.hpp"
1.7 +5 -1 xml-xalan/c/src/XPath/FunctionTranslate.cpp
Index: FunctionTranslate.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionTranslate.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- FunctionTranslate.cpp 2000/12/01 22:20:47 1.6
+++ FunctionTranslate.cpp 2000/12/04 20:48:17 1.7
@@ -54,7 +54,11 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
-#include <XPath/FunctionTranslate.hpp>
+#include "FunctionTranslate.hpp"
+
+
+
+#include "XObjectFactory.hpp"
1.4 +5 -1 xml-xalan/c/src/XPath/FunctionTrue.cpp
Index: FunctionTrue.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionTrue.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- FunctionTrue.cpp 2000/11/21 21:08:20 1.3
+++ FunctionTrue.cpp 2000/12/04 20:48:17 1.4
@@ -54,7 +54,11 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
-#include <XPath/FunctionTrue.hpp>
+#include "FunctionTrue.hpp"
+
+
+
+#include "XObjectFactory.hpp"
1.19 +2 -16 xml-xalan/c/src/XPath/XNodeSet.cpp
Index: XNodeSet.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XNodeSet.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- XNodeSet.cpp 2000/11/02 01:46:00 1.18
+++ XNodeSet.cpp 2000/12/04 20:48:17 1.19
@@ -164,25 +164,11 @@
const XalanNode* const theNode = m_value->item(0);
assert(theNode != 0);
- const XalanNode::NodeType theType = theNode->getNodeType();
-
- if (theType == XalanNode::COMMENT_NODE ||
- theType == XalanNode::PROCESSING_INSTRUCTION_NODE)
- {
#if defined(XALAN_NO_MUTABLE)
- ((XNodeSet*)this)->m_cachedStringValue = theNode->getNodeValue();
+ DOMServices::getNodeData(*theNode, ((XNodeSet*)this)->m_cachedStringValue);
#else
- m_cachedStringValue = theNode->getNodeValue();
+ DOMServices::getNodeData(*theNode, m_cachedStringValue);
#endif
- }
- else
- {
-#if defined(XALAN_NO_MUTABLE)
- DOMServices::getNodeData(*theNode, ((XNodeSet*)this)->m_cachedStringValue);
-#else
- DOMServices::getNodeData(*theNode, m_cachedStringValue);
-#endif
- }
}
return m_cachedStringValue;
1.37 +1 -9 xml-xalan/c/src/XPath/XPath.cpp
Index: XPath.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XPath.cpp,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- XPath.cpp 2000/11/27 21:43:43 1.36
+++ XPath.cpp 2000/12/04 20:48:17 1.37
@@ -1095,7 +1095,7 @@
const XObjectPtr
XPath::variable(
- XalanNode* context,
+ XalanNode* /* context */,
int opPos,
XPathExecutionContext& executionContext) const
{
@@ -1120,14 +1120,6 @@
executionContext.error(TranscodeFromLocalCodePage("Could not get variable named ") + varName.str());
throw;
- }
-
- if(result.null() == true)
- {
- executionContext.warn(TranscodeFromLocalCodePage("VariableReference given for variable out ") +
- TranscodeFromLocalCodePage("of context or without definition! Name = ") +
- varName.str(),
- context);
}
return result;
1.29 +17 -1 xml-xalan/c/src/XPath/XPathExecutionContext.hpp
Index: XPathExecutionContext.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathExecutionContext.hpp,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- XPathExecutionContext.hpp 2000/11/21 21:08:35 1.28
+++ XPathExecutionContext.hpp 2000/12/04 20:48:18 1.29
@@ -507,11 +507,27 @@
XalanDOMString&
get() const
{
+ assert(m_string != 0);
+
+ return *m_string;
+ }
+
+ operator XalanDOMString& () const
+ {
+ assert(m_string != 0);
+
return *m_string;
}
private:
+ // Not implemented...
+ GetAndReleaseCachedString&
+ operator=(const GetAndReleaseCachedString&);
+
+ GetAndReleaseCachedString(const GetAndReleaseCachedString&);
+
+
XPathExecutionContext& m_executionContext;
XalanDOMString* const m_string;
@@ -560,7 +576,7 @@
* @return pointer to an XObject if the variable was found, 0 if it was not
*/
virtual const XObjectPtr
- getVariable(const QName& name) const = 0;
+ getVariable(const QName& name) = 0;
/**
* Retrieve the resolver for namespaces.
1.27 +1 -1 xml-xalan/c/src/XPath/XPathExecutionContextDefault.cpp
Index: XPathExecutionContextDefault.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathExecutionContextDefault.cpp,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- XPathExecutionContextDefault.cpp 2000/11/30 19:40:58 1.26
+++ XPathExecutionContextDefault.cpp 2000/12/04 20:48:18 1.27
@@ -448,7 +448,7 @@
const XObjectPtr
-XPathExecutionContextDefault::getVariable(const QName& name) const
+XPathExecutionContextDefault::getVariable(const QName& name)
{
return m_xobjectFactory.createUnknown(name.getLocalPart());
}
1.27 +1 -2 xml-xalan/c/src/XPath/XPathExecutionContextDefault.hpp
Index: XPathExecutionContextDefault.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathExecutionContextDefault.hpp,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- XPathExecutionContextDefault.hpp 2000/11/30 19:40:59 1.26
+++ XPathExecutionContextDefault.hpp 2000/12/04 20:48:18 1.27
@@ -239,8 +239,7 @@
MutableNodeRefList& nodelist);
virtual const XObjectPtr
- getVariable(
- const QName& name) const;
+ getVariable(const QName& name);
virtual const PrefixResolver*
getPrefixResolver() const;
1.25 +14 -5 xml-xalan/c/src/XSLT/ElemLiteralResult.cpp
Index: ElemLiteralResult.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemLiteralResult.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- ElemLiteralResult.cpp 2000/11/27 21:44:22 1.24
+++ ElemLiteralResult.cpp 2000/12/04 20:48:30 1.25
@@ -218,7 +218,7 @@
XalanNode* sourceNode,
const QName& mode) const
{
- executionContext.startElement(toCharArray(getElementName()));
+ executionContext.startElement(c_wstr(getElementName()));
ElemUse::execute(executionContext, sourceTree, sourceNode, mode);
@@ -226,12 +226,16 @@
{
const AVTVectorType::size_type nAttrs = m_avts.size();
+ StylesheetExecutionContext::GetAndReleaseCachedString theGuard1(executionContext);
+ StylesheetExecutionContext::GetAndReleaseCachedString theGuard2(executionContext);
+
+ XalanDOMString& thePrefix = theGuard1.get();
+ XalanDOMString& theStringedValue = theGuard2.get();
+
for(AVTVectorType::size_type i = 0; i < nAttrs; i++)
{
const AVT* const avt = m_avts[i];
- XalanDOMString thePrefix;
-
const XalanDOMString& theName = avt->getName();
if (startsWith(theName, DOMServices::s_XMLNamespaceWithSeparator) == true)
@@ -239,8 +243,10 @@
thePrefix = substring(theName, DOMServices::s_XMLNamespaceWithSeparatorLength);
}
- XalanDOMString theStringedValue;
+ StylesheetExecutionContext::GetAndReleaseCachedString theGuard2(executionContext);
+ XalanDOMString& theStringedValue = theGuard2.get();
+
avt->evaluate(theStringedValue, sourceNode, *this, executionContext);
if (isEmpty(thePrefix) == true ||
@@ -254,6 +260,9 @@
c_wstr(avt->getType()),
length(theStringedValue) == 0 ? &theDummy : c_wstr(theStringedValue));
}
+
+ clear(thePrefix);
+ clear(theStringedValue);
}
}
@@ -261,7 +270,7 @@
executeChildren(executionContext, sourceTree, sourceNode, mode);
- executionContext.endElement(toCharArray(getElementName()));
+ executionContext.endElement(c_wstr(getElementName()));
}
1.8 +1 -1 xml-xalan/c/src/XSLT/ElemParam.cpp
Index: ElemParam.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemParam.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ElemParam.cpp 2000/11/21 21:09:58 1.7
+++ ElemParam.cpp 2000/12/04 20:48:33 1.8
@@ -98,7 +98,7 @@
{
const XObjectPtr obj = executionContext.getParamVariable(m_qname);
- if(obj.null() == true)
+ if (obj.null() == true)
{
ElemVariable::execute(executionContext, sourceTree, sourceNode, mode);
}
1.11 +33 -15 xml-xalan/c/src/XSLT/ElemVariable.cpp
Index: ElemVariable.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemVariable.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- ElemVariable.cpp 2000/11/27 21:44:35 1.10
+++ ElemVariable.cpp 2000/12/04 20:48:33 1.11
@@ -155,14 +155,39 @@
{
ElemTemplateElement::execute(executionContext, sourceTree, sourceNode, mode);
- if(0 != m_selectPattern)
+ const XObjectPtr theValue(getValue(executionContext, sourceTree, sourceNode));
+
+ if (theValue.null() == false)
+ {
+ executionContext.pushVariable(
+ m_qname,
+ theValue,
+ getParentNodeElem());
+ }
+ else
{
executionContext.pushVariable(
m_qname,
- getParentNodeElem(),
- *m_selectPattern,
- sourceNode,
- *this);
+ this,
+ getParentNodeElem());
+ }
+}
+
+
+
+const XObjectPtr
+ElemVariable::getValue(
+ StylesheetExecutionContext& executionContext,
+ XalanNode* sourceTree,
+ XalanNode* sourceNode) const
+{
+ if(m_selectPattern == 0)
+ {
+ return executionContext.createXResultTreeFrag(*this, sourceTree, sourceNode);
+ }
+ else
+ {
+ const XObjectPtr theValue(m_selectPattern->execute(sourceNode, *this, executionContext));
if(0 != executionContext.getTraceListeners())
{
@@ -173,16 +198,9 @@
*this,
StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("select")),
*m_selectPattern,
- executionContext.getVariable(m_qname)));
+ theValue));
}
- }
- else
- {
- executionContext.pushVariable(
- m_qname,
- getParentNodeElem(),
- *this,
- sourceTree,
- sourceNode);
+
+ return theValue;
}
}
1.10 +7 -1 xml-xalan/c/src/XSLT/ElemVariable.hpp
Index: ElemVariable.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemVariable.hpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- ElemVariable.hpp 2000/11/27 21:44:37 1.9
+++ ElemVariable.hpp 2000/12/04 20:48:33 1.10
@@ -58,7 +58,7 @@
#define XALAN_ELEMVARIABLE_HEADER_GUARD
/**
- * $Id: ElemVariable.hpp,v 1.9 2000/11/27 21:44:37 dbertoni Exp $
+ * $Id: ElemVariable.hpp,v 1.10 2000/12/04 20:48:33 dbertoni Exp $
*
* $State: Exp $
*
@@ -150,6 +150,12 @@
XalanNode* sourceTree,
XalanNode* sourceNode,
const QName& mode) const;
+
+ const XObjectPtr
+ getValue(
+ StylesheetExecutionContext& executionContext,
+ XalanNode* sourceTree,
+ XalanNode* sourceNode) const;
protected:
1.21 +1 -0 xml-xalan/c/src/XSLT/FunctionDocument.cpp
Index: FunctionDocument.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/FunctionDocument.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- FunctionDocument.cpp 2000/11/21 22:42:39 1.20
+++ FunctionDocument.cpp 2000/12/04 20:48:33 1.21
@@ -71,6 +71,7 @@
+#include <XPath/XObjectFactory.hpp>
#include <XPath/PrefixResolver.hpp>
1.10 +13 -2 xml-xalan/c/src/XSLT/FunctionElementAvailable.cpp
Index: FunctionElementAvailable.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/FunctionElementAvailable.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- FunctionElementAvailable.cpp 2000/11/27 21:44:46 1.9
+++ FunctionElementAvailable.cpp 2000/12/04 20:48:33 1.10
@@ -62,6 +62,10 @@
+#include <XPath/XObjectFactory.hpp>
+
+
+
FunctionElementAvailable::FunctionElementAvailable()
{
}
@@ -97,9 +101,16 @@
}
else
{
- const XalanDOMString elementName = indexOfNSSep == nameLength ? fullName : substring(fullName, indexOfNSSep + 1);
+ if (indexOfNSSep == nameLength)
+ {
+ return executionContext.getXObjectFactory().createBoolean(executionContext.elementAvailable(theNamespace, fullName));
+ }
+ else
+ {
+ const XalanDOMString elementName = substring(fullName, indexOfNSSep + 1);
- return executionContext.getXObjectFactory().createBoolean(executionContext.elementAvailable(theNamespace, elementName));
+ return executionContext.getXObjectFactory().createBoolean(executionContext.elementAvailable(theNamespace, elementName));
+ }
}
}
1.9 +4 -0 xml-xalan/c/src/XSLT/FunctionFormatNumber.cpp
Index: FunctionFormatNumber.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/FunctionFormatNumber.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- FunctionFormatNumber.cpp 2000/11/21 21:10:08 1.8
+++ FunctionFormatNumber.cpp 2000/12/04 20:48:33 1.9
@@ -65,6 +65,10 @@
+#include <XPath/XObjectFactory.hpp>
+
+
+
#include "Constants.hpp"
1.9 +5 -1 xml-xalan/c/src/XSLT/FunctionFunctionAvailable.cpp
Index: FunctionFunctionAvailable.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/FunctionFunctionAvailable.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- FunctionFunctionAvailable.cpp 2000/11/21 21:10:09 1.8
+++ FunctionFunctionAvailable.cpp 2000/12/04 20:48:34 1.9
@@ -62,6 +62,10 @@
+#include <XPath/XObjectFactory.hpp>
+
+
+
FunctionFunctionAvailable::FunctionFunctionAvailable()
{
}
@@ -89,7 +93,7 @@
const XalanDOMString prefix = indexOfNSSep < nameLength ? substring(fullName, 0, indexOfNSSep) : XalanDOMString();
- const XalanDOMString theNamespace = executionContext.getNamespaceForPrefix(prefix);
+ const XalanDOMString& theNamespace = executionContext.getNamespaceForPrefix(prefix);
const XalanDOMString functionName = indexOfNSSep == nameLength ? fullName : substring(fullName, indexOfNSSep + 1);
1.10 +6 -2 xml-xalan/c/src/XSLT/FunctionGenerateID.cpp
Index: FunctionGenerateID.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/FunctionGenerateID.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- FunctionGenerateID.cpp 2000/11/21 22:42:40 1.9
+++ FunctionGenerateID.cpp 2000/12/04 20:48:34 1.10
@@ -67,6 +67,7 @@
#include <XPath/NodeRefListBase.hpp>
+#include <XPath/XObjectFactory.hpp>
@@ -89,6 +90,7 @@
+// Append the suffix to the provided string.
void
getSuffix(
const XalanNode* theNode,
@@ -153,13 +155,15 @@
XalanDOMString& theID = theGuard.get();
+#if defined(XALAN_USE_XERCES_DOMSTRING)
getSuffix(context, theID);
assert(length(theID) != 0);
-#if defined(XALAN_USE_XERCES_DOMSTRING)
return executionContext.getXObjectFactory().createString(m_prefix + theID);
#else
- insert(theID, 0, m_prefix);
+ theID = m_prefix;
+
+ getSuffix(context, theID);
return executionContext.getXObjectFactory().createString(theID);
#endif
1.18 +8 -3 xml-xalan/c/src/XSLT/FunctionKey.cpp
Index: FunctionKey.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/FunctionKey.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- FunctionKey.cpp 2000/11/21 22:42:40 1.17
+++ FunctionKey.cpp 2000/12/04 20:48:34 1.18
@@ -78,6 +78,7 @@
#include <XPath/MutableNodeRefList.hpp>
#include <XPath/NodeRefListBase.hpp>
+#include <XPath/XObjectFactory.hpp>
@@ -135,7 +136,7 @@
assert(executionContext.getPrefixResolver() != 0);
- const XalanDOMString keyname = arg1->str();
+ const XalanDOMString& keyname = arg1->str();
assert(arg2.null() == false);
@@ -163,11 +164,13 @@
StringSetType usedrefs;
+ XalanDOMString ref;
+
for(unsigned int i = 0; i < nRefs; i++)
{
assert(theNodeSet.item(i) != 0);
- const XalanDOMString ref = DOMServices::getNodeData(*theNodeSet.item(i));
+ DOMServices::getNodeData(*theNodeSet.item(i), ref);
if(0 != length(ref))
{
@@ -184,12 +187,14 @@
*theNodeRefList.get());
}
}
+
+ clear(ref);
}
}
}
else
{
- const XalanDOMString ref = arg2->str();
+ const XalanDOMString& ref = arg2->str();
executionContext.getNodeSetByKey(docContext,
keyname,
1.15 +1 -0 xml-xalan/c/src/XSLT/FunctionSystemProperty.cpp
Index: FunctionSystemProperty.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/FunctionSystemProperty.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- FunctionSystemProperty.cpp 2000/11/21 21:10:14 1.14
+++ FunctionSystemProperty.cpp 2000/12/04 20:48:34 1.15
@@ -69,6 +69,7 @@
#include <XPath/MutableNodeRefList.hpp>
#include <XPath/NodeRefListBase.hpp>
+#include <XPath/XObjectFactory.hpp>
1.11 +4 -0 xml-xalan/c/src/XSLT/FunctionUnparsedEntityURI.cpp
Index: FunctionUnparsedEntityURI.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/FunctionUnparsedEntityURI.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- FunctionUnparsedEntityURI.cpp 2000/11/21 22:42:40 1.10
+++ FunctionUnparsedEntityURI.cpp 2000/12/04 20:48:34 1.11
@@ -63,6 +63,10 @@
+#include <XPath/XObjectFactory.hpp>
+
+
+
FunctionUnparsedEntityURI::FunctionUnparsedEntityURI()
{
}
1.14 +92 -87 xml-xalan/c/src/XSLT/KeyTable.cpp
Index: KeyTable.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/KeyTable.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- KeyTable.cpp 2000/11/21 21:10:16 1.13
+++ KeyTable.cpp 2000/12/04 20:48:35 1.14
@@ -138,101 +138,39 @@
{
const KeyDeclaration& kd = keyDeclarations[i];
-// if (equals(kd.getName(), name))
+ if (executionContext.getInConstruction(kd) == true)
{
- if (executionContext.getInConstruction(kd) == true)
- {
- throw XSLTProcessorException(
+ throw XSLTProcessorException(
TranscodeFromLocalCodePage("The use of the key() function in the \"match\" or \"use\" attribute of xsl:key is illegal!"),
TranscodeFromLocalCodePage("XSLTKeyIllegalKeyFunctionException"));
- }
- else
- {
- executionContext.beginConstruction(kd);
+ }
+ else
+ {
+ executionContext.beginConstruction(kd);
- // See if our node matches the given key declaration according to
- // the match attribute on xsl:key.
- assert(kd.getMatchPattern() != 0);
+ // See if our node matches the given key declaration according to
+ // the match attribute on xsl:key.
+ assert(kd.getMatchPattern() != 0);
- const double score =
+ const double score =
kd.getMatchPattern()->getMatchScore(testNode,
resolver,
executionContext);
- if(score == XPath::s_MatchScoreNone)
- {
- executionContext.endConstruction(kd);
- }
- else
- {
- // Query from the node, according the the select pattern in the
- // use attribute in xsl:key.
- assert(kd.getUse() != 0);
-
- const XObjectPtr xuse =
- kd.getUse()->execute(testNode, resolver, NodeRefList(), executionContext);
-
- const NodeRefListBase* nl = 0;
- unsigned int nUseValues;
- XalanDOMString exprResult;
- if(xuse->getType() != xuse->eTypeNodeSet)
- {
- nUseValues = 1;
- exprResult = xuse->str();
- }
- else
- {
- nl = &xuse->nodeset();
- // Use each node in the node list as a key value that we'll be
- // able to use to look up the given node.
- nUseValues = nl->getLength();
- }
- // Use each node in the node list as a key value that we'll be
- // able to use to look up the given node.
- for(unsigned int k = 0; k < nUseValues; k++)
- {
- // Use getExpr to get the string value of the given node. I hope
- // the string assumption is the right thing... I can't see how
- // it could work any other way.
- if(0 != nl)
- {
- XalanNode* const useNode = nl->item(k);
- assert(useNode != 0);
-
- exprResult = DOMServices::getNodeData(*useNode);
- }
-
- MutableNodeRefList& keyNodes =
- m_keys[kd.getName()][exprResult];
-
- // See if the matched node is already in the
- // table set. If it is there, we're done, otherwise
- // add it.
- bool foundit = false;
-
- const unsigned int nKeyNodes = keyNodes.getLength(); //size();
-
- for(unsigned int j = 0; j < nKeyNodes; j++)
- {
- if(testNode == keyNodes.item(j))
- {
- foundit = true;
- break;
- }
- } // end for j
-
- if(foundit == false)
- {
- keyNodes.addNode(testNode);
- }
- } // end for(int k = 0; k < nUseValues; k++)
-
- executionContext.endConstruction(kd);
- } // if(score != kd.getMatchPattern().s_MatchScoreNone)
- } // if (kd.getInConstruction() == true)
- } // if (equals(kd.getName(), name)
- } // end for(int i = 0; i < nDeclarations; i++)
+ if(score != XPath::s_MatchScoreNone)
+ {
+ processKeyDeclaration(
+ m_keys,
+ kd,
+ testNode,
+ resolver,
+ executionContext);
+ }
+ executionContext.endConstruction(kd);
+ } // if (kd.getInConstruction() == true)
+ } // end for(int i = 0; i < nDeclarations; ++i)
+
nodeIndex++;
if(0 != attrs)
@@ -270,7 +208,7 @@
pos = nextNode;
} // while(0 != pos)
-} // end buildKeysTable method
+} // end constructor
@@ -289,7 +227,7 @@
if (i != m_keys.end())
{
- const NodeListMapType& theMap = (*i).second;
+ const NodeListMapType& theMap = (*i).second;
const NodeListMapType::const_iterator j = theMap.find(ref);
@@ -303,4 +241,71 @@
// a list of nodes. So this is just an empty one
// to return when the ref is not found.
return s_dummyList;
+}
+
+
+
+void
+KeyTable::addIfNotFound(
+ MutableNodeRefList& theNodeList,
+ XalanNode* theNode)
+{
+ if (theNodeList.indexOf(theNode) == MutableNodeRefList::npos)
+ {
+ theNodeList.addNode(theNode);
+ }
+}
+
+
+
+void
+KeyTable::processKeyDeclaration(
+ KeysMapType& theKeys,
+ const KeyDeclaration& kd,
+ XalanNode* testNode,
+ const PrefixResolver& resolver,
+ StylesheetExecutionContext& executionContext)
+{
+ // Query from the node, according the the select pattern in the
+ // use attribute in xsl:key.
+ assert(kd.getUse() != 0);
+
+ const XObjectPtr xuse =
+ kd.getUse()->execute(testNode, resolver, NodeRefList(), executionContext);
+
+ if(xuse->getType() != xuse->eTypeNodeSet)
+ {
+ addIfNotFound(
+ theKeys[kd.getName()][xuse->str()],
+ testNode);
+ }
+ else
+ {
+ const NodeRefListBase& nl = xuse->nodeset();
+
+ // Use each node in the node list as a key value that we'll be
+ // able to use to look up the given node.
+ const unsigned int nUseValues = nl.getLength();
+
+ StylesheetExecutionContext::GetAndReleaseCachedString theGuard(executionContext);
+
+ XalanDOMString& nodeData = theGuard.get();
+
+ // Use each node in the node list as a key value that we'll be
+ // able to use to look up the given node.
+ for(unsigned int i = 0; i < nUseValues; ++i)
+ {
+ // Get the string value of the node to use as the result of the
+ // expression.
+ assert(nl.item(i) != 0);
+
+ DOMServices::getNodeData(*nl.item(i), nodeData);
+
+ addIfNotFound(
+ theKeys[kd.getName()][nodeData],
+ testNode);
+
+ clear(nodeData);
+ }
+ }
}
1.10 +20 -1 xml-xalan/c/src/XSLT/KeyTable.hpp
Index: KeyTable.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/KeyTable.hpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- KeyTable.hpp 2000/09/19 15:12:01 1.9
+++ KeyTable.hpp 2000/12/04 20:48:35 1.10
@@ -58,7 +58,7 @@
#define XALAN_KEYTABLE_HEADER_GUARD
/**
- * $Id: KeyTable.hpp,v 1.9 2000/09/19 15:12:01 dbertoni Exp $
+ * $Id: KeyTable.hpp,v 1.10 2000/12/04 20:48:35 dbertoni Exp $
*
* $State: Exp $
*
@@ -177,6 +177,25 @@
}
private:
+
+ /**
+ * Helper function to add a node to the list if not found.
+ *
+ * @param theNodeList the node list.
+ * @param theNode the node to add.
+ */
+ static void
+ addIfNotFound(
+ MutableNodeRefList& theNodeList,
+ XalanNode* theNode);
+
+ static void
+ processKeyDeclaration(
+ KeysMapType& theKeys,
+ const KeyDeclaration& kd,
+ XalanNode* testNode,
+ const PrefixResolver& resolver,
+ StylesheetExecutionContext& executionContext);
/**
* The document key. This table should only be used with contexts
1.45 +33 -22 xml-xalan/c/src/XSLT/Stylesheet.cpp
Index: Stylesheet.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/Stylesheet.cpp,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -r1.44 -r1.45
--- Stylesheet.cpp 2000/12/01 21:02:54 1.44
+++ Stylesheet.cpp 2000/12/04 20:48:35 1.45
@@ -1063,10 +1063,36 @@
StylesheetExecutionContext& executionContext,
const ParamVectorType& topLevelParams) const
{
- ParamVectorType::size_type i = 0;
+#if 1
+ {
+ // First, push any imports...
+ const StylesheetVectorType::const_reverse_iterator rend = m_imports.rend();
+
+ for(StylesheetVectorType::const_reverse_iterator i = m_imports.rbegin(); i != rend; ++i)
+ {
+ const Stylesheet* const stylesheet = *i;
+ assert(stylesheet != 0);
+
+ stylesheet->pushTopLevelVariables(executionContext, topLevelParams);
+ }
+ }
+#else
+ {
+ // First, push any imports...
+ const StylesheetVectorType::const_reverse_iterator nImports = m_imports.size();
+
+ for(StylesheetVectorType::size_type i = 0; i < nImports; ++i)
+ {
+ const Stylesheet* const stylesheet = m_imports[i];
+
+ stylesheet->pushTopLevelVariables(executionContext, topLevelParams);
+ }
+ }
+#endif
+
const ParamVectorType::size_type nVars = m_topLevelVariables.size();
- for(; i < nVars; i++)
+ for(ParamVectorType::size_type i = 0; i < nVars; ++i)
{
ElemVariable* const var = m_topLevelVariables[i];
@@ -1087,12 +1113,10 @@
{
isParam = true;
- const XObjectPtr theXObject = arg.getXObject();
-
- if (theXObject.null() == false)
+ if (arg.getXObject().null() == false)
{
executionContext.pushVariable(arg.getName(),
- theXObject,
+ arg.getXObject(),
0);
}
else
@@ -1111,25 +1135,12 @@
if (isParam == false)
{
- XalanNode* const doc = executionContext.getRootDocument();
- assert(doc != 0);
-
- var->execute(executionContext,
- doc,
- doc,
- QNameByReference());
+ executionContext.pushVariable(var->getName(),
+ var,
+ var->getParentNodeElem());
}
}
- // Now, push any imports...
- const ParamVectorType::size_type nImports = m_imports.size();
-
- for(i = 0; i < nImports; i++)
- {
- const Stylesheet* const stylesheet = m_imports[i];
-
- stylesheet->pushTopLevelVariables(executionContext, topLevelParams);
- }
}
1.39 +20 -4 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.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- StylesheetExecutionContext.hpp 2000/11/30 20:34:12 1.38
+++ StylesheetExecutionContext.hpp 2000/12/04 20:48:35 1.39
@@ -119,6 +119,7 @@
class ElemTemplateElement;
+class ElemVariable;
class FormatterListener;
class FormatterToDOM;
class FormatterToHTML;
@@ -592,16 +593,31 @@
XalanNode* sourceNode) = 0;
/**
+ * Push a named variable onto the variables stack.
+ * The variable has already been evaluated.
+ *
+ * @param name name of variable
+ * @param val pointer to XObject value
+ * @param element element marker for variable
+ */
+ virtual void
+ pushVariable(
+ const QName& name,
+ const XObjectPtr val,
+ const ElemTemplateElement* element) = 0;
+
+ /**
* Push a named variable onto the processor variable stack
+ * The variable will be evaluated when first referenced.
*
* @param name name of variable
- * @param var pointer to XObject value
+ * @param var pointer to ElemVariable instance
* @param element element marker for variable
*/
virtual void
pushVariable(
const QName& name,
- const XObjectPtr var,
+ const ElemVariable* var,
const ElemTemplateElement* element) = 0;
/**
@@ -655,7 +671,7 @@
* @return pointer to XObject for variable
*/
virtual const XObjectPtr
- getParamVariable(const QName& theName) const = 0;
+ getParamVariable(const QName& theName) = 0;
/**
* Push a frame marker for an element.
@@ -1438,7 +1454,7 @@
MutableNodeRefList& nodelist) = 0;
virtual const XObjectPtr
- getVariable(const QName& name) const = 0;
+ getVariable(const QName& name) = 0;
virtual const PrefixResolver*
getPrefixResolver() const = 0;
1.43 +31 -5 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.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- StylesheetExecutionContextDefault.cpp 2000/11/27 21:44:52 1.42
+++ StylesheetExecutionContextDefault.cpp 2000/12/04 20:48:35 1.43
@@ -500,9 +500,20 @@
void
StylesheetExecutionContextDefault::pushVariable(
const QName& name,
- const XObjectPtr var,
+ const XObjectPtr val,
const ElemTemplateElement* element)
{
+ m_variablesStack.pushVariable(name, val, element);
+}
+
+
+
+void
+StylesheetExecutionContextDefault::pushVariable(
+ const QName& name,
+ const ElemVariable* var,
+ const ElemTemplateElement* element)
+{
m_variablesStack.pushVariable(name, var, element);
}
@@ -673,9 +684,13 @@
const XObjectPtr
-StylesheetExecutionContextDefault::getParamVariable(const QName& theName) const
+StylesheetExecutionContextDefault::getParamVariable(const QName& theName)
{
- return m_variablesStack.getParamVariable(theName);
+ bool fFound;
+
+ const XObjectPtr theValue(m_variablesStack.getParamVariable(theName, *this, fFound));
+
+ return theValue;
}
@@ -1545,9 +1560,20 @@
const XObjectPtr
-StylesheetExecutionContextDefault::getVariable(const QName& name) const
+StylesheetExecutionContextDefault::getVariable(const QName& name)
{
- return m_variablesStack.getVariable(name);
+ bool fFound;
+
+ const XObjectPtr theValue(m_variablesStack.getVariable(name, *this, fFound));
+
+ if(fFound == false)
+ {
+ warn(
+ TranscodeFromLocalCodePage("Variable reference given for variable out of context or without definition! Name = ") +
+ name.getLocalPart());
+ }
+
+ return theValue;
}
1.40 +11 -5 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.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- StylesheetExecutionContextDefault.hpp 2000/11/27 21:44:55 1.39
+++ StylesheetExecutionContextDefault.hpp 2000/12/04 20:48:35 1.40
@@ -62,7 +62,6 @@
// Base class include file.
-#include "Stylesheet.hpp"
#include "StylesheetExecutionContext.hpp"
@@ -79,10 +78,11 @@
+#include <XSLT/Stylesheet.hpp>
#include <XSLT/VariablesStack.hpp>
-class Stylesheet;
+
class XPathProcessor;
class XPathSupport;
class XObjectFactory;
@@ -264,8 +264,14 @@
virtual void
pushVariable(
+ const QName& name,
+ const XObjectPtr val,
+ const ElemTemplateElement* element);
+
+ virtual void
+ pushVariable(
const QName& name,
- const XObjectPtr var,
+ const ElemVariable* var,
const ElemTemplateElement* element);
virtual void
@@ -305,7 +311,7 @@
const ElemTemplateElement* targetTemplate);
virtual const XObjectPtr
- getParamVariable(const QName& theName) const;
+ getParamVariable(const QName& theName);
virtual void
pushElementFrame(const ElemTemplateElement* elem);
@@ -678,7 +684,7 @@
MutableNodeRefList& nodelist);
virtual const XObjectPtr
- getVariable(const QName& name) const;
+ getVariable(const QName& name);
virtual const PrefixResolver*
getPrefixResolver() const;
1.9 +142 -64 xml-xalan/c/src/XSLT/VariablesStack.cpp
Index: VariablesStack.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/VariablesStack.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- VariablesStack.cpp 2000/11/27 21:45:01 1.8
+++ VariablesStack.cpp 2000/12/04 20:48:35 1.9
@@ -66,11 +66,17 @@
+#include "ElemVariable.hpp"
+#include "StylesheetExecutionContext.hpp"
+
+
+
VariablesStack::VariablesStack() :
m_stack(),
m_globalStackFrameIndex(-1),
m_globalStackFrameMarked(false),
- m_currentStackFrameIndex(0)
+ m_currentStackFrameIndex(0),
+ m_forceGlobalOnlySearch(false)
{
m_stack.reserve(eDefaultStackSize);
}
@@ -156,33 +162,6 @@
-class PopPushStackEntry
-{
-public:
-
- PopPushStackEntry(VariablesStack& theVariablesStack) :
- m_variablesStack(theVariablesStack),
- m_stackEntry(theVariablesStack.back())
- {
- assert(m_stackEntry.getType() == VariablesStack::StackEntry::eContextMarker);
-
- theVariablesStack.pop();
- }
-
- ~PopPushStackEntry()
- {
- m_variablesStack.push(m_stackEntry);
- }
-
-private:
-
- VariablesStack& m_variablesStack;
-
- const VariablesStack::StackEntry m_stackEntry;
-};
-
-
-
class CommitPushElementFrame
{
public:
@@ -212,9 +191,9 @@
private:
- VariablesStack* m_variableStack;
+ VariablesStack* m_variableStack;
- const ElemTemplateElement* const m_targetTemplate;
+ const ElemTemplateElement* const m_targetTemplate;
};
@@ -261,9 +240,18 @@
const void
VariablesStack::PushParamFunctor::operator()(const VariablesStack::ParamsVectorType::value_type& theEntry)
{
- assert(theEntry.first != 0);
+ assert(theEntry.m_qname != 0);
- m_variablesStack.push(VariablesStack::StackEntry(theEntry.first, theEntry.second));
+ if (theEntry.m_value.null() == false)
+ {
+ m_variablesStack.push(VariablesStack::StackEntry(theEntry.m_qname, theEntry.m_value));
+ }
+ else
+ {
+ assert(theEntry.m_variable != 0);
+
+ m_variablesStack.push(VariablesStack::StackEntry(theEntry.m_qname, theEntry.m_variable));
+ }
}
@@ -297,6 +285,22 @@
void
VariablesStack::pushVariable(
const QName& name,
+ const ElemVariable* var,
+ const ElemTemplateElement* e)
+{
+ if(elementFrameAlreadyPushed(e) == false)
+ {
+ pushElementFrame(e);
+ }
+
+ push(StackEntry(&name, var));
+}
+
+
+
+void
+VariablesStack::pushVariable(
+ const QName& name,
const XObjectPtr val,
const ElemTemplateElement* e)
{
@@ -329,60 +333,113 @@
+class SetAndRestoreForceGlobalSearch
+{
+public:
+
+ SetAndRestoreForceGlobalSearch(VariablesStack& variablesStack) :
+ m_variablesStack(variablesStack),
+ m_savedForceSearch(variablesStack.m_forceGlobalOnlySearch)
+ {
+ variablesStack.m_forceGlobalOnlySearch = true;
+ }
+
+ ~SetAndRestoreForceGlobalSearch()
+ {
+ m_variablesStack.m_forceGlobalOnlySearch = m_savedForceSearch;
+ }
+
+private:
+
+ VariablesStack& m_variablesStack;
+
+ const bool m_savedForceSearch;
+};
+
+
+
const XObjectPtr
VariablesStack::findXObject(
- const QName& name,
- bool fSearchGlobalSpace) const
+ const QName& name,
+ StylesheetExecutionContext& executionContext,
+ bool fSearchGlobalSpace,
+ bool& fNameFound)
{
- const StackEntry* const theVariable =
- findVariable(name, fSearchGlobalSpace);
+ StackEntry* const theEntry =
+ findEntry(name, fSearchGlobalSpace);
- if (theVariable == 0)
+ if (theEntry == 0)
{
+ fNameFound = false;
+
return XObjectPtr();
}
else
{
- assert(theVariable->getType() == StackEntry::eVariable);
+ fNameFound = true;
+
+ assert(theEntry->getType() == StackEntry::eVariable);
+
+ XObjectPtr theValue(theEntry->getValue());
+
+ if (theValue.null() == true)
+ {
+ const ElemVariable* const var = theEntry->getVariable();
+
+ if (var != 0)
+ {
+ XalanNode* const doc = executionContext.getRootDocument();
+ assert(doc != 0);
+
+ SetAndRestoreForceGlobalSearch theGuard(*this);
+
+ theValue = var->getValue(executionContext, doc, doc);
+ assert(theValue.null() == false);
- return theVariable->getVariable();
+ theEntry->setValue(theValue);
+ }
+ }
+
+ return theValue;
}
}
-const VariablesStack::StackEntry*
-VariablesStack::findVariable(
+VariablesStack::StackEntry*
+VariablesStack::findEntry(
const QName& qname,
- bool fSearchGlobalSpace) const
+ bool fSearchGlobalSpace)
{
- const StackEntry* theResult = 0;
+ StackEntry* theResult = 0;
- const unsigned int nElems = getCurrentStackFrameIndex();
-
- // There is guaranteed to be a context marker at
- // the bottom of the stack, so i should stop at
- // 1.
- for(unsigned int i = nElems - 1; i > 0; --i)
+ if (m_forceGlobalOnlySearch == false)
{
- const StackEntry& theEntry =
- m_stack[i];
+ const unsigned int nElems = getCurrentStackFrameIndex();
- if(theEntry.getType() == StackEntry::eVariable)
+ // There is guaranteed to be a context marker at
+ // the bottom of the stack, so i should stop at
+ // 1.
+ for(unsigned int i = nElems - 1; i > 0; --i)
{
- assert(theEntry.getName() != 0);
+ StackEntry& theEntry = m_stack[i];
- if(theEntry.getName()->equals(qname))
+ if(theEntry.getType() == StackEntry::eVariable)
{
- theResult = &theEntry;
+ assert(theEntry.getName() != 0);
+
+ if(theEntry.getName()->equals(qname))
+ {
+ theResult = &theEntry;
+ break;
+ }
+ }
+ else if(theEntry.getType() == StackEntry::eContextMarker)
+ {
break;
}
}
- else if(theEntry.getType() == StackEntry::eContextMarker)
- {
- break;
- }
}
if(0 == theResult && true == fSearchGlobalSpace && m_globalStackFrameIndex > 1)
@@ -390,7 +447,7 @@
// Look in the global space
for(unsigned int i = m_globalStackFrameIndex - 1; i > 0; i--)
{
- const StackEntry& theEntry = m_stack[i];
+ StackEntry& theEntry = m_stack[i];
if(theEntry.getType() == StackEntry::eVariable)
{
@@ -494,6 +551,20 @@
m_type(eVariable),
m_qname(name),
m_value(val),
+ m_variable(0),
+ m_element(0)
+{
+}
+
+
+
+VariablesStack::StackEntry::StackEntry(
+ const QName* name,
+ const ElemVariable* var) :
+ m_type(eVariable),
+ m_qname(name),
+ m_value(),
+ m_variable(var),
m_element(0)
{
}
@@ -504,6 +575,7 @@
m_type(eElementFrameMarker),
m_qname(0),
m_value(),
+ m_variable(0),
m_element(elem)
{
}
@@ -514,6 +586,7 @@
m_type(theSource.m_type),
m_qname(0),
m_value(),
+ m_variable(0),
m_element(0)
{
// Use operator=() to do the work...
@@ -539,15 +612,19 @@
m_value = theRHS.m_value;
+ m_variable = theRHS.m_variable;
+
m_element = 0;
}
else if (m_type == eElementFrameMarker)
{
- m_element = theRHS.m_element;
-
m_qname = 0;
m_value = XObjectPtr();
+
+ m_variable = 0;
+
+ m_element = theRHS.m_element;
}
return *this;
@@ -573,8 +650,9 @@
}
else if (m_type == eVariable)
{
- // We only need to compare the variable pointer..
- if (m_value == theRHS.m_value)
+ // We only need to compare the variable related members...
+ if (m_value == theRHS.m_value ||
+ m_variable == theRHS.m_variable)
{
fResult = true;
}
1.7 +119 -23 xml-xalan/c/src/XSLT/VariablesStack.hpp
Index: VariablesStack.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/VariablesStack.hpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- VariablesStack.hpp 2000/11/27 21:45:03 1.6
+++ VariablesStack.hpp 2000/12/04 20:48:35 1.7
@@ -80,6 +80,7 @@
class Arg;
class ElemTemplateElement;
+class ElemVariable;
class StylesheetExecutionContext;
class XalanNode;
@@ -139,10 +140,44 @@
void
popContextMarker();
+ struct ParamsVectorEntry
+ {
+ ParamsVectorEntry() :
+ m_qname(0),
+ m_value(),
+ m_variable(0)
+ {
+ }
+
+ ParamsVectorEntry(
+ const QName* qname,
+ const XObjectPtr value) :
+ m_qname(qname),
+ m_value(value),
+ m_variable(0)
+ {
+ }
+
+ ParamsVectorEntry(
+ const QName* qname,
+ const ElemVariable* variable) :
+ m_qname(qname),
+ m_value(),
+ m_variable(variable)
+ {
+ }
+
+ const QName* m_qname;
+
+ XObjectPtr m_value;
+
+ const ElemVariable* m_variable;
+ };
+
#if defined(XALAN_NO_NAMESPACES)
- typedef vector<pair<const QName*, XObjectPtr> > ParamsVectorType;
+ typedef vector<ParamsVectorEntry> ParamsVectorType;
#else
- typedef std::vector<std::pair<const QName*, XObjectPtr> > ParamsVectorType;
+ typedef std::vector<ParamsVectorEntry> ParamsVectorType;
#endif
/**
@@ -159,33 +194,60 @@
/**
* Given a name, return a string representing the value, but don't look
- * in the global space.
+ * in the global space. Since the variable may not yet have been
+ * evaluated, this may return a null XObjectPtr.
*
* @param theName name of variable
+ * @param exeuctionContext the current execution context
+ * @param fNameFound set to true if the name was found, false if not.
* @return pointer to XObject for variable
*/
const XObjectPtr
- getParamVariable(const QName& qname) const
+ getParamVariable(
+ const QName& qname,
+ StylesheetExecutionContext& executionContext,
+ bool& fNameFound)
{
- return findXObject(qname, false);
+ return findXObject(qname, executionContext, false, fNameFound);
}
/**
- * Given a name, find the corresponding XObject.
+ * Given a name, find the corresponding XObject. Since the variable may
+ * not yet have been evaluated, this may return a null XObjectPtr.
*
* @param qname name of variable
+ * @param exeuctionContext the current execution context
+ * @param fNameFound set to true if the name was found, false if not.
* @return pointer to the corresponding XObject
*/
const XObjectPtr
- getVariable(const QName& name) const
+ getVariable(
+ const QName& qname,
+ StylesheetExecutionContext& executionContext,
+ bool& fNameFound)
{
- return findXObject(name, true);
+ return findXObject(qname, executionContext, true, fNameFound);
}
/**
* Push a named variable onto the processor variable stack. Don't forget
+ * to call startContext before pushing a series of arguments for a given
+ * template.
+ *
+ * @param name name of variable
+ * @param val pointer to ElemVariable
+ * @param e element marker for variable
+ */
+ void
+ pushVariable(
+ const QName& name,
+ const ElemVariable* var,
+ const ElemTemplateElement* e);
+
+ /**
+ * Push a named variable onto the processor variable stack. Don't forget
* to call startContext before pushing a series of arguments for a given
- * macro call.
+ * template.
*
* @param name name of variable
* @param val pointer to XObject value
@@ -264,7 +326,7 @@
private:
- VariablesStack& m_variablesStack;
+ VariablesStack& m_variablesStack;
};
private:
@@ -310,9 +372,8 @@
friend class CommitPushElementFrame;
friend class EnsurePop;
- friend class PopPushStackEntry;
- friend class PushFunctor;
friend class PushParamFunctor;
+ friend class SetAndRestoreForceGlobalSearch;
class StackEntry
{
@@ -334,13 +395,20 @@
StackEntry();
/**
- * Construct a variable.
+ * Construct a variable that is already evaluated.
*/
StackEntry(
const QName* name,
const XObjectPtr val);
/**
+ * Construct a variable that has not been evaluated yet.
+ */
+ StackEntry(
+ const QName* name,
+ const ElemVariable* var);
+
+ /**
* Construct an element frame marker.
*/
StackEntry(const ElemTemplateElement* elem);
@@ -384,12 +452,34 @@
* @return pointer to XObject
*/
const XObjectPtr
- getVariable() const
+ getValue() const
{
return m_value;
}
/**
+ * Retrieve object's XObject pointer. Valid only for variables
+ *
+ * @return pointer to XObject
+ */
+ void
+ setValue(const XObjectPtr& theValue)
+ {
+ m_value = theValue;
+ }
+
+ /**
+ * Retrieve object's XObject pointer. Valid only for variables
+ *
+ * @return pointer to XObject
+ */
+ const ElemVariable*
+ getVariable() const
+ {
+ return m_variable;
+ }
+
+ /**
* Retrieve the ElemTemplateElem where frame begins. Valid only for element frame markers
*
* @return ElemTemplateElement corresponding to marker
@@ -415,6 +505,8 @@
XObjectPtr m_value;
+ const ElemVariable* m_variable;
+
const ElemTemplateElement* m_element;
};
@@ -429,27 +521,31 @@
const XObjectPtr
findXObject(
- const QName& name,
- bool fSearchGlobalSpace) const;
+ const QName& name,
+ StylesheetExecutionContext& executionContext,
+ bool fSearchGlobalSpace,
+ bool& fNameFound);
- const StackEntry*
- findVariable(
+ StackEntry*
+ findEntry(
const QName& name,
- bool fSearchGlobalSpace) const;
+ bool fSearchGlobalSpace);
+
+ VariableStackStackType m_stack;
- VariableStackStackType m_stack;
+ int m_globalStackFrameIndex;
- int m_globalStackFrameIndex;
+ bool m_globalStackFrameMarked;
- bool m_globalStackFrameMarked;
+ bool m_forceGlobalOnlySearch;
/**
* This is the top of the stack frame from where a search
* for a variable or param should take place. It may not
* be the real stack top.
*/
- unsigned int m_currentStackFrameIndex;
+ unsigned int m_currentStackFrameIndex;
};
1.74 +3 -5 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.73
retrieving revision 1.74
diff -u -r1.73 -r1.74
--- XSLTEngineImpl.cpp 2000/12/01 21:03:40 1.73
+++ XSLTEngineImpl.cpp 2000/12/04 20:48:36 1.74
@@ -2095,9 +2095,9 @@
pfrag.get(),
0);
- setMustFlushPendingStartDocument(true);
+// setMustFlushPendingStartDocument(true);
- flushPending();
+// flushPending();
StylesheetExecutionContext::OutputContextPushPop theOutputContextPushPop(
executionContext,
@@ -2571,9 +2571,7 @@
const XObjectPtr xobj =
evalXPathStr(expression, contextNode, namespaceContext, executionContext);
- const XalanDOMString exprResult(xobj->str());
-
- append(buffer, exprResult);
+ append(buffer, xobj->str());
clear(lookahead); // breaks out of inner while loop
break;