xalan-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dbert...@apache.org
Subject cvs commit: xml-xalan/c/src/xalanc/XSLT StylesheetRoot.cpp
Date Sat, 03 Apr 2004 02:27:22 GMT
dbertoni    2004/04/02 18:27:22

  Modified:    c/src/xalanc/XSLT StylesheetRoot.cpp
  Log:
  Cleanup inefficiencies and bug in shouldStripSourceNode().
  
  Revision  Changes    Path
  1.14      +53 -61    xml-xalan/c/src/xalanc/XSLT/StylesheetRoot.cpp
  
  Index: StylesheetRoot.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XSLT/StylesheetRoot.cpp,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- StylesheetRoot.cpp	26 Feb 2004 22:58:58 -0000	1.13
  +++ StylesheetRoot.cpp	3 Apr 2004 02:27:22 -0000	1.14
  @@ -808,75 +808,67 @@
   {
   	bool	strip = false;
   
  -	XalanNode*	parent = DOMServices::getParentOfNode(textNode);
  +	XalanNode* const	parent = textNode.getParentNode();
  +	assert(parent != 0 && parent->getNodeType() == XalanNode::ELEMENT_NODE);
  +
  +	XPath::eMatchScore	highPreserveScore = XPath::eMatchScoreNone;
  +	XPath::eMatchScore	highStripScore = XPath::eMatchScoreNone;
   
  -	while(0 != parent)
   	{
  -		if(parent->getNodeType() == XalanNode::ELEMENT_NODE)
  +		const XPathVectorType&	theElements =
  +				m_whitespacePreservingElements;
  +
  +		const XPathVectorType::size_type	nTests =
  +				theElements.size();
  +
  +		for(XPathVectorType::size_type i = 0; i < nTests; i++)
   		{
  -			XPath::eMatchScore	highPreserveScore = XPath::eMatchScoreNone;
  -			XPath::eMatchScore	highStripScore = XPath::eMatchScoreNone;
  +			const XPath* const	matchPat = theElements[i];
  +			assert(matchPat != 0);
  +
  +			const XPath::eMatchScore	score = matchPat->getMatchScore(parent, executionContext);
  +
  +			if(score > highPreserveScore)
  +				highPreserveScore = score;
  +		}
  +	}
  +
  +	{
  +		const XPathVectorType&	theElements =
  +				m_whitespaceStrippingElements;
  +
  +		const XPathVectorType::size_type	nTests =
  +			theElements.size();
   
  -			{
  -				const XPathVectorType&	theElements =
  -						m_whitespacePreservingElements;
  -
  -				const XPathVectorType::size_type	nTests =
  -						theElements.size();
  -
  -				for(XPathVectorType::size_type i = 0; i < nTests; i++)
  -				{
  -					const XPath* const	matchPat = theElements[i];
  -					assert(matchPat != 0);
  -
  -					const XPath::eMatchScore	score = matchPat->getMatchScore(parent, executionContext);
  -
  -					if(score > highPreserveScore)
  -						highPreserveScore = score;
  -				}
  -			}
  -
  -			{
  -				const XPathVectorType&	theElements =
  -						m_whitespaceStrippingElements;
  -
  -				const XPathVectorType::size_type	nTests =
  -					theElements.size();
  -
  -				for(XPathVectorType::size_type i = 0; i < nTests; i++)
  -				{
  -					const XPath* const	matchPat =
  +		for(XPathVectorType::size_type i = 0; i < nTests; i++)
  +		{
  +			const XPath* const	matchPat =
   									theElements[i];
  -					assert(matchPat != 0);
  +			assert(matchPat != 0);
   
  -					const XPath::eMatchScore	score = matchPat->getMatchScore(parent, executionContext);
  +			const XPath::eMatchScore	score = matchPat->getMatchScore(parent, executionContext);
   
  -					if(score > highStripScore)
  -						highStripScore = score;
  -				}
  -			}
  -
  -			if(highPreserveScore > XPath::eMatchScoreNone ||
  -			   highStripScore > XPath::eMatchScoreNone)
  -			{
  -				if(highPreserveScore > highStripScore)
  -				{
  -					strip = false;
  -				}
  -				else if(highStripScore > highPreserveScore)
  -				{
  -					strip = true;
  -				}
  -				else
  -				{
  -					executionContext.warn(
  -						XalanMessageLoader::getMessage(XalanMessages::MatchConflictBetween_strip_space_preserve_space));

  -				}
  -				break;
  -			}
  +			if(score > highStripScore)
  +				highStripScore = score;
  +		}
  +	}
  +			
  +	if(highPreserveScore > XPath::eMatchScoreNone ||
  +	   highStripScore > XPath::eMatchScoreNone)
  +	{
  +		if(highPreserveScore > highStripScore)
  +		{
  +			strip = false;
  +		}
  +		else if(highStripScore > highPreserveScore)
  +		{
  +			strip = true;
  +		}
  +		else
  +		{
  +			executionContext.warn(
  +					XalanMessageLoader::getMessage(XalanMessages::MatchConflictBetween_strip_space_preserve_space));

   		}
  -
  -		parent = parent->getParentNode();
   	}
   
   	return strip;
  
  
  

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


Mime
View raw message