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 2002/11/03 04:41:07 UTC

cvs commit: xml-xalan/c/src/XSLT AVT.cpp ElemApplyImport.cpp ElemApplyTemplates.cpp ElemApplyTemplates.hpp ElemAttributeSet.cpp ElemAttributeSet.hpp ElemCallTemplate.cpp ElemCallTemplate.hpp ElemDecimalFormat.cpp ElemDecimalFormat.hpp ElemExtensionCall.cpp ElemForEach.cpp ElemNumber.cpp ElemNumber.hpp ElemPI.cpp ElemParam.cpp ElemParam.hpp ElemTemplate.cpp ElemTemplate.hpp ElemTemplateElement.cpp ElemTemplateElement.hpp ElemUse.hpp ElemVariable.cpp ElemVariable.hpp ElemWithParam.cpp ElemWithParam.hpp Stylesheet.cpp Stylesheet.hpp StylesheetConstructionContext.hpp StylesheetConstructionContextDefault.cpp StylesheetConstructionContextDefault.hpp StylesheetExecutionContext.hpp StylesheetExecutionContextDefault.cpp StylesheetExecutionContextDefault.hpp StylesheetHandler.cpp StylesheetHandler.hpp StylesheetRoot.cpp

dbertoni    2002/11/02 19:41:07

  Modified:    c/src/XSLT AVT.cpp ElemApplyImport.cpp
                        ElemApplyTemplates.cpp ElemApplyTemplates.hpp
                        ElemAttributeSet.cpp ElemAttributeSet.hpp
                        ElemCallTemplate.cpp ElemCallTemplate.hpp
                        ElemDecimalFormat.cpp ElemDecimalFormat.hpp
                        ElemExtensionCall.cpp ElemForEach.cpp
                        ElemNumber.cpp ElemNumber.hpp ElemPI.cpp
                        ElemParam.cpp ElemParam.hpp ElemTemplate.cpp
                        ElemTemplate.hpp ElemTemplateElement.cpp
                        ElemTemplateElement.hpp ElemUse.hpp
                        ElemVariable.cpp ElemVariable.hpp ElemWithParam.cpp
                        ElemWithParam.hpp Stylesheet.cpp Stylesheet.hpp
                        StylesheetConstructionContext.hpp
                        StylesheetConstructionContextDefault.cpp
                        StylesheetConstructionContextDefault.hpp
                        StylesheetExecutionContext.hpp
                        StylesheetExecutionContextDefault.cpp
                        StylesheetExecutionContextDefault.hpp
                        StylesheetHandler.cpp StylesheetHandler.hpp
                        StylesheetRoot.cpp
  Log:
  Huge cleanup and move to more block allocation of stylesheet objects.
  
  Revision  Changes    Path
  1.19      +0 -7      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.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- AVT.cpp	31 Oct 2002 07:15:56 -0000	1.18
  +++ AVT.cpp	3 Nov 2002 03:41:05 -0000	1.19
  @@ -254,13 +254,6 @@
   							// expression.
   							clear(buffer);
   
  -							const XPath* const	xpath =
  -								constructionContext.createXPath(
  -											locator,
  -											exprBuffer,
  -											resolver);
  -							assert(xpath != 0);
  -
   							assert(m_partsSize + 1 < nTokens);
   
   							m_parts[m_partsSize++] =
  
  
  
  1.18      +1 -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.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- ElemApplyImport.cpp	24 Sep 2002 01:42:34 -0000	1.17
  +++ ElemApplyImport.cpp	3 Nov 2002 03:41:05 -0000	1.18
  @@ -126,7 +126,7 @@
   
   	if (executionContext.getCurrentTemplate() == 0)
   	{
  -		executionContext.error("There is no current template", sourceNode, this);
  +		executionContext.error("There is no current template", sourceNode, getLocator());
   	}
   
   	ElemTemplateElement::execute(executionContext);
  
  
  
  1.26      +42 -32    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.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- ElemApplyTemplates.cpp	24 Sep 2002 01:42:34 -0000	1.25
  +++ ElemApplyTemplates.cpp	3 Nov 2002 03:41:05 -0000	1.26
  @@ -2,7 +2,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 1999 The Apache Software Foundation.  All rights 
  + * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights 
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -62,6 +62,10 @@
   
   
   
  +#include <XPath/XalanQNameByValue.hpp>
  +
  +
  +
   #include "Constants.hpp"
   #include "Stylesheet.hpp"
   #include "StylesheetRoot.hpp"
  @@ -71,6 +75,10 @@
   
   
   
  +static const XalanQNameByValue	s_defaultMode;
  +
  +
  +
   ElemApplyTemplates::ElemApplyTemplates(
   			StylesheetConstructionContext&	constructionContext,
   			Stylesheet&						stylesheetTree,
  @@ -83,7 +91,7 @@
   				columnNumber,
   				StylesheetConstructionContext::ELEMNAME_APPLY_TEMPLATES),
   	m_isDefaultTemplate(false),
  -	m_mode()
  +	m_mode(0)
   {
   	const unsigned	int nAttrs = atts.getLength();
   
  @@ -97,7 +105,7 @@
   		}
   		else if (equals(aname, Constants::ATTRNAME_MODE))
   		{
  -			m_mode = XalanQNameByValue(atts.getValue(i), getStylesheet().getNamespaces());
  +			m_mode = constructionContext.createXalanQName(atts.getValue(i), getStylesheet().getNamespaces(), getLocator());
   		}
   		else if (!isAttrOK(aname, atts, i, constructionContext))
   		{
  @@ -116,7 +124,19 @@
   			*this);
   	}
   
  -	assert(m_selectPattern != 0);
  +	if (m_mode == 0)
  +	{
  +		m_mode = &s_defaultMode;
  +	}
  +	else if (m_mode->isValid() == false)
  +	{
  +		constructionContext.error(
  +				"xsl:apply-templates has an illegal 'mode' attribute",
  +				0,
  +				this);
  +	}
  +
  +	assert(m_selectPattern != 0 && m_mode != 0);
   }
   
   
  @@ -138,7 +158,7 @@
   void
   ElemApplyTemplates::execute(StylesheetExecutionContext&		executionContext) const
   {
  -	assert(m_selectPattern != 0);
  +	assert(m_selectPattern != 0 && m_mode != 0);
   
   	if(0 != executionContext.getTraceListeners())
   	{
  @@ -147,50 +167,40 @@
   	}
   
   	XalanNode* const	sourceNode = executionContext.getCurrentNode();
  +	assert(sourceNode != 0);
   
  -	if (sourceNode == 0)
  -	{
  -		executionContext.error(
  -			"There is no current node in ElemApplyTemplates::execute()",
  -			sourceNode,
  -			this);
  -	}
  -    else
  -	{
  -		// Dragons here.  Push the params & stack frame, but then execute the
  -		// select statement inside transformSelectedChildren, which must be
  -		// executed in the stack frame before the new stack frame.  Because of
  -		// depth-first searching, this gets worse.
  -		StylesheetExecutionContext::ParamsPushPop	thePushPop(
  +	// Push the params & stack frame, but then execute the select
  +	// expression inside transformSelectedChildren, which must be
  +	// executed in the stack frame before the new stack frame.
  +	StylesheetExecutionContext::ParamsPushPop	thePushPop(
   			executionContext,
   			*this,
   			sourceNode,
   			this);
   
  -		const XalanQName* const		currentMode = executionContext.getCurrentMode();
  -		assert(currentMode != 0);
  +	const XalanQName* const		currentMode = executionContext.getCurrentMode();
  +	assert(currentMode != 0);
   
  -		if (m_isDefaultTemplate == false &&
  -			!m_mode.equals(*currentMode))
  -		{
  -			executionContext.setCurrentMode(&m_mode);
  +	if (m_isDefaultTemplate == false &&
  +		!m_mode->equals(*currentMode))
  +	{
  +		executionContext.setCurrentMode(m_mode);
   
  -			transformSelectedChildren(
  +		transformSelectedChildren(
   				executionContext,
   				0,
   				sourceNode,
   				thePushPop.getStackFrameIndex());
   
  -			executionContext.setCurrentMode(currentMode);
  -		}
  -		else
  -		{
  -			transformSelectedChildren(
  +		executionContext.setCurrentMode(currentMode);
  +	}
  +	else
  +	{
  +		transformSelectedChildren(
   				executionContext,
   				0,
   				sourceNode,
   				thePushPop.getStackFrameIndex());
  -		}
   	}
   }
   
  
  
  
  1.12      +4 -4      xml-xalan/c/src/XSLT/ElemApplyTemplates.hpp
  
  Index: ElemApplyTemplates.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemApplyTemplates.hpp,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ElemApplyTemplates.hpp	13 Aug 2001 17:08:52 -0000	1.11
  +++ ElemApplyTemplates.hpp	3 Nov 2002 03:41:05 -0000	1.12
  @@ -2,7 +2,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 1999 The Apache Software Foundation.  All rights 
  + * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights 
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -75,7 +75,7 @@
   
   
   
  -#include <XPath/XalanQNameByValue.hpp>
  +class XalanQName;
   
   
   
  @@ -141,7 +141,7 @@
   
   	bool				m_isDefaultTemplate;
   
  -	XalanQNameByValue	m_mode;
  +	const XalanQName*	m_mode;
   };
   
   
  
  
  
  1.22      +7 -4      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.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- ElemAttributeSet.cpp	24 Sep 2002 01:42:34 -0000	1.21
  +++ ElemAttributeSet.cpp	3 Nov 2002 03:41:05 -0000	1.22
  @@ -80,7 +80,7 @@
   			lineNumber,
   			columnNumber,
   			StylesheetConstructionContext::ELEMNAME_ATTRIBUTE_SET),
  -	m_QName()
  +	m_qname(0)
   {
   	const unsigned int	nAttrs = atts.getLength();
   
  @@ -90,7 +90,10 @@
   
   		if(equals(aname, Constants::ATTRNAME_NAME))
   		{
  -			m_QName.set(atts.getValue(i), stylesheetTree.getNamespaces());
  +			m_qname = constructionContext.createXalanQName(
  +				atts.getValue(i),
  +				stylesheetTree.getNamespaces(),
  +				getLocator());
   
   			stylesheetTree.addAttributeSet(this);
   		}
  @@ -104,14 +107,14 @@
   		}
   	}
   
  -	if(m_QName.isEmpty() == true)
  +	if(m_qname == 0)
   	{
   		constructionContext.error(
   			"xsl:attribute-set must have a 'name' attribute",
   			0,
   			this);
   	}
  -	else if (isValidNCName(m_QName.getLocalPart()) == false)
  +	else if (m_qname->isValid() == false)
   	{
   		constructionContext.error(
   			"xsl:attribute-set has an invalid 'name' attribute",
  
  
  
  1.14      +4 -6      xml-xalan/c/src/XSLT/ElemAttributeSet.hpp
  
  Index: ElemAttributeSet.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemAttributeSet.hpp,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- ElemAttributeSet.hpp	8 Nov 2001 01:08:48 -0000	1.13
  +++ ElemAttributeSet.hpp	3 Nov 2002 03:41:05 -0000	1.14
  @@ -69,10 +69,6 @@
   
   
   
  -#include <XPath/XalanQNameByValue.hpp>
  -
  -
  -
   class ElemAttributeSet : public ElemUse
   {
   public:
  @@ -104,7 +100,9 @@
   	const XalanQName&
   	getQName() const
   	{
  -		return m_QName;
  +		assert(m_qname != 0);
  +
  +		return *m_qname;
   	}
   
   
  @@ -123,7 +121,7 @@
   
   private:
   
  -	XalanQNameByValue	m_QName;
  +	const XalanQName*	m_qname;
   };
   
   
  
  
  
  1.25      +17 -21    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.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- ElemCallTemplate.cpp	24 Sep 2002 01:42:34 -0000	1.24
  +++ ElemCallTemplate.cpp	3 Nov 2002 03:41:05 -0000	1.25
  @@ -87,7 +87,7 @@
   						lineNumber,
   						columnNumber,
   						StylesheetConstructionContext::ELEMNAME_CALL_TEMPLATE),
  -	m_templateName(),
  +	m_templateName(0),
   	m_template(0)
   {
   	const unsigned int	nAttrs = atts.getLength();
  @@ -98,7 +98,10 @@
   
   		if(equals(aname, Constants::ATTRNAME_NAME))
   		{
  -			m_templateName.set(atts.getValue(i), getStylesheet().getNamespaces());        
  +			m_templateName = constructionContext.createXalanQName(
  +					atts.getValue(i),
  +					getStylesheet().getNamespaces(),
  +					getLocator());
   		}
   		else if(!isAttrOK(aname, atts, i, constructionContext))
   		{
  @@ -109,14 +112,14 @@
   		}
   	}
   
  -	if (m_templateName.isEmpty() == true)
  +	if (m_templateName == 0)
   	{
   		constructionContext.error(
   			"xsl:call-template must have a 'name' attribute",
   			0,
   			this);
   	}
  -	else if (isValidNCName(m_templateName.getLocalPart()) == false)
  +	else if (m_templateName->isValid() == false)
   	{
   		constructionContext.error(
   			"xsl:call-template has an invalid 'name' attribute",
  @@ -126,7 +129,7 @@
   }
   
   
  -	
  +
   ElemCallTemplate::~ElemCallTemplate()
   {
   }
  @@ -167,10 +170,9 @@
   			StylesheetConstructionContext&	constructionContext,
   			const NamespacesHandler&		theParentHandler)
   {
  -	assert(m_templateName.isEmpty() == false);
  +	assert(m_templateName != 0);
   
  -	m_template =
  -		getStylesheet().getStylesheetRoot().findNamedTemplate(m_templateName);
  +	m_template = getStylesheet().getStylesheetRoot().findNamedTemplate(*m_templateName);
   
   	if(m_template == 0)
   	{
  @@ -189,18 +191,12 @@
   bool
   ElemCallTemplate::childTypeAllowed(int	xslToken) const
   {
  -	bool	fResult = false;
  -	
  -	switch(xslToken)
  -	{
  -	// char-instructions 
  -	case StylesheetConstructionContext::ELEMNAME_WITH_PARAM:
  -		fResult = true;
  -		break;
  -		
  -	default:
  -		break;
  +	if (xslToken == StylesheetConstructionContext::ELEMNAME_WITH_PARAM)
  +	{
  +		return true;
  +	}
  +	else
  +	{
  +		return false;
   	}
  -	
  -	return fResult;
   }
  
  
  
  1.15      +1 -5      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.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- ElemCallTemplate.hpp	13 Aug 2001 17:08:53 -0000	1.14
  +++ ElemCallTemplate.hpp	3 Nov 2002 03:41:05 -0000	1.15
  @@ -64,10 +64,6 @@
   
   
   
  -#include <XPath/XalanQNameByValue.hpp>
  -
  -
  -
   // Base class header file.
   #include "ElemTemplateElement.hpp"
   
  @@ -133,7 +129,7 @@
   	operator=(const ElemCallTemplate&);
   
   	// Data members...
  -	XalanQNameByValue		m_templateName;
  +	const XalanQName*		m_templateName;
   
   	const ElemTemplate*		m_template;
   };
  
  
  
  1.12      +14 -3     xml-xalan/c/src/XSLT/ElemDecimalFormat.cpp
  
  Index: ElemDecimalFormat.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemDecimalFormat.cpp,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ElemDecimalFormat.cpp	24 Sep 2002 01:42:34 -0000	1.11
  +++ ElemDecimalFormat.cpp	3 Nov 2002 03:41:05 -0000	1.12
  @@ -66,12 +66,20 @@
   
   
   
  +#include <XPath/XalanQNameByValue.hpp>
  +
  +
  +
   #include "Constants.hpp"
   #include "Stylesheet.hpp"
   #include "StylesheetConstructionContext.hpp"
   
   
   
  +static const XalanQNameByValue	s_empty;
  +
  +
  +
   ElemDecimalFormat::ElemDecimalFormat(
   			StylesheetConstructionContext&	constructionContext,
   			Stylesheet& 					stylesheetTree,
  @@ -86,7 +94,7 @@
   	m_countMatchPattern(0),
   	m_fromMatchPattern(0),
   	m_valueExpr(0),
  -	m_qname(),
  +	m_qname(&s_empty),
   	m_decimalFormatSymbols()
   {
   	m_decimalFormatSymbols.setInfinity(XalanDOMString());
  @@ -102,7 +110,10 @@
   		{
   			assert(atts.getValue(i) != 0);
   
  -			m_qname.set(atts.getValue(i), getStylesheet().getNamespaces());
  +			m_qname = constructionContext.createXalanQName(
  +						atts.getValue(i),
  +						getStylesheet().getNamespaces(),
  +						getLocator());
   		}
   		else if(equals(aname, Constants::ATTRNAME_DECIMALSEPARATOR))
   		{
  @@ -273,7 +284,7 @@
   
   	// Look for duplicate decimal-format names
   	const XalanDecimalFormatSymbols* const	theOther =
  -			stylesheetTree.getDecimalFormatSymbols(m_qname);
  +			stylesheetTree.getDecimalFormatSymbols(*m_qname);
   
   	if (theOther != 0 && *theOther != m_decimalFormatSymbols)
   	{
  
  
  
  1.10      +4 -6      xml-xalan/c/src/XSLT/ElemDecimalFormat.hpp
  
  Index: ElemDecimalFormat.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemDecimalFormat.hpp,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ElemDecimalFormat.hpp	26 Nov 2001 23:27:03 -0000	1.9
  +++ ElemDecimalFormat.hpp	3 Nov 2002 03:41:05 -0000	1.10
  @@ -73,10 +73,6 @@
   
   
   
  -#include <XPath/XalanQNameByValue.hpp>
  -
  -
  -
   class XPath;
   
   
  @@ -120,7 +116,9 @@
   	const XalanQName&
   	getQName() const
   	{
  -		return m_qname;
  +		assert(m_qname != 0);
  +
  +		return *m_qname;
   	}
   
   private:
  @@ -129,7 +127,7 @@
   	const XPath*				m_fromMatchPattern;
   	const XPath*				m_valueExpr;
   
  -	XalanQNameByValue			m_qname;
  +	const XalanQName*			m_qname;
   
   	XalanDecimalFormatSymbols	m_decimalFormatSymbols;
   };
  
  
  
  1.13      +4 -1      xml-xalan/c/src/XSLT/ElemExtensionCall.cpp
  
  Index: ElemExtensionCall.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemExtensionCall.cpp,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- ElemExtensionCall.cpp	24 Sep 2002 01:42:34 -0000	1.12
  +++ ElemExtensionCall.cpp	3 Nov 2002 03:41:05 -0000	1.13
  @@ -99,7 +99,10 @@
   void
   ElemExtensionCall::execute(StylesheetExecutionContext&		executionContext) const
   {
  -	executionContext.warn("Xalan C++ does not yet handle extensions!");
  +	executionContext.warn(
  +		"Xalan C++ does not yet handle extensions!",
  +		0,
  +		getLocator());
   
   	for (const ElemTemplateElement*	child = getFirstChildElem(); child != 0; child = child->getNextSiblingElem())
   	{
  
  
  
  1.28      +9 -1      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.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- ElemForEach.cpp	24 Sep 2002 01:42:34 -0000	1.27
  +++ ElemForEach.cpp	3 Nov 2002 03:41:05 -0000	1.28
  @@ -209,7 +209,7 @@
   			executionContext.error(
   				"There is no current node in ElemForEach::execute()",
   				sourceNode, 
  -				this);
  +				getLocator());
   		}
   	}
   }
  @@ -418,6 +418,14 @@
   
   	if (theXObject.null() == false)
   	{
  +		if (theXObject->getType() != XObject::eTypeNodeSet)
  +		{
  +			executionContext.error(
  +				"xsl:for-each 'select' must evaluate to a node-set",
  +				sourceNodeContext,
  +				getLocator());
  +		}
  +
   		const NodeRefListBase&	sourceNodes = theXObject->nodeset();
   
   		if(0 != executionContext.getTraceListeners())
  
  
  
  1.68      +4 -8      xml-xalan/c/src/XSLT/ElemNumber.cpp
  
  Index: ElemNumber.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemNumber.cpp,v
  retrieving revision 1.67
  retrieving revision 1.68
  diff -u -r1.67 -r1.68
  --- ElemNumber.cpp	31 Oct 2002 07:15:56 -0000	1.67
  +++ ElemNumber.cpp	3 Nov 2002 03:41:05 -0000	1.68
  @@ -243,8 +243,7 @@
   			StylesheetExecutionContext&		executionContext,
   			const XPath*					fromMatchPattern,
   			const XPath*					countMatchPattern,
  -			XalanNode*						context,
  -			const XalanElement*				/* namespaceContext */) const
  +			XalanNode*						context) const
   {
   	XalanNode*	contextCopy = context;
   
  @@ -283,8 +282,7 @@
   			StylesheetExecutionContext&		executionContext,
   			const XPath*					fromMatchPattern,
   			const XPath*					countMatchPattern,
  -			XalanNode*						context,
  -			const XalanElement*				/* namespaceContext */) const
  +			XalanNode*						context) const
   {  
   	XalanNode*	contextCopy = context;
   
  @@ -730,8 +728,7 @@
   				executionContext,
   				m_fromMatchPattern,
   				countMatchPattern,
  -				sourceNode,
  -				this);
  +				sourceNode);
   	}
   	else
   	{
  @@ -739,8 +736,7 @@
   				executionContext,
   				m_fromMatchPattern,
   				countMatchPattern,
  -				sourceNode,
  -				this);
  +				sourceNode);
   	}
   
   	return target;
  
  
  
  1.42      +17 -15    xml-xalan/c/src/XSLT/ElemNumber.hpp
  
  Index: ElemNumber.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemNumber.hpp,v
  retrieving revision 1.41
  retrieving revision 1.42
  diff -u -r1.41 -r1.42
  --- ElemNumber.hpp	24 Sep 2002 06:57:42 -0000	1.41
  +++ ElemNumber.hpp	3 Nov 2002 03:41:05 -0000	1.42
  @@ -179,35 +179,37 @@
   	 * Given a 'from' pattern (ala xsl:number), a match pattern 
   	 * and a context, find the first ancestor that matches the 
   	 * pattern (including the context handed in).
  +	 *
  +	 * @param executionContext The current execution context
   	 * @param matchPatternString The match pattern.
  -	 * @param node The node that "." expresses.
  -	 * @param namespaceContext The context in which namespaces in the 
  -	 * queries are supposed to be expanded.
  +	 * @param matchPatternString The count match pattern.
  +	 * @param node The context node
  +	 * @return A pointer to the matched node.
   	 */
   	XalanNode*
   	findAncestor(
   			StylesheetExecutionContext&		executionContext,
   			const XPath*					fromMatchPattern,
   			const XPath*					countMatchPattern,
  -			XalanNode*						context,
  -			const XalanElement*				namespaceContext) const;
  +			XalanNode*						context) const;
   
   	/**
  -	* Given a 'from' pattern (ala xsl:number), a match pattern 
  -	* and a context, find the first ancestor that matches the 
  -	* pattern (including the context handed in).
  -	* @param matchPatternString The match pattern.
  -	* @param node The node that "." expresses.
  -	* @param namespaceContext The context in which namespaces in the 
  -	* queries are supposed to be expanded.
  -	*/
  +	 * Given a 'from' pattern (ala xsl:number), a match pattern 
  +	 * and a context, find the first ancestor that matches the 
  +	 * pattern (including the context handed in).
  +	 *
  +	 * @param executionContext The current execution context
  +	 * @param matchPatternString The match pattern.
  +	 * @param matchPatternString The count match pattern.
  +	 * @param node The context node
  +	 * @return A pointer to the matched node.
  +	 */
   	XalanNode*
   	findPrecedingOrAncestorOrSelf(
   			StylesheetExecutionContext&		executionContext,
   			const XPath*					fromMatchPattern,
   			const XPath*					countMatchPattern,
  -			XalanNode*						context,
  -			const XalanElement*				namespaceContext) const;
  +			XalanNode*						context) const;
   
   	/**
   	 * Get the count match pattern, or a default value.
  
  
  
  1.25      +2 -2      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.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- ElemPI.cpp	31 Oct 2002 07:15:56 -0000	1.24
  +++ ElemPI.cpp	3 Nov 2002 03:41:05 -0000	1.25
  @@ -143,11 +143,11 @@
   
   	if(equalsIgnoreCaseASCII(piName, Constants::ATTRVAL_OUTPUT_METHOD_XML))
   	{
  -		executionContext.error("processing-instruction name can not be 'xml'", 0, this);
  +		executionContext.error("processing-instruction name can not be 'xml'", 0, getLocator());
   	}
   	else if(!isValidNCName(piName))
   	{
  -		executionContext.error("processing-instruction name must be a valid NCName", 0, this);
  +		executionContext.error("processing-instruction name must be a valid NCName", 0, getLocator());
   	}
   
   	StylesheetExecutionContext::SetAndRestoreCopyTextNodesOnly	theSetAndRestore(executionContext, true);
  
  
  
  1.15      +4 -2      xml-xalan/c/src/XSLT/ElemParam.cpp
  
  Index: ElemParam.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemParam.cpp,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- ElemParam.cpp	24 Sep 2002 05:59:38 -0000	1.14
  +++ ElemParam.cpp	3 Nov 2002 03:41:05 -0000	1.15
  @@ -2,7 +2,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 1999 The Apache Software Foundation.  All rights 
  + * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights 
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -99,7 +99,9 @@
   void
   ElemParam::execute(StylesheetExecutionContext&		executionContext) const
   {
  -	const XObjectPtr	obj = executionContext.getParamVariable(m_qname);
  +	assert(m_qname != 0);
  +
  +	const XObjectPtr	obj = executionContext.getParamVariable(*m_qname);
   
   	if (obj.null() == true)
   	{
  
  
  
  1.10      +1 -1      xml-xalan/c/src/XSLT/ElemParam.hpp
  
  Index: ElemParam.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemParam.hpp,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ElemParam.hpp	9 Mar 2001 16:19:59 -0000	1.9
  +++ ElemParam.hpp	3 Nov 2002 03:41:05 -0000	1.10
  @@ -2,7 +2,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 1999 The Apache Software Foundation.  All rights 
  + * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights 
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  
  
  
  1.27      +45 -6     xml-xalan/c/src/XSLT/ElemTemplate.cpp
  
  Index: ElemTemplate.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemTemplate.cpp,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- ElemTemplate.cpp	24 Sep 2002 05:59:38 -0000	1.26
  +++ ElemTemplate.cpp	3 Nov 2002 03:41:05 -0000	1.27
  @@ -71,12 +71,20 @@
   
   
   
  +#include <XPath/XalanQNameByValue.hpp>
  +
  +
  +
   #include "Constants.hpp"
   #include "Stylesheet.hpp"
   #include "StylesheetConstructionContext.hpp"
   
   
   
  +static const XalanQNameByValue	s_empty;
  +
  +
  +
   ElemTemplate::ElemTemplate(
   			StylesheetConstructionContext&	constructionContext,
   			Stylesheet&						stylesheetTree,
  @@ -89,8 +97,8 @@
   						columnNumber,
   						StylesheetConstructionContext::ELEMNAME_TEMPLATE),
   	m_matchPattern(0),
  -	m_name(),
  -	m_mode(),
  +	m_name(&s_empty),
  +	m_mode(&s_empty),
   	m_priority(XPath::getMatchScoreValue(XPath::eMatchScoreNone))
   {
   	const unsigned int	nAttrs = atts.getLength();
  @@ -105,7 +113,10 @@
   		}
   		else if (equals(aname, Constants::ATTRNAME_NAME))
   		{
  -			m_name = XalanQNameByValue(atts.getValue(i), getStylesheet().getNamespaces());
  +			m_name = constructionContext.createXalanQName(
  +						atts.getValue(i),
  +						getStylesheet().getNamespaces(),
  +						getLocator());
   		}
   		else if (equals(aname, Constants::ATTRNAME_PRIORITY))
   		{
  @@ -115,7 +126,10 @@
   		}
   		else if (equals(aname, Constants::ATTRNAME_MODE))
   		{
  -			m_mode = XalanQNameByValue(atts.getValue(i), getStylesheet().getNamespaces());
  +			m_mode = constructionContext.createXalanQName(
  +						atts.getValue(i),
  +						getStylesheet().getNamespaces(),
  +						getLocator());
   		}
   		else if(!(isAttrOK(aname, atts, i, constructionContext) || 
   				 processSpaceAttr(aname, atts, i, constructionContext)))
  @@ -127,7 +141,7 @@
   		}
   	}
   
  -	const bool	isEmptyName = m_name.isEmpty();
  +	const bool	isEmptyName = m_name->isEmpty();
   
   	if(0 == m_matchPattern && isEmptyName == true)
   	{
  @@ -136,19 +150,44 @@
   				0,
   				this);
   	}
  -	else if (isEmptyName == false && isValidNCName(m_name.getLocalPart()) == false)
  +	else if (isEmptyName == false && m_name->isValid() == false)
   	{
   		constructionContext.error(
   			"xsl:template has an invalid 'name' attribute",
   			0,
   			this);
   	}
  +	else if (m_mode->isEmpty() == false && m_mode->isValid() == false)
  +	{
  +		constructionContext.error(
  +			"xsl:template has an invalid 'mode' attribute",
  +			0,
  +			this);
  +	}
   }
   
   
   
   ElemTemplate::~ElemTemplate()
   {
  +}
  +
  +
  +
  +void
  +ElemTemplate::addToStylesheet(
  +			StylesheetConstructionContext&	constructionContext,
  +			Stylesheet&						theStylesheet)
  +{
  +	theStylesheet.addTemplate(this, constructionContext); 
  +}
  +
  +
  +
  +const XalanQName&
  +ElemTemplate::getNameAttribute() const
  +{ 
  +	return *m_name;
   }
   
   
  
  
  
  1.14      +13 -18    xml-xalan/c/src/XSLT/ElemTemplate.hpp
  
  Index: ElemTemplate.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemTemplate.hpp,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- ElemTemplate.hpp	16 Apr 2002 05:45:50 -0000	1.13
  +++ ElemTemplate.hpp	3 Nov 2002 03:41:05 -0000	1.14
  @@ -71,10 +71,6 @@
   
   
   
  -#include <XPath/XalanQNameByValue.hpp>
  -
  -
  -
   class XPath;
   
   
  @@ -103,17 +99,6 @@
   	~ElemTemplate();
   
   	/**
  -	 * Retrieve the qualified name of element
  -	 * 
  -	 * @return QName for element
  -	 */
  -	const XalanQName&
  -	getName() const
  -	{
  -		return m_name;
  -	}
  -
  -	/**
   	 * Retrieve the mode of element
   	 * 
   	 * @return QName for mode
  @@ -121,7 +106,9 @@
   	const XalanQName&
   	getMode() const
   	{
  -		return m_mode;
  +		assert(m_mode != 0);
  +
  +		return *m_mode;
   	}
   
   	/**
  @@ -146,6 +133,14 @@
   		return m_priority;
   	}
   
  +	virtual const XalanQName&
  +	getNameAttribute() const;
  +
  +	virtual void
  +	addToStylesheet(
  +			StylesheetConstructionContext&	constructionContext,
  +			Stylesheet&						theStylesheet);
  +
   	virtual const XalanDOMString&
   	getElementName() const;
   
  @@ -172,8 +167,8 @@
   	// Data members...
   	const XPath*		m_matchPattern;
   
  -	XalanQNameByValue	m_name;
  -	XalanQNameByValue	m_mode;
  +	const XalanQName*	m_name;
  +	const XalanQName*	m_mode;
   
   	double				m_priority;
   };
  
  
  
  1.82      +47 -71    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.81
  retrieving revision 1.82
  diff -u -r1.81 -r1.82
  --- ElemTemplateElement.cpp	27 Sep 2002 23:32:23 -0000	1.81
  +++ ElemTemplateElement.cpp	3 Nov 2002 03:41:05 -0000	1.82
  @@ -113,6 +113,8 @@
   
   const XalanEmptyNamedNodeMap	ElemTemplateElement::s_fakeAttributes;
   
  +const XalanQNameByReference			ElemTemplateElement::s_emptyQName(s_emptyString, s_emptyString);
  +
   
   
   ElemTemplateElement::ElemTemplateElement(
  @@ -323,6 +325,27 @@
   
   
   
  +const XalanQName&
  +ElemTemplateElement::getNameAttribute() const
  +{
  +	return s_emptyQName;
  +}
  +
  +
  +
  +void
  +ElemTemplateElement::addToStylesheet(
  +			StylesheetConstructionContext&	constructionContext,
  +			Stylesheet&						/* theStylesheet */)
  +{
  +	constructionContext.error(
  +		"An illegal call to addToStylesheet() was made during compilation of the stylesheet.",
  +		0,
  +		this);
  +}
  +
  +
  +
   XalanDOMString&
   ElemTemplateElement::doChildrenToString(
   			StylesheetExecutionContext&		executionContext, 
  @@ -532,6 +555,8 @@
   ElemTemplateElement::appendChildElem(ElemTemplateElement*	newChild)
   {
   	assert(newChild != 0);
  +	assert(newChild->getXSLToken() != StylesheetConstructionContext::ELEMNAME_TEXT);
  +	assert(newChild->getXSLToken() != StylesheetConstructionContext::ELEMNAME_UNDEFINED);
   
   	if (newChild->isWhitespace() == false &&
   		childTypeAllowed(newChild->getXSLToken()) == false)
  @@ -865,8 +890,7 @@
   #endif
   ElemTemplateElement::cloneNode(bool		/* deep */) const
   {
  -	//should not be called
  -	assert(false);	
  +	throw XalanDOMException(XalanDOMException::NOT_SUPPORTED_ERR);
   
   	return 0;
   }
  @@ -875,84 +899,37 @@
   
   XalanNode*
   ElemTemplateElement::insertBefore(
  -			XalanNode*	newChild,
  -			XalanNode*	refChild)
  +			XalanNode*	/* newChild */,
  +			XalanNode*	/* refChild */)
   {
  -#if defined(XALAN_OLD_STYLE_CASTS) || !defined(XALAN_RTTI_AVAILABLE)
  -	return insertBeforeElem((ElemTemplateElement*)newChild,
  -							(ElemTemplateElement*)refChild);
  -#else
  -	return insertBeforeElem(dynamic_cast<ElemTemplateElement*>(newChild),
  -							dynamic_cast<ElemTemplateElement*>(refChild));
  -#endif
  +	throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
  +
  +	// Dummy return value...
  +	return 0;
   }
   
   
   
   XalanNode*
   ElemTemplateElement::replaceChild(
  -			XalanNode*	newChild,
  -			XalanNode*	oldChild)
  +			XalanNode*	/* newChild */,
  +			XalanNode*	/* oldChild */)
   {
  -#if defined(XALAN_OLD_STYLE_CASTS) || !defined(XALAN_RTTI_AVAILABLE)
  -	return replaceChildElem((ElemTemplateElement*)newChild,
  -							(ElemTemplateElement*)oldChild);
  -#else
  -	return replaceChildElem(dynamic_cast<ElemTemplateElement*>(newChild),
  -							dynamic_cast<ElemTemplateElement*>(oldChild));
  -#endif
  +	throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
  +
  +	// Dummy return value...
  +	return 0;
   }
   
   
   
   XalanNode*
  -ElemTemplateElement::removeChild(XalanNode*		oldChild)
  +ElemTemplateElement::removeChild(XalanNode*		/* oldChild */)
   {
  -	assert(oldChild != 0);
  +	throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
   
  -	XalanNode*				ret = 0;
  -
  -	// first try the common, easy cases
  -	if (oldChild == 0 || oldChild->getParentNode() != this)
  -	{
  -		throw XalanDOMException(XalanDOMException::NOT_FOUND_ERR);
  -	}
  -	else
  -	{
  -		ElemTemplateElement*	pTest = m_firstChild;
  -		assert(pTest != 0);
  -
  -		if (pTest == oldChild)
  -		{
  -			ElemTemplateElement* const	nextChild =
  -				pTest->getNextSiblingElem();
  -
  -			if (nextChild != 0)
  -			{
  -				nextChild->setPreviousSiblingElem(0);
  -			}
  -
  -			pTest->setNextSiblingElem(0);
  -			m_firstChild = nextChild;
  -
  -			ret = pTest;
  -		}
  -		else
  -		{
  -			// now we walk this singly-linked list, peeling one ahead, since we need be
  -			// able to patch up the list
  -
  -			while (pTest->getNextSibling() != 0 && pTest->getNextSibling() != oldChild)
  -				pTest = pTest->getNextSiblingElem();
  -
  -			ret = pTest->getNextSibling();
  -
  -			if (pTest->getNextSibling() != 0)
  -				pTest->setNextSiblingElem(pTest->getNextSiblingElem()->getNextSiblingElem());
  -		}
  -	}
  -
  -	return ret;
  +	// Dummy return value...
  +	return 0;
   }
   
   
  @@ -963,13 +940,12 @@
    */
   
   XalanNode*
  -ElemTemplateElement::appendChild(XalanNode*		oldChild)
  +ElemTemplateElement::appendChild(XalanNode*		/* oldChild */)
   {
  -#if defined(XALAN_OLD_STYLE_CASTS) || !defined(XALAN_RTTI_AVAILABLE)
  -	return appendChildElem((ElemTemplateElement*)oldChild);
  -#else
  -	return appendChildElem(dynamic_cast<ElemTemplateElement*>(oldChild));
  -#endif
  +	throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
  +
  +	// Dummy return value...
  +	return 0;
   }
   
   
  
  
  
  1.49      +38 -2     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.48
  retrieving revision 1.49
  diff -u -r1.48 -r1.49
  --- ElemTemplateElement.hpp	27 Sep 2002 23:32:23 -0000	1.48
  +++ ElemTemplateElement.hpp	3 Nov 2002 03:41:05 -0000	1.49
  @@ -82,6 +82,10 @@
   
   
   
  +#include <XPath/XalanQNameByReference.hpp>
  +
  +
  +
   #include <XSLT/NamespacesHandler.hpp>
   
   
  @@ -100,6 +104,8 @@
   {
   public:
   
  +	typedef XalanElement::NodeType	NodeType;
  +
   	/**
   	 * Construct a template element instance.
   	 * 
  @@ -121,7 +127,7 @@
   	 * Special constructor used by dummy elements which do not exist in the
   	 * final stylesheet.
   	 * 
  -	 * @param constructionContext  context when object constructed
  +	 * @param constructionContext  The current construction context
   	 * @param stylesheetTree	   owning stylesheet
   	 * @param xslToken			   an integer representing the type of instance.
   	 */
  @@ -310,9 +316,37 @@
   	virtual bool
   	isWhitespace() const;
   
  +	/** 
  +	 * Get a string for the name of the element.  Useful for debugging purposes,
  +	 * and error reporting.
  +	 * 
  +	 * @return A string containing the name of the element.
  +	 */
   	virtual const XalanDOMString&
   	getElementName() const = 0;
   
  +	/** 
  +	 * Get the QName associated with any name attribute of this element.
  +	 * If the element has no name attribute, this will be an empty QName.
  +	 * 
  +	 * @return A string containing the name of the element.
  +	 */
  +	virtual const XalanQName&
  +	getNameAttribute() const;
  +
  +	/** 
  +	 * Called during compilation when an instance is not parented by
  +	 * another element, and thus, is a child of the stylesheet..
  +	 * 
  +	 * @param constructionContext  The current construction context
  +	 * @param theStylesheet The owning stylesheet
  +	 * @return nothing
  +	 */
  +	virtual void
  +	addToStylesheet(
  +			StylesheetConstructionContext&	constructionContext,
  +			Stylesheet&						theStylesheet);
  +
   #if defined(XALAN_NO_NAMESPACES)
   	typedef map<XalanDOMString,
   				XalanDOMString,
  @@ -821,7 +855,7 @@
   		const ElemTextLiteral*	m_textLiteralChild;
   	};
   
  -	XalanNodeListSurrogate	m_surrogateChildren;
  +	const XalanNodeListSurrogate	m_surrogateChildren;
   
   	const XalanDOMString&	m_baseIndentifier;
   
  @@ -836,6 +870,8 @@
   	LocatorProxy			m_locatorProxy;
   
   	static const XalanEmptyNamedNodeMap 	s_fakeAttributes;
  +
  +	static const XalanQNameByReference		s_emptyQName;
   
   	// Not implemented...
   	ElemTemplateElement(const ElemTemplateElement&);
  
  
  
  1.19      +0 -4      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.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- ElemUse.hpp	31 Oct 2002 07:15:56 -0000	1.18
  +++ ElemUse.hpp	3 Nov 2002 03:41:05 -0000	1.19
  @@ -69,10 +69,6 @@
   
   
   
  -#include <XPath/XalanQNameByValue.hpp>
  -
  -
  -
   #include "Constants.hpp"
   
   
  
  
  
  1.28      +88 -19    xml-xalan/c/src/XSLT/ElemVariable.cpp
  
  Index: ElemVariable.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemVariable.cpp,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- ElemVariable.cpp	24 Sep 2002 05:59:38 -0000	1.27
  +++ ElemVariable.cpp	3 Nov 2002 03:41:05 -0000	1.28
  @@ -84,12 +84,13 @@
   			const AttributeList&			atts,
   			int								lineNumber,
   			int								columnNumber) :
  -	ElemTemplateElement(constructionContext,
  -						stylesheetTree,
  -						lineNumber,
  -						columnNumber,
  -						StylesheetConstructionContext::ELEMNAME_VARIABLE),
  -	m_qname(),
  +	ParentType(
  +		constructionContext,
  +		stylesheetTree,
  +		lineNumber,
  +		columnNumber,
  +		StylesheetConstructionContext::ELEMNAME_VARIABLE),
  +	m_qname(0),
   	m_selectPattern(0),
   	m_isTopLevel(false),
   	m_value(0),
  @@ -107,12 +108,13 @@
   			int								lineNumber,
   			int								columnNumber,
   			int								xslToken) :
  -	ElemTemplateElement(constructionContext,
  -						stylesheetTree,
  -						lineNumber,
  -						columnNumber,
  -						xslToken),
  -	m_qname(),
  +	ParentType(
  +		constructionContext,
  +		stylesheetTree,
  +		lineNumber,
  +		columnNumber,
  +		xslToken),
  +	m_qname(0),
   	m_selectPattern(0),
   	m_isTopLevel(false),
   	m_value(0),
  @@ -147,7 +149,10 @@
   		}
   		else if (equals(aname, Constants::ATTRNAME_NAME))
   		{
  -			m_qname = XalanQNameByValue(atts.getValue(i), stylesheetTree.getNamespaces());
  +			m_qname = constructionContext.createXalanQName(
  +						atts.getValue(i),
  +						stylesheetTree.getNamespaces(),
  +						getLocator());
   		}
   		else if(!(isAttrOK(aname, atts, i, constructionContext) || 
   				 processSpaceAttr(aname, atts, i, constructionContext)))
  @@ -159,13 +164,60 @@
   		}
   	}
   
  -	if(m_qname.isEmpty())
  +	if(m_qname == 0)
   	{
   		constructionContext.error(
   			"xsl:variable must have a 'name' attribute",
   			0,
   			this);
   	}
  +	else if (m_qname->isValid() == false)
  +	{
  +		constructionContext.error(
  +			"xsl:variable has an invalid 'name' attribute",
  +			0,
  +			this);
  +	}
  +}
  +
  +
  +
  +const XalanQName&
  +ElemVariable::getNameAttribute() const
  +{
  +	assert(m_qname != 0);
  +
  +	return *m_qname;
  +}
  +
  +
  +
  +void
  +ElemVariable::addToStylesheet(
  +			StylesheetConstructionContext&	constructionContext,
  +			Stylesheet&						theStylesheet)
  +{
  +	// Processing a top-level element only...
  +	if (&theStylesheet != &getStylesheet())
  +	{
  +		constructionContext.error(
  +			"The ElemVariable instance was added to wrong stylesheet.",
  +			0,
  +			this);
  +	}
  +	else if (getParentNode() != 0)
  +	{
  +		constructionContext.error(
  +			"The ElemVariable instance is already parented and cannot be a top-level element.",
  +			0,
  +			this);
  +	}
  +	else
  +	{
  +		theStylesheet.setTopLevelVariable(this);
  +
  +		m_isTopLevel = true;
  +	}
   }
   
   
  @@ -179,23 +231,40 @@
   
   
   void
  -ElemVariable::execute(StylesheetExecutionContext&		executionContext) const
  +ElemVariable::setParentNodeElem(ElemTemplateElement*	theParent)
  +{
  +	if (m_isTopLevel == true)
  +	{
  +		throw XalanDOMException(XalanDOMException::HIERARCHY_REQUEST_ERR);
  +	}
  +	else
  +	{
  +		ParentType::setParentNodeElem(theParent);
  +	}
  +}
  +
  +
  +
  +void
  +ElemVariable::execute(StylesheetExecutionContext&	executionContext) const
   {
  -	ElemTemplateElement::execute(executionContext);
  +	assert(m_qname != 0);
  +
  +	ParentType::execute(executionContext);
   
   	const XObjectPtr	theValue(getValue(executionContext, executionContext.getCurrentNode()));
   
   	if (theValue.null() == false)
   	{
   		executionContext.pushVariable(
  -				m_qname,
  +				*m_qname,
   				theValue,
   				getParentNodeElem());
   	}
   	else
   	{
   		executionContext.pushVariable(
  -				m_qname,
  +				*m_qname,
   				this,
   				getParentNodeElem());
   	}
  @@ -212,7 +281,7 @@
   	{
   		if (getFirstChild() == 0)
   		{
  -			return executionContext.getXObjectFactory().createString(XalanDOMString());
  +			return executionContext.getXObjectFactory().createStringReference(s_emptyString);
   		}
   		else
   		{
  
  
  
  1.18      +15 -25    xml-xalan/c/src/XSLT/ElemVariable.hpp
  
  Index: ElemVariable.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemVariable.hpp,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- ElemVariable.hpp	24 Sep 2002 01:42:35 -0000	1.17
  +++ ElemVariable.hpp	3 Nov 2002 03:41:05 -0000	1.18
  @@ -74,7 +74,6 @@
   
   
   
  -#include <XPath/XalanQNameByValue.hpp>
   #include <XPath/XObject.hpp>
   
   
  @@ -91,6 +90,8 @@
   {
   public:
   
  +	typedef ElemTemplateElement		ParentType;
  +
   	/**
   	 * Construct an object corresponding to an "xsl:variable" element
   	 * 
  @@ -121,30 +122,16 @@
   		return m_isTopLevel;
   	}
   
  -	/**
  -	 * Sets whether this is a top level variable.
  -	 * 
  -	 * @param bTopLevel value of flag to set
  -	 */
  -	void
  -	setTopLevel(bool bTopLevel)
  -	{
  -		m_isTopLevel = bTopLevel;
  -	}
  -
  -	/**
  -	 * Retrieve the object name.
  -	 * 
  -	 * @return qualified name of object
  -	 */
  -	const XalanQName&
  -	getName() const
  -	{ 
  -		return m_qname;
  -	}
  -
   	// These methods are inherited from ElemTemplateElement ...
   	
  +	virtual const XalanQName&
  +	getNameAttribute() const;
  +
  +	virtual void
  +	addToStylesheet(
  +			StylesheetConstructionContext&	constructionContext,
  +			Stylesheet&						theStylesheet);
  +
   	virtual const XalanDOMString&
   	getElementName() const;
   
  @@ -156,6 +143,9 @@
   			StylesheetExecutionContext&		executionContext,
   			XalanNode*						sourceNode) const;
   
  +	virtual void
  +	setParentNodeElem(ElemTemplateElement*		theParent);
  +
   protected:
   
   	/**
  @@ -189,7 +179,7 @@
   			const AttributeList&			atts);
   
   
  -	XalanQNameByValue	m_qname;
  +	const XalanQName*	m_qname;
   
   private:
   
  
  
  
  1.13      +13 -3     xml-xalan/c/src/XSLT/ElemWithParam.cpp
  
  Index: ElemWithParam.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemWithParam.cpp,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- ElemWithParam.cpp	24 Sep 2002 01:42:35 -0000	1.12
  +++ ElemWithParam.cpp	3 Nov 2002 03:41:05 -0000	1.13
  @@ -84,7 +84,7 @@
   						columnNumber,
   						StylesheetConstructionContext::ELEMNAME_WITH_PARAM),
   	m_selectPattern(0),
  -	m_qname()
  +	m_qname(0)
   {
   	const unsigned int	nAttrs = atts.getLength();
   
  @@ -98,7 +98,10 @@
   		}
   		else if(equals(aname, Constants::ATTRNAME_NAME))
   		{
  -			m_qname = XalanQNameByValue(atts.getValue(i), stylesheetTree.getNamespaces());
  +			m_qname = constructionContext.createXalanQName(
  +						atts.getValue(i),
  +						stylesheetTree.getNamespaces(),
  +						getLocator());
   		}
   		else if(!isAttrOK(aname, atts, i, constructionContext))
   		{
  @@ -109,10 +112,17 @@
   		}
   	}
   
  -	if(m_qname.isEmpty() == true)
  +	if(m_qname == 0)
   	{
   		constructionContext.error(
   			"xsl:with-param must have a 'name' attribute",
  +			0,
  +			this);
  +	}
  +	else if (m_qname->isValid() == false)
  +	{
  +		constructionContext.error(
  +			"xsl:with-param has an invalid 'name' attribute",
   			0,
   			this);
   	}
  
  
  
  1.10      +4 -6      xml-xalan/c/src/XSLT/ElemWithParam.hpp
  
  Index: ElemWithParam.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemWithParam.hpp,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ElemWithParam.hpp	10 Jul 2002 05:09:48 -0000	1.9
  +++ ElemWithParam.hpp	3 Nov 2002 03:41:05 -0000	1.10
  @@ -69,10 +69,6 @@
   
   
   
  -#include <XPath/XalanQNameByValue.hpp>
  -
  -
  -
   class XPath;
   
   
  @@ -108,7 +104,9 @@
   	const XalanQName&
   	getQName() const
   	{
  -		return m_qname;
  +		assert(m_qname != 0);
  +
  +		return *m_qname;
   	}
   
   	/**
  @@ -136,7 +134,7 @@
   	// Data members...
   	const XPath*		m_selectPattern;
   
  -	XalanQNameByValue	m_qname;
  +	const XalanQName*	m_qname;
   };
   
   
  
  
  
  1.84      +47 -15    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.83
  retrieving revision 1.84
  diff -u -r1.83 -r1.84
  --- Stylesheet.cpp	31 Oct 2002 08:12:04 -0000	1.83
  +++ Stylesheet.cpp	3 Nov 2002 03:41:05 -0000	1.84
  @@ -230,8 +230,9 @@
   
   void
   Stylesheet::processKeyElement(
  -			ElemTemplateElement*			nsContext,
  +			const PrefixResolver&			nsContext,
   			const AttributeList&			atts,
  +			const Locator*					locator,
   			StylesheetConstructionContext&	constructionContext)
   {
   	const XalanDOMChar* 	nameAttr = 0;
  @@ -254,7 +255,7 @@
   					constructionContext.createMatchPattern(
   						0,
   						XalanDOMString(atts.getValue(i)),
  -						*nsContext);
  +						nsContext);
   		}
   		else if(equals(aname, Constants::ATTRNAME_USE))
   		{
  @@ -262,37 +263,54 @@
   					constructionContext.createXPath(
   						0,
   						atts.getValue(i),
  -						*nsContext);
  +						nsContext);
   		}
   		else if (isAttrOK(aname, atts, i, constructionContext) == false)
   		{
  -			constructionContext.error("xsl:key has an illegal attribute");
  +			constructionContext.error(
  +				"xsl:key has an illegal attribute",
  +				0,
  +				locator);
   		}
   	}
   
   	if(0 == nameAttr)
   	{
  -		constructionContext.error("xsl:key requires a 'name' attribute");
  +		constructionContext.error(
  +			"xsl:key requires a 'name' attribute",
  +			0,
  +			locator);
   	}
   
   	if(0 == matchAttr)
   	{
  -		constructionContext.error("xsl:key requires a 'match' attribute");
  +		constructionContext.error(
  +			"xsl:key requires a 'match' attribute",
  +			0,
  +			locator);
   	}
   
   	if(0 == useAttr)
   	{
  -		constructionContext.error("xsl:key requires a 'use' attribute");
  +		constructionContext.error(
  +			"xsl:key requires a 'use' attribute",
  +			0,
  +			locator);
   	}
   
  -	const XalanQNameByValue		theQName(nameAttr, m_namespaces, constructionContext.getLocatorFromStack());
  +	const XalanQName* const		theQName =
  +		constructionContext.createXalanQName(nameAttr, m_namespaces, locator);
  +	assert(theQName != 0);
   
  -	if (theQName.isValid() == false)
  +	if (theQName->isValid() == false)
   	{
  -		constructionContext.error("xsl:key has an invalid 'name' attribute");
  +		constructionContext.error(
  +			"xsl:key has an invalid 'name' attribute",
  +			0,
  +			locator);
   	}
   
  -	m_keyDeclarations.push_back(KeyDeclaration(theQName, *matchAttr, *useAttr));
  +	m_keyDeclarations.push_back(KeyDeclaration(*theQName, *matchAttr, *useAttr));
   }
   
   
  @@ -599,7 +617,21 @@
   {
   	assert(theTemplate != 0);
   
  -	if(0 == m_firstTemplate)
  +	if (m_isWrapperless == true)
  +	{
  +		if (m_wrapperlessTemplate != 0)
  +		{
  +			constructionContext.error(
  +				"The stylesheet already has a wrapperless template",
  +				0,
  +				theTemplate);
  +		}
  +		else
  +		{
  +			m_wrapperlessTemplate = theTemplate;
  +		}
  +	}
  +	else if(0 == m_firstTemplate)
   	{
   		m_firstTemplate = theTemplate;
   	}
  @@ -624,7 +656,7 @@
   
   	// If it's a named template, then we need to
   	// and it to the map of named templates.
  -	const XalanQName&	theName = theTemplate->getName();
  +	const XalanQName&	theName = theTemplate->getNameAttribute();
   
   	if(theName.isEmpty() == false)
   	{
  @@ -1260,7 +1292,7 @@
   			{
   				const ParamVectorType::value_type&	arg = topLevelParams[k];
   
  -				if(arg.getName().equals(var->getName()))
  +				if(arg.getName().equals(var->getNameAttribute()))
   				{
   					isParam = true;
   
  @@ -1288,7 +1320,7 @@
   
   		if (isParam == false)
   		{
  -			executionContext.pushVariable(var->getName(),
  +			executionContext.pushVariable(var->getNameAttribute(),
   										  var,
   										  var->getParentNodeElem());
   		}
  
  
  
  1.52      +7 -30     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.51
  retrieving revision 1.52
  diff -u -r1.51 -r1.52
  --- Stylesheet.hpp	31 Oct 2002 08:12:04 -0000	1.51
  +++ Stylesheet.hpp	3 Nov 2002 03:41:05 -0000	1.52
  @@ -562,17 +562,6 @@
   	}
   
   	/**
  -	 * Set the manufactured template to use if there is no wrapper.
  -	 * 
  -	 * @param templ template to use
  -	 */
  -	void
  -	setWrapperlessTemplate(ElemTemplate*	templ)
  -	{
  -		m_wrapperlessTemplate = templ;
  -	}
  -
  -	/**
   	 * whether there is a wrapper template
   	 * 
   	 * @return true is there is a wrapper
  @@ -608,27 +597,16 @@
   	/**
   	 * Process the xsl:key element.
   	 * 
  -	 * @param nsContext 		  element providing context for namespaces
  -	 * @param atts				  attribute list for element
  -	 * @param constructionContext context for evaluation
  -	 */
  -	/*
  -	 * (Notes to myself)
  -	 * What we need to do is:
  -	 * 1) As this function is called, build a table of KeyDeclarations.
  -	 * 2) During either XML processing, or upon request, walk the XML 
  -	 * document tree, and build a hash table:
  -	 * a) keyed by name,
  -	 * b) each with a value of a hashtable, keyed by the value returned by 
  -	 *	  the use attribute,
  -	 * c) each with a value that is a nodelist.
  -	 * Thus, for a given key or keyref, look up hashtable by name, 
  -	 * look up the nodelist by the given reference.
  +	 * @param nsContext The PrefixResolver instance for namespace prefixes.
  +	 * @param atts The attribute list for element.
  +	 * #param locator The Locator instance for error reporting, if any.  May be 0.    
  +	 * @param constructionContext The current construction context.
   	 */
   	void
   	processKeyElement(
  -			ElemTemplateElement*			nsContext,
  +			const PrefixResolver&			nsContext,
   			const AttributeList&			atts,
  +			const Locator*					locator,
   			StylesheetConstructionContext&	constructionContext);
   
   	/**
  @@ -903,8 +881,7 @@
   	}
   
   	/**
  -	 * Set a top level variable, to be serialized with the rest of the
  -	 * stylesheet.
  +	 * Set a top level variable.
   	 *
   	 * @param var top-level variable declared with "xsl:variable" or
   	 *			  xsl:param-variable.
  
  
  
  1.18      +42 -5     xml-xalan/c/src/XSLT/StylesheetConstructionContext.hpp
  
  Index: StylesheetConstructionContext.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetConstructionContext.hpp,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- StylesheetConstructionContext.hpp	31 Oct 2002 07:15:56 -0000	1.17
  +++ StylesheetConstructionContext.hpp	3 Nov 2002 03:41:05 -0000	1.18
  @@ -417,26 +417,47 @@
   	/**
   	 * Given an name, determine if it is the xml:space attribute
   	 *
  -	 * @param name a name
  +	 * @param theAttributeName The name to check
  +	 * @param theStylesheet The current Stylesheet instance
  +	 * @param theLocator The Locator for error reporting.  May be 0.
  +	 *
   	 * @return true if the string is the xml:space attribute name
   	 */
   	virtual bool
   	isXMLSpaceAttribute(
   			const XalanDOMChar*		theAttributeName,
   			const Stylesheet&		theStylesheet,
  -			const Locator*			theLocator) = 0;
  +			const Locator*			theLocator = 0) = 0;
   
   	/**
   	 * Given an name, determine if it is the xsl:use-attribute-sets attribute
   	 *
  -	 * @param name a name
  +	 * @param theAttributeName The name to check
  +	 * @param theStylesheet The current Stylesheet instance
  +	 * @param theLocator The Locator for error reporting.  May be 0.
  +	 *
   	 * @return true if the string is the xsl:use-attribute-sets attribute name
   	 */
   	virtual bool
   	isXSLUseAttributeSetsAttribute(
   			const XalanDOMChar*		theAttributeName,
   			const Stylesheet&		theStylesheet,
  -			const Locator*			theLocator) = 0;
  +			const Locator*			theLocator = 0) = 0;
  +
  +	/**
  +	 * Given an name, determine if it is a valid QName
  +	 *
  +	 * @param theName The name to check
  +	 * @param theStylesheet The current Stylesheet instance
  +	 * @param theLocator The Locator for error reporting.  May be 0.
  +	 *
  +	 * @return true if the string is a valid QName.
  +	 */
  +	virtual bool
  +	isValidQName(
  +			const XalanDOMChar*		theName,
  +			const Stylesheet&		theStylesheet,
  +			const Locator*			theLocator = 0) = 0;
   
   	/**
   	 * Given an XSL tag name, return an integer token that corresponds to
  @@ -570,8 +591,24 @@
   	 * @return A pointer to the new instance
   	 */
   	virtual const XalanQName*
  -	createXalanQNameByValue(
  +	createXalanQName(
   			const XalanDOMString&		qname,
  +			const NamespacesStackType&	namespaces,
  +			const Locator*				locator = 0,
  +			bool						fUseDefault = false) = 0;
  +
  +	/**
  +	 * Create a XalanQName-derived instance.
  +	 *
  +	 * @param qname The qname string
  +	 * @param namespaces The stack of namespaces
  +	 * @param Locator The current Locator, if any
  +	 * @param fUseDefault If true, a qname without a prefix will use the default namespace
  +	 * @return A pointer to the new instance
  +	 */
  +	virtual const XalanQName*
  +	createXalanQName(
  +			const XalanDOMChar*			qname,
   			const NamespacesStackType&	namespaces,
   			const Locator*				locator = 0,
   			bool						fUseDefault = false) = 0;
  
  
  
  1.28      +29 -1     xml-xalan/c/src/XSLT/StylesheetConstructionContextDefault.cpp
  
  Index: StylesheetConstructionContextDefault.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetConstructionContextDefault.cpp,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- StylesheetConstructionContextDefault.cpp	1 Nov 2002 16:51:26 -0000	1.27
  +++ StylesheetConstructionContextDefault.cpp	3 Nov 2002 03:41:05 -0000	1.28
  @@ -606,6 +606,21 @@
   
   
   
  +bool
  +StylesheetConstructionContextDefault::isValidQName(
  +			const XalanDOMChar*		theName,
  +			const Stylesheet&		theStylesheet,
  +			const Locator*			theLocator)
  +{
  +	assert(theName != 0);
  +
  +	m_scratchQName.set(theName, theStylesheet.getNamespaces(), theLocator, false);
  +
  +	return m_scratchQName.isValid();
  +}
  +
  +
  +
   int
   StylesheetConstructionContextDefault::getElementToken(const XalanDOMString&		name) const
   {
  @@ -784,8 +799,21 @@
   
   
   const XalanQName*
  -StylesheetConstructionContextDefault::createXalanQNameByValue(
  +StylesheetConstructionContextDefault::createXalanQName(
   			const XalanDOMString&		qname,
  +			const NamespacesStackType&	namespaces,
  +			const Locator*				locator,
  +			bool						fUseDefault)
  +{
  +	return 	m_xalanQNameByValueAllocator.create(qname, namespaces, locator, fUseDefault);
  +
  +}
  +
  +
  +
  +const XalanQName*
  +StylesheetConstructionContextDefault::createXalanQName(
  +			const XalanDOMChar*			qname,
   			const NamespacesStackType&	namespaces,
   			const Locator*				locator,
   			bool						fUseDefault)
  
  
  
  1.27      +16 -3     xml-xalan/c/src/XSLT/StylesheetConstructionContextDefault.hpp
  
  Index: StylesheetConstructionContextDefault.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetConstructionContextDefault.hpp,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- StylesheetConstructionContextDefault.hpp	1 Nov 2002 01:36:28 -0000	1.26
  +++ StylesheetConstructionContextDefault.hpp	3 Nov 2002 03:41:05 -0000	1.27
  @@ -333,13 +333,19 @@
   	isXMLSpaceAttribute(
   			const XalanDOMChar*		theAttributeName,
   			const Stylesheet&		theStylesheet,
  -			const Locator*			theLocator);
  +			const Locator*			theLocator = 0);
   
   	virtual bool
   	isXSLUseAttributeSetsAttribute(
   			const XalanDOMChar*		theAttributeName,
   			const Stylesheet&		theStylesheet,
  -			const Locator*			theLocator);
  +			const Locator*			theLocator = 0);
  +
  +	virtual bool
  +	isValidQName(
  +			const XalanDOMChar*		theName,
  +			const Stylesheet&		theStylesheet,
  +			const Locator*			theLocator = 0);
   
   	virtual int
   	getElementToken(const XalanDOMString&	name) const;
  @@ -396,8 +402,15 @@
   	allocateAVTPartPointerVector(size_type	theLength);
   
   	virtual const XalanQName*
  -	createXalanQNameByValue(
  +	createXalanQName(
   			const XalanDOMString&		qname,
  +			const NamespacesStackType&	namespaces,
  +			const Locator*				locator = 0,
  +			bool						fUseDefault = false);
  +
  +	virtual const XalanQName*
  +	createXalanQName(
  +			const XalanDOMChar*			qname,
   			const NamespacesStackType&	namespaces,
   			const Locator*				locator = 0,
   			bool						fUseDefault = false);
  
  
  
  1.79      +83 -40    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.78
  retrieving revision 1.79
  diff -u -r1.78 -r1.79
  --- StylesheetExecutionContext.hpp	21 Sep 2002 01:24:41 -0000	1.78
  +++ StylesheetExecutionContext.hpp	3 Nov 2002 03:41:05 -0000	1.79
  @@ -164,6 +164,85 @@
   	// These interfaces are new...
   
   	/**
  +	 * Report an error and throw an exception.
  +	 * 
  +	 * @param msg The text of the message.
  +	 * @param styleNode The stylesheet node were the error occurred.
  +	 * @param sourceNode The source node where the error occurred.  May be 0.
  +	 */
  +	virtual void
  +	error(
  +			const XalanDOMString&		msg,
  +			const ElemTemplateElement&	styleNode,
  +			const XalanNode* 			sourceNode = 0) const = 0;
  +
  +	/**
  +	 * Report an error and throw an exception.
  +	 * 
  +	 * @param msg The text of the message.
  +	 * @param styleNode The stylesheet node were the error occurred.
  +	 * @param sourceNode The source node where the error occurred.  May be 0.
  +	 */
  +	virtual void
  +	error(
  +			const char*					msg,
  +			const ElemTemplateElement&	styleNode,
  +			const XalanNode* 			sourceNode = 0) const = 0;
  +
  +	/**
  +	 * Report a  warning.
  +	 * 
  +	 * @param msg The text of the message.
  +	 * @param styleNode The stylesheet node were the warning occurred.
  +	 * @param sourceNode The source node where the warning occurred.  May be 0.
  +	 */
  +	virtual void
  +	warn(
  +			const XalanDOMString&		msg,
  +			const ElemTemplateElement&	styleNode,
  +			const XalanNode* 			sourceNode = 0) const = 0;
  +
  +	/**
  +	 * Report a  warning.
  +	 * 
  +	 * @param msg The text of the message.
  +	 * @param styleNode The stylesheet node were the warning occurred.
  +	 * @param sourceNode The source node where the warning occurred.  May be 0.
  +	 */
  +	virtual void
  +	warn(
  +			const char*					msg,
  +			const ElemTemplateElement&	styleNode,
  +			const XalanNode* 			sourceNode = 0) const = 0;
  +
  +	/**
  +	 * Report a  message.
  +	 * 
  +	 * @param msg The text of the message.
  +	 * @param styleNode The stylesheet node were the message occurred.
  +	 * @param sourceNode The source node where the message occurred.  May be 0.
  +	 */
  +	virtual void
  +	message(
  +			const XalanDOMString&		msg,
  +			const ElemTemplateElement&	styleNode,
  +			const XalanNode* 			sourceNode = 0) const = 0;
  +
  +
  +	/**
  +	 * Report a  message.
  +	 * 
  +	 * @param msg The text of the message.
  +	 * @param styleNode The stylesheet node were the message occurred.
  +	 * @param sourceNode The source node where the message occurred.  May be 0.
  +	 */
  +	virtual void
  +	message(
  +			const char*					msg,
  +			const ElemTemplateElement&	styleNode,
  +			const XalanNode* 			sourceNode = 0) const = 0;
  +
  +	/**
   	 * Determine whether conflicts should be reported.
   	 * 
   	 * @return true if conflicts should not be warned
  @@ -1882,24 +1961,12 @@
   	virtual void
   	error(
   			const XalanDOMString&	msg,
  -			const XalanNode* 		sourceNode = 0,
  -			const XalanNode*		styleNode = 0) const = 0;
  -
  -	virtual void
  -	error(
  -			const XalanDOMString&	msg,
   			const XalanNode* 		sourceNode,
   			const Locator* 			locator) const = 0;
   
   	virtual void
   	error(
   			const char*			msg,
  -			const XalanNode* 	sourceNode = 0,
  -			const XalanNode* 	styleNode = 0) const = 0;
  -
  -	virtual void
  -	error(
  -			const char*			msg,
   			const XalanNode* 	sourceNode,
   			const Locator* 		locator) const = 0;
   
  @@ -1907,49 +1974,25 @@
   	warn(
   			const XalanDOMString&	msg,
   			const XalanNode* 		sourceNode = 0,
  -			const XalanNode* 		styleNode = 0) const = 0;
  -
  -	virtual void
  -	warn(
  -			const XalanDOMString&	msg,
  -			const XalanNode* 		sourceNode,
  -			const Locator* 			locator) const = 0;
  +			const Locator* 			locator = 0) const = 0;
   
   	virtual void
   	warn(
   			const char*			msg,
   			const XalanNode* 	sourceNode = 0,
  -			const XalanNode* 	styleNode = 0) const = 0;
  -
  -	virtual void
  -	warn(
  -			const char*			msg,
  -			const XalanNode* 	sourceNode,
  -			const Locator* 		locator) const = 0;
  +			const Locator* 		locator = 0) const = 0;
   
   	virtual void
   	message(
   			const XalanDOMString&	msg,
   			const XalanNode* 		sourceNode = 0,
  -			const XalanNode* 		styleNode = 0) const = 0;
  -
  -	virtual void
  -	message(
  -			const XalanDOMString&	msg,
  -			const XalanNode* 	sourceNode,
  -			const Locator* 		locator) const = 0;
  +			const Locator* 			locator = 0) const = 0;
   
   	virtual void
   	message(
   			const char*			msg,
   			const XalanNode* 	sourceNode = 0,
  -			const XalanNode* 	styleNode = 0) const = 0;
  -
  -	virtual void
  -	message(
  -			const char*			msg,
  -			const XalanNode* 	sourceNode,
  -			const Locator* 		locator) const = 0;
  +			const Locator* 		locator = 0) const = 0;
   };
   
   
  
  
  
  1.104     +49 -24    xml-xalan/c/src/XSLT/StylesheetExecutionContextDefault.cpp
  
  Index: StylesheetExecutionContextDefault.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetExecutionContextDefault.cpp,v
  retrieving revision 1.103
  retrieving revision 1.104
  diff -u -r1.103 -r1.104
  --- StylesheetExecutionContextDefault.cpp	25 Sep 2002 01:36:53 -0000	1.103
  +++ StylesheetExecutionContextDefault.cpp	3 Nov 2002 03:41:05 -0000	1.104
  @@ -2166,13 +2166,13 @@
   
   void
   StylesheetExecutionContextDefault::error(
  -			const XalanDOMString&	msg,
  -			const XalanNode* 		sourceNode,
  -			const XalanNode*		styleNode) const
  +			const XalanDOMString&		msg,
  +			const ElemTemplateElement&	styleNode,
  +			const XalanNode*			sourceNode) const
   {
   	assert(m_xsltProcessor != 0);
   
  -	m_xsltProcessor->error(msg, sourceNode, styleNode);
  +	m_xsltProcessor->error(msg, sourceNode != 0 ? sourceNode : getCurrentNode(), &styleNode);
   }
   
   
  @@ -2185,6 +2185,11 @@
   {
   	assert(m_xsltProcessor != 0);
   
  +	if (sourceNode == 0)
  +	{
  +		sourceNode = getCurrentNode();
  +	}
  +
   	if (locator != 0)
   	{
   		m_xsltProcessor->error(msg, *locator, sourceNode);
  @@ -2199,11 +2204,11 @@
   
   void
   StylesheetExecutionContextDefault::error(
  -			const char*			msg,
  -			const XalanNode*	sourceNode,
  -			const XalanNode*	styleNode) const
  +			const char*					msg,
  +			const ElemTemplateElement&	styleNode,
  +			const XalanNode*			sourceNode) const
   {
  -	error(TranscodeFromLocalCodePage(msg), sourceNode, styleNode);
  +	error(TranscodeFromLocalCodePage(msg), styleNode, sourceNode);
   }
   
   
  @@ -2221,13 +2226,18 @@
   
   void
   StylesheetExecutionContextDefault::warn(
  -			const XalanDOMString&	msg,
  -			const XalanNode* 		sourceNode,
  -			const XalanNode*		styleNode) const
  +			const XalanDOMString&		msg,
  +			const ElemTemplateElement&	styleNode,
  +			const XalanNode* 			sourceNode) const
   {
   	assert(m_xsltProcessor != 0);
   
  -	m_xsltProcessor->warn(msg, sourceNode, styleNode);
  +	if (sourceNode == 0)
  +	{
  +		sourceNode = getCurrentNode();
  +	}
  +
  +	m_xsltProcessor->warn(msg, sourceNode, &styleNode);
   }
   
   
  @@ -2240,6 +2250,11 @@
   {
   	assert(m_xsltProcessor != 0);
   
  +	if (sourceNode == 0)
  +	{
  +		sourceNode = getCurrentNode();
  +	}
  +
   	if (locator != 0)
   	{
   		m_xsltProcessor->warn(msg, *locator, sourceNode);
  @@ -2254,11 +2269,11 @@
   
   void
   StylesheetExecutionContextDefault::warn(
  -			const char*			msg,
  -			const XalanNode*	sourceNode,
  -			const XalanNode*	styleNode) const
  +			const char*					msg,
  +			const ElemTemplateElement&	styleNode,
  +			const XalanNode*			sourceNode) const
   {
  -	warn(TranscodeFromLocalCodePage(msg), sourceNode, styleNode);
  +	warn(TranscodeFromLocalCodePage(msg), styleNode, sourceNode);
   }
   
   
  @@ -2276,13 +2291,18 @@
   
   void
   StylesheetExecutionContextDefault::message(
  -			const XalanDOMString&	msg,
  -			const XalanNode* 		sourceNode,
  -			const XalanNode*		styleNode) const
  +			const XalanDOMString&		msg,
  +			const ElemTemplateElement&	styleNode,
  +			const XalanNode* 			sourceNode) const
   {
   	assert(m_xsltProcessor != 0);
   
  -	m_xsltProcessor->message(msg, sourceNode, styleNode);
  +	if (sourceNode == 0)
  +	{
  +		sourceNode = getCurrentNode();
  +	}
  +
  +	m_xsltProcessor->message(msg, sourceNode, &styleNode);
   }
   
   
  @@ -2295,6 +2315,11 @@
   {
   	assert(m_xsltProcessor != 0);
   
  +	if (sourceNode == 0)
  +	{
  +		sourceNode = getCurrentNode();
  +	}
  +
   	if (locator != 0)
   	{
   		m_xsltProcessor->message(msg, *locator, sourceNode);
  @@ -2309,11 +2334,11 @@
   
   void
   StylesheetExecutionContextDefault::message(
  -			const char*			msg,
  -			const XalanNode*	sourceNode,
  -			const XalanNode*	styleNode) const
  +			const char*					msg,
  +			const ElemTemplateElement&	styleNode,
  +			const XalanNode*			sourceNode) const
   {
  -	message(TranscodeFromLocalCodePage(msg), sourceNode, styleNode);
  +	message(TranscodeFromLocalCodePage(msg), styleNode, sourceNode);
   }
   
   
  
  
  
  1.84      +36 -36    xml-xalan/c/src/XSLT/StylesheetExecutionContextDefault.hpp
  
  Index: StylesheetExecutionContextDefault.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetExecutionContextDefault.hpp,v
  retrieving revision 1.83
  retrieving revision 1.84
  diff -u -r1.83 -r1.84
  --- StylesheetExecutionContextDefault.hpp	21 Sep 2002 01:24:41 -0000	1.83
  +++ StylesheetExecutionContextDefault.hpp	3 Nov 2002 03:41:06 -0000	1.84
  @@ -280,6 +280,42 @@
   
   	// These interfaces are inherited from StylesheetExecutionContext...
   
  +	virtual void
  +	error(
  +			const XalanDOMString&		msg,
  +			const ElemTemplateElement&	styleNode,
  +			const XalanNode* 			sourceNode = 0) const;
  +
  +	virtual void
  +	error(
  +			const char*					msg,
  +			const ElemTemplateElement&	styleNode,
  +			const XalanNode* 			sourceNode = 0) const;
  +
  +	virtual void
  +	warn(
  +			const XalanDOMString&		msg,
  +			const ElemTemplateElement&	styleNode,
  +			const XalanNode* 			sourceNode = 0) const;
  +
  +	virtual void
  +	warn(
  +			const char*					msg,
  +			const ElemTemplateElement&	styleNode,
  +			const XalanNode* 			sourceNode = 0) const;
  +
  +	virtual void
  +	message(
  +			const XalanDOMString&		msg,
  +			const ElemTemplateElement&	styleNode,
  +			const XalanNode* 			sourceNode = 0) const;
  +
  +	virtual void
  +	message(
  +			const char*					msg,
  +			const ElemTemplateElement&	styleNode,
  +			const XalanNode* 			sourceNode = 0) const;
  +
   	virtual bool
   	getQuietConflictWarnings() const;
   
  @@ -939,68 +975,32 @@
   	virtual void
   	error(
   			const XalanDOMString&	msg,
  -			const XalanNode* 		sourceNode = 0,
  -			const XalanNode*		styleNode = 0) const;
  -
  -	virtual void
  -	error(
  -			const XalanDOMString&	msg,
   			const XalanNode* 		sourceNode,
   			const Locator* 			locator) const;
   
   	virtual void
   	error(
   			const char*			msg,
  -			const XalanNode* 	sourceNode = 0,
  -			const XalanNode* 	styleNode = 0) const;
  -
  -	virtual void
  -	error(
  -			const char*			msg,
   			const XalanNode* 	sourceNode,
   			const Locator* 		locator) const;
   
   	virtual void
   	warn(
   			const XalanDOMString&	msg,
  -			const XalanNode* 		sourceNode = 0,
  -			const XalanNode* 		styleNode = 0) const;
  -
  -	virtual void
  -	warn(
  -			const XalanDOMString&	msg,
   			const XalanNode* 		sourceNode,
   			const Locator* 			locator) const;
   
   	virtual void
   	warn(
   			const char*			msg,
  -			const XalanNode* 	sourceNode = 0,
  -			const XalanNode* 	styleNode = 0) const;
  -
  -	virtual void
  -	warn(
  -			const char*			msg,
   			const XalanNode* 	sourceNode,
   			const Locator* 		locator) const;
   
   	virtual void
   	message(
   			const XalanDOMString&	msg,
  -			const XalanNode* 		sourceNode = 0,
  -			const XalanNode* 		styleNode = 0) const;
  -
  -	virtual void
  -	message(
  -			const XalanDOMString&	msg,
   			const XalanNode* 	sourceNode,
   			const Locator* 		locator) const;
  -
  -	virtual void
  -	message(
  -			const char*			msg,
  -			const XalanNode* 	sourceNode = 0,
  -			const XalanNode* 	styleNode = 0) const;
   
   	virtual void
   	message(
  
  
  
  1.93      +222 -177  xml-xalan/c/src/XSLT/StylesheetHandler.cpp
  
  Index: StylesheetHandler.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetHandler.cpp,v
  retrieving revision 1.92
  retrieving revision 1.93
  diff -u -r1.92 -r1.93
  --- StylesheetHandler.cpp	31 Oct 2002 07:15:56 -0000	1.92
  +++ StylesheetHandler.cpp	3 Nov 2002 03:41:06 -0000	1.93
  @@ -129,6 +129,10 @@
   
   
   
  +typedef StylesheetConstructionContext::GetAndReleaseCachedString	GetAndReleaseCachedString;
  +
  +
  +
   StylesheetHandler::StylesheetHandler(
   			Stylesheet&						stylesheetTree,
   			StylesheetConstructionContext&	constructionContext) :
  @@ -137,10 +141,9 @@
   	m_constructionContext(constructionContext),
   	m_elemStack(),
   	m_elemStackParentedElements(),
  -	m_strayElements(),
   	m_whiteSpaceElems(),
   	m_pTemplate(0),
  -	m_lastPopped(0),	
  +	m_lastPopped(),
   	m_inTemplate(false),
   	m_foundStylesheet(false),
   	m_foundNotImport(false),
  @@ -148,11 +151,6 @@
   	m_accumulateText(),
   	m_includeBase(stylesheetTree.getBaseIdentifier()),
   	m_inExtensionElementStack(),
  -	m_inLXSLTScript(false),
  -	m_LXSLTScriptBody(),
  -	m_LXSLTScriptLang(),
  -	m_LXSLTScriptSrcURL(),
  -	m_pLXSLTExtensionNSH(0),
   	m_locatorsPushed(0),
   	m_globalVariableNames(),
   	m_inScopeVariableNamesStack()
  @@ -200,18 +198,11 @@
   			 m_whiteSpaceElems.end(),
   			 DeleteFunctor<ElemTextLiteral>());
   
  -	// Clean up the stray elements.
  -	for_each(m_strayElements.begin(),
  -			 m_strayElements.end(),
  -			 DeleteFunctor<ElemTemplateElement>());
  -
   	// Clean up any template that's left over...
   	if (m_pTemplate != m_stylesheet.getWrapperlessTemplate())
   	{
   		delete m_pTemplate;
   	}
  -
  -	m_elemStackParentedElements.clear();
   }
   
   
  @@ -224,12 +215,16 @@
   }
   
   
  -void StylesheetHandler::startDocument()
  +
  +void
  +StylesheetHandler::startDocument()
   {
   }
   
   
  -void StylesheetHandler::endDocument()
  +
  +void
  +StylesheetHandler::endDocument()
   {
   	m_constructionContext.popLocatorStack();
   
  @@ -409,7 +404,7 @@
   
   			if(!m_inTemplate)
   			{
  -				processTopLevelElement(name, m_elementLocalName, ns, atts, xslToken, locator, fPreserveSpace, fSpaceAttrProcessed);
  +				processTopLevelElement(name, atts, xslToken, locator, fPreserveSpace, fSpaceAttrProcessed);
   			}
   			else
   			{
  @@ -526,7 +521,7 @@
             
   				case StylesheetConstructionContext::ELEMNAME_VARIABLE:
   					{
  -						XalanAutoPtr<ElemVariable>	newVar(
  +						XalanAutoPtr<ElemTemplateElement>	newVar(
   							new ElemVariable(
   									m_constructionContext,
   									m_stylesheet,
  @@ -534,7 +529,7 @@
   									lineNumber,
   									columnNumber));
   
  -						checkForOrAddVariableName(newVar->getName(), locator);
  +						checkForOrAddVariableName(newVar->getNameAttribute(), locator);
   
   						elem = newVar.release();
   					}
  @@ -571,7 +566,11 @@
   					{
   						ElemTemplateElement* const	parent = m_elemStack.back();
   
  -						if(StylesheetConstructionContext::ELEMNAME_CHOOSE == parent->getXSLToken())
  +						if(StylesheetConstructionContext::ELEMNAME_CHOOSE != parent->getXSLToken())
  +						{
  +							error("xsl:when not parented by xsl:choose.", locator);
  +						}
  +						else
   						{
   							ElemTemplateElement* const	lastChild = parent->getLastChildElem();
   
  @@ -585,13 +584,9 @@
   							}
   							else
   							{
  -								error("(StylesheetHandler) misplaced xsl:when.", locator);
  +								error("Misplaced xsl:when", locator);
   							}
   						}
  -						else
  -						{
  -							error("(StylesheetHandler) xsl:when not parented by xsl:choose.", locator);
  -						}
   					}
   					break;
             
  @@ -599,7 +594,11 @@
   					{
   						ElemTemplateElement* parent = m_elemStack.back();
   
  -						if(StylesheetConstructionContext::ELEMNAME_CHOOSE == parent->getXSLToken())
  +						if(StylesheetConstructionContext::ELEMNAME_CHOOSE != parent->getXSLToken())
  +						{
  +							error("xsl:otherwise not parented by xsl:choose.", locator);
  +						}
  +						else
   						{
   							ElemTemplateElement* lastChild = parent->getLastChildElem();
   
  @@ -616,10 +615,6 @@
   								error("Misplaced xsl:otherwise.", locator);
   							}
   						}
  -						else
  -						{
  -							error("xsl:otherwise not parented by xsl:choose.", locator);
  -						}
   					}
   					break;
   
  @@ -636,8 +631,6 @@
   					break;
   
   				case StylesheetConstructionContext::ELEMNAME_TEXT:
  -				  // Just push the element on the stack to signal
  -				  // that space should be preserved.
   					m_elemStack.push_back(new ElemText(m_constructionContext,
   											m_stylesheet,
   											atts, lineNumber, columnNumber));
  @@ -684,25 +677,21 @@
   				case StylesheetConstructionContext::ELEMNAME_PRESERVE_SPACE:
   				case StylesheetConstructionContext::ELEMNAME_STRIP_SPACE:
   					{
  -						const XalanDOMString	msg(XalanDOMString(name) + " is not allowed inside a template.");
  -
  -						error(msg, locator);
  +						error(name, XALAN_STATIC_UCODE_STRING(" is not allowed inside a template."), locator);
   					}
   					break;
   
   				default:
   					{
  -						const XalanDOMString	msg("Unknown XSL element: " + m_elementLocalName);
  -
   						// If this stylesheet is declared to be of a higher version than the one
   						// supported, don't flag an error.
   						if(m_constructionContext.getXSLTVersionSupported() < m_stylesheet.getXSLTVerDeclared())
   						{
  -							m_constructionContext.warn(msg);
  +							warn(name, XALAN_STATIC_UCODE_STRING(" is an unknown XSL element."), locator);
   						}
   						else
   						{
  -							error(msg, locator);
  +							error(name, XALAN_STATIC_UCODE_STRING(" is an unknown XSL element."), locator);
   						}
   					}
   				}
  @@ -858,11 +847,11 @@
   
   	m_inScopeVariableNamesStack.push_back(QNameSetVectorType::value_type());
   
  -	m_stylesheet.setWrapperlessTemplate(m_pTemplate);
  -
   	m_foundStylesheet = true;
   	m_stylesheet.setWrapperless(true);
   
  +	m_pTemplate->addToStylesheet(m_constructionContext, m_stylesheet);
  +
   	// This attempts to optimize for a literal result element with
   	// the name HTML, so we don't have to switch on-the-fly.
   	if(equalsIgnoreCaseASCII(name, Constants::ELEMNAME_HTML_STRING) == true)
  @@ -920,8 +909,6 @@
   void
   StylesheetHandler::processTopLevelElement(
   			const XalanDOMChar*		name,
  -			const XalanDOMString&	localName,
  -			const XalanDOMString&	ns,
   			const AttributeList&	atts,
   			int						xslToken,
   			const Locator*			locator,
  @@ -954,17 +941,10 @@
   		m_inScopeVariableNamesStack.push_back(QNameSetVectorType::value_type());
   		break;
   
  -	case StylesheetConstructionContext::ELEMNAME_EXTENSION:
  -		if(!equalsIgnoreCaseASCII(ns, m_constructionContext.getXalanXSLNameSpaceURL()))
  -		{
  -			m_constructionContext.warn("Old syntax: the functions instruction should use a url of " + m_constructionContext.getXalanXSLNameSpaceURL());
  -		}
  -		break;
  -
   	case StylesheetConstructionContext::ELEMNAME_VARIABLE:
   	case StylesheetConstructionContext::ELEMNAME_PARAM:
   		{
  -			ElemVariable* varelem = (StylesheetConstructionContext::ELEMNAME_PARAM == xslToken) 
  +			ElemTemplateElement* const	elem = (StylesheetConstructionContext::ELEMNAME_PARAM == xslToken) 
   									   ? new ElemParam(m_constructionContext,
   													   m_stylesheet,
   													   atts, 
  @@ -974,19 +954,17 @@
   															atts, 
   															lineNumber, columnNumber);
   
  -			XalanAutoPtr<ElemVariable>	newVar(varelem);
  +			XalanAutoPtr<ElemTemplateElement>	newVar(elem);
   
  -			checkForOrAddVariableName(varelem->getName(), locator);
  +			checkForOrAddVariableName(elem->getNameAttribute(), locator);
   
  -			m_elemStack.push_back(varelem);
  +			m_elemStack.push_back(elem);
   			m_inTemplate = true; // fake it out
   			m_inScopeVariableNamesStack.push_back(QNameSetVectorType::value_type());
  -			m_stylesheet.setTopLevelVariable(varelem);
  -			m_elemStackParentedElements.insert(varelem);
  +			elem->addToStylesheet(m_constructionContext, m_stylesheet);
  +			m_elemStackParentedElements.insert(elem);
   
   			newVar.release();
  -
  -			varelem->setTopLevel(true);
   		}
   	break;
   
  @@ -997,9 +975,11 @@
   
   	case StylesheetConstructionContext::ELEMNAME_KEY:
   		{
  -			ElemEmpty nsContext(m_constructionContext, m_stylesheet, lineNumber, columnNumber);
  -
  -			m_stylesheet.processKeyElement(&nsContext, atts, m_constructionContext);
  +			m_stylesheet.processKeyElement(
  +				XalanQName::PrefixResolverProxy(m_stylesheet.getNamespaces(), m_stylesheet.getURI()),
  +				atts,
  +				locator,
  +				m_constructionContext);
   		}
   		break;
   
  @@ -1066,9 +1046,7 @@
   	case StylesheetConstructionContext::ELEMNAME_APPLY_IMPORTS:
   		if (inExtensionElement() == false)
   		{
  -			const XalanDOMString	msg("(StylesheetHandler) " + XalanDOMString(name) + " not allowed inside a stylesheet.");
  -				
  -			error(msg, locator);
  +			error(name, XALAN_STATIC_UCODE_STRING(" is not allowed inside a stylesheet."), locator);
   		}
   		break;
   
  @@ -1079,9 +1057,7 @@
   	default:
   		if (inExtensionElement() == false)
   		{
  -			const XalanDOMString	msg("Unknown XSL element: " + localName);
  -
  -			error(msg, locator);
  +			error(name, XALAN_STATIC_UCODE_STRING(" is an unknown XSL element"), locator);
   		}
   		break;
   	}
  @@ -1113,11 +1089,13 @@
   		}
   		else if(equals(aname, Constants::ATTRNAME_EXTENSIONELEMENTPREFIXES))
   		{
  +			const GetAndReleaseCachedString		theGuard(m_constructionContext);
  +
  +			XalanDOMString&		prefix = theGuard.get();
  +
   			StringTokenizer tokenizer(atts.getValue(i),
   									  Constants::DEFAULT_WHITESPACE_SEPARATOR_STRING);
   
  -			XalanDOMString	prefix;
  -
   			while(tokenizer.hasMoreTokens() == true)
   			{
   				tokenizer.nextToken(prefix);
  @@ -1150,13 +1128,7 @@
   		{
   			if(false == m_stylesheet.isWrapperless())
   			{
  -				const XalanDOMString	msg(
  -					"(StylesheetHandler) " +
  -					XalanDOMString(name) + 
  -					" has an illegal attribute: " +
  -					aname);
  -
  -				error(msg, locator);
  +				illegalAttributeError(name, aname, locator);
   			}
   		}
   
  @@ -1237,8 +1209,6 @@
   			const Locator*			locator,
   			int						xslToken)
   {
  -	ElemEmpty nsNode(m_constructionContext, m_stylesheet, getLineNumber(locator), getColumnNumber(locator));
  -
   	const unsigned int	nAttrs = atts.getLength();
   
   	bool foundIt = false;
  @@ -1256,17 +1226,24 @@
   			StringTokenizer		tokenizer(atts.getValue(i),
   										  Constants::DEFAULT_WHITESPACE_SEPARATOR_STRING);
   
  +			const GetAndReleaseCachedString		theGuard(m_constructionContext);
  +
  +			XalanDOMString&		wildcardName = theGuard.get();
  +
   			while(tokenizer.hasMoreTokens())
   			{
   				// Use only the root, at least for right now.
  -				const XalanDOMString	wildcardName = tokenizer.nextToken();
  +				tokenizer.nextToken(wildcardName);
   
   				/**
   				 * Creating a match pattern is too much overhead, but it's a reasonably 
   				 * easy and safe way to do this right now.
   				 */
   				const XPath* const	matchPat =
  -						m_constructionContext.createMatchPattern(0, wildcardName, nsNode);
  +						m_constructionContext.createMatchPattern(
  +								0,
  +								wildcardName,
  +								XalanQName::PrefixResolverProxy(m_stylesheet.getNamespaces(), m_stylesheet.getURI()));
   
   				if(isPreserveSpace == true)
   				{
  @@ -1280,18 +1257,13 @@
   		}
   		else if(!isAttrOK(aname, atts, i))
   		{
  -			const XalanDOMString	msg(XalanDOMString(name) + " has an illegal attribute: " + aname);
  -
  -			error(msg, locator);
  +			illegalAttributeError(name, aname, locator);
   		}
   	}
   
   	if(!foundIt && inExtensionElement() == false)
   	{
  -		const XalanDOMString	msg("(StylesheetHandler) " + XalanDOMString(name) +
  -			" requires a " + Constants::ATTRNAME_ELEMENTS + " attribute.");
  -
  -		error(msg, locator);
  +		error("xsl:strip-space or xsl:preserve-space requires an elements attribute", locator);
   	}
   }
   
  @@ -1335,25 +1307,11 @@
   	{
   		if (e.getExceptionCode() == XalanDOMException::HIERARCHY_REQUEST_ERR)
   		{
  -			// $$$ ToDo: There is a bug in the version of gcc that
  -			// we're using when the optimizer is enabled.  Constructing
  -			// this error message from the parameter results in an internal
  -			// compiler error, so I'm using a local variable instead.
  -#if defined(__GNUC__)
  -			const ElemTemplateElement* const	localElem = elem;
  -
  -			XalanDOMString	theMessage(localElem->getElementName());
  -
  -#else
  -			XalanDOMString	theMessage(elem->getElementName());
  -#endif
  -
  -			append(theMessage, " is not allowed at this position in the stylesheet");
  -
  -			error(theMessage, locator);
  +			error(
  +				elem->getElementName(),
  +				XALAN_STATIC_UCODE_STRING(" is not allowed at this position in the stylesheet"),
  +				locator);
   		}
  -
  -		throw;
   	}
   
   	m_elemStackParentedElements.insert(elem);
  @@ -1378,6 +1336,8 @@
   		m_elemStackParentedElements.erase(m_elemStack.back());
   		m_elemStack.pop_back();
   	}
  +
  +	m_lastPopped = 0;
   }
   
   
  @@ -1427,9 +1387,17 @@
   				error("Imports can only occur as the first elements in the stylesheet.", locator);
   			}
   
  -			const XalanDOMString	saved_XSLNameSpaceURL = m_stylesheet.getXSLTNamespaceURI();
  +			const GetAndReleaseCachedString		theGuard1(m_constructionContext);
   
  -			const XalanDOMString	href(atts.getValue(i));
  +			XalanDOMString&		saved_XSLNameSpaceURL = theGuard1.get();
  +
  +			saved_XSLNameSpaceURL = m_stylesheet.getXSLTNamespaceURI();
  +
  +			const GetAndReleaseCachedString		theGuard2(m_constructionContext);
  +
  +			XalanDOMString&		href = theGuard2.get();
  +
  +			href = atts.getValue(i);
   
   			Stylesheet::URLStackType&	includeStack = m_stylesheet.getIncludeStack();
   			assert(includeStack.empty() == false);
  @@ -1441,9 +1409,11 @@
   
   			if(stackContains(importStack, hrefUrl))
   			{
  -				const XalanDOMString	msg(hrefUrl + " is directly or indirectly importing itself.");
  +				// Just reuse the href string...
  +				href = hrefUrl;
  +				href += XALAN_STATIC_UCODE_STRING(" is directly or indirectly importing itself.");
   
  -				error(msg, locator);
  +				error(href, locator);
   			}
   
   			importStack.push_back(hrefUrl);
  @@ -1469,21 +1439,18 @@
   		}
   		else if(!isAttrOK(aname, atts, i))
   		{
  -			const XalanDOMString	msg(XalanDOMString(name) + " has an illegal attribute: " + aname);
  -
  -			error(msg, locator);
  +			illegalAttributeError(name, aname, locator);
   		}
   	}
   
   	if(!foundIt)
   	{
  -		const XalanDOMString	msg("Could not find href attribute for " + XalanDOMString(name));
  -
  -		error(msg, locator);
  +		error("xsl:import requires an href attribute", locator);
   	}
   }
   
   
  +
   void
   StylesheetHandler::processInclude(
   			const XalanDOMChar*		name,
  @@ -1525,27 +1492,21 @@
   		}
   		else if(!isAttrOK(aname, atts, i))
   		{
  -			const XalanDOMString	msg(XalanDOMString(name) + " has an illegal attribute: " + aname);
  -
  -			error(msg, locator);
  +			illegalAttributeError(name, aname, locator);
   		}
   	}
   
   	if(!foundIt)
   	{
  -		const XalanDOMString	msg("Could not find href attribute for " + XalanDOMString(name));
  -
  -		error(msg, locator);
  +		error("xsl:include requires an href attribute", locator);
   	}
   }
   
   
   
   void
  -StylesheetHandler::endElement(const XMLCh* const name)
  +StylesheetHandler::endElement(const XMLCh* const /* name */)
   {
  -	const Locator* const	locator = m_constructionContext.getLocatorFromStack();
  -
   #if !defined(XALAN_NO_NAMESPACES)
   	using std::for_each;
   #endif
  @@ -1564,8 +1525,11 @@
   	assert(m_elemStack.empty() == false);
   
   	m_lastPopped = m_elemStack.back();
  +
  +	assert(m_lastPopped != 0);
  +
   	m_elemStack.pop_back();
  -	m_elemStackParentedElements.erase(m_lastPopped);
  +	m_elemStackParentedElements.erase(m_lastPopped.get());
   	m_lastPopped->finishedConstruction();
   
   	const int tok = m_lastPopped->getXSLToken();
  @@ -1580,19 +1544,13 @@
   	if(StylesheetConstructionContext::ELEMNAME_TEMPLATE == tok)
   	{
   		m_inTemplate = false;
  -		m_stylesheet.addTemplate(m_pTemplate, m_constructionContext);
  +		m_pTemplate->addToStylesheet(m_constructionContext, m_stylesheet);
   		m_pTemplate = 0;
   	}
   	else if((StylesheetConstructionContext::ELEMNAME_PARAM == tok) ||
   			 StylesheetConstructionContext::ELEMNAME_VARIABLE == tok)
   	{
  -#if defined(XALAN_OLD_STYLE_CASTS)
  -		const ElemVariable* const	var = (const ElemVariable*)m_lastPopped;
  -#else
  -		const ElemVariable* const	var = static_cast<const ElemVariable*>(m_lastPopped);
  -#endif
  -
  -		if(var->isTopLevel() == true)
  +		if(m_lastPopped->getParentNode() == 0)
   		{
   			// Top-level param or variable
   			m_inTemplate = false;
  @@ -1602,40 +1560,6 @@
   	{
   		m_inTemplate = false;
   	}
  -	else if (tok == StylesheetConstructionContext::ELEMNAME_UNDEFINED ||
  -			 tok == StylesheetConstructionContext::ELEMNAME_TEXT)
  -	{
  -		// These are stray elements, so stuff them away
  -		// to be deleted when we're finished...
  -		m_strayElements.push_back(m_lastPopped);
  -	}
  -
  -	// BEGIN SANJIVA CODE
  -	if (m_inLXSLTScript) 
  -	{
  -		if (isEmpty(m_LXSLTScriptLang)) 
  -		{
  -			const XalanDOMString	msg(XalanDOMString(name) + " attribute \'lang\' is missing");
  -
  -			error(msg, locator);
  -		}
  -		if (m_pLXSLTExtensionNSH == 0) 
  -		{
  -			const XalanDOMString	msg("(StylesheetHandler) misplaced " + XalanDOMString(name) + " element?? Missing container element " + "'component'");
  -
  -			error(msg, locator);
  -		}
  -
  -		m_pLXSLTExtensionNSH->setScript(m_LXSLTScriptLang, m_LXSLTScriptSrcURL, m_LXSLTScriptBody);
  -		
  -		// reset state
  -		m_inLXSLTScript = false;
  -		clear(m_LXSLTScriptLang);
  -		clear(m_LXSLTScriptSrcURL);
  -		clear(m_LXSLTScriptBody);
  -		m_pLXSLTExtensionNSH = 0;
  -	}
  -	// END SANJIVA CODE
   
   	assert(m_inExtensionElementStack.empty() == false);
   
  @@ -1813,7 +1737,7 @@
   				const bool	isLastPoppedXSLText = (m_lastPopped != 0) &&
   						(StylesheetConstructionContext::ELEMNAME_TEXT == m_lastPopped->getXSLToken());
   
  -				if(isPrevCharData && ! isLastPoppedXSLText)
  +				if(isPrevCharData == true && isLastPoppedXSLText == false)
   				{
   					appendChildElementToParent(
   						parent,
  @@ -1833,11 +1757,6 @@
   			}
   		}
   	}
  -	else if (m_inLXSLTScript)
  -	{
  -		append(m_LXSLTScriptBody, chars);
  -	}
  -
   	// TODO: Flag error if text inside of stylesheet
   }
   
  @@ -1911,12 +1830,116 @@
   
   
   
  +void
  +StylesheetHandler::error(
  +			const XalanDOMChar*		theMessage1,
  +			const XalanDOMChar*		theMessage2,
  +			const Locator*			theLocator) const
  +{
  +	const GetAndReleaseCachedString		theGuard(m_constructionContext);
  +
  +	XalanDOMString&		msg = theGuard.get();
  +
  +	msg = theMessage1;
  +	msg += theMessage2;
  +
  +	error(msg, theLocator);
  +}
  +
  +
  +
  +
  +void
  +StylesheetHandler::error(
  +			const XalanDOMChar*		theMessage1,
  +			const XalanDOMString&	theMessage2,
  +			const Locator*			theLocator) const
  +{
  +	error(theMessage1, theMessage2.c_str(), theLocator);
  +}
  +
  +
  +
  +void
  +StylesheetHandler::error(
  +			const XalanDOMString&	theMessage1,
  +			const XalanDOMChar*		theMessage2,
  +			const Locator*			theLocator) const
  +{
  +	error(theMessage1.c_str(), theMessage2, theLocator);
  +}
  +
  +
  +
  +
  +void
  +StylesheetHandler::error(
  +			const XalanDOMString&	theMessage1,
  +			const XalanDOMString&	theMessage2,
  +			const Locator*			theLocator) const
  +{
  +	error(theMessage1.c_str(), theMessage2.c_str(), theLocator);
  +}
  +
  +
  +
  +void
  +StylesheetHandler::warn(
  +			const XalanDOMChar*		theMessage1,
  +			const XalanDOMString&	theMessage2,
  +			const Locator*			theLocator) const
  +{
  +	warn(theMessage1, theMessage2.c_str(), theLocator);
  +}
  +
  +
  +
  +
  +void
  +StylesheetHandler::warn(
  +			const XalanDOMChar*		theMessage1,
  +			const XalanDOMChar*		theMessage2,
  +			const Locator*			theLocator) const
  +{
  +	const GetAndReleaseCachedString		theGuard(m_constructionContext);
  +
  +	XalanDOMString&		msg = theGuard.get();
  +
  +	msg = theMessage1;
  +	msg += theMessage2;
  +
  +	m_constructionContext.warn(msg, 0, theLocator);
  +}
  +
  +
  +
  +void
  +StylesheetHandler::illegalAttributeError(
  +			const XalanDOMChar*		theElementName,
  +			const XalanDOMChar*		theAttributeName,
  +			const Locator*			theLocator) const
  +
  +{
  +	const GetAndReleaseCachedString		theGuard(m_constructionContext);
  +
  +	XalanDOMString&		msg = theGuard.get();
  +
  +	msg = theElementName;
  +	msg += XALAN_STATIC_UCODE_STRING(" has an illegal attribute '");
  +	msg += theAttributeName;
  +	msg += XALAN_STATIC_UCODE_STRING("'");
  +
  +	error(msg, theLocator);
  +}
  +
  +
  +
   StylesheetHandler::PushPopIncludeState::PushPopIncludeState(StylesheetHandler&	theHandler) :
   	m_handler(theHandler),
   	m_elemStack(theHandler.m_elemStack),
   	m_elemStackParentedElements(theHandler.m_elemStackParentedElements),
   	m_pTemplate(theHandler.m_pTemplate),
  -	m_lastPopped(theHandler.m_lastPopped),
  +	m_lastPopped(),
   	m_inTemplate(theHandler.m_inTemplate),
   	m_foundStylesheet(theHandler.m_foundStylesheet),
   	m_XSLNameSpaceURL(theHandler.m_stylesheet.getXSLTNamespaceURI()),
  @@ -1927,9 +1950,12 @@
   	m_inExtensionElementStack()
   {
   	clear(m_handler.m_accumulateText);
  +
   	m_handler.m_elemStack.clear();
   	m_handler.m_pTemplate = 0;
  -	m_handler.m_lastPopped = 0;
  +
  +	m_lastPopped.swap(theHandler.m_lastPopped);
  +
   	m_handler.m_inTemplate = false;
   	m_handler.m_foundStylesheet = false;
   	m_handler.m_foundNotImport = false;
  @@ -1961,7 +1987,9 @@
   	m_handler.m_elemStack = m_elemStack;
   	m_handler.m_elemStackParentedElements = m_elemStackParentedElements;
   	m_handler.m_pTemplate = m_pTemplate;
  -	m_handler.m_lastPopped = m_lastPopped;
  +
  +	m_lastPopped.swap(m_handler.m_lastPopped);
  +
   	m_handler.m_inTemplate = m_inTemplate;
   	m_handler.m_foundStylesheet = m_foundStylesheet;
   	m_handler.m_stylesheet.setXSLTNamespaceURI(m_XSLNameSpaceURL);
  @@ -1978,7 +2006,24 @@
   
   
   
  -const XalanDOMString			StylesheetHandler::s_emptyString;
  +void
  +StylesheetHandler::LastPoppedHolder::cleanup()
  +{
  +	if (m_lastPopped != 0)
  +	{
  +		const int tok = m_lastPopped->getXSLToken();
  +
  +		if (tok == StylesheetConstructionContext::ELEMNAME_UNDEFINED ||
  +			tok == StylesheetConstructionContext::ELEMNAME_TEXT)
  +		{
  +			delete m_lastPopped;
  +		}
  +	}
  +}
  +
  +
  +
  +const XalanDOMString	StylesheetHandler::s_emptyString;
   
   
   
  
  
  
  1.37      +133 -20   xml-xalan/c/src/XSLT/StylesheetHandler.hpp
  
  Index: StylesheetHandler.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetHandler.hpp,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- StylesheetHandler.hpp	31 Oct 2002 07:15:56 -0000	1.36
  +++ StylesheetHandler.hpp	3 Nov 2002 03:41:06 -0000	1.37
  @@ -457,6 +457,48 @@
   			const Locator*	theLocator) const;
   
   	void
  +	illegalAttributeError(
  +			const XalanDOMChar*		theElementName,
  +			const XalanDOMChar*		theAttributeName,
  +			const Locator*			theLocator) const;
  +
  +	void
  +	error(
  +			const XalanDOMChar*		theMessage1,
  +			const XalanDOMChar*		theMessage2,
  +			const Locator*			theLocator) const;
  +
  +	void
  +	error(
  +			const XalanDOMChar*		theMessage1,
  +			const XalanDOMString&	theMessage2,
  +			const Locator*			theLocator) const;
  +
  +	void
  +	error(
  +			const XalanDOMString&	theMessage1,
  +			const XalanDOMChar*		theMessage2,
  +			const Locator*			theLocator) const;
  +
  +	void
  +	error(
  +			const XalanDOMString&	theMessage1,
  +			const XalanDOMString&	theMessage2,
  +			const Locator*			theLocator) const;
  +
  +	void
  +	warn(
  +			const XalanDOMChar*		theMessage1,
  +			const XalanDOMChar*		theMessage2,
  +			const Locator*			theLocator) const;
  +
  +	void
  +	warn(
  +			const XalanDOMChar*		theMessage1,
  +			const XalanDOMString&	theMessage2,
  +			const Locator*			theLocator) const;
  +
  +	void
   	error(
   			const XalanDOMString&	theMessage,
   			const Locator*			theLocator) const;
  @@ -477,8 +519,6 @@
   	void
   	processTopLevelElement(
   			const XalanDOMChar*		name,
  -			const XalanDOMString&	localName,
  -			const XalanDOMString&	ns,
   			const AttributeList&	atts,
   			int						xslToken,
   			const Locator*			locator,
  @@ -556,27 +596,107 @@
   	ElemTemplateSetType		m_elemStackParentedElements;
   
   	/**
  -	 * The stack of stray elements, to be delete when finished.
  -	 */
  -	ElemTemplateStackType	m_strayElements;
  -
  -	/**
   	 * Need to keep a stack of found whitespace elements so that 
   	 * whitespace elements next to non-whitespace elements can 
   	 * be merged.  For instance: &lt;out> &lt;![CDATA[test]]> &lt;/out>
   	 */
  -	ElemTextLiteralStackType m_whiteSpaceElems;
  +	ElemTextLiteralStackType	m_whiteSpaceElems;
   
   	/**
   	 * The current template.
   	 */
   	ElemTemplate* m_pTemplate;
  -	
  +
  +	class LastPoppedHolder
  +	{
  +	public:
  +
  +		LastPoppedHolder() :
  +			m_lastPopped(0)
  +		{
  +		}
  +
  +		~LastPoppedHolder()
  +		{
  +			cleanup();
  +		}
  +
  +		ElemTemplateElement*
  +		operator->() const
  +		{
  +			return m_lastPopped;
  +		}
  +
  +		bool
  +		operator==(ElemTemplateElement*		theRHS)
  +		{
  +			return m_lastPopped == theRHS;
  +		}
  +
  +		bool
  +		operator!=(ElemTemplateElement*		theRHS)
  +		{
  +			return m_lastPopped != theRHS;
  +		}
  +
  +		void
  +		operator=(ElemTemplateElement*	theRHS)
  +		{
  +			if (theRHS != m_lastPopped)
  +			{
  +				cleanup();
  +
  +				m_lastPopped = theRHS;
  +			}
  +		}
  +
  +		void
  +		swap(LastPoppedHolder&	theOther)
  +		{
  +			ElemTemplateElement* const	theTemp = m_lastPopped;
  +
  +			m_lastPopped = theOther.m_lastPopped;
  +
  +			theOther.m_lastPopped = theTemp;
  +		}
  +
  +		ElemTemplateElement*
  +		get() const
  +		{
  +			return m_lastPopped;
  +		}
  +
  +	private:
  +
  +		void
  +		set(ElemTemplateElement*	theNewElement)
  +		{
  +			if (theNewElement != m_lastPopped)
  +			{
  +				cleanup();
  +
  +				m_lastPopped = theNewElement;
  +			}
  +		}
  +
  +		// Not implemented...
  +		LastPoppedHolder&
  +		operator=(const LastPoppedHolder&);
  +
  +		LastPoppedHolder(const LastPoppedHolder&);
  +
  +		// Helper functions...
  +		void
  +		cleanup();
  +
  +		// Data members...
  +		ElemTemplateElement*	m_lastPopped;
  +	};
  +
   	/**
  -	 * The last element popped from the stack.  I'm not totally clear 
  -	 * anymore as to why this is needed.
  +	 * Manages the last element popped from the stack.
   	 */
  -	ElemTemplateElement* m_lastPopped;
  +	LastPoppedHolder	m_lastPopped;
   	
   	/**
   	 * True if the process is in a template context.
  @@ -610,13 +730,6 @@
   
   	BoolStackType	m_preserveSpaceStack;
   
  -	bool					m_inLXSLTScript;
  -
  -	XalanDOMString			m_LXSLTScriptBody;
  -	XalanDOMString			m_LXSLTScriptLang;
  -	XalanDOMString			m_LXSLTScriptSrcURL;
  -	ExtensionNSHandler*		m_pLXSLTExtensionNSH;
  -
   	// Note that these variables must not be saved by
   	// PushPopIncludeState...
   	unsigned long	m_locatorsPushed;
  @@ -661,7 +774,7 @@
   
   		ElemTemplate* const					m_pTemplate;
   
  -		ElemTemplateElement* const			m_lastPopped;		
  +		LastPoppedHolder					m_lastPopped;		
   
   		const bool							m_inTemplate;		
   
  
  
  
  1.66      +1 -1      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.65
  retrieving revision 1.66
  diff -u -r1.65 -r1.66
  --- StylesheetRoot.cpp	31 Oct 2002 07:15:56 -0000	1.65
  +++ StylesheetRoot.cpp	3 Nov 2002 03:41:06 -0000	1.66
  @@ -552,7 +552,7 @@
   				--theTokenCount;
   
   				m_cdataSectionElems.push_back(
  -					constructionContext.createXalanQNameByValue(theToken, getNamespaces(), theLocator, true));
  +					constructionContext.createXalanQName(theToken, getNamespaces(), theLocator, true));
   			}
   
   			assert(theTokenizer.hasMoreTokens() == false);
  
  
  

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