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...@apache.org on 2001/06/29 20:53:38 UTC

cvs commit: xml-xalan/c/src/XSLT ElemApplyImport.cpp ElemAttributeSet.cpp ElemLiteralResult.cpp ElemTemplateElement.cpp ElemTemplateElement.hpp ElemUse.cpp ElemUse.hpp Stylesheet.cpp Stylesheet.hpp StylesheetRoot.cpp StylesheetRoot.hpp XSLTEngineImpl.cpp XSLTEngineImpl.hpp

dbertoni    01/06/29 11:53:38

  Modified:    c/src/XSLT ElemApplyImport.cpp ElemAttributeSet.cpp
                        ElemLiteralResult.cpp ElemTemplateElement.cpp
                        ElemTemplateElement.hpp ElemUse.cpp ElemUse.hpp
                        Stylesheet.cpp Stylesheet.hpp StylesheetRoot.cpp
                        StylesheetRoot.hpp XSLTEngineImpl.cpp
                        XSLTEngineImpl.hpp
  Log:
  New performance tweaks.
  
  Revision  Changes    Path
  1.13      +2 -3      xml-xalan/c/src/XSLT/ElemApplyImport.cpp
  
  Index: ElemApplyImport.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemApplyImport.cpp,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- ElemApplyImport.cpp	2001/06/06 21:55:16	1.12
  +++ ElemApplyImport.cpp	2001/06/29 18:53:10	1.13
  @@ -124,9 +124,8 @@
   	assert(sourceNode != 0);
   
   	transformChild(executionContext,
  -				   *this, 
  -				   0,                    
  -				   DOMServices::getParentOfNode(*sourceNode), 
  +				   *this,
  +				   0,
   				   sourceNode);   
   }
   
  
  
  
  1.12      +1 -1      xml-xalan/c/src/XSLT/ElemAttributeSet.cpp
  
  Index: ElemAttributeSet.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemAttributeSet.cpp,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ElemAttributeSet.cpp	2001/06/25 15:19:59	1.11
  +++ ElemAttributeSet.cpp	2001/06/29 18:53:12	1.12
  @@ -93,7 +93,7 @@
   		{
   			m_QName = QNameByValue(atts.getValue(i), stylesheetTree.getNamespaces());
   
  -			stylesheetTree.addAttributeSet(m_QName, this);
  +			stylesheetTree.addAttributeSet(this);
   		}
   		else if(!(processUseAttributeSets(constructionContext, aname, atts, i) ||
   					isAttrOK(aname, atts, i, constructionContext)))
  
  
  
  1.39      +35 -3     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.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- ElemLiteralResult.cpp	2001/06/13 22:24:59	1.38
  +++ ElemLiteralResult.cpp	2001/06/29 18:53:12	1.39
  @@ -220,8 +220,40 @@
   		}
   	}
   
  +	if (nAttrs != 0 ||
  +		m_namespacesHandler.getNamespaceDeclarationsCount() != 0)
  +	{
  +		canGenerateAttributes(true);
  +	}
  +	else
  +	{
  +		// OK, let's turn this off and see what our
  +		// base classes say about it when we chain up...
  +		canGenerateAttributes(false);
  +	}
  +
   	// OK, now we can chain-up...
   	ElemUse::postConstruction(constructionContext, theParentHandler);
  +
  +	// OK, now let's do some more checking to see if we'll
  +	// generate attributes...
  +	if (canGenerateAttributes() == false)
  +	{
  +		// If there are no children, we can't generate any attributes...
  +		if (hasChildren() == true)
  +		{
  +			assert(getFirstChildElem() != 0);
  +
  +			// If there's a single text child, or the first child
  +			// is another LRE, then we won't generate any attributes.
  +			// Otherwise, we might...
  +			if (hasSingleTextChild() == false &&
  +				getFirstChildElem()->getXSLToken() != Constants::ELEMNAME_LITERALRESULT)
  +			{
  +				canGenerateAttributes(true);
  +			}
  +		}
  +	}
   }
   
   
  @@ -247,7 +279,7 @@
   
   
   void
  -ElemLiteralResult::execute(StylesheetExecutionContext&		executionContext) const
  +ElemLiteralResult::execute(StylesheetExecutionContext&	executionContext) const
   {
   	executionContext.startElement(c_wstr(getElementName()));
   
  @@ -255,14 +287,14 @@
   
   	m_namespacesHandler.outputResultNamespaces(executionContext);
   
  -	// OK, now let's check to make sure we don't have to change the default namespace...
  +	// OK, let's check to make sure we don't have to change the default namespace...
   	const XalanDOMString* const		theCurrentDefaultNamespace =
   				executionContext.getResultNamespaceForPrefix(s_emptyString);
   
   	if (theCurrentDefaultNamespace != 0)
   	{
   		const XalanDOMString* const		theElementDefaultNamespace =
  -					m_namespacesHandler.getNamespace(s_emptyString);
  +						m_namespacesHandler.getNamespace(s_emptyString);
   
   		if (theElementDefaultNamespace == 0)
   		{
  
  
  
  1.61      +34 -34    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.60
  retrieving revision 1.61
  diff -u -r1.60 -r1.61
  --- ElemTemplateElement.cpp	2001/06/25 21:58:53	1.60
  +++ ElemTemplateElement.cpp	2001/06/29 18:53:13	1.61
  @@ -107,10 +107,12 @@
   
   
   
  -const XalanDOMString	ElemTemplateElement::s_emptyString;
  +const XalanDOMString			ElemTemplateElement::s_emptyString;
   
  +const XalanEmptyNamedNodeMap	ElemTemplateElement::s_fakeAttributes;
   
   
  +
   ElemTemplateElement::ElemTemplateElement(
   			StylesheetConstructionContext&	/* constructionContext */,
   			Stylesheet&						stylesheetTree,
  @@ -126,16 +128,15 @@
   	m_stylesheet(stylesheetTree),
   	m_lineNumber(lineNumber),
   	m_columnNumber(columnNumber),
  -	m_defaultSpace(true),	
  +	m_defaultSpace(true),
   	m_xslToken(xslToken),
   	m_parentNode(0),
   	m_nextSibling(0),
   	m_previousSibling(0),
   	m_firstChild(0),
   	m_surrogateChildren(*this),
  -	m_fakeAttributes(),
   	m_baseIndentifier(stylesheetTree.getCurrentIncludeBaseIdentifier()),
  -	m_optimizationFlags(0)
  +	m_optimizationFlags(eCanGenerateAttributes)
   {
   }
   
  @@ -743,7 +744,6 @@
   					executionContext,
   					xslInstruction,
   					theTemplate,
  -					sourceNodeContext,
   					sourceNodes,
   					nNodes);
   			}
  @@ -773,7 +773,6 @@
   					executionContext,
   					xslInstruction,
   					theTemplate,
  -					sourceNodeContext,
   					*sortedSourceNodes,
   					nNodes);
   			}
  @@ -788,7 +787,6 @@
   			StylesheetExecutionContext&			executionContext,
   			const ElemTemplateElement&			xslInstruction,
   			const ElemTemplateElement*			theTemplate,
  -			XalanNode*							sourceNodeContext,
   			const NodeRefListBase&				sourceNodes,
   			unsigned int						sourceNodesCount) const
   {
  @@ -813,7 +811,6 @@
   				executionContext,
   				xslInstruction,
   				theTemplate,
  -				sourceNodeContext, 
   				childNode);
   	}
   }
  @@ -825,7 +822,6 @@
   			StylesheetExecutionContext&		executionContext,
   			const ElemTemplateElement&		xslInstruction,
   			const ElemTemplateElement*		theTemplate,
  -			XalanNode*						selectContext,
   			XalanNode*						child) const
   {
   	const XalanNode::NodeType	nodeType = child->getNodeType();
  @@ -834,8 +830,6 @@
   	{
   		// Find the XSL template that is the best match for the 
   		// element...
  -		const Stylesheet*	foundStylesheet = 0;
  -
   		const bool			isApplyImports = xslInstruction.getXSLToken() == Constants::ELEMNAME_APPLY_IMPORTS;
   
   		const Stylesheet*	stylesheetTree = isApplyImports ?
  @@ -846,8 +840,7 @@
   						executionContext,
   						child,
   						*executionContext.getCurrentMode(),
  -						isApplyImports,
  -						foundStylesheet);
  +						isApplyImports);
   	}
   
   	if(0 == theTemplate)
  @@ -1021,7 +1014,7 @@
   const XalanNamedNodeMap*
   ElemTemplateElement::getAttributes() const
   {
  -	return &m_fakeAttributes;
  +	return &s_fakeAttributes;
   }
   
   
  @@ -1262,39 +1255,41 @@
   {
   	m_namespacesHandler.postConstruction(getElementName(), &theParentHandler);
   
  -    for (ElemTemplateElement* node = m_firstChild; node != 0; node = node->m_nextSibling) 
  -    {
  -		node->postConstruction(constructionContext, m_namespacesHandler);
  +	if (hasChildren() == true)
  +	{
  +		for (ElemTemplateElement* node = m_firstChild; node != 0; node = node->m_nextSibling) 
  +		{
  +			node->postConstruction(constructionContext, m_namespacesHandler);
   
  -		const int	theToken = node->getXSLToken();
  +			const int	theToken = node->getXSLToken();
   
  -		if (hasVariables() == false &&
  -			(theToken == Constants::ELEMNAME_VARIABLE ||
  -			 theToken == Constants::ELEMNAME_PARAMVARIABLE))
  -		{
  -			m_optimizationFlags |= eHasVariables;
  -		}
  +			if (hasVariables() == false &&
  +				(theToken == Constants::ELEMNAME_VARIABLE ||
  +				 theToken == Constants::ELEMNAME_PARAMVARIABLE))
  +			{
  +				m_optimizationFlags |= eHasVariables;
  +			}
   
  -		if (hasParams() == false &&
  -			theToken == Constants::ELEMNAME_WITHPARAM)
  -		{
  -			m_optimizationFlags |= eHasParams;
  +			if (hasParams() == false &&
  +				theToken == Constants::ELEMNAME_WITHPARAM)
  +			{
  +				m_optimizationFlags |= eHasParams;
  +			}
   		}
  -	}
   
  -	if (hasChildren() == true)
  -	{
   		assert(m_firstChild != 0);
   
  +		const int	theToken = m_firstChild->getXSLToken();
  +
   		// There are opportunities for optimization if there's only one
   		// xsl:text child node.  See childrenToString()...
  -		if (m_firstChild->getXSLToken() == Constants::ELEMNAME_TEXTLITERALRESULT &&
  +		if (theToken == Constants::ELEMNAME_TEXTLITERALRESULT &&
   			m_firstChild->getNextSibling() == 0)
   		{
   			m_optimizationFlags |= eHasSingleTextChild;
   		}
  -		else if (m_firstChild->getXSLToken() == Constants::ELEMNAME_CALLTEMPLATE &&
  -			m_firstChild->getNextSibling() == 0)
  +		else if (theToken == 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
  @@ -1314,6 +1309,11 @@
   
   				delete theCallTemplateChild;
   			}
  +		}
  +		else if (canGenerateAttributes() == false &&
  +				 theToken != Constants::ELEMNAME_LITERALRESULT)
  +		{
  +			m_optimizationFlags |= eCanGenerateAttributes;
   		}
   	}
   }
  
  
  
  1.32      +31 -11    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.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- ElemTemplateElement.hpp	2001/06/25 21:58:54	1.31
  +++ ElemTemplateElement.hpp	2001/06/29 18:53:14	1.32
  @@ -77,13 +77,10 @@
   
   
   #include <PlatformSupport/DOMStringHelper.hpp>
  +#include <PlatformSupport/PrefixResolver.hpp>
   
   
   
  -#include <DOMSupport/PrefixResolver.hpp>
  -
  -
  -
   #include <XSLT/NamespacesHandler.hpp>
   
   
  @@ -695,8 +692,31 @@
   		return m_optimizationFlags & eHasDirectTemplate ? true : false;
   	}
   
  +	/**
  +	 *
  +	 * Determine whether or not the instance can generate
  +	 */
  +	bool
  +	canGenerateAttributes() const
  +	{
  +		return m_optimizationFlags & eCanGenerateAttributes ? true : false;
  +	}
  +
   protected:
   
  +	void
  +	canGenerateAttributes(bool	value)
  +	{
  +		if (value == true)
  +		{
  +			m_optimizationFlags |= eCanGenerateAttributes;
  +		}
  +		else
  +		{
  +			m_optimizationFlags &= ~eCanGenerateAttributes;
  +		}
  +	}
  +
   	/**
   	 * Get the namespace for a given prefix.
   	 * 
  @@ -738,7 +758,6 @@
   	 * @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.
   	 */
  @@ -747,7 +766,6 @@
   			StylesheetExecutionContext&			executionContext,
   			const ElemTemplateElement&			xslInstruction,
   			const ElemTemplateElement*			theTemplate,
  -			XalanNode*							sourceNodeContext,
   			const NodeRefListBase&				sourceNodes,
   			unsigned int						sourceNodesCount) const;
   
  @@ -759,7 +777,6 @@
   	 * @param xslInstruction The calling element (deprecated -- I dont think we 
   	 *      need this).
   	 * @param template The template to use if xsl:for-each, or null.
  -	 * @param selectContext The selection context.
   	 * @param child The source context node.
   	 * @return true if applied a template, false if not.
   	 */
  @@ -768,7 +785,6 @@
   			StylesheetExecutionContext&		executionContext,
   			const ElemTemplateElement&		xslInstruction,
   			const ElemTemplateElement*		theTemplate,
  -			XalanNode*						selectContext,
   			XalanNode*						child) const;
   
   	/**
  @@ -831,13 +847,17 @@
   
   	XalanNodeListSurrogate	m_surrogateChildren;
   
  -	XalanEmptyNamedNodeMap	m_fakeAttributes;
  -
   	const XalanDOMString	m_baseIndentifier;
   
  -	enum { eHasParams = 1, eHasSingleTextChild = 2, eHasVariables = 4, eHasDirectTemplate = 8 };
  +	enum { eHasParams = 1,
  +		   eHasSingleTextChild = 2,
  +		   eHasVariables = 4,
  +		   eHasDirectTemplate = 8,
  +		   eCanGenerateAttributes = 16 };
   
   	unsigned				m_optimizationFlags;
  +
  +	static const XalanEmptyNamedNodeMap		s_fakeAttributes;
   };
   
   
  
  
  
  1.13      +24 -2     xml-xalan/c/src/XSLT/ElemUse.cpp
  
  Index: ElemUse.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemUse.cpp,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- ElemUse.cpp	2001/06/25 15:20:02	1.12
  +++ ElemUse.cpp	2001/06/29 18:53:15	1.13
  @@ -112,13 +112,35 @@
   
   
   void
  +ElemUse::postConstruction(
  +			StylesheetConstructionContext&	constructionContext,
  +			const NamespacesHandler&		theParentHandler)
  +{
  +	if (m_attributeSetsNames.size() != 0)
  +	{
  +		canGenerateAttributes(true);
  +	}
  +
  +	// OK, now we can chain-up...
  +	ElemTemplateElement::postConstruction(constructionContext, theParentHandler);
  +}
  +
  +
  +
  +void
   ElemUse::execute(StylesheetExecutionContext&		executionContext) const
   {
   	ElemTemplateElement::execute(executionContext);
   
   	if(0 != m_attributeSetsNames.size())
  -		getStylesheet().getStylesheetRoot().applyAttrSets(m_attributeSetsNames, 
  -				executionContext, executionContext.getCurrentNode());
  +	{
  +		assert(canGenerateAttributes() == true);
  +
  +		getStylesheet().getStylesheetRoot().applyAttrSets(
  +				m_attributeSetsNames, 
  +				executionContext,
  +				executionContext.getCurrentNode());
  +	}
   }
   
   
  
  
  
  1.13      +5 -0      xml-xalan/c/src/XSLT/ElemUse.hpp
  
  Index: ElemUse.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemUse.hpp,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- ElemUse.hpp	2001/06/25 15:20:03	1.12
  +++ ElemUse.hpp	2001/06/29 18:53:17	1.13
  @@ -138,6 +138,11 @@
   	getElementName() const;
   
   	virtual void
  +	postConstruction(
  +			StylesheetConstructionContext&	constructionContext,
  +			const NamespacesHandler&		theParentHandler);
  +
  +	virtual void
   	execute(StylesheetExecutionContext&		executionContext) const;
   
   private:
  
  
  
  1.58      +239 -419  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.57
  retrieving revision 1.58
  diff -u -r1.57 -r1.58
  --- Stylesheet.cpp	2001/06/27 18:27:58	1.57
  +++ Stylesheet.cpp	2001/06/29 18:53:18	1.58
  @@ -111,10 +111,14 @@
   
   
   
  -const XalanDOMString	Stylesheet::s_emptyString;
  +const XalanDOMString			Stylesheet::s_emptyString;
   
  +const QNameByReference			Stylesheet::s_emptyQName;
   
  +const XalanEmptyNamedNodeMap	Stylesheet::s_fakeAttributes;
   
  +
  +
   Stylesheet::Stylesheet(
   		StylesheetRoot& 				root,
   		const XalanDOMString&			baseIdentifier,
  @@ -122,22 +126,20 @@
   	XalanDocument(),
   	PrefixResolver(),
   	m_stylesheetRoot(root),
  -	m_needToBuildKeysTable(false),
   	m_baseIdent(baseIdentifier),
   	m_keyDeclarations(),
   	m_XSLTNamespaceURI(constructionContext.getXSLTNamespaceURI()),
   	m_whitespacePreservingElements(),
   	m_whitespaceStrippingElements(),	
   	m_imports(),
  +	m_importsSize(0),
   	m_namespaces(),
   	m_namespaceDecls(),
  -	m_tablesAreInvalid(true),
   	m_isWrapperless(false),
   	m_wrapperlessTemplate(0),
   	m_extensionNamespaces(),
   	m_firstTemplate(0),
   	m_includeStack(),
  -	m_defaultSpace(true),
   	m_namedTemplates(),
   	m_topLevelVariables(),
   	m_XSLTVerDeclared(1.0L),
  @@ -150,13 +152,11 @@
   	m_piPatternList(),
   	m_nodePatternList(),
   	m_anyPatternList(),
  -	m_anyPatternBegin(m_anyPatternList.begin()),
  -	m_anyPatternEnd(m_anyPatternList.end()),
   	m_matchPattern2Container(),
   	m_patternCount(0),
   	m_attributeSets(),
  +	m_attributeSetsSize(0),
   	m_surrogateChildren(*this),
  -	m_fakeAttributes(),
   	m_elemDecimalFormats(),
   	m_prefixAliases(),
   	m_namespacesHandler()
  @@ -271,17 +271,15 @@
   	}
   
   	if(0 == nameAttr)
  -		constructionContext.error(TranscodeFromLocalCodePage("xsl:key	requires a ") + Constants::ATTRNAME_NAME + " attribute!");
  +		constructionContext.error(TranscodeFromLocalCodePage("xsl:key requires a ") + Constants::ATTRNAME_NAME + " attribute!");
   
   	if(0 == matchAttr)
  -		constructionContext.error(TranscodeFromLocalCodePage("xsl:key	requires a ") + Constants::ATTRNAME_MATCH + " attribute!");
  +		constructionContext.error(TranscodeFromLocalCodePage("xsl:key requires a ") + Constants::ATTRNAME_MATCH + " attribute!");
   
   	if(0 == useAttr)
  -		constructionContext.error(TranscodeFromLocalCodePage("xsl:key	requires a ") + Constants::ATTRNAME_USE + " attribute!");
  +		constructionContext.error(TranscodeFromLocalCodePage("xsl:key requires a ") + Constants::ATTRNAME_USE + " attribute!");
   
   	m_keyDeclarations.push_back(KeyDeclaration(XalanDOMString(nameAttr), *matchAttr, *useAttr));
  -
  -	m_needToBuildKeysTable = true;
   }
   
   
  @@ -313,16 +311,6 @@
   
   
   
  -void
  -Stylesheet::popNamespaces() 
  -{
  -	assert(m_namespaces.empty() == false);
  -
  -	m_namespaces.pop_back(); 
  -}
  -
  -
  -
   class attrSetCompare
   {
   public:
  @@ -351,6 +339,8 @@
   Stylesheet::postConstruction(StylesheetConstructionContext&		constructionContext)
   {
   	{
  +		m_importsSize = m_imports.size();
  +
   		// 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();
  @@ -373,13 +363,6 @@
   		}
   	}
   
  -	// We may need to build keys, since we may have inherited them from
  -	// our imports.
  -	if (m_needToBuildKeysTable == false && m_keyDeclarations.size() > 0)
  -	{
  -		m_needToBuildKeysTable = true;
  -	}
  -
   	// Call postConstruction() on our own namespaces handler...
   	m_namespacesHandler.postConstruction();
   
  @@ -447,38 +430,61 @@
   
   			theCurrent->postConstruction(constructionContext, m_namespacesHandler);
   		}
  +
  +		// Now that we're done with removing duplicates, cache the size...
  +		m_attributeSetsSize = m_attributeSets.size();
   	}
   
  -	const PatternTableListType::iterator	theNodeBegin = m_nodePatternList.begin();
  -	const PatternTableListType::iterator	theNodeEnd = m_nodePatternList.end();
  +	// OK, now we need to add everything template that matches "node()"
  +	// to the end of the text, comment, and PI template lists.
  +	PatternTableListType::iterator	theBegin = m_nodePatternList.begin();
  +	PatternTableListType::iterator	theEnd = m_nodePatternList.end();
   
  -	m_textPatternList.insert(
  -		m_textPatternList.end(),
  -		theNodeBegin,
  -		theNodeEnd);
  -
  -	m_commentPatternList.insert(
  -		m_commentPatternList.end(),
  -		theNodeBegin,
  -		theNodeEnd);
  -
  -	m_piPatternList.insert(
  -		m_piPatternList.end(),
  -		theNodeBegin,
  -		theNodeEnd);
  -
  -	m_anyPatternList.insert(
  -		m_anyPatternList.end(),
  -		theNodeBegin,
  -		theNodeEnd);
  +	if (theBegin != theEnd)
  +	{
  +		m_textPatternList.insert(
  +			m_textPatternList.end(),
  +			theBegin,
  +			theEnd);
   
  -	m_anyPatternBegin = m_anyPatternList.begin();
  -	m_anyPatternEnd = m_anyPatternList.end();
  +		m_commentPatternList.insert(
  +			m_commentPatternList.end(),
  +			theBegin,
  +			theEnd);
   
  -	m_patternCount = m_matchPattern2Container.size();
  +		m_piPatternList.insert(
  +			m_piPatternList.end(),
  +			theBegin,
  +			theEnd);
  +	}
  +
  +	m_nodePatternList.insert(
  +			theEnd,
  +			m_anyPatternList.begin(),
  +			m_anyPatternList.end());
  +
  +	theBegin = m_nodePatternList.begin();
  +	theEnd = m_nodePatternList.end();
  +
  +	if (theBegin != theEnd)
  +	{
  +		PatternTableMapType::iterator	i =
  +				m_patternTable.begin();
  +
  +		while(i != m_patternTable.end())
  +		{
  +			PatternTableListType&	theTable = (*i).second;
  +
  +			theTable.insert(
  +				theTable.end(),
  +				theBegin,
  +				theEnd);
   
  -	// We don't need this any more, so clear it out...
  -	PatternTableListType().swap(m_nodePatternList);
  +			++i;
  +		}
  +	}
  +
  +	m_patternCount = m_matchPattern2Container.size();
   }
   
   
  @@ -519,14 +525,6 @@
   
   
   const XalanDOMString*
  -Stylesheet::getNamespaceFromStack(const XalanDOMString&		nodeName) const
  -{
  -	return getNamespaceFromStack(c_wstr(nodeName));
  -}
  -
  -
  -
  -const XalanDOMString*
   Stylesheet::getNamespaceFromStack(const XalanDOMChar* 	nodeName) const
   {
   	assert(nodeName != 0);
  @@ -543,32 +541,6 @@
   
   
   
  -const XalanDOMString*
  -Stylesheet::getNamespaceForPrefix(const XalanDOMString& 	prefix) const
  -{
  -	return QName::getNamespaceForPrefix(m_namespaceDecls, prefix);
  -}
  -
  -
  -
  -const XalanDOMString*
  -Stylesheet::getNamespaceForPrefixFromStack(const XalanDOMString&	prefix) const
  -{
  -	return QName::getNamespaceForPrefix(m_namespaces, prefix);
  -}
  -
  -
  -
  -const XalanDOMString*
  -Stylesheet::getNamespaceForPrefixFromStack(const XalanDOMChar*	prefix) const
  -{
  -	assert(prefix != 0);
  -
  -	return QName::getNamespaceForPrefix(m_namespaces, XalanDOMString(prefix));
  -}
  -
  -
  -
   bool
   Stylesheet::getYesOrNo(
   			const XalanDOMChar* 			aname,
  @@ -688,11 +660,11 @@
   						*theTemplate,
   						pos,
   						target,
  -						*this,
   						*xp,
   						xp->getExpression().getCurrentPattern()));
   
  -				MatchPattern2* newMatchPat = &m_matchPattern2Container.back();
  +				const MatchPattern2* const	newMatchPat =
  +					&m_matchPattern2Container.back();
   
   				// Always put things on the front of the list, so
   				// templates later in the stylesheet are always
  @@ -753,13 +725,17 @@
   const ElemTemplate*
   Stylesheet::findNamedTemplate(const QName&	qname) const
   {
  -	const ElemTemplate*		namedTemplate = 0;
  -
   	ElemTemplateMapType::const_iterator it = m_namedTemplates.find(qname);
   
  -	// Look for the template in the imports
  -	if(it == m_namedTemplates.end())
  +	if(it != m_namedTemplates.end())
   	{
  +		return (*it).second;
  +	}
  +	else
  +	{
  +		const ElemTemplate*		namedTemplate = 0;
  +
  +		// Look for the template in the imports
   		const StylesheetVectorType::size_type	nImports = m_imports.size();
   
   		for(StylesheetVectorType::size_type i = 0; i < nImports; ++i)
  @@ -771,29 +747,13 @@
   			if(0 != namedTemplate)
   				break;
   		}
  -	}
  -	else
  -	{
  -		namedTemplate = (*it).second;
  -	}
   
  -	return namedTemplate;
  +		return namedTemplate;
  +	}
   }
   	
   
   
  -const ElemTemplate*
  -Stylesheet::findTemplate(
  -			StylesheetExecutionContext& 	executionContext,
  -			XalanNode*						targetNode) const
  -{
  -	const Stylesheet*	theDummy;
  -
  -	return findTemplate(executionContext, targetNode, QNameByReference(), false, theDummy);
  -}
  -
  -
  -
   void
   Stylesheet::addObjectIfNotFound(
   			const MatchPattern2*		thePattern,
  @@ -818,7 +778,7 @@
   
   
   
  -void
  +inline void
   Stylesheet::addObjectIfNotFound(
   			const MatchPattern2*	thePattern,
   			const MatchPattern2* 	thePatternArray[],
  @@ -856,9 +816,7 @@
   
   
   inline const Stylesheet::PatternTableListType* 
  -Stylesheet::locateMatchPatternList2(
  -			const XalanDOMString&	theName,
  -			bool&					usedWildcard) const
  +Stylesheet::locateMatchPatternList2(const XalanDOMString&	theName) const
   {
   	assert(m_patternTableEnd == m_patternTable.end());
   
  @@ -866,17 +824,53 @@
   		m_patternTable.find(theName);
   
   	if (i != m_patternTableEnd)
  -	{		
  -		usedWildcard = false;
  -
  +	{
   		return &(*i).second;
   	}
   	else
  +	{
  +		return &m_nodePatternList;
  +	}
  +}
  +
  +
  +
  +inline const Stylesheet::PatternTableListType*
  +Stylesheet::locateMatchPatternList2(const XalanNode&	theNode) const
  +{
  +	switch(theNode.getNodeType())
   	{
  -		usedWildcard = true;
  +	case XalanNode::ELEMENT_NODE:
  +		return locateMatchPatternList2(DOMServices::getLocalNameOfNode(theNode));
  +		break;
  +
  +	case XalanNode::PROCESSING_INSTRUCTION_NODE:
  +		return &m_piPatternList;
  +		break;
  +
  +	case XalanNode::ATTRIBUTE_NODE:
  +		return locateMatchPatternList2(DOMServices::getLocalNameOfNode(theNode));
  +		break;
  +
  +	case XalanNode::CDATA_SECTION_NODE:
  +	case XalanNode::TEXT_NODE:
  +		return &m_textPatternList;
  +		break;
   
  +	case XalanNode::COMMENT_NODE:
  +		return &m_commentPatternList;
  +		break;
  +
  +	case XalanNode::DOCUMENT_NODE:
  +		return &m_rootPatternList;
  +		break;
  +
  +	case XalanNode::DOCUMENT_FRAGMENT_NODE:
   		return &m_anyPatternList;
  +		break;
   	}
  +
  +	return locateMatchPatternList2(theNode.getNodeName());
   }
   
   
  @@ -886,22 +880,19 @@
   			StylesheetExecutionContext& 	executionContext,
   			XalanNode*						targetNode, 
   			const QName&					mode,
  -			bool							onlyUseImports,
  -			const Stylesheet*&				foundStylesheet) const
  +			bool							onlyUseImports) const
   {
   	assert(targetNode != 0);
   	assert(m_patternCount == m_matchPattern2Container.size());
  -	assert(m_anyPatternBegin == m_anyPatternList.begin());
  -	assert(m_anyPatternEnd == m_anyPatternList.end());
  -
  -	const ElemTemplate*		theResult = 0;
   
  -	if(m_isWrapperless)
  +	if(m_isWrapperless == true)
   	{
  -		theResult = m_wrapperlessTemplate;
  +		return m_wrapperlessTemplate;
   	}
   	else
   	{
  +		const ElemTemplate*		theResult = 0;
  +
   		const ElemTemplate*		bestMatchedRule = 0;
   		const MatchPattern2*	bestMatchedPattern = 0; // Syncs with bestMatchedRule
   		double					bestMatchPatPriority = XPath::s_MatchScoreNone;
  @@ -919,194 +910,127 @@
   		{
   			// Points to the current list of match patterns.  Note
   			// that this may point to more than one table.
  -			const PatternTableListType* 	matchPatternList = 0;
  -			const XalanNode::NodeType		targetNodeType = targetNode->getNodeType();
  -
  -			// Assume we'll match a wildcard.  This will only change
  -			// for elements, attributes, and for our default catch-all,
  -			// but it will keep us from checking m_anyPatternList.
  -			bool							usedWildcard = true;
  -
  -			switch(targetNodeType)
  -			{
  -			case XalanNode::ELEMENT_NODE:
  -				matchPatternList =
  -					locateMatchPatternList2(
  -							DOMServices::getLocalNameOfNode(*targetNode),
  -							usedWildcard);
  -				break;
  -
  -			case XalanNode::PROCESSING_INSTRUCTION_NODE:
  -				matchPatternList = &m_piPatternList;
  -				break;
  -
  -			case XalanNode::ATTRIBUTE_NODE:
  -				matchPatternList = locateMatchPatternList2(
  -							DOMServices::getLocalNameOfNode(*targetNode),
  -							usedWildcard);
  -				break;
  -
  -			case XalanNode::CDATA_SECTION_NODE:
  -			case XalanNode::TEXT_NODE:
  -				matchPatternList = &m_textPatternList;
  -				break;
  -
  -			case XalanNode::COMMENT_NODE:
  -				matchPatternList = &m_commentPatternList;
  -				break;
  -
  -			case XalanNode::DOCUMENT_NODE:
  -				matchPatternList = &m_rootPatternList;
  -				break;
  -
  -			case XalanNode::DOCUMENT_FRAGMENT_NODE:
  -				matchPatternList = &m_anyPatternList;
  -				break;
  -
  -			default:
  -				matchPatternList = locateMatchPatternList2(
  -							targetNode->getNodeName(),
  -							usedWildcard);
  -				break;
  -			}
  -
  +			const PatternTableListType* 	matchPatternList =
  +				locateMatchPatternList2(*targetNode);
   			assert(matchPatternList != 0);
   
  -			const XalanDOMString*	prevPat = 0;
  -			const MatchPattern2*	prevMatchPat = 0;
  -			double					prevMatchPatPriority = XPath::s_MatchScoreNone;
  -
  -			// These are iterators into the current table.
  -			// Note that we may re-seat these iterators to
  -			// point into a different table, if we have
  -			// to match wildcards.
  -			PatternTableListType::const_iterator	theCurrentEntry =
  +			PatternTableListType::const_iterator		theCurrentEntry =
   				matchPatternList->begin();
   
  -			PatternTableListType::const_iterator	theTableEnd =
  +			const PatternTableListType::const_iterator	theTableEnd =
   				matchPatternList->end();
   
  -			while(theCurrentEntry != theTableEnd)
  +			if (theCurrentEntry != theTableEnd)
   			{
  -				const MatchPattern2*	matchPat = *theCurrentEntry;
  -				double					matchPatPriority = XPath::s_MatchScoreNone;
  -				assert(matchPat != 0);
  -
  -				const ElemTemplate*		rule = matchPat->getTemplate();
  -
  -				// We'll be needing to match rules according to what 
  -				// mode we're in.
  -				const QName&			ruleMode =
  -						rule->getMode();
  -
  -				// The logic here should be that if we are not in a mode AND
  -				// the rule does not have a node, then go ahead.
  -				// OR if we are in a mode, AND the rule has a node, 
  -				// AND the rules match, then go ahead.
  -				bool haveMode = !mode.isEmpty();
  -				bool haveRuleMode = !ruleMode.isEmpty();
  +				const XalanDOMString*	prevPat = 0;
  +				const MatchPattern2*	prevMatchPat = 0;
  +				double					prevMatchPatPriority = XPath::s_MatchScoreNone;
   
  -				if ( (!haveMode && !haveRuleMode) || (haveMode && haveRuleMode && ruleMode.equals(mode)))
  +				do
   				{
  -					const XalanDOMString*	patterns = matchPat->getPattern();
  -					assert(patterns != 0);
  +					const MatchPattern2*	matchPat = *theCurrentEntry;
  +					double					matchPatPriority = XPath::s_MatchScoreNone;
  +					assert(matchPat != 0);
  +
  +					const ElemTemplate*	const	rule = matchPat->getTemplate();
  +					assert(rule != 0);
  +
  +					// We'll be needing to match rules according to what 
  +					// mode we're in.
  +					const QName&	ruleMode = rule->getMode();
  +
  +					// The logic here should be that if we are not in a mode AND
  +					// the rule does not have a node, then go ahead.
  +					// OR if we are in a mode, AND the rule has a node, 
  +					// AND the rules match, then go ahead.
  +					const bool	haveMode = !mode.isEmpty();
  +					const bool	haveRuleMode = !ruleMode.isEmpty();
   
  -					if(!isEmpty(*patterns) &&
  -					   !(prevMatchPat != 0 &&
  -					     (prevPat != 0 && equals(*prevPat, *patterns)) &&
  -						 prevMatchPat->getTemplate()->getPriority() == matchPat->getTemplate()->getPriority()))
  +					if ((!haveMode && !haveRuleMode) ||
  +						(haveMode && haveRuleMode && ruleMode.equals(mode)))
   					{
  -						prevPat = patterns;
  -						prevMatchPat = matchPat;
  -						prevMatchPatPriority = matchPatPriority;
  -						matchPatPriority = XPath::s_MatchScoreNone;
  +						const XalanDOMString*	patterns = matchPat->getPattern();
  +						assert(patterns != 0);
   
  -						const XPath* const	xpath = matchPat->getExpression();
  +						if(!isEmpty(*patterns) &&
  +						   !(prevMatchPat != 0 &&
  +							 (prevPat != 0 && equals(*prevPat, *patterns)) &&
  +							 prevMatchPat->getTemplate()->getPriority() == matchPat->getTemplate()->getPriority()))
  +						{
  +							prevPat = patterns;
  +							prevMatchPat = matchPat;
  +							prevMatchPatPriority = matchPatPriority;
  +							matchPatPriority = XPath::s_MatchScoreNone;
   
  -						double score =
  -								xpath->getMatchScore(targetNode, *this, executionContext);
  +							const XPath* const	xpath = matchPat->getExpression();
   
  -						if(XPath::s_MatchScoreNone != score)
  -						{
  -							const double priorityVal = rule->getPriority();
  -							const double priorityOfRule 
  -									  = (XPath::s_MatchScoreNone != priorityVal) 
  -															  ? priorityVal : score;
  -
  -							matchPatPriority = priorityOfRule;
  -							const double priorityOfBestMatched =
  -										(0 != bestMatchedPattern) ?
  -												bestMatchPatPriority : 
  -												XPath::s_MatchScoreNone;
  +							double score =
  +									xpath->getMatchScore(targetNode, *this, executionContext);
   
  -							if(priorityOfRule > priorityOfBestMatched)
  +							if(XPath::s_MatchScoreNone != score)
   							{
  -								nConflicts = 0;
  +								const double priorityVal = rule->getPriority();
  +								const double priorityOfRule 
  +										  = (XPath::s_MatchScoreNone != priorityVal) 
  +																  ? priorityVal : score;
  +
  +								matchPatPriority = priorityOfRule;
  +								const double priorityOfBestMatched =
  +											(0 != bestMatchedPattern) ?
  +													bestMatchPatPriority : 
  +													XPath::s_MatchScoreNone;
   
  -								bestMatchedRule = rule;
  -								bestMatchedPattern = matchPat;
  -								bestMatchPatPriority = matchPatPriority;
  -							}
  -							else if(priorityOfRule == priorityOfBestMatched)
  -							{
  -								if (conflicts == 0)
  +								if(priorityOfRule > priorityOfBestMatched)
   								{
  -									if (m_patternCount > sizeof(conflictsArray) / sizeof(conflictsArray[0]))
  -									{
  -										conflictsVector.reset(new const MatchPattern2*[m_patternCount]);
  +									nConflicts = 0;
   
  -										conflicts = conflictsVector.get();
  -									}
  -									else
  +									bestMatchedRule = rule;
  +									bestMatchedPattern = matchPat;
  +									bestMatchPatPriority = matchPatPriority;
  +								}
  +								else if(priorityOfRule == priorityOfBestMatched)
  +								{
  +									if (conflicts == 0)
   									{
  -										conflicts = conflictsArray;
  +										if (m_patternCount > sizeof(conflictsArray) / sizeof(conflictsArray[0]))
  +										{
  +											conflictsVector.reset(new const MatchPattern2*[m_patternCount]);
  +
  +											conflicts = conflictsVector.get();
  +										}
  +										else
  +										{
  +											conflicts = conflictsArray;
  +										}
   									}
  -								}
   
  -								assert(conflicts != 0);
  +									assert(conflicts != 0);
   
  -								// Add the best matched pattern so far.
  -								addObjectIfNotFound(bestMatchedPattern, conflicts, nConflicts);
  +									// Add the best matched pattern so far.
  +									addObjectIfNotFound(bestMatchedPattern, conflicts, nConflicts);
   
  -								// Add the pattern that caused the conflict...
  -								conflicts[nConflicts++] = matchPat;
  +									// Add the pattern that caused the conflict...
  +									conflicts[nConflicts++] = matchPat;
   
  -								bestMatchedRule = rule;
  -								bestMatchedPattern = matchPat;
  -								bestMatchPatPriority = matchPatPriority;
  +									bestMatchedRule = rule;
  +									bestMatchedPattern = matchPat;
  +									bestMatchPatPriority = matchPatPriority;
  +								}
   							}
   						}
   					}
  -				}
   
  -				theCurrentEntry++;
  +					++theCurrentEntry;
   
  -				// We also have to consider wildcard matches.
  -				if(theCurrentEntry == theTableEnd &&
  -				   usedWildcard == false &&
  -				   m_anyPatternBegin != m_anyPatternEnd)
  -				{
  -					assert(targetNodeType != XalanNode::TEXT_NODE &&
  -						   targetNodeType != XalanNode::CDATA_SECTION_NODE &&
  -						   targetNodeType != XalanNode::DOCUMENT_NODE &&
  -						   targetNodeType != XalanNode::PROCESSING_INSTRUCTION_NODE &&
  -						   targetNodeType != XalanNode::COMMENT_NODE);
  -
  -					usedWildcard = true;
  -
  -					// Re-seat the iterators...
  -					theCurrentEntry = m_anyPatternBegin;
  -
  -					theTableEnd = m_anyPatternEnd;
  -				}
  -			}	// end while
  +				} while(theCurrentEntry != theTableEnd);
  +			}
   		} // end if(useImports == false)
   
   		if(0 == bestMatchedRule)
   		{
  -			const unsigned int	nImports = m_imports.size();
  +			assert(m_importsSize == m_imports.size());
   
  -			for(unsigned int i = 0; i < nImports; i++)
  +			for(unsigned int i = 0; i < m_importsSize; i++)
   			{
   				const Stylesheet* const 	stylesheet =
   					m_imports[i];
  @@ -1114,8 +1038,7 @@
   				bestMatchedRule = stylesheet->findTemplate(executionContext,
   														   targetNode,
   														   mode, 
  -														   false,
  -														   foundStylesheet);
  +														   false);
   				if(0 != bestMatchedRule)
   					break;
   			}
  @@ -1173,16 +1096,9 @@
   				executionContext.warn(conflictsString);
   			}
   		}
  -
  -		if((0 != bestMatchedPattern) && (0 != foundStylesheet))
  -		{
  -			foundStylesheet = bestMatchedPattern->getStylesheet();
  -		}
   
  -		theResult = bestMatchedRule;
  +		return bestMatchedRule;
   	}
  -
  -	return theResult;
   }
   
   
  @@ -1272,21 +1188,6 @@
   
   
   
  -const XalanDOMString&
  -Stylesheet::getCurrentIncludeBaseIdentifier() const
  -{
  -	if (m_includeStack.size() == 0)
  -	{
  -		return getBaseIdentifier();
  -	}
  -	else
  -	{
  -		return m_includeStack.back();
  -	}
  -}
  -
  -
  -
   void
   Stylesheet::processNSAliasElement(
   			const XalanDOMChar*				name,
  @@ -1337,9 +1238,13 @@
   
   	// Build a table of aliases, the key is the stylesheet uri and the
   	// value is the result uri
  -	if (length(*stylesheetNamespace) != 0 &&
  -		length(*resultNamespace) != 0)
  +	if (length(*stylesheetNamespace) == 0 ||
  +		length(*resultNamespace) == 0)
   	{
  +		constructionContext.error("Missing namespace URI for specified prefix");
  +	}
  +	else
  +	{
   #if 1
   		// $$$ ToDo: Enable other code.  Perhaps an error?
   		m_prefixAliases[*stylesheetNamespace] = *resultNamespace;
  @@ -1360,10 +1265,6 @@
   		}
   #endif
   	}
  -	else
  -	{
  -		constructionContext.error("Missing namespace URI for specified prefix");
  -	}
   }
   
   
  @@ -1381,87 +1282,38 @@
   XalanDOMString
   Stylesheet::getAliasNamespaceURI(const XalanDOMString&	uri) const
   {
  -	XalanDOMString	result;
  -
   	const StringToStringMapType::const_iterator	i =
   		m_prefixAliases.find(uri);
   
   	if (i != m_prefixAliases.end())
   	{
  -		result = (*i).second;
  +		assert(length((*i).second) > 0);
   
  -		assert(length(result) > 0);
  +		return (*i).second;
   	}
   	else
   	{
  +		XalanDOMString	theResult;
  +
   		const StylesheetVectorType::size_type	nImports =
   			m_imports.size();
   
   		for(StylesheetVectorType::size_type i = 0; i < nImports; ++i)
   		{
  -			result = m_imports[i]->getAliasNamespaceURI(uri);
  +			theResult = m_imports[i]->getAliasNamespaceURI(uri);
   
  -			if(length(result) != 0)
  +			if(length(theResult) != 0)
   			{
   				break;
   			}
   		}
  -	}
  -
  -	return result;
  -}
  -
  -
  -
  -void
  -Stylesheet::processExcludeResultPrefixes(
  -		const XalanDOMChar*				theValue,
  -		StylesheetConstructionContext&	theConstructionContext)
  -{
  -	m_namespacesHandler.processExcludeResultPrefixes(theValue, m_namespaces, theConstructionContext);
  -}
  -
   
  -
  -const Stylesheet*
  -Stylesheet::getPreviousImport(const Stylesheet*		stylesheet) const
  -{
  -	const Stylesheet*	previous = 0;
  -
  -	const StylesheetVectorType::size_type	nImports =
  -			m_imports.size();
  -
  -	for(StylesheetVectorType::size_type i = 0; i < nImports; ++i)
  -	{
  -		if (m_imports[i] == stylesheet)
  -		{
  -			if (i + 1 < nImports)
  -			{
  -				previous = m_imports[i + 1];
  -
  -				break;
  -			}
  -		}
  +		return theResult;
   	}
  -
  -	return previous;
   }
   
   
   
  -void
  -Stylesheet::processDecimalFormatElement(
  -			ElemDecimalFormat*				elemDecimalFormat,
  -			const AttributeList&			/* atts */,
  -			StylesheetConstructionContext&	/* constructionContext */)
  -{
  -	assert(elemDecimalFormat != 0);
  -
  -	m_elemDecimalFormats.push_back(elemDecimalFormat);
  -}
  -
  -
  -
   const XalanDecimalFormatSymbols*
   Stylesheet::getDecimalFormatSymbols(const XalanDOMString&	name) const
   {
  @@ -1493,10 +1345,7 @@
   	// it.
   	if(dfs == 0)
   	{
  -		const StylesheetVectorType::size_type	nImports =
  -			m_imports.size();
  -
  -		for(StylesheetVectorType::size_type i = 0; i < nImports; ++i)
  +		for(StylesheetVectorType::size_type i = 0; i < m_importsSize; ++i)
   		{
   			dfs = m_imports[i]->getDecimalFormatSymbols(name);
   
  @@ -1512,43 +1361,20 @@
   
   
   
  -/**
  - * Add an attribute set to the list.
  - */
  -void
  -Stylesheet::addAttributeSet(
  -		const QName&		/* qname */, 
  -		ElemAttributeSet*	attrSet)
  -{
  -	assert(attrSet != 0);
  -
  -	m_attributeSets.push_back(attrSet);
  -}		
  -
  -
  -
  -/**
  - * Add the attributes from the named attribute sets to the attribute list.
  - * TODO: Error handling for: "It is an error if there are two attribute sets 
  - * with the same expanded-name and with equal import precedence and that both 
  - * contain the same attribute unless there is a definition of the attribute 
  - * set with higher import precedence that also contains the attribute."
  - */
   void
   Stylesheet::applyAttrSets(
  -			const QNameVectorType&			attributeSetsNames, 
  -			StylesheetExecutionContext& 	executionContext, 			
  +			const QNameVectorType&			attributeSetsNames,
  +			StylesheetExecutionContext& 	executionContext,			
   			XalanNode*						sourceNode) const
   {
   	const QNameVectorType::size_type	nNames = attributeSetsNames.size();
   
   	if(0 != nNames)
   	{
  -		// Process up the import chain...
  -		const StylesheetVectorType::size_type	nImports =
  -			m_imports.size();
  +		assert(m_importsSize == m_imports.size());
   
  -		for(StylesheetVectorType::size_type i = 0; i < nImports; i++)
  +		// Process up the import chain...
  +		for(StylesheetVectorType::size_type i = 0; i < m_importsSize; i++)
   		{
   			const Stylesheet* const 	stylesheet = m_imports[i];
   
  @@ -1561,9 +1387,10 @@
   		for(QNameVectorType::size_type j = 0; j < nNames; j++)
   		{
   			const QName&							qname = attributeSetsNames[j];
  -			const StylesheetVectorType::size_type	nSets = m_attributeSets.size();
  +
  +			assert(m_attributeSetsSize == m_attributeSets.size());
   
  -			for(StylesheetVectorType::size_type k = 0; k < nSets; k++)
  +			for(StylesheetVectorType::size_type k = 0; k < m_attributeSetsSize; k++)
   			{
   				const ElemAttributeSet* const	attrSet = m_attributeSets[k];
   				assert(attrSet != 0);
  @@ -1579,21 +1406,6 @@
   
   
   
  -const Stylesheet::NamespaceVectorType&
  -Stylesheet::getCurrentNamespace() const
  -{
  -	if (m_namespaces.size() > 0)
  -	{
  -		return m_namespaces.back();
  -	}
  -	else
  -	{
  -		return s_emptyNamespace;
  -	}
  -}
  -
  -
  -
   const XalanDOMString&
   Stylesheet::getNodeName() const
   {
  @@ -1669,7 +1481,7 @@
   const XalanNamedNodeMap*
   Stylesheet::getAttributes() const
   {
  -	return &m_fakeAttributes;
  +	return &s_fakeAttributes;
   }
   
   
  @@ -2017,6 +1829,14 @@
   	assert(false);	
   
   	return false;
  +}
  +
  +
  +
  +const XalanDOMString*
  +Stylesheet::getNamespaceForPrefix(const XalanDOMString& 	prefix) const
  +{
  +	return QName::getNamespaceForPrefix(m_namespaceDecls, prefix);
   }
   
   
  
  
  
  1.38      +87 -109   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.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- Stylesheet.hpp	2001/06/27 18:27:59	1.37
  +++ Stylesheet.hpp	2001/06/29 18:53:19	1.38
  @@ -79,7 +79,7 @@
   #include <XalanDOM/XalanNodeListSurrogate.hpp>
   
   
  -#include <DOMSupport/PrefixResolver.hpp>
  +#include <PlatformSupport/PrefixResolver.hpp>
   
   
   
  @@ -292,7 +292,10 @@
   	 * there is nothing on the stack.
   	 */
   	const NamespaceVectorType&
  -	getCurrentNamespace() const;
  +	getCurrentNamespace() const
  +	{
  +		return m_namespaces.size() > 0 ? m_namespaces.back() : s_emptyNamespace;
  +	}
   
   	/** 
   	 * Push the namespace declarations from the current attribute 
  @@ -307,7 +310,12 @@
   	 * Pop a namespace declaration from the namespace stack.
   	 */
   	void
  -	popNamespaces();
  +	popNamespaces()
  +	{
  +		assert(m_namespaces.empty() == false);
  +
  +		m_namespaces.pop_back(); 
  +	}
   
   	/**
   	 * Called after construction is completed.
  @@ -338,7 +346,10 @@
   	 * @return namespace string for node, or null if not found.
   	 */
   	const XalanDOMString*
  -	getNamespaceFromStack(const XalanDOMString& 	nodeName) const;
  +	getNamespaceFromStack(const XalanDOMString& 	nodeName) const
  +	{
  +		return getNamespaceFromStack(c_wstr(nodeName));
  +	}
   
   	/**
   	 * Get the namespace from a qualified name.
  @@ -357,7 +368,10 @@
   	 * @return namespace corresponding to prefix, or null if not found.
   	 */
   	const XalanDOMString*
  -	getNamespaceForPrefixFromStack(const XalanDOMString&	prefix) const;
  +	getNamespaceForPrefixFromStack(const XalanDOMString&	prefix) const
  +	{
  +		return QName::getNamespaceForPrefix(m_namespaces, prefix);
  +	}
   
   	/**
   	 * Get the namespace from a prefix by searching the stack of namespace
  @@ -367,8 +381,13 @@
   	 * @return namespace corresponding to prefix, or null if not found.
   	 */
   	const XalanDOMString*
  -	getNamespaceForPrefixFromStack(const XalanDOMChar*	prefix) const;
  +	getNamespaceForPrefixFromStack(const XalanDOMChar*	prefix) const
  +	{
  +		assert(prefix != 0);
   
  +		return QName::getNamespaceForPrefix(m_namespaces, XalanDOMString(prefix));
  +	}
  +
   	/**
   	 * See if there is a namespace alias.
   	 * 
  @@ -397,19 +416,13 @@
   	void
   	processExcludeResultPrefixes(
   		const XalanDOMChar*				theValue,
  -		StylesheetConstructionContext&	theConstructionContext);
  -
  -	/**
  -	 * This recursive function is called starting from the
  -	 * stylesheet root, and tries to find a match for the
  -	 * passed stylesheet, and then will return the previous
  -	 * sibling, or 0 if there was no previous sibling.
  -	 *
  -	 * @param stylesheet the stylesheet to search
  -	 * @return the stylesheet's previous import if found, or 0 not found.
  -	 */
  -	const Stylesheet*
  -	getPreviousImport(const Stylesheet*		stylesheet) const;
  +		StylesheetConstructionContext&	theConstructionContext)
  +	{
  +		m_namespacesHandler.processExcludeResultPrefixes(
  +				theValue,
  +				m_namespaces,
  +				theConstructionContext);
  +	}
   
   	/**
   	 * Add a template to the list of names templates
  @@ -430,7 +443,7 @@
   	 * @param constructionContext context for construction
   	 * @return true if value equals string constant for "yes," false otherwise
   	 */
  -	virtual bool
  +	bool
   	getYesOrNo(
   			const XalanDOMChar*				aname,
   			const XalanDOMChar*				val,
  @@ -478,7 +491,10 @@
   	 * @return string for base identifier
   	 */
   	const XalanDOMString&
  -	getCurrentIncludeBaseIdentifier() const;
  +	getCurrentIncludeBaseIdentifier() const
  +	{
  +		return m_includeStack.size() == 0 ? getBaseIdentifier() : m_includeStack.back();
  +	}
   
   	/**
   	 * Process an xsl:namespace-alias element.
  @@ -497,15 +513,15 @@
   	 * Process an xsl:decimal-format element.
   	 *
   	 * @param elemDecimalFormat   the element
  -	 * @param attrs	 the current attribute list
  -	 * @param constructionContext  the active construction context
   	 */
   	void
  -	processDecimalFormatElement(
  -			ElemDecimalFormat*				elemDecimalFormat,
  -			const AttributeList&			atts,
  -			StylesheetConstructionContext&	constructionContext);
  +	processDecimalFormatElement(ElemDecimalFormat*	elemDecimalFormat)
  +	{
  +		assert(elemDecimalFormat != 0);
   
  +		m_elemDecimalFormats.push_back(elemDecimalFormat);
  +	}
  +
   	/**
   	 * Retrieve the XalanDecimalFormatSymbols instance associated with
   	 * the name.
  @@ -519,14 +535,16 @@
   	/**
   	 * Add an attribute set to the list.
   	 *
  -	 * @param qname   qualified name of attribute set
   	 * @param attrSet pointer to attribute set to add
   	 */
   	void
  -	addAttributeSet(
  -		const QName&		qname, 
  -		ElemAttributeSet*	attrSet);
  +	addAttributeSet(ElemAttributeSet*	attrSet)
  +	{
  +		assert(attrSet != 0);
   
  +		m_attributeSets.push_back(attrSet);
  +	}
  +
   	/**
   	 * Apply the set of named attributes to a node in a given context with a
   	 * given mode
  @@ -540,28 +558,6 @@
   			const QNameVectorType&			attributeSetsNames,
   			StylesheetExecutionContext& 	executionContext,
   			XalanNode*						sourceNode) const;
  -  
  -	/**
  -	 * Determine whether default whitespace processing is in effect
  -	 * 
  -	 * @return true if default whitespace processing is in effect
  -	 */
  -	bool
  -	isDefaultSpaceProcessing() const
  -	{
  -		return m_defaultSpace;
  -	}
  -
  -	/**
  -	 * Set whether default whitespace processing is in effect
  -	 * 
  -	 * @param bEnabled true if default processing should be enabled
  -	 */
  -	void
  -	setDefaultSpaceProcessing(bool bEnabled)
  -	{
  -		m_defaultSpace = bEnabled;
  -	}
   
   	/**
   	 * Add an imported stylesheet.
  @@ -678,7 +674,10 @@
   	const ElemTemplate*
   	findTemplate(
   			StylesheetExecutionContext& 	executionContext,
  -			XalanNode*						targetNode) const;
  +			XalanNode*						targetNode) const
  +	{
  +		return findTemplate(executionContext, targetNode, s_emptyQName, false);
  +	}
   
   	/**
   	 * Given a target element, find the template that best matches in the given
  @@ -695,8 +694,7 @@
   			StylesheetExecutionContext& 	executionContext,
   			XalanNode*						targetNode, 
   			const QName&					mode,
  -			bool							onlyUseImports,
  -			const Stylesheet*&				foundStylesheet) const;
  +			bool							onlyUseImports) const;
   
   	/**
   	 * A class to contain a match pattern and it's corresponding template.
  @@ -712,7 +710,6 @@
   		 * @param theTemplate node that contains the template for this pattern
   		 * @param posInStylesheet position in stylesheet
   		 * @param targetString target string
  -		 * @param stylesheet stylesheet for pattern
   		 * @param matchPattern the match pattern
   		 * @param pattern the pattern string
   		 */
  @@ -720,13 +717,11 @@
   				const ElemTemplate&		theTemplate,
   				int 					posInStylesheet,
   				const XalanDOMString&	targetString,
  -				const Stylesheet& 		stylesheet,
   				const XPath&			matchPattern,
   				const XalanDOMString&	pattern) :
   			m_template(&theTemplate),
   			m_posInStylesheet(posInStylesheet),
   			m_targetString(targetString),
  -			m_stylesheet(&stylesheet),
   			m_matchPattern(&matchPattern),
   			m_pattern(&pattern)
   		{
  @@ -736,7 +731,6 @@
   			m_template(0),
   			m_posInStylesheet(0),
   			m_targetString(),
  -			m_stylesheet(0),
   			m_matchPattern(0),
   			m_pattern(0)
   		{
  @@ -747,17 +741,6 @@
   		}
   
   		/**
  -		 * Retrieve stylesheet associated with pattern.
  -		 * 
  -		 * @return stylesheet for pattern
  -		 */
  -		const Stylesheet*
  -		getStylesheet() const
  -		{
  -			return m_stylesheet;
  -		}
  -
  -		/**
   		 * Retrieve string for target.
   		 * 
   		 * @return target string
  @@ -817,13 +800,12 @@
   		const ElemTemplate*		m_template;
   		int						m_posInStylesheet;
   		XalanDOMString			m_targetString;
  -		const Stylesheet*		m_stylesheet;
   		const XPath*			m_matchPattern;
   		const XalanDOMString*	m_pattern;
   	};
   
   #if defined(XALAN_NO_NAMESPACES)
  -	typedef vector<MatchPattern2*>				PatternTableListType;
  +	typedef vector<const MatchPattern2*>		PatternTableListType;
   
   	typedef vector<const MatchPattern2*>		PatternTableVectorType;
   
  @@ -833,7 +815,7 @@
   
   	typedef deque<MatchPattern2>				MatchPattern2Container;
   #else
  -	typedef std::vector<MatchPattern2*>			PatternTableListType;
  +	typedef std::vector<const MatchPattern2*>	PatternTableListType;
   
   	typedef std::vector<const MatchPattern2*>	PatternTableVectorType;
   
  @@ -870,17 +852,23 @@
   			unsigned int&			theArraySize);
   
   	/**
  -	 * Given a name, , locate the start of a list of 
  -	 * possible templates that match that name, also
  -	 * trying wild card matches.
  +	 * Given a name, locate the start of a list of 
  +	 * possible templates that match that name.  If
  +	 * none match, then use the default list.
   	 *
   	 * @param theName The name to match
  -	 * @param usedWildCard Set to true if wild card matching was used, false if not.
  +	 */
  +	const PatternTableListType*
  +	locateMatchPatternList2(const XalanDOMString&	theName) const;
  +
  +	/**
  +	 * Given a XalanNode, locate the start of a list of 
  +	 * possible templates that match it.
  +	 *
  +	 * @param XalanNode The node to match
   	 */
   	const PatternTableListType*
  -	locateMatchPatternList2(
  -			const XalanDOMString&	theName,
  -			bool&					usedWildcard) const;
  +	locateMatchPatternList2(const XalanNode&	theNode) const;
   
   	/**
   	 * Add an extension namespace handler. This provides methods for calling
  @@ -1138,11 +1126,6 @@
   	StylesheetRoot& 					m_stylesheetRoot;
   
   	/**
  -	 * This is set to true if an xsl:key directive is found.
  -	 */
  -	bool								m_needToBuildKeysTable;
  -
  -	/**
   	 * The base URL of the XSL document.
   	 */
   	XalanDOMString						m_baseIdent;
  @@ -1185,6 +1168,8 @@
   	 */
   	StylesheetVectorType					m_imports;
   
  +	StylesheetVectorType::size_type			m_importsSize;
  +
   	/**
   	 * A stack to keep track of the result tree namespaces.
   	 */
  @@ -1203,11 +1188,6 @@
   	static const NamespaceVectorType		s_emptyNamespace;
   
   	/**
  -	 * Tells if the stylesheet tables need to be rebuilt.
  -	 */
  -	bool									m_tablesAreInvalid;
  -
  -	/**
   	 * Tells if the stylesheet is without an xsl:stylesheet and xsl:template
   	 * wrapper.
   	 */
  @@ -1235,26 +1215,18 @@
   	 */
   	URLStackType							m_includeStack;
   
  -	/** 
  -	 * Tell if this stylesheet has the default space handling
  -	 * turned off or on according to the xml:space attribute.
  -	 * @serial
  -	 */
  -	bool									m_defaultSpace;
  -  
   	/**
   	 * Keyed on string macro names, and holding values that are macro elements
   	 * in the XSL DOM tree. Initialized in initMacroLookupTable, and used in
   	 * findNamedTemplate.
   	 */
   	ElemTemplateMapType						m_namedTemplates;
  -  
  +
   	/**
   	 * Table for defined constants, keyed on the names.
   	 */
   	ElemVariableVectorType					m_topLevelVariables;
   
  -
   	/**
   	 * The version of XSL that was declared.
   	 */
  @@ -1267,12 +1239,12 @@
   	 * lists of the actual patterns that match the target element to some degree
   	 * of specifity.
   	 */
  -	PatternTableMapType 					m_patternTable;
  +	PatternTableMapType 						m_patternTable;
   
  -	PatternTableMapType::const_iterator		m_patternTableEnd;
  +	const PatternTableMapType::const_iterator	m_patternTableEnd;
   
   	/**
  -	 * These tables are for text, comment, and root node templates.
  +	 * These tables are for text, comment, root, and PI node templates.
   	 */
   	PatternTableListType					m_textPatternList;
   
  @@ -1282,6 +1254,12 @@
   
   	PatternTableListType					m_piPatternList;
   
  +	/**
  +	 * This table is for patterns that match "node()".  Once
  +	 * all of the templates have been processed, we'll combine
  +	 * this list with m_anyPatternList, and use that for Element
  +	 * and Attribute nodes which don't have a specific template.
  +	 */
   	PatternTableListType					m_nodePatternList;
   
   	/**
  @@ -1289,10 +1267,6 @@
   	 */
   	PatternTableListType					m_anyPatternList;
   
  -	PatternTableListType::const_iterator	m_anyPatternBegin;
  -
  -	PatternTableListType::const_iterator	m_anyPatternEnd;
  -
   	/**
   	 * This will hold all of the MatchPattern2 instances for the
   	 * stylesheet.
  @@ -1306,9 +1280,9 @@
   
   	AttributeSetVectorType 					m_attributeSets;
   
  -	XalanNodeListSurrogate					m_surrogateChildren;
  +	AttributeSetVectorType::size_type		m_attributeSetsSize;
   
  -	XalanEmptyNamedNodeMap					m_fakeAttributes;
  +	XalanNodeListSurrogate					m_surrogateChildren;
   
   	ElemDecimalFormatVectorType				m_elemDecimalFormats;
   
  @@ -1317,6 +1291,10 @@
   	NamespacesHandler						m_namespacesHandler;
   
   	static const XalanDOMString				s_emptyString;
  +
  +	static const QNameByReference			s_emptyQName;
  +
  +	static const XalanEmptyNamedNodeMap		s_fakeAttributes;
   };
   
   
  
  
  
  1.46      +63 -47    xml-xalan/c/src/XSLT/StylesheetRoot.cpp
  
  Index: StylesheetRoot.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetRoot.cpp,v
  retrieving revision 1.45
  retrieving revision 1.46
  diff -u -r1.45 -r1.46
  --- StylesheetRoot.cpp	2001/06/27 18:27:01	1.45
  +++ StylesheetRoot.cpp	2001/06/29 18:53:19	1.46
  @@ -118,19 +118,13 @@
   
   
   
  -//#define XALAN_VQ_SPECIAL_TRACE
  +#define XALAN_VQ_SPECIAL_TRACE
   #if defined(XALAN_VQ_SPECIAL_TRACE)
   #include "C:/Program Files/Rational/Quantify/pure.h"
   #endif
   
   
   
  -/**
  - * Constructor for a Stylesheet needs a Document.
  - * @exception XSLProcessorException thrown if the active ProblemListener and
  - *            XMLParserLiaison decide the error condition is severe enough to
  - *            halt processing.
  - */
   StylesheetRoot::StylesheetRoot(
           const XalanDOMString&			baseIdentifier,
   		StylesheetConstructionContext&	constructionContext) :
  @@ -148,10 +142,12 @@
   	m_resultNameSpaceURL(),
   	m_outputMethod(FormatterListener::OUTPUT_METHOD_NONE),
   	m_cdataSectionElems(),
  +	m_hasCdataSectionElems(false),
   	m_importStack(),
   	m_defaultTextRule(0),
   	m_defaultRule(0),
  -	m_defaultRootRule(0)
  +	m_defaultRootRule(0),
  +	m_needToBuildKeysTable(false)
   
   {
   	// Our base class has already resolved the URI and pushed it on
  @@ -177,6 +173,37 @@
   
   
   void
  +StylesheetRoot::postConstruction(StylesheetConstructionContext&		constructionContext)
  +{
  +	// Chain-up first...
  +	Stylesheet::postConstruction(constructionContext);
  +
  +	// We may need to build keys, since we may have inherited them from
  +	// our imports.
  +	if (m_needToBuildKeysTable == false && m_keyDeclarations.size() > 0)
  +	{
  +		m_needToBuildKeysTable = true;
  +	}
  +
  +#if !defined(XALAN_NO_NAMESPACES)
  +	using std::sort;
  +	using std::less;
  +#endif
  +
  +	sort(
  +			m_cdataSectionElems.begin(),
  +			m_cdataSectionElems.end(),
  +			less<QName>());
  +
  +	if (m_cdataSectionElems.size() != 0)
  +	{
  +		m_hasCdataSectionElems = true;
  +	}
  +}
  +
  +
  +
  +void
   StylesheetRoot::process(
   			XalanNode*						sourceTree, 
   			XSLTResultTarget&				outputTarget,
  @@ -189,8 +216,8 @@
   	if(0 == rootRule)
   	{
   		rootRule = m_defaultRootRule;
  -		assert(rootRule);
   	}
  +	assert(rootRule);
   
   	executionContext.setStylesheetRoot(this);
   
  @@ -250,14 +277,10 @@
   			XSLTResultTarget&				outputTarget,
   			StylesheetExecutionContext&		executionContext) const
   {
  -	FormatterListener*	flistener = outputTarget.getFormatterListener();;
  +	FormatterListener*	flistener = outputTarget.getFormatterListener();
   
   	if(flistener == 0)
   	{
  -		// $$$ ToDo: For right now, XSLTResultTarget::getDocumentHandler()
  -		// and XSLTResultTarget::getFormatterListener() both return a
  -		// FormatterListener*.  When we have RTTI on all platforms, that
  -		// may change...
   		flistener = outputTarget.getDocumentHandler();
   	}
   
  @@ -265,13 +288,13 @@
   	{
   		// Do encoding stuff here...
   	}
  -	/*
  -	 * Output target has a character or byte stream or file
  -	 */
   	else if(0 != outputTarget.getCharacterStream() ||
   			0 != outputTarget.getByteStream() ||
   			0 != length(outputTarget.getFileName()))
   	{
  +		/*
  +		 * Output target has a character or byte stream or file
  +		 */
   		Writer*		pw = 0;
   
   		if(0 != outputTarget.getCharacterStream())
  @@ -339,11 +362,11 @@
   
   		executionContext.setFormatterListener(flistener);
   	}
  -	/*
  -	 * Output target has a node
  -	 */
   	else if(outputTarget.hasDOMTarget() == true)
   	{
  +		/*
  +		 * Output target has a node
  +		 */
   		if (outputTarget.getDocument() != 0)
   		{
   			flistener = executionContext.createFormatterToDOM(outputTarget.getDocument(), 0);
  @@ -372,11 +395,11 @@
   			assert(0);
   		}
   	}
  -	/*
  -	 * Create an empty document and set the output target node to this
  -	 */
   	else
   	{
  +		/*
  +		 * Create an empty document and set the output target node to this
  +		 */
   		XalanDocument* const	theDocument = executionContext.createDocument();
   
   		outputTarget.setDocument(theDocument);
  @@ -391,28 +414,6 @@
   
   
   
  -XalanDOMString 
  -StylesheetRoot::getJavaOutputEncoding() const 
  -{ 
  -    XalanDOMString	encoding;
  -
  -    if(isEmpty(m_encoding))
  -	{
  -		encoding  = StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("UTF8"));
  -	}
  -    else if(equalsIgnoreCase(m_encoding, StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("UTF-16"))))
  -	{
  -		encoding  = StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("Unicode"));
  -	}
  -
  -// @@ JMD: do we need this ??
  -//    else
  -// @@ to do       encoding = FormatterToXML.convertMime2JavaEncoding( m_encoding ); 
  -    return encoding;
  -}
  -
  -
  -
   void 
   StylesheetRoot::processOutputSpec(
   			const XalanDOMChar*				name, 
  @@ -499,8 +500,8 @@
   		}
   	}
   
  -	if((FormatterListener::OUTPUT_METHOD_HTML == m_outputMethod) &&
  -		 (false == didSpecifyIndent))
  +	if(FormatterListener::OUTPUT_METHOD_HTML == m_outputMethod &&
  +	   false == didSpecifyIndent)
   	{
   		m_indentResult = true;
   	}
  @@ -601,6 +602,21 @@
   	assert(m_defaultRule != 0);
   	assert(m_defaultTextRule != 0);
   	assert(m_defaultRootRule != 0);
  +}
  +
  +
  +
  +bool
  +StylesheetRoot::isCDATASectionElementName(const QName&	theQName) const
  +{
  +#if !defined(XALAN_NO_NAMESPACES)
  +	using std::find;
  +#endif
  +
  +	return find(
  +			m_cdataSectionElems.begin(),
  +			m_cdataSectionElems.end(),
  +			theQName) != m_cdataSectionElems.end() ? true : false;
   }
   
   
  
  
  
  1.15      +33 -23    xml-xalan/c/src/XSLT/StylesheetRoot.hpp
  
  Index: StylesheetRoot.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetRoot.hpp,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- StylesheetRoot.hpp	2001/06/21 15:40:44	1.14
  +++ StylesheetRoot.hpp	2001/06/29 18:53:20	1.15
  @@ -77,7 +77,6 @@
   
   
   class StylesheetConstructionContext;
  -class XMLURL;
   class XSLTResultTarget;
   
   
  @@ -105,6 +104,12 @@
   	~StylesheetRoot();
   
   	/**
  +	 * Called after construction is completed.
  +	 */
  +	virtual void
  +	postConstruction(StylesheetConstructionContext&		constructionContext);
  +
  +	/**
   	 * Transform the source tree to the output in the given result tree target.
   	 *
   	 * @param inputSource  The input source tree
  @@ -189,15 +194,6 @@
   	}
   
   	/**
  -	 * Get the java output encoding string that was specified in the
  -	 * xsl:output element
  -	 *
  -	 * @return encoding string
  -	 */
  -	XalanDOMString 
  -	getJavaOutputEncoding() const;
  -
  -	/**
   	 * Get the media-type string that was specified in the 
   	 * xsl:output element
   	 *
  @@ -406,16 +402,24 @@
   		m_outputMethod = meth;
   	}
   
  +	bool
  +	hasCDATASectionElements() const
  +	{
  +		assert(m_hasCdataSectionElems == false && m_cdataSectionElems.size() == 0 ||
  +			   m_hasCdataSectionElems == true && m_cdataSectionElems.size() != 0);
  +
  +		return m_hasCdataSectionElems;
  +	}
  +
   	/**
  -	 * Retrieve list of CDATA section elements.
  +	 * Determine if a QName is in the list of CDATA section
  +	 * element QNames.
   	 * 
  -	 * @return vector of elements
  +	 * @param theQName The QName of the element to check.
  +	 * @return true or false
   	 */
  -	const QNameVectorType&
  -	getCDATASectionElems() const
  -	{
  -		return m_cdataSectionElems;
  -	}
  +	bool
  +	isCDATASectionElementName(const QName&	theQName) const;
   
   	/**
   	 * Given a valid element key, return the corresponding node list.
  @@ -445,7 +449,7 @@
   	 * The URL that belongs to the result namespace.
   	 * @serial
   	 */
  -	XalanDOMString	m_resultNameSpaceURL;
  +	XalanDOMString				m_resultNameSpaceURL;
   
   	/**
   	 * The output method as specified in xsl:output.
  @@ -456,33 +460,39 @@
   	 * List of qnames that specifies elements that should be formatted 
   	 * as CDATA.
   	 */
  -	QNameVectorType		m_cdataSectionElems;
  +	QNameVectorType				m_cdataSectionElems;
  +
  +	bool						m_hasCdataSectionElems;
   
   	/**
   	 * A stack of who's importing whom is needed in order to detect 
   	 * a recursive include or import, which is an error.
   	 */
  -	URLStackType	m_importStack;
  +	URLStackType				m_importStack;
   
   
   	/**
   	 * The default template to use for text nodes if we don't find 
   	 * anything else.  This is initialized in initDefaultRule().
   	 */
  -	ElemTemplate*	m_defaultTextRule;
  +	ElemTemplate*				m_defaultTextRule;
   
   	/**
   	 * The default template to use if we don't find anything
   	 * else.  This is initialized in initDefaultRule().
   	 */
  -	ElemTemplate*	m_defaultRule;
  +	ElemTemplate*				m_defaultRule;
   
   	/**
   	 * The default template to use for the root if we don't find 
   	 * anything else.  This is initialized in initDefaultRule().
   	 */
  -	ElemTemplate*	m_defaultRootRule;
  +	ElemTemplate*				m_defaultRootRule;
   
  +	/**
  +	 * This is set to true if an xsl:key directive is found.
  +	 */
  +	bool						m_needToBuildKeysTable;
   };
   
   
  
  
  
  1.103     +60 -50    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.102
  retrieving revision 1.103
  diff -u -r1.102 -r1.103
  --- XSLTEngineImpl.cpp	2001/06/25 20:17:22	1.102
  +++ XSLTEngineImpl.cpp	2001/06/29 18:53:21	1.103
  @@ -65,18 +65,6 @@
   
   
   
  -#include <XalanDOM/XalanDOMException.hpp>
  -#include <XalanDOM/XalanNode.hpp>
  -#include <XalanDOM/XalanAttr.hpp>
  -#include <XalanDOM/XalanComment.hpp>
  -#include <XalanDOM/XalanCDATASection.hpp>
  -#include <XalanDOM/XalanNodeList.hpp>
  -#include <XalanDOM/XalanNamedNodeMap.hpp>
  -#include <XalanDOM/XalanProcessingInstruction.hpp>
  -#include <XalanDOM/XalanText.hpp>
  -
  -
  -
   #include <sax/DocumentHandler.hpp>
   #include <sax/EntityResolver.hpp>
   #include <sax/Locator.hpp>
  @@ -90,6 +78,18 @@
   
   
   
  +#include <XalanDOM/XalanDOMException.hpp>
  +#include <XalanDOM/XalanNode.hpp>
  +#include <XalanDOM/XalanAttr.hpp>
  +#include <XalanDOM/XalanComment.hpp>
  +#include <XalanDOM/XalanCDATASection.hpp>
  +#include <XalanDOM/XalanNodeList.hpp>
  +#include <XalanDOM/XalanNamedNodeMap.hpp>
  +#include <XalanDOM/XalanProcessingInstruction.hpp>
  +#include <XalanDOM/XalanText.hpp>
  +
  +
  +
   #include <PlatformSupport/PrintWriter.hpp>
   #include <PlatformSupport/StringTokenizer.hpp>
   #include <PlatformSupport/XalanUnicode.hpp>
  @@ -147,6 +147,7 @@
   #include "TraceListener.hpp"
   #include "XSLTInputSource.hpp"
   #include "XSLTProcessorException.hpp"
  +#include "XSLTResultTarget.hpp"
   
   
   
  @@ -200,7 +201,8 @@
   	m_domSupport(domSupport),
   	m_executionContext(0),
   	m_outputContextStack(),
  -	m_resultNamespacesStack()
  +	m_resultNamespacesStack(),
  +	m_dummyAttributesList()
   {
   	m_outputContextStack.pushContext();
   }
  @@ -410,6 +412,14 @@
   		{
   			executionContext.setStylesheetRoot(m_stylesheetRoot);
   
  +			FormatterListener* const	theFormatter =
  +				outputTarget.getDocumentHandler();
  +
  +			if (theFormatter != 0)
  +			{
  +				theFormatter->setPrefixResolver(this);
  +			}
  +
   			m_stylesheetRoot->process(sourceTree, outputTarget, executionContext);
   
   			if(0 != m_diagnosticsPrintWriter)
  @@ -1699,7 +1709,7 @@
   		assert(getFormatterListener() != 0);
   		assert(m_executionContext != 0);
   
  -		m_cdataStack.push_back(isCDataResultElem(thePendingElementName)? true : false);
  +		m_cdataStack.push_back(isCDataResultElem(thePendingElementName) ? true : false);
   
   		AttributeListImpl&	thePendingAttributes =
   				getPendingAttributesImpl();
  @@ -1793,11 +1803,8 @@
   	}
   
   	m_resultNamespacesStack.popContext();
  -
  -	const Stylesheet::QNameVectorType&	cdataElems =
  -		m_stylesheetRoot->getCDATASectionElems();
   
  -	if(0 != cdataElems.size())
  +	if(m_stylesheetRoot->hasCDATASectionElements() == true)
   	{
   		m_cdataStack.pop_back();
   	}
  @@ -2073,10 +2080,8 @@
   
   	flushPending();
   
  -	const Stylesheet::QNameVectorType&	cdataElems =
  -		m_stylesheetRoot->getCDATASectionElems();
  -
  -	if(0 != cdataElems.size() && 0 != m_cdataStack.size())
  +	if(m_stylesheetRoot->hasCDATASectionElements() == true &&
  +	   0 != m_cdataStack.size())
   	{
   		getFormatterListener()->cdata(ch, length);
   
  @@ -2343,55 +2348,60 @@
   bool
   XSLTEngineImpl::isCDataResultElem(const XalanDOMString&		elementName) const
   {
  -	typedef Stylesheet::QNameVectorType		QNameVectorType;
  -
  -	bool is = false;
  -	const QNameVectorType&				cdataElems = m_stylesheetRoot->getCDATASectionElems();
  -	const QNameVectorType::size_type	theSize = cdataElems.size();
  +	assert(m_executionContext != 0);
   
  -	if(0 != theSize)
  +	if(m_stylesheetRoot->hasCDATASectionElements() == false)
   	{
  -		const XalanDOMString*	elemNS = 0;
  -		XalanDOMString			elemLocalName;
  +		return false;
  +	}
  +	else
  +	{
  +		bool	fResult = false;
   
   		const unsigned int	indexOfNSSep = indexOf(elementName, XalanUnicode::charColon);
   
   		if(indexOfNSSep == length(elementName))
   		{
  -			elemLocalName = elementName;
  +			fResult =
  +				m_stylesheetRoot->isCDATASectionElementName(QNameByReference(s_emptyString, elementName));
   		}
   		else
   		{
  -			const XalanDOMString	prefix = substring(elementName, 0, indexOfNSSep);
  +			typedef StylesheetExecutionContext::GetAndReleaseCachedString	GetAndReleaseCachedString;
  +
  +			GetAndReleaseCachedString	elemLocalNameGuard(*m_executionContext);
  +			GetAndReleaseCachedString	prefixGuard(*m_executionContext);
  +
  +			XalanDOMString&		elemLocalName = elemLocalNameGuard.get();
  +			XalanDOMString&		prefix = prefixGuard.get();
  +
  +			substring(elementName, prefix, 0, indexOfNSSep);
  +			substring(elementName, elemLocalName, indexOfNSSep + 1);
   
   			if(equals(prefix, DOMServices::s_XMLString))
   			{
  -				elemNS = &DOMServices::s_XMLNamespaceURI;
  +				fResult =
  +					m_stylesheetRoot->isCDATASectionElementName(QNameByReference(DOMServices::s_XMLNamespaceURI, elementName));
   			}
   			else
   			{
  -				elemNS = getResultNamespaceForPrefix(prefix);
  -			}
  +				const XalanDOMString* const		elemNS =
  +					getResultNamespaceForPrefix(prefix);
   
  -			if(elemNS == 0)
  -			{
  -				error("Prefix must resolve to a namespace: " + prefix);
  +				if(elemNS == 0)
  +				{
  +					error("Prefix must resolve to a namespace: " + prefix);
  +				}
  +				else
  +				{
  +					fResult =
  +						m_stylesheetRoot->isCDATASectionElementName(QNameByReference(*elemNS, elementName));
  +				}
   			}
  -
  -			elemLocalName = substring(elementName, indexOfNSSep + 1);
   		}
  -
  -		const QNameByReference	theQName(elemNS != 0 ? *elemNS : s_emptyString, elemLocalName);
  -
  -		for(Stylesheet::QNameVectorType::size_type i = 0; i < theSize && is == false; i++)
  -		{
  -			const QName&	qname = cdataElems[i];
   
  -			is = qname.equals(theQName);
  -		}
  +		return fResult;
   	}
  -
  -	return is;
   }
   	
   
  
  
  
  1.70      +6 -4      xml-xalan/c/src/XSLT/XSLTEngineImpl.hpp
  
  Index: XSLTEngineImpl.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/XSLTEngineImpl.hpp,v
  retrieving revision 1.69
  retrieving revision 1.70
  diff -u -r1.69 -r1.70
  --- XSLTEngineImpl.hpp	2001/06/25 20:17:24	1.69
  +++ XSLTEngineImpl.hpp	2001/06/29 18:53:23	1.70
  @@ -98,13 +98,10 @@
   
   #include <PlatformSupport/AttributeListImpl.hpp>
   #include <PlatformSupport/DOMStringHelper.hpp>
  +#include <PlatformSupport/PrefixResolver.hpp>
   
   
   
  -#include <DOMSupport/PrefixResolver.hpp>
  -
  -
  -
   #include <XPath/Function.hpp>
   #include <XPath/NameSpace.hpp>
   
  @@ -1727,6 +1724,11 @@
   	 * Stack of current result namespaces...
   	 */
   	ResultNamespacesStack			m_resultNamespacesStack;
  +
  +	/*
  +	 * Dummy AttributeListImpl
  +	 */
  +	AttributeListImpl				m_dummyAttributesList;
   
   	static void
   	installFunctions();
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org