dbertoni 01/06/06 14:55:50
Modified: c/src/XSLT AVT.cpp AVT.hpp AVTPartXPath.cpp AVTPartXPath.hpp
ElemApplyImport.cpp ElemApplyTemplates.cpp
ElemAttribute.cpp ElemAttribute.hpp
ElemCallTemplate.cpp ElemCallTemplate.hpp
ElemComment.cpp ElemForEach.cpp ElemForEach.hpp
ElemLiteralResult.cpp ElemLiteralResult.hpp
ElemMessage.cpp ElemPI.cpp ElemTemplateElement.cpp
ElemTemplateElement.hpp ElemTextLiteral.cpp
ElemTextLiteral.hpp Stylesheet.cpp Stylesheet.hpp
StylesheetExecutionContext.cpp
StylesheetExecutionContext.hpp XSLTEngineImpl.cpp
Log:
Optimization work.
Revision Changes Path
1.11 +33 -14 xml-xalan/c/src/XSLT/AVT.cpp
Index: AVT.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/AVT.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- AVT.cpp 2001/04/30 18:12:47 1.10
+++ AVT.cpp 2001/06/06 21:55:14 1.11
@@ -72,6 +72,10 @@
+#include <DOMSupport/DOMServices.hpp>
+
+
+
#include "AVTPartSimple.hpp"
#include "AVTPartXPath.hpp"
#include "StylesheetConstructionContext.hpp"
@@ -116,11 +120,11 @@
const XalanDOMChar*
stringedValue,
const PrefixResolver& resolver,
StylesheetConstructionContext& constructionContext) :
- AVTPart(),
m_parts(),
m_simpleString(),
// $$$ ToDo: Explicit XalanDOMString constructor
m_name(XalanDOMString(name)),
+ m_prefix(getPrefix(name)),
m_pcType(type)
{
StringTokenizer tokenizer(stringedValue,
theTokenDelimiterCharacters, true);
@@ -135,11 +139,11 @@
{
m_parts.reserve(nTokens + 1);
- XalanDOMString buffer;
- XalanDOMString exprBuffer;
- XalanDOMString t; // base token
- XalanDOMString lookahead; // next token
- XalanDOMString error; // if non-null, break from loop
+ XalanDOMString buffer;
+ XalanDOMString exprBuffer;
+ XalanDOMString t; // base token
+ XalanDOMString lookahead; // next token
+ XalanDOMString error; // if non-null, break from loop
while(tokenizer.hasMoreTokens())
{
@@ -235,12 +239,13 @@
lookahead =
tokenizer.nextToken();
} // end
while(!equals(lookahead, "}"))
assert(equals(lookahead, theRightCurlyBracketString));
-
+
// Proper close of
attribute template. Evaluate the
// expression.
clear(buffer);
const XPath* const
xpath = constructionContext.createXPath(exprBuffer, resolver);
+ assert(xpath != 0);
m_parts.push_back(new
AVTPartXPath(xpath));
@@ -345,21 +350,35 @@
{
buf = m_simpleString;
}
- else if(!m_parts.empty())
+ else
{
clear(buf);
- const AVTPartPtrVectorType::size_type n = m_parts.size();
-
- for(AVTPartPtrVectorType::size_type i = 0; i < n; i++)
+ if(m_parts.empty() == false)
{
- assert(m_parts[i] != 0);
+ const AVTPartPtrVectorType::size_type n =
m_parts.size();
+
+ for(AVTPartPtrVectorType::size_type i = 0; i < n; i++)
+ {
+ assert(m_parts[i] != 0);
- m_parts[i]->evaluate(buf, contextNode, prefixResolver,
executionContext);
+ m_parts[i]->evaluate(buf, contextNode,
prefixResolver, executionContext);
+ }
}
}
+}
+
+
+
+XalanDOMString
+AVT::getPrefix(const XalanDOMChar* theName)
+{
+ if (startsWith(theName, DOMServices::s_XMLNamespaceWithSeparator) ==
true)
+ {
+ return substring(theName,
DOMServices::s_XMLNamespaceWithSeparatorLength);
+ }
else
{
- clear(buf);
+ return XalanDOMString();
}
}
1.11 +40 -8 xml-xalan/c/src/XSLT/AVT.hpp
Index: AVT.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/AVT.hpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- AVT.hpp 2000/11/30 20:34:02 1.10
+++ AVT.hpp 2001/06/06 21:55:15 1.11
@@ -58,7 +58,7 @@
#define XALAN_AVT_HEADER_GUARD
/**
- * $Id: AVT.hpp,v 1.10 2000/11/30 20:34:02 auriemma Exp $
+ * $Id: AVT.hpp,v 1.11 2001/06/06 21:55:15 dbertoni Exp $
*
* $State: Exp $
*
@@ -77,11 +77,10 @@
-#include <XSLT/AVTPart.hpp>
-
-
-
+class AVTPart;
class PrefixResolver;
+class XPathExecutionContext;
+class XalanNode;
class StylesheetConstructionContext;
@@ -89,7 +88,7 @@
/**
* Class to hold an Attribute Value Template.
*/
-class AVT: public AVTPart
+class AVT //: public AVTPart
{
public:
@@ -126,6 +125,18 @@
}
/**
+ * Retrieve the prefix of the name of the Attribute Value Template,
+ * if any.
+ *
+ * @return The prefix part of the AVT's name
+ */
+ const XalanDOMString&
+ getPrefix() const
+ {
+ return m_prefix;
+ }
+
+ /**
* Retrieve the type of the Attribute Value Template
*
* @return type of AVT
@@ -136,9 +147,18 @@
return m_pcType;
}
- // These methods are inherited from AVTPart ...
+ /**
+ * Retrieve the "simple" value
+ *
+ * @return The "simple" value of the AVT.
+ */
+ const XalanDOMString&
+ getSimpleValue() const
+ {
+ return m_simpleString;
+ }
- virtual void
+ void
evaluate(
XalanDOMString& buf,
XalanNode* contextNode,
@@ -153,6 +173,16 @@
private:
+ /**
+ * Get the prefix from theName, if any.
+ *
+ * @param theName name of AVT
+ *
+ * @return A string containing the prefix.
+ */
+ XalanDOMString
+ getPrefix(const XalanDOMChar* theName);
+
// not implemented
AVT(const AVT &);
AVT& operator=(const AVT &);
@@ -162,6 +192,8 @@
XalanDOMString m_simpleString;
const XalanDOMString m_name;
+
+ const XalanDOMString m_prefix;
const XalanDOMString m_pcType;
};
1.8 +13 -2 xml-xalan/c/src/XSLT/AVTPartXPath.cpp
Index: AVTPartXPath.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/AVTPartXPath.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- AVTPartXPath.cpp 2000/11/21 21:09:55 1.7
+++ AVTPartXPath.cpp 2001/06/06 21:55:15 1.8
@@ -78,8 +78,19 @@
+XObjectPtr
+AVTPartXPath::evaluate(
+ XalanNode* contextNode,
+ const PrefixResolver& prefixResolver,
+ XPathExecutionContext& executionContext) const
+{
+ return m_pXPath->execute(contextNode, prefixResolver, executionContext);
+}
+
+
+
void
-AVTPartXPath:: evaluate(
+AVTPartXPath::evaluate(
XalanDOMString& buf,
XalanNode* contextNode,
const PrefixResolver& prefixResolver,
@@ -89,6 +100,6 @@
if(0 != xobj.get())
{
- append(buf, xobj->str());
+ xobj->str(buf);
}
}
1.6 +13 -3 xml-xalan/c/src/XSLT/AVTPartXPath.hpp
Index: AVTPartXPath.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/AVTPartXPath.hpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- AVTPartXPath.hpp 2000/08/10 18:43:03 1.5
+++ AVTPartXPath.hpp 2001/06/06 21:55:15 1.6
@@ -58,21 +58,25 @@
#define XALAN_AVTPARTXPATH_HEADER_GUARD
/**
- * $Id: AVTPartXPath.hpp,v 1.5 2000/08/10 18:43:03 dbertoni Exp $
+ * $Id: AVTPartXPath.hpp,v 1.6 2001/06/06 21:55:15 dbertoni Exp $
*
* $State: Exp $
*
*/
// Base include file. Must be first.
-#include "XSLTDefinitions.hpp"
+#include <XSLT/XSLTDefinitions.hpp>
-#include "AVTPart.hpp"
+#include <XPath/XObject.hpp>
+#include <XSLT/AVTPart.hpp>
+
+
+
class PrefixResolver;
class XPath;
class XPathEnvSupport;
@@ -95,6 +99,12 @@
*/
AVTPartXPath(const XPath* xpath);
+
+ virtual XObjectPtr
+ evaluate(
+ XalanNode* contextNode,
+ const PrefixResolver& prefixResolver,
+ XPathExecutionContext& executionContext) const;
// These methods are inherited from AVTPart ...
1.12 +2 -1 xml-xalan/c/src/XSLT/ElemApplyImport.cpp
Index: ElemApplyImport.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemApplyImport.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- ElemApplyImport.cpp 2001/03/29 22:24:25 1.11
+++ ElemApplyImport.cpp 2001/06/06 21:55:16 1.12
@@ -120,7 +120,8 @@
{
ElemTemplateElement::execute(executionContext);
- XalanNode* sourceNode = executionContext.getCurrentNode();
+ XalanNode* const sourceNode = executionContext.getCurrentNode();
+ assert(sourceNode != 0);
transformChild(executionContext,
*this,
1.16 +10 -17 xml-xalan/c/src/XSLT/ElemApplyTemplates.cpp
Index: ElemApplyTemplates.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemApplyTemplates.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- ElemApplyTemplates.cpp 2001/03/29 22:24:25 1.15
+++ ElemApplyTemplates.cpp 2001/06/06 21:55:17 1.16
@@ -98,7 +98,7 @@
switch(tok)
{
case Constants::TATTRNAME_SELECT:
- m_pSelectPattern =
constructionContext.createXPath(atts.getValue(i), *this);
+ m_selectPattern =
constructionContext.createXPath(atts.getValue(i), *this);
break;
case Constants::TATTRNAME_MODE:
@@ -114,12 +114,12 @@
}
}
- if(0 == m_pSelectPattern)
+ if(0 == m_selectPattern)
{
- m_pSelectPattern =
constructionContext.createXPath(XALAN_STATIC_UCODE_STRING("node()"), *this);
+ m_selectPattern =
constructionContext.createXPath(XALAN_STATIC_UCODE_STRING("node()"), *this);
}
- assert(m_pSelectPattern != 0);
+ assert(m_selectPattern != 0);
}
@@ -141,7 +141,7 @@
void
ElemApplyTemplates::execute(StylesheetExecutionContext&
executionContext) const
{
- assert(m_pSelectPattern != 0);
+ assert(m_selectPattern != 0);
if(0 != executionContext.getTraceListeners())
{
@@ -159,40 +159,33 @@
// depth-first searching, this gets worse.
StylesheetExecutionContext::ParamsPushPop thePushPop(
executionContext,
- this,
*this,
sourceNode,
this);
assert(executionContext.getCurrentMode() != 0);
- if (m_isDefaultTemplate == false &&
- !m_mode.equals(*executionContext.getCurrentMode()))
- {
- const QName* const oldMode =
executionContext.getCurrentMode();
+ const QName* const currentMode =
executionContext.getCurrentMode();
+ if (m_isDefaultTemplate == false &&
+ !m_mode.equals(*currentMode))
+ {
executionContext.setCurrentMode(&m_mode);
transformSelectedChildren(
executionContext,
- *this,
0,
sourceNode,
- *m_pSelectPattern,
- Constants::ELEMNAME_APPLY_TEMPLATES,
thePushPop.getStackFrameIndex());
- executionContext.setCurrentMode(oldMode);
+ executionContext.setCurrentMode(currentMode);
}
else
{
transformSelectedChildren(
executionContext,
- *this,
0,
sourceNode,
- *m_pSelectPattern,
- Constants::ELEMNAME_APPLY_TEMPLATES,
thePushPop.getStackFrameIndex());
}
}
1.25 +3 -5 xml-xalan/c/src/XSLT/ElemAttribute.cpp
Index: ElemAttribute.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemAttribute.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- ElemAttribute.cpp 2001/05/18 21:22:17 1.24
+++ ElemAttribute.cpp 2001/06/06 21:55:17 1.25
@@ -370,11 +370,9 @@
{
StylesheetExecutionContext::GetAndReleaseCachedString
theResult(executionContext);
- childrenToString(
- executionContext,
- theResult.get());
-
- executionContext.addResultAttribute(attrName,
theResult.get());
+ executionContext.addResultAttribute(
+ attrName,
+ childrenToString(executionContext,
theResult.get()));
}
}
}
1.10 +4 -3 xml-xalan/c/src/XSLT/ElemAttribute.hpp
Index: ElemAttribute.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemAttribute.hpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- ElemAttribute.hpp 2001/03/09 16:20:08 1.9
+++ ElemAttribute.hpp 2001/06/06 21:55:18 1.10
@@ -58,7 +58,7 @@
#define XALAN_ELEMATTRIBUTE_HEADER_GUARD
/**
- * $Id: ElemAttribute.hpp,v 1.9 2001/03/09 16:20:08 auriemma Exp $
+ * $Id: ElemAttribute.hpp,v 1.10 2001/06/06 21:55:18 dbertoni Exp $
*
*
* $State: Exp $
@@ -77,6 +77,7 @@
class AVT;
+class ElemTextLiteral;
@@ -122,8 +123,8 @@
ElemAttribute(const ElemAttribute &);
ElemAttribute& operator=(const ElemAttribute &);
- const AVT* m_pNameAVT;
- const AVT* m_pNamespaceAVT;
+ const AVT* m_pNameAVT;
+ const AVT* m_pNamespaceAVT;
};
1.16 +28 -17 xml-xalan/c/src/XSLT/ElemCallTemplate.cpp
Index: ElemCallTemplate.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemCallTemplate.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- ElemCallTemplate.cpp 2001/03/09 16:20:07 1.15
+++ ElemCallTemplate.cpp 2001/06/06 21:55:19 1.16
@@ -87,7 +87,8 @@
lineNumber,
columnNumber,
Constants::ELEMNAME_CALLTEMPLATE),
- m_templateName()
+ m_templateName(),
+ m_template(0)
{
const unsigned int nAttrs = atts.getLength();
@@ -128,34 +129,44 @@
void
-ElemCallTemplate::execute(StylesheetExecutionContext&
executionContext) const
+ElemCallTemplate::execute(StylesheetExecutionContext&
executionContext) const
{
ElemTemplateElement::execute(executionContext);
- XalanNode* sourceNode = executionContext.getCurrentNode();
+ XalanNode* const sourceNode = executionContext.getCurrentNode();
+ assert(sourceNode != 0);
- assert(isEmpty(m_templateName.getLocalPart()) == false);
+ assert(m_template != 0);
- const ElemTemplate* const theTemplate =
-
getStylesheet().getStylesheetRoot().findNamedTemplate(m_templateName,
- executionContext);
-
- if(0 != theTemplate)
- {
- StylesheetExecutionContext::ParamsPushPop thePushPop(
+ StylesheetExecutionContext::ParamsPushPop thePushPop(
executionContext,
- theTemplate,
*this,
sourceNode,
- theTemplate);
+ m_template);
- theTemplate->execute(executionContext);
- }
- else
+ m_template->execute(executionContext);
+}
+
+
+
+void
+ElemCallTemplate::postConstruction(
+ StylesheetConstructionContext& constructionContext,
+ const NamespacesHandler&
theParentHandler)
+{
+ assert(m_templateName.isEmpty() == false);
+
+ m_template =
+
getStylesheet().getStylesheetRoot().findNamedTemplate(m_templateName);
+
+ if(m_template == 0)
{
- executionContext.error("Could not find template named: '" +
+ constructionContext.error("Could not find template named: '" +
m_templateName.getLocalPart() + "'");
}
+
+ // OK, now we can chain-up...
+ ElemTemplateElement::postConstruction(constructionContext,
theParentHandler);
}
1.13 +18 -1 xml-xalan/c/src/XSLT/ElemCallTemplate.hpp
Index: ElemCallTemplate.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemCallTemplate.hpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- ElemCallTemplate.hpp 2001/03/09 16:20:07 1.12
+++ ElemCallTemplate.hpp 2001/06/06 21:55:20 1.13
@@ -73,6 +73,10 @@
+class ElemTemplate;
+
+
+
class ElemCallTemplate: public ElemTemplateElement
{
public:
@@ -104,6 +108,17 @@
virtual void
execute(StylesheetExecutionContext& executionContext) const;
+ virtual void
+ postConstruction(
+ StylesheetConstructionContext& constructionContext,
+ const NamespacesHandler&
theParentHandler);
+
+ const ElemTemplate*
+ getTemplate() const
+ {
+ return m_template;
+ }
+
protected:
virtual bool
@@ -118,7 +133,9 @@
operator=(const ElemCallTemplate&);
// Data members...
- QNameByValue m_templateName;
+ QNameByValue m_templateName;
+
+ const ElemTemplate* m_template;
};
1.10 +2 -6 xml-xalan/c/src/XSLT/ElemComment.cpp
Index: ElemComment.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemComment.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- ElemComment.cpp 2001/03/09 16:20:06 1.9
+++ ElemComment.cpp 2001/06/06 21:55:20 1.10
@@ -114,17 +114,13 @@
void
-ElemComment::execute(StylesheetExecutionContext&
executionContext) const
+ElemComment::execute(StylesheetExecutionContext& executionContext) const
{
ElemTemplateElement::execute(executionContext);
StylesheetExecutionContext::GetAndReleaseCachedString
theResult(executionContext);
- childrenToString(
- executionContext,
- theResult.get());
-
- executionContext.comment(c_wstr(theResult.get()));
+
executionContext.comment(c_wstr(childrenToString(executionContext,theResult.get())));
}
1.14 +114 -9 xml-xalan/c/src/XSLT/ElemForEach.cpp
Index: ElemForEach.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemForEach.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- ElemForEach.cpp 2001/04/30 18:12:48 1.13
+++ ElemForEach.cpp 2001/06/06 21:55:21 1.14
@@ -76,6 +76,7 @@
#include "ElemSort.hpp"
+#include "NodeSorter.hpp"
#include "StylesheetConstructionContext.hpp"
#include "StylesheetExecutionContext.hpp"
@@ -92,7 +93,7 @@
lineNumber,
columnNumber,
Constants::ELEMNAME_FOREACH),
- m_pSelectPattern(0)
+ m_selectPattern(0)
{
const unsigned int nAttrs = atts.getLength();
@@ -102,7 +103,7 @@
if(equals(aname, Constants::ATTRNAME_SELECT))
{
- m_pSelectPattern =
constructionContext.createXPath(atts.getValue(i), *this);
+ m_selectPattern =
constructionContext.createXPath(atts.getValue(i), *this);
}
else if(!(isAttrOK(aname, atts, i, constructionContext) ||
processSpaceAttr(aname, atts, i)))
{
@@ -110,7 +111,7 @@
}
}
- if(0 == m_pSelectPattern)
+ if(0 == m_selectPattern)
{
constructionContext.error(Constants::ELEMNAME_FOREACH_WITH_PREFIX_STRING + "
requires attribute: " + Constants::ATTRNAME_SELECT);
}
@@ -130,7 +131,7 @@
lineNumber,
columnNumber,
xslToken),
- m_pSelectPattern(0)
+ m_selectPattern(0)
{
}
@@ -158,9 +159,9 @@
void
-ElemForEach::execute(StylesheetExecutionContext&
executionContext) const
+ElemForEach::execute(StylesheetExecutionContext& executionContext) const
{
- assert(m_pSelectPattern != 0);
+ assert(m_selectPattern != 0);
XalanNode* const sourceNode = executionContext.getCurrentNode();
@@ -168,11 +169,8 @@
{
transformSelectedChildren(
executionContext,
- *this,
this,
sourceNode,
- *m_pSelectPattern,
- Constants::ELEMNAME_FOREACH,
executionContext.getCurrentStackFrameIndex());
}
else
@@ -182,4 +180,111 @@
sourceNode,
this);
}
+}
+
+
+
+void
+ElemForEach::transformSelectedChildren(
+ StylesheetExecutionContext&
executionContext,
+ const ElemTemplateElement* theTemplate,
+ XalanNode*
sourceNodeContext,
+ int
selectStackFrameIndex) const
+{
+ const unsigned int nChildren = getSortElems().size();
+
+ if (nChildren == 0)
+ {
+ ElemTemplateElement::transformSelectedChildren(
+ executionContext,
+ *this,
+ theTemplate,
+ sourceNodeContext,
+ *m_selectPattern,
+ 0,
+ selectStackFrameIndex);
+ }
+ else
+ {
+ typedef NodeSorter::NodeSortKeyVectorType
NodeSortKeyVectorType;
+ typedef StylesheetExecutionContext::BorrowReturnNodeSorter
BorrowReturnNodeSorter;
+
+ BorrowReturnNodeSorter sorter(executionContext);
+
+ NodeSortKeyVectorType& keys = sorter->getSortKeys();
+ assert(keys.size() == 0);
+
+ CollectionClearGuard<NodeSortKeyVectorType>
guard(keys);
+
+ // Reserve the space now...
+ keys.reserve(nChildren);
+
+ // Get some temporary strings to use for evaluting the AVTs...
+ XPathExecutionContext::GetAndReleaseCachedString
theTemp1(executionContext);
+
+ XalanDOMString& langString = theTemp1.get();
+
+ XPathExecutionContext::GetAndReleaseCachedString
theTemp2(executionContext);
+
+ XalanDOMString& scratchString = theTemp2.get();
+
+ // March backwards, performing a sort on each xsl:sort child.
+ // Probably not the most efficient method.
+ for(unsigned int i = 0; i < nChildren; i++)
+ {
+ const ElemSort* const sort = getSortElems()[i];
+ assert(sort != 0);
+
+ const AVT* avt = sort->getLangAVT();
+
+ if(0 != avt)
+ {
+ avt->evaluate(langString, sourceNodeContext,
*this, executionContext);
+ }
+
+ avt = sort->getDataTypeAVT();
+
+ if(0 != avt)
+ {
+ avt->evaluate(scratchString, sourceNodeContext,
*this, executionContext);
+ }
+
+ const bool treatAsNumbers =
!isEmpty(scratchString) && equals(scratchString,
Constants::ATTRVAL_DATATYPE_NUMBER) ?
+ true : false;
+
+ clear(scratchString);
+
+ avt = sort->getOrderAVT();
+
+ if(0 != avt)
+ {
+ avt->evaluate(scratchString, sourceNodeContext,
*this, executionContext);
+ }
+
+ const bool descending = !isEmpty(scratchString) &&
equals(scratchString, Constants::ATTRVAL_ORDER_DESCENDING) ?
+ true : false;
+
+ clear(scratchString);
+
+ assert(sort->getSelectPattern() != 0);
+
+ keys.push_back(
+ NodeSortKey(
+ executionContext,
+ *sort->getSelectPattern(),
+ treatAsNumbers,
+ descending,
+ langString,
+ *this));
+ }
+
+ ElemTemplateElement::transformSelectedChildren(
+ executionContext,
+ *this,
+ theTemplate,
+ sourceNodeContext,
+ *m_selectPattern,
+ sorter.get(),
+ selectStackFrameIndex);
+ }
}
1.11 +17 -1 xml-xalan/c/src/XSLT/ElemForEach.hpp
Index: ElemForEach.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemForEach.hpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- ElemForEach.hpp 2001/03/09 16:20:02 1.10
+++ ElemForEach.hpp 2001/06/06 21:55:21 1.11
@@ -149,7 +149,23 @@
int
columnNumber,
int
xslToken);
- const XPath* m_pSelectPattern;
+ /**
+ * Perform a query if needed, and call transformChild for each child.
+ *
+ * @param executionContext The current execution context
+ * @param template The owning template context.
+ * @param sourceNodeContext The current source node context.
+ * @param selectStackFrameIndex stack frame context for executing the
+ * select statement
+ */
+ void
+ transformSelectedChildren(
+ StylesheetExecutionContext&
executionContext,
+ const ElemTemplateElement* theTemplate,
+ XalanNode*
sourceNodeContext,
+ int
selectStackFrameIndex) const;
+
+ const XPath* m_selectPattern;
private:
1.37 +35 -22 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.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- ElemLiteralResult.cpp 2001/05/14 01:03:08 1.36
+++ ElemLiteralResult.cpp 2001/06/06 21:55:22 1.37
@@ -198,7 +198,9 @@
void
-ElemLiteralResult::postConstruction(const NamespacesHandler&
theParentHandler)
+ElemLiteralResult::postConstruction(
+ StylesheetConstructionContext& constructionContext,
+ const NamespacesHandler&
theParentHandler)
{
// OK, now check all attribute AVTs to make sure
// our NamespacesHandler knows about any prefixes
@@ -220,11 +222,31 @@
}
// OK, now we can chain-up...
- ElemUse::postConstruction(theParentHandler);
+ ElemUse::postConstruction(constructionContext, theParentHandler);
}
+inline void
+ElemLiteralResult::doAddResultAttribute(
+ StylesheetExecutionContext&
executionContext,
+ const XalanDOMString& thePrefix,
+ const XalanDOMString& theName,
+ const XalanDOMString& theValue) const
+{
+ if (isEmpty(thePrefix) == true ||
+ shouldExcludeResultNamespaceNode(
+ thePrefix,
+ theValue) == false)
+ {
+ executionContext.addResultAttribute(
+ theName,
+ theValue);
+ }
+}
+
+
+
void
ElemLiteralResult::execute(StylesheetExecutionContext&
executionContext) const
{
@@ -259,39 +281,30 @@
{
const AVTVectorType::size_type nAttrs = m_avts.size();
- StylesheetExecutionContext::GetAndReleaseCachedString
theGuard1(executionContext);
- StylesheetExecutionContext::GetAndReleaseCachedString
theGuard2(executionContext);
+ StylesheetExecutionContext::GetAndReleaseCachedString
theGuard(executionContext);
- XalanDOMString& thePrefix = theGuard1.get();
- XalanDOMString& theStringedValue = theGuard2.get();
+ XalanDOMString& theStringedValue = theGuard.get();
for(AVTVectorType::size_type i = 0; i < nAttrs; ++i)
{
const AVT* const avt = m_avts[i];
const XalanDOMString& theName = avt->getName();
-
- if (startsWith(theName,
DOMServices::s_XMLNamespaceWithSeparator) == true)
- {
- thePrefix = substring(theName,
DOMServices::s_XMLNamespaceWithSeparatorLength);
- }
- StylesheetExecutionContext::GetAndReleaseCachedString
theGuard2(executionContext);
+ const XalanDOMString& thePrefix = avt->getPrefix();
- avt->evaluate(theStringedValue,
executionContext.getCurrentNode(), *this, executionContext);
+ const XalanDOMString& theSimpleValue =
avt->getSimpleValue();
- if (isEmpty(thePrefix) == true ||
- shouldExcludeResultNamespaceNode(
- thePrefix,
- theStringedValue) == false)
+ if (isEmpty(theSimpleValue) == false)
{
- executionContext.addResultAttribute(
- theName,
- theStringedValue);
+ doAddResultAttribute(executionContext,
thePrefix, theName, theSimpleValue);
}
+ else
+ {
+ avt->evaluate(theStringedValue,
executionContext.getCurrentNode(), *this, executionContext);
- clear(thePrefix);
- clear(theStringedValue);
+ doAddResultAttribute(executionContext,
thePrefix, theName, theStringedValue);
+ }
}
}
1.21 +18 -1 xml-xalan/c/src/XSLT/ElemLiteralResult.hpp
Index: ElemLiteralResult.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemLiteralResult.hpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- ElemLiteralResult.hpp 2001/05/17 16:14:05 1.20
+++ ElemLiteralResult.hpp 2001/06/06 21:55:23 1.21
@@ -105,7 +105,9 @@
getElementName() const;
virtual void
- postConstruction(const NamespacesHandler& theParentHandler);
+ postConstruction(
+ StylesheetConstructionContext& constructionContext,
+ const NamespacesHandler&
theParentHandler);
virtual bool
isAttrOK(
@@ -165,6 +167,21 @@
shouldExcludeResultNamespaceNode(
const XalanDOMString& thePrefix,
const XalanDOMString& theURI) const;
+
+ /**
+ * Add a result attribute, if necessary.
+ *
+ * @param executionContext The current execution context
+ * @param thePrefix The prefix of the attribute
+ * @param theName The name of the attribute.
+ * @param theValue The value of the attribute.
+ */
+ void
+ doAddResultAttribute(
+ StylesheetExecutionContext&
executionContext,
+ const XalanDOMString& thePrefix,
+ const XalanDOMString& theName,
+ const XalanDOMString& theValue) const;
/**
* The name of the literal result element.
1.11 +4 -7 xml-xalan/c/src/XSLT/ElemMessage.cpp
Index: ElemMessage.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemMessage.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- ElemMessage.cpp 2001/03/09 16:20:00 1.10
+++ ElemMessage.cpp 2001/06/06 21:55:25 1.11
@@ -129,13 +129,10 @@
StylesheetExecutionContext::GetAndReleaseCachedString
theResult(executionContext);
- XalanNode* sourceNode = executionContext.getCurrentNode();
-
- childrenToString(
- executionContext,
- theResult.get());
-
- executionContext.message(theResult.get(), sourceNode, this);
+ executionContext.message(
+ childrenToString(executionContext,theResult.get()),
+ executionContext.getCurrentNode(),
+ this);
if (m_terminate == true)
{
1.14 +3 -5 xml-xalan/c/src/XSLT/ElemPI.cpp
Index: ElemPI.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemPI.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- ElemPI.cpp 2001/03/09 16:19:59 1.13
+++ ElemPI.cpp 2001/06/06 21:55:26 1.14
@@ -150,11 +150,9 @@
StylesheetExecutionContext::GetAndReleaseCachedString
theResult(executionContext);
- childrenToString(
- executionContext,
- theResult.get());
-
- executionContext.processingInstruction(c_wstr(piName),
c_wstr(theResult.get()));
+ executionContext.processingInstruction(
+ c_wstr(piName),
+ c_wstr(childrenToString(executionContext,theResult.get())));
}
1.57 +156 -232 xml-xalan/c/src/XSLT/ElemTemplateElement.cpp
Index: ElemTemplateElement.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemTemplateElement.cpp,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -r1.56 -r1.57
--- ElemTemplateElement.cpp 2001/05/14 01:03:08 1.56
+++ ElemTemplateElement.cpp 2001/06/06 21:55:27 1.57
@@ -95,8 +95,7 @@
#include "Constants.hpp"
-#include "ElemForEach.hpp"
-#include "ElemSort.hpp"
+#include "ElemCallTemplate.hpp"
#include "ElemTemplate.hpp"
#include "NamespacesHandler.hpp"
#include "NodeSorter.hpp"
@@ -108,7 +107,7 @@
-const XalanDOMString
ElemTemplateElement::s_emptyString;
+const XalanDOMString ElemTemplateElement::s_emptyString;
@@ -135,7 +134,8 @@
m_firstChild(0),
m_surrogateChildren(*this),
m_fakeAttributes(),
- m_baseIndentifier(stylesheetTree.getCurrentIncludeBaseIdentifier())
+ m_baseIndentifier(stylesheetTree.getCurrentIncludeBaseIdentifier()),
+ m_optimizationFlags(0)
{
}
@@ -145,7 +145,10 @@
{
delete m_nextSibling;
- delete m_firstChild;
+ if (hasDirectTemplate() == false)
+ {
+ delete m_firstChild;
+ }
}
@@ -251,7 +254,7 @@
{
XalanDOMChar c = charAt(s, 0);
- if(!(XalanXMLChar::isLetter(c) || (c ==
XalanUnicode::charLowLine)))
+ if(!(XalanXMLChar::isLetter(c) || c ==
XalanUnicode::charLowLine))
return false;
if(len > 1)
@@ -292,14 +295,36 @@
void
-ElemTemplateElement::executeChildren(StylesheetExecutionContext&
executionContext) const
+ElemTemplateElement::executeChildren(StylesheetExecutionContext&
executionContext) const
{
- StylesheetExecutionContext::PushAndPopElementFrame
thePushAndPop(executionContext, this);
+ if (hasChildren() == true)
+ {
+ if (hasDirectTemplate() == true)
+ {
+ assert(m_directTemplate != 0);
- for (ElemTemplateElement* node = m_firstChild; node != 0; node =
node->m_nextSibling)
- {
- node->execute(executionContext);
- }
+ m_directTemplate->execute(executionContext);
+ }
+ else
+ {
+ if (hasParams() == true || hasVariables() == true)
+ {
+
StylesheetExecutionContext::PushAndPopElementFrame
thePushAndPop(executionContext, this);
+
+ for (ElemTemplateElement* node = m_firstChild;
node != 0; node = node->m_nextSibling)
+ {
+ node->execute(executionContext);
+ }
+ }
+ else
+ {
+ for (ElemTemplateElement* node = m_firstChild;
node != 0; node = node->m_nextSibling)
+ {
+ node->execute(executionContext);
+ }
+ }
+ }
+ }
}
@@ -309,43 +334,55 @@
StylesheetExecutionContext& executionContext,
XalanNode*
sourceNode) const
{
- const XPathExecutionContext::CurrentNodeSetAndRestore
theCurrentNodeSetAndRestore(executionContext, sourceNode);
+ if (hasChildren() == true)
+ {
+ const XPathExecutionContext::CurrentNodeSetAndRestore
theCurrentNodeSetAndRestore(executionContext, sourceNode);
- executeChildren(executionContext);
+ executeChildren(executionContext);
+ }
}
-void
+const XalanDOMString&
ElemTemplateElement::childrenToString(
StylesheetExecutionContext&
executionContext,
XalanDOMString& result)
const
{
- reserve(result, length(result) + 1024);
-
- // Create a print writer and formatter to generate the children as
- // a string.
- DOMStringPrintWriter thePrintWriter(result);
-
- // Borrow a FormatterToText, and don't normalize CR/LF, since we don't
want
- // this text to be normalized. Finally, have the formatter handle any
ignorable
- // whitespace events.
- StylesheetExecutionContext::BorrowReturnFormatterToText theFormatter(
- executionContext,
- thePrintWriter,
- false,
- true);
+ if (hasSingleTextChild() == true)
+ {
+ return m_firstChild->getNodeValue();
+ }
+ else
+ {
+ reserve(result, length(result) + 1024);
- // Create an object to set and restore the execution state.
- StylesheetExecutionContext::OutputContextPushPop
theOutputContextPushPop(
+ // Create a print writer and formatter to generate the children
as
+ // a string.
+ DOMStringPrintWriter thePrintWriter(result);
+
+ // Borrow a FormatterToText, and don't normalize CR/LF, since
we don't want
+ // this text to be normalized. Finally, have the formatter
handle any ignorable
+ // whitespace events.
+ StylesheetExecutionContext::BorrowReturnFormatterToText
theFormatter(
executionContext,
- theFormatter.get());
+ thePrintWriter,
+ false,
+ true);
+
+ // Create an object to set and restore the execution state.
+ StylesheetExecutionContext::OutputContextPushPop
theOutputContextPushPop(
+ executionContext,
+ theFormatter.get());
- theFormatter->startDocument();
+ theFormatter->startDocument();
- executeChildren(executionContext);
+ executeChildren(executionContext);
- theFormatter->endDocument();
+ theFormatter->endDocument();
+
+ return result;
+ }
}
@@ -576,139 +613,6 @@
StylesheetExecutionContext&
executionContext,
const ElemTemplateElement& xslInstruction,
const ElemTemplateElement* theTemplate,
- XalanNode*
sourceNodeContext,
- const XPath&
selectPattern,
- int
xslToken,
- int
selectStackFrameIndex) const
-{
- // @@ JMD: Now in method processSortKeys in java ...
- if(Constants::ELEMNAME_APPLY_TEMPLATES == xslToken ||
- Constants::ELEMNAME_FOREACH == xslToken)
- {
- const ElemForEach* foreach =
-#if defined(XALAN_OLD_STYLE_CASTS)
- (const ElemForEach*)&xslInstruction;
-#else
- static_cast<const ElemForEach*>(&xslInstruction);
-#endif
-
- const unsigned int nChildren =
foreach->getSortElems().size();
-
- if (nChildren == 0)
- {
- doTransformSelectedChildren(
- executionContext,
- xslInstruction,
- theTemplate,
- sourceNodeContext,
- selectPattern,
- 0,
- selectStackFrameIndex);
- }
- else
- {
- typedef NodeSorter::NodeSortKeyVectorType
NodeSortKeyVectorType;
- typedef
StylesheetExecutionContext::BorrowReturnNodeSorter BorrowReturnNodeSorter;
-
- BorrowReturnNodeSorter sorter(executionContext);
-
- NodeSortKeyVectorType& keys = sorter->getSortKeys();
- assert(keys.size() == 0);
-
- CollectionClearGuard<NodeSortKeyVectorType>
guard(keys);
-
- // Reserve the space now...
- keys.reserve(nChildren);
-
- // Get some temporary strings to use for evaluting the
AVTs...
- XPathExecutionContext::GetAndReleaseCachedString
theTemp1(executionContext);
-
- XalanDOMString& langString = theTemp1.get();
-
- XPathExecutionContext::GetAndReleaseCachedString
theTemp2(executionContext);
-
- XalanDOMString& scratchString = theTemp2.get();
-
- // March backwards, performing a sort on each xsl:sort
child.
- // Probably not the most efficient method.
- for(unsigned int i = 0; i < nChildren; i++)
- {
- const ElemSort* const sort =
foreach->getSortElems()[i];
- assert(sort != 0);
-
- const AVT* avt = sort->getLangAVT();
-
- if(0 != avt)
- {
- avt->evaluate(langString,
sourceNodeContext, xslInstruction, executionContext);
- }
-
- avt = sort->getDataTypeAVT();
-
- if(0 != avt)
- {
- avt->evaluate(scratchString,
sourceNodeContext, xslInstruction, executionContext);
- }
-
- const bool treatAsNumbers =
!isEmpty(scratchString) && equals(scratchString,
Constants::ATTRVAL_DATATYPE_NUMBER) ?
- true : false;
-
- clear(scratchString);
-
- avt = sort->getOrderAVT();
-
- if(0 != avt)
- {
- avt->evaluate(scratchString,
sourceNodeContext, xslInstruction, executionContext);
- }
-
- const bool descending =
!isEmpty(scratchString) && equals(scratchString,
Constants::ATTRVAL_ORDER_DESCENDING) ?
- true : false;
-
- clear(scratchString);
-
- assert(sort->getSelectPattern() != 0);
-
- keys.push_back(
- NodeSortKey(
- executionContext,
- *sort->getSelectPattern(),
- treatAsNumbers,
- descending,
- langString,
- xslInstruction));
- }
-
- doTransformSelectedChildren(
- executionContext,
- xslInstruction,
- theTemplate,
- sourceNodeContext,
- selectPattern,
- sorter.get(),
- selectStackFrameIndex);
- }
- }
- else
- {
- doTransformSelectedChildren(
- executionContext,
- xslInstruction,
- theTemplate,
- sourceNodeContext,
- selectPattern,
- 0,
- selectStackFrameIndex);
- }
-}
-
-
-
-void
-ElemTemplateElement::doTransformSelectedChildren(
- StylesheetExecutionContext&
executionContext,
- const ElemTemplateElement& xslInstruction,
- const ElemTemplateElement* theTemplate,
XalanNode*
sourceNodeContext,
const XPath&
selectPattern,
NodeSorter*
sorter,
@@ -723,14 +627,12 @@
executionContext,
selectStackFrameIndex);
- theXObject =
- selectPattern.execute(
+ theXObject = selectPattern.execute(
sourceNodeContext,
xslInstruction,
executionContext);
}
- // @@ JMD: Should this be an assert ??
if (theXObject.null() == false)
{
const NodeRefListBase& sourceNodes = theXObject->nodeset();
@@ -750,78 +652,56 @@
if (nNodes > 0)
{
- doTransformSelectedChildren(
+ // If there's not NodeSorter, or we've only selected
one node,
+ // then just do the transform...
+ if (sorter == 0 || nNodes == 1)
+ {
+ transformSelectedChildren(
executionContext,
xslInstruction,
theTemplate,
sourceNodeContext,
- selectStackFrameIndex,
- sorter,
sourceNodes,
nNodes);
- }
- }
-}
-
-
+ }
+ else
+ {
+ typedef
StylesheetExecutionContext::SetAndRestoreCurrentStackFrameIndex
SetAndRestoreCurrentStackFrameIndex;
+ typedef
StylesheetExecutionContext::ContextNodeListSetAndRestore
ContextNodeListSetAndRestore;
+ typedef
StylesheetExecutionContext::BorrowReturnMutableNodeRefList
BorrowReturnMutableNodeRefList;
-void
-ElemTemplateElement::doTransformSelectedChildren(
- StylesheetExecutionContext&
executionContext,
- const ElemTemplateElement& xslInstruction,
- const ElemTemplateElement* theTemplate,
- XalanNode*
sourceNodeContext,
- int
selectStackFrameIndex,
- NodeSorter*
sorter,
- const NodeRefListBase& sourceNodes,
- unsigned int
sourceNodesCount) const
-{
- if (sorter != 0)
- {
- typedef
StylesheetExecutionContext::SetAndRestoreCurrentStackFrameIndex
SetAndRestoreCurrentStackFrameIndex;
- typedef
StylesheetExecutionContext::ContextNodeListSetAndRestore
ContextNodeListSetAndRestore;
- typedef
StylesheetExecutionContext::BorrowReturnMutableNodeRefList
BorrowReturnMutableNodeRefList;
+ BorrowReturnMutableNodeRefList
sortedSourceNodes(executionContext);
- BorrowReturnMutableNodeRefList
sortedSourceNodes(executionContext);
+ *sortedSourceNodes = sourceNodes;
- *sortedSourceNodes = sourceNodes;
+ {
+ SetAndRestoreCurrentStackFrameIndex
theStackFrameSetAndRestore(
+ executionContext,
+ selectStackFrameIndex);
+
+ ContextNodeListSetAndRestore
theContextNodeListSetAndRestore(
+ executionContext,
+ sourceNodes);
- {
- SetAndRestoreCurrentStackFrameIndex
theStackFrameSetAndRestore(
- executionContext,
- selectStackFrameIndex);
+ sorter->sort(executionContext,
*sortedSourceNodes);
+ }
- ContextNodeListSetAndRestore
theContextNodeListSetAndRestore(
+ transformSelectedChildren(
executionContext,
- sourceNodes);
-
- sorter->sort(executionContext, *sortedSourceNodes);
+ xslInstruction,
+ theTemplate,
+ sourceNodeContext,
+ *sortedSourceNodes,
+ nNodes);
+ }
}
-
- doTransformSelectedChildren(
- executionContext,
- xslInstruction,
- theTemplate,
- sourceNodeContext,
- *sortedSourceNodes,
- sourceNodesCount);
}
- else
- {
- doTransformSelectedChildren(
- executionContext,
- xslInstruction,
- theTemplate,
- sourceNodeContext,
- sourceNodes,
- sourceNodesCount);
- }
}
void
-ElemTemplateElement::doTransformSelectedChildren(
+ElemTemplateElement::transformSelectedChildren(
StylesheetExecutionContext&
executionContext,
const ElemTemplateElement&
xslInstruction,
const ElemTemplateElement*
theTemplate,
@@ -846,11 +726,6 @@
XalanNode* const childNode = sourceNodes.item(i);
assert(childNode != 0);
- if(XalanNode::DOCUMENT_NODE != childNode->getNodeType() &&
childNode->getOwnerDocument() == 0)
- {
- error("Child node does not have an owner document!");
- }
-
transformChild(
executionContext,
xslInstruction,
@@ -875,7 +750,7 @@
if(0 == theTemplate)
{
// Find the XSL template that is the best match for the
- // element, and call buildResultFromTemplate.
+ // element...
const Stylesheet* foundStylesheet = 0;
const bool isApplyImports =
xslInstruction.getXSLToken() == Constants::ELEMNAME_APPLY_IMPORTS;
@@ -1302,13 +1177,62 @@
void
-ElemTemplateElement::postConstruction(const NamespacesHandler&
theParentHandler)
+ElemTemplateElement::postConstruction(
+ StylesheetConstructionContext& constructionContext,
+ const NamespacesHandler&
theParentHandler)
{
m_namespacesHandler.postConstruction(getElementName(),
&theParentHandler);
for (ElemTemplateElement* node = m_firstChild; node != 0; node =
node->m_nextSibling)
{
- node->postConstruction(m_namespacesHandler);
+ node->postConstruction(constructionContext,
m_namespacesHandler);
+
+ if (hasVariables() == false &&
+ node->getXSLToken() == Constants::ELEMNAME_VARIABLE)
+ {
+ m_optimizationFlags |= eHasVariables;
+ }
+
+ if (hasParams() == false &&
+ node->getXSLToken() == Constants::ELEMNAME_WITHPARAM)
+ {
+ m_optimizationFlags |= eHasParams;
+ }
+ }
+
+ if (hasChildren() == true)
+ {
+ assert(m_firstChild != 0);
+
+ // There are opportunities for optimization if there's only one
+ // xsl:text child node. See childrenToString()...
+ if (m_firstChild->getXSLToken() ==
Constants::ELEMNAME_TEXTLITERALRESULT &&
+ m_firstChild->getNextSibling() == 0)
+ {
+ m_optimizationFlags |= eHasSingleTextChild;
+ }
+ else if (m_firstChild->getXSLToken() ==
Constants::ELEMNAME_CALLTEMPLATE &&
+ m_firstChild->getNextSibling() == 0)
+ {
+ // Just a single xsl:call-template child, so we don't
need to
+ // execute it if it has no params -- we can just
execute the
+ // template directly...
+ if (m_firstChild->hasParams() == false)
+ {
+ m_optimizationFlags |= eHasDirectTemplate;
+
+ ElemCallTemplate* const
theCallTemplateChild =
+#if defined(XALAN_OLD_STYLE_CASTS)
+ (ElemCallTemplate*)m_firstChild;
+#else
+
static_cast<ElemCallTemplate*>(m_firstChild);
+#endif
+
+ m_directTemplate =
theCallTemplateChild->getTemplate();
+
+ delete theCallTemplateChild;
+ }
+ }
}
}
1.30 +51 -66 xml-xalan/c/src/XSLT/ElemTemplateElement.hpp
Index: ElemTemplateElement.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemTemplateElement.hpp,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- ElemTemplateElement.hpp 2001/05/14 01:03:09 1.29
+++ ElemTemplateElement.hpp 2001/06/06 21:55:28 1.30
@@ -89,6 +89,7 @@
class AttributeList;
+class ElemTemplate;
class NamespacesHandler;
class NodeRefListBase;
class NodeSorter;
@@ -223,12 +224,16 @@
/**
* Take the contents of a template element, process it, and
- * convert it to a string.
+ * convert it to a string. Returns a const reference to
+ * the resulting string value. Note that this may _not_ be
+ * the XalanDOMString instance passed in, if an optimization
+ * is available to return a pre-existing string.
*
* @param executionContext The current execution context
* @param result result of executing the elements children
+ * @result a reference to a string containing the result.
*/
- void
+ const XalanDOMString&
childrenToString(
StylesheetExecutionContext&
executionContext,
XalanDOMString& result)
const;
@@ -256,17 +261,7 @@
isWhitespace() const;
/**
- * Tell if the string is whitespace.
- *
- * @param string string in question
- * @return true if the string is pure whitespace
- */
-// static bool
-// isWhitespace(const XalanDOMString& theString);
-
- /**
* Throw a template element runtime error.
- * (Note: should we throw a SAXException instead?)
*
* @param msg Description of the error that occurred
*/
@@ -275,7 +270,6 @@
/**
* Throw a template element runtime error.
- * (Note: should we throw a SAXException instead?)
*
* @param msg Description of the error that occurred
*/
@@ -351,7 +345,9 @@
* Called after construction is completed.
*/
virtual void
- postConstruction(const NamespacesHandler& theParentHandler);
+ postConstruction(
+ StylesheetConstructionContext& constructionContext,
+ const NamespacesHandler&
theParentHandler);
// Type-safe getters/setters...
@@ -633,6 +629,36 @@
virtual const XalanDOMString&
getURI() const;
+ bool
+ hasParams() const
+ {
+ return m_optimizationFlags & eHasParams ? true : false;
+ }
+
+ bool
+ hasVariables() const
+ {
+ return m_optimizationFlags & eHasVariables ? true : false;
+ }
+
+ bool
+ hasSingleTextChild() const
+ {
+ return m_optimizationFlags & eHasSingleTextChild ? true : false;
+ }
+
+ bool
+ hasChildren() const
+ {
+ return m_firstChild != 0 ? true : false;
+ }
+
+ bool
+ hasDirectTemplate() const
+ {
+ return m_optimizationFlags & eHasDirectTemplate ? true : false;
+ }
+
protected:
/**
@@ -656,7 +682,6 @@
* @param template The owning template context.
* @param sourceNodeContext The current source node context.
* @param selectPattern The XPath with which to perform the selection.
- * @param xslToken The current XSLT instruction
* @param selectStackFrameIndex stack frame context for executing the
* select statement
*/
@@ -667,28 +692,6 @@
const ElemTemplateElement* theTemplate,
XalanNode*
sourceNodeContext,
const XPath&
selectPattern,
- int
xslToken,
- int
selectStackFrameIndex) const;
-
- /**
- * Perform a query if needed, and call transformChild for each child.
- *
- * @param executionContext The current execution context
- * @param xslInstruction The stylesheet element context (deprecated --
I do
- * not think we need this).
- * @param template The owning template context.
- * @param sourceNodeContext The current source node context.
- * @param selectPattern The XPath with which to perform the selection.
- * @param selectStackFrameIndex stack frame context for executing the
- * select statement
- */
- void
- doTransformSelectedChildren(
- StylesheetExecutionContext&
executionContext,
- const ElemTemplateElement& xslInstruction,
- const ElemTemplateElement* theTemplate,
- XalanNode*
sourceNodeContext,
- const XPath&
selectPattern,
NodeSorter*
sorter,
int
selectStackFrameIndex) const;
@@ -698,40 +701,13 @@
* @param executionContext The current execution context
* @param xslInstruction The stylesheet element context (deprecated --
I do
* not think we need this).
- * @param template The owning template context.
- * @param sourceNodeContext The current source node context.
- * @param selectPattern The XPath with which to perform the selection.
- * @param xslToken The current XSLT instruction (deprecated -- I do not
- * think we want this).
- * @param selectStackFrameIndex stack frame context for executing the
- * select statement
- * @param sorter If non-null, use the sorter to sort the nodes.
- * @param sourceNodesCount The number of source nodes.
- */
- void
- doTransformSelectedChildren(
- StylesheetExecutionContext&
executionContext,
- const ElemTemplateElement& xslInstruction,
- const ElemTemplateElement* theTemplate,
- XalanNode*
sourceNodeContext,
- int
selectStackFrameIndex,
- NodeSorter*
sorter,
- const NodeRefListBase& sourceNodes,
- unsigned int
sourceNodesCount) const;
-
- /**
- * Perform a query if needed, and call transformChild for each child.
- *
- * @param executionContext The current execution context
- * @param xslInstruction The stylesheet element context (deprecated --
I do
- * not think we need this).
* @param theTemplate The owning template context.
* @param sourceNodeContext The current source node context.
* @param sourceNodes The source nodes to transform.
* @param sourceNodesCount The count of source nodes to transform.
*/
void
- doTransformSelectedChildren(
+ transformSelectedChildren(
StylesheetExecutionContext&
executionContext,
const ElemTemplateElement&
xslInstruction,
const ElemTemplateElement*
theTemplate,
@@ -797,13 +773,22 @@
ElemTemplateElement* m_parentNode;
ElemTemplateElement* m_nextSibling;
ElemTemplateElement* m_previousSibling;
- ElemTemplateElement* m_firstChild;
+ union
+ {
+ ElemTemplateElement* m_firstChild;
+ const ElemTemplate* m_directTemplate;
+ };
+
XalanNodeListSurrogate m_surrogateChildren;
XalanEmptyNamedNodeMap m_fakeAttributes;
const XalanDOMString m_baseIndentifier;
+
+ enum { eHasParams = 1, eHasSingleTextChild = 2, eHasVariables = 4,
eHasDirectTemplate = 8 };
+
+ unsigned m_optimizationFlags;
};
1.14 +12 -5 xml-xalan/c/src/XSLT/ElemTextLiteral.cpp
Index: ElemTextLiteral.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemTextLiteral.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- ElemTextLiteral.cpp 2001/03/29 22:24:26 1.13
+++ ElemTextLiteral.cpp 2001/06/06 21:55:29 1.14
@@ -90,9 +90,8 @@
m_isCData(isCData),
m_preserveSpace(preserveSpace),
m_disableOutputEscaping(disableOutputEscaping),
- m_ch(ch + start, ch + start + length)
+ m_ch(ch + start, length)
{
- assert(XMLChVectorType::size_type(int(m_ch.size())) == m_ch.size());
}
@@ -104,6 +103,14 @@
const XalanDOMString&
+ElemTextLiteral::getNodeValue() const
+{
+ return m_ch;
+}
+
+
+
+const XalanDOMString&
ElemTextLiteral::getElementName() const
{
return Constants::PSEUDONAME_TEXT;
@@ -114,7 +121,7 @@
bool
ElemTextLiteral::isWhitespace() const
{
- return isXMLWhitespace(&*m_ch.begin(), 0, m_ch.size());
+ return isXMLWhitespace(m_ch);
}
@@ -126,10 +133,10 @@
if(!m_disableOutputEscaping)
{
- executionContext.characters(&*m_ch.begin(), 0,
unsigned(m_ch.size()));
+ executionContext.characters(toCharArray(m_ch), 0, length(m_ch));
}
else
{
- executionContext.charactersRaw(&*m_ch.begin(), 0,
unsigned(m_ch.size()));
+ executionContext.charactersRaw(toCharArray(m_ch), 0,
length(m_ch));
}
}
1.12 +6 -9 xml-xalan/c/src/XSLT/ElemTextLiteral.hpp
Index: ElemTextLiteral.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemTextLiteral.hpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- ElemTextLiteral.hpp 2001/03/29 22:24:26 1.11
+++ ElemTextLiteral.hpp 2001/06/06 21:55:29 1.12
@@ -63,7 +63,7 @@
-#include <vector>
+#include <XalanDOM/XalanDOMString.hpp>
@@ -116,13 +116,7 @@
return m_preserveSpace;
}
-#if defined(XALAN_NO_NAMESPACES)
- typedef vector<XalanDOMChar> XMLChVectorType;
-#else
- typedef std::vector<XalanDOMChar> XMLChVectorType;
-#endif
-
- const XMLChVectorType&
+ const XalanDOMString&
getText() const
{
return m_ch;
@@ -134,6 +128,9 @@
// These methods are inherited from ElemTemplateElement ...
virtual const XalanDOMString&
+ getNodeValue() const;
+
+ virtual const XalanDOMString&
getElementName() const;
virtual void
@@ -151,7 +148,7 @@
const bool m_preserveSpace;
const bool m_disableOutputEscaping;
- const XMLChVectorType m_ch;
+ const XalanDOMString m_ch;
};
1.55 +52 -32 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.54
retrieving revision 1.55
diff -u -r1.54 -r1.55
--- Stylesheet.cpp 2001/05/14 01:03:11 1.54
+++ Stylesheet.cpp 2001/06/06 21:55:29 1.55
@@ -326,27 +326,29 @@
void
-Stylesheet::postConstruction()
+Stylesheet::postConstruction(StylesheetConstructionContext&
constructionContext)
{
- // Call postConstruction() on any imported stylesheets, the get any
aliases
- // in reverse order, to preserve import precedence. Also, get any key
declarations.
- const StylesheetVectorType::reverse_iterator theEnd =
m_imports.rend();
- StylesheetVectorType::reverse_iterator i = m_imports.rbegin();
-
- while(i != theEnd)
{
- (*i)->postConstruction();
+ // Call postConstruction() on any imported stylesheets, the get
any aliases
+ // in reverse order, to preserve import precedence. Also, get
any key declarations.
+ const StylesheetVectorType::reverse_iterator theEnd =
m_imports.rend();
+ StylesheetVectorType::reverse_iterator i = m_imports.rbegin();
+
+ while(i != theEnd)
+ {
+ (*i)->postConstruction(constructionContext);
-
m_namespacesHandler.copyNamespaceAliases((*i)->getNamespacesHandler());
+
m_namespacesHandler.copyNamespaceAliases((*i)->getNamespacesHandler());
- // $$ ToDo: Should we clear the imported stylesheet's key
- // declarations after we copy them?
- m_keyDeclarations.insert(
- m_keyDeclarations.end(),
- (*i)->m_keyDeclarations.begin(),
- (*i)->m_keyDeclarations.end());
+ // $$ ToDo: Should we clear the imported stylesheet's
key
+ // declarations after we copy them?
+ m_keyDeclarations.insert(
+ m_keyDeclarations.end(),
+ (*i)->m_keyDeclarations.begin(),
+ (*i)->m_keyDeclarations.end());
- ++i;
+ ++i;
+ }
}
// We may need to build keys, since we may have inherited them from
@@ -358,17 +360,42 @@
// Call postConstruction() on our own namespaces handler...
m_namespacesHandler.postConstruction();
+
+
+ {
+ for (ElemTemplateElement* node = m_firstTemplate;
+ node != 0;
+ node = node->getNextSiblingElem())
+ {
+ node->postConstruction(constructionContext,
m_namespacesHandler);
+ }
+ }
- ElemTemplateElement* node = m_firstTemplate;
+ {
+ for (ElemVariableVectorType::iterator it =
m_topLevelVariables.begin();
+ it != m_topLevelVariables.end();
+ ++it)
+ {
+ (*it)->postConstruction(constructionContext,
m_namespacesHandler);
+ }
+ }
- for (; node != 0; node = node->getNextSiblingElem())
- {
- node->postConstruction(m_namespacesHandler);
+ {
+ for (ElemTemplateElement* node = m_wrapperlessTemplate;
+ node != 0;
+ node = node->getNextSiblingElem())
+ {
+ node->postConstruction(constructionContext,
m_namespacesHandler);
+ }
}
+
+ {
+ for (AttributeSetVectorType::size_type i = 0; i <
m_attributeSets.size(); ++i)
+ {
+ assert(m_attributeSets[i] != 0);
- for (node = m_wrapperlessTemplate; node != 0; node =
node->getNextSiblingElem())
- {
- node->postConstruction(m_namespacesHandler);
+
m_attributeSets[i]->postConstruction(constructionContext, m_namespacesHandler);
+ }
}
m_patternCount = m_patternTable.size();
@@ -590,9 +617,7 @@
const ElemTemplate*
-Stylesheet::findNamedTemplate(
- const QName& qname,
- StylesheetExecutionContext& executionContext) const
+Stylesheet::findNamedTemplate(const QName& qname) const
{
const ElemTemplate* namedTemplate = 0;
@@ -607,7 +632,7 @@
{
const Stylesheet* const stylesheet = m_imports[i];
- namedTemplate = stylesheet->findNamedTemplate(qname,
executionContext);
+ namedTemplate = stylesheet->findNamedTemplate(qname);
if(0 != namedTemplate)
break;
@@ -616,11 +641,6 @@
else
{
namedTemplate = (*it).second;
- }
-
- if(0 == namedTemplate)
- {
- executionContext.warn("Could not find xsl:template named: " +
qname.getLocalPart());
}
return namedTemplate;
1.36 +5 -11 xml-xalan/c/src/XSLT/Stylesheet.hpp
Index: Stylesheet.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/Stylesheet.hpp,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- Stylesheet.hpp 2001/05/14 01:03:11 1.35
+++ Stylesheet.hpp 2001/06/06 21:55:30 1.36
@@ -138,7 +138,7 @@
typedef map<QNameByReference,
ElemTemplate*,
less<QName> >
ElemTemplateMapType;
- typedef vector<ElemAttributeSet*>
AttributeSetMapType;
+ typedef vector<ElemAttributeSet*>
AttributeSetVectorType;
typedef vector<ElemVariable*>
ElemVariableVectorType;
typedef vector<KeyDeclaration>
KeyDeclarationVectorType;
typedef map<const XalanNode*,
@@ -153,7 +153,7 @@
typedef std::map<XalanDOMString, XalanDOMString>
StringToStringMapType;
typedef std::map<XalanDOMString, ExtensionNSHandler*>
ExtensionNamespacesMapType;
typedef std::map<QNameByReference, ElemTemplate*>
ElemTemplateMapType;
- typedef std::vector<ElemAttributeSet*>
AttributeSetMapType;
+ typedef std::vector<ElemAttributeSet*>
AttributeSetVectorType;
typedef std::vector<ElemVariable*>
ElemVariableVectorType;
typedef std::vector<KeyDeclaration>
KeyDeclarationVectorType;
typedef std::map<const XalanNode*, KeyTable*>
KeyTablesTableType;
@@ -314,7 +314,7 @@
* Called after construction is completed.
*/
virtual void
- postConstruction();
+ postConstruction(StylesheetConstructionContext&
constructionContext);
/**
* See if this is a xmlns attribute, and, if so, process it.
@@ -663,13 +663,10 @@
* Locate a template via the "name" attribute.
*
* @param name qualified name of template
- * @param executionContext current execution context
* @return pointer to template found or 0 if none found
*/
const ElemTemplate*
- findNamedTemplate(
- const QName& qname,
- StylesheetExecutionContext& executionContext) const;
+ findNamedTemplate(const QName& qname) const;
/**
* Given a target element, find the template that best matches in the
given
@@ -1267,10 +1264,7 @@
*/
PatternTableMapType::size_type m_patternCount;
- /**
- * Table of attribute sets, keyed by set name.
- */
- AttributeSetMapType m_attributeSets;
+ AttributeSetVectorType m_attributeSets;
XalanNodeListSurrogate
m_surrogateChildren;
1.8 +22 -13 xml-xalan/c/src/XSLT/StylesheetExecutionContext.cpp
Index: StylesheetExecutionContext.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetExecutionContext.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- StylesheetExecutionContext.cpp 2001/04/11 02:36:21 1.7
+++ StylesheetExecutionContext.cpp 2001/06/06 21:55:31 1.8
@@ -82,32 +82,41 @@
StylesheetExecutionContext::ParamsPushPop::ParamsPushPop(
StylesheetExecutionContext&
executionContext,
- const ElemTemplateElement* /*
contextElement */,
const ElemTemplateElement&
xslCallTemplateElement,
XalanNode*
sourceNode,
const ElemTemplateElement* targetTemplate)
:
m_executionContext(executionContext),
- m_savedStackFrameIndex(executionContext.getCurrentStackFrameIndex())
+ m_savedStackFrameIndex(executionContext.getCurrentStackFrameIndex()),
+ m_pushContextMarker(xslCallTemplateElement.hasVariables() ||
xslCallTemplateElement.hasParams())
{
- executionContext.pushContextMarker();
+ if (m_pushContextMarker == true)
+ {
+ executionContext.pushContextMarker();
+
+
executionContext.setCurrentStackFrameIndex(m_savedStackFrameIndex);
+
+ if (xslCallTemplateElement.hasParams() == true)
+ {
+ executionContext.pushParams(
+ xslCallTemplateElement,
+ sourceNode,
+ targetTemplate);
+ }
- executionContext.setCurrentStackFrameIndex(m_savedStackFrameIndex);
-
- executionContext.pushParams(
- xslCallTemplateElement,
- sourceNode,
- targetTemplate);
-
- executionContext.setCurrentStackFrameIndex();
+ executionContext.setCurrentStackFrameIndex();
+ }
}
StylesheetExecutionContext::ParamsPushPop::~ParamsPushPop()
{
- m_executionContext.popContextMarker();
+ if (m_pushContextMarker == true)
+ {
+ m_executionContext.popContextMarker();
- m_executionContext.setCurrentStackFrameIndex(m_savedStackFrameIndex);
+
m_executionContext.setCurrentStackFrameIndex(m_savedStackFrameIndex);
+ }
}
1.55 +2 -1 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.54
retrieving revision 1.55
diff -u -r1.54 -r1.55
--- StylesheetExecutionContext.hpp 2001/05/14 01:03:11 1.54
+++ StylesheetExecutionContext.hpp 2001/06/06 21:55:31 1.55
@@ -796,7 +796,6 @@
ParamsPushPop(
StylesheetExecutionContext&
executionContext,
- const ElemTemplateElement* contextElement,
const ElemTemplateElement&
xslCallTemplateElement,
XalanNode*
sourceNode,
const ElemTemplateElement* targetTemplate);
@@ -814,6 +813,8 @@
StylesheetExecutionContext& m_executionContext;
const int
m_savedStackFrameIndex;
+
+ const bool
m_pushContextMarker;
};
/**
1.100 +3 -3 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.99
retrieving revision 1.100
diff -u -r1.99 -r1.100
--- XSLTEngineImpl.cpp 2001/05/14 01:03:12 1.99
+++ XSLTEngineImpl.cpp 2001/06/06 21:55:33 1.100
@@ -535,7 +535,7 @@
displayDuration(XALAN_STATIC_UCODE_STRING("Parse of ") + xslIdentifier,
&xslIdentifier);
}
- theStylesheet->postConstruction();
+ theStylesheet->postConstruction(constructionContext);
}
catch(const XSLException&)
{
@@ -876,7 +876,7 @@
localXSLURLString,
frag);
- stylesheet->postConstruction();
+ stylesheet->postConstruction(constructionContext);
theGuard.release();
}
@@ -927,7 +927,7 @@
m_parserLiaison.parseXMLStream(inputSource,
stylesheetProcessor);
- stylesheet->postConstruction();
+ stylesheet->postConstruction(constructionContext);
theGuard.release();
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]