You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by db...@locus.apache.org on 2000/05/15 17:56:39 UTC

cvs commit: xml-xalan/c/src/XSLT ElemValueOf.hpp ElemValueOf.cpp

dbertoni    00/05/15 08:56:39

  Modified:    c/src/XSLT ElemValueOf.hpp ElemValueOf.cpp
  Log:
  Added optimization for "." select.
  
  Revision  Changes    Path
  1.5       +5 -0      xml-xalan/c/src/XSLT/ElemValueOf.hpp
  
  Index: ElemValueOf.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemValueOf.hpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ElemValueOf.hpp	2000/04/11 15:09:26	1.4
  +++ ElemValueOf.hpp	2000/05/15 15:56:38	1.5
  @@ -118,6 +118,11 @@
   	 * Tells if this element should disable escaping.
   	 */
   	bool			m_disableOutputEscaping;
  +
  +	/**
  +	 * True if the select pattern is '.'
  +	 */
  +	bool			m_isDot;
   };
   
   
  
  
  
  1.6       +74 -32    xml-xalan/c/src/XSLT/ElemValueOf.cpp
  
  Index: ElemValueOf.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemValueOf.cpp,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ElemValueOf.cpp	2000/04/20 16:47:34	1.5
  +++ ElemValueOf.cpp	2000/05/15 15:56:38	1.6
  @@ -66,6 +66,7 @@
   
   
   
  +#include <XPath/XObjectFactory.hpp>
   #include <XPath/XPath.hpp>
   
   
  @@ -93,7 +94,8 @@
   						columnNumber,
   						Constants::ELEMNAME_VALUEOF),
   	m_selectPattern(0),
  -	m_disableOutputEscaping(false)
  +	m_disableOutputEscaping(false),
  +	m_isDot(false)
   {
   	const unsigned int	nAttrs = atts.getLength();
   
  @@ -107,8 +109,18 @@
   		switch(tok)
   		{
   		case Constants::TATTRNAME_SELECT:
  -			m_selectPattern = constructionContext.createXPath(atts.getValue(i), 
  -															  *this);
  +			{
  +				const XalanDOMChar* const	avalue = atts.getValue(i);
  +				assert(avalue != 0);
  +
  +				if (avalue[0] == '.' && avalue[1] == 0)
  +				{
  +					m_isDot = true;
  +				}
  +
  +				m_selectPattern = constructionContext.createXPath(avalue, 
  +																  *this);
  +			}
   			break;
   
   		case Constants::TATTRNAME_DISABLE_OUTPUT_ESCAPING:
  @@ -148,46 +160,76 @@
   			XalanNode*						sourceTree,
   			XalanNode*						sourceNode,
   			const QName&					mode) const
  -{    
  +{
   	ElemTemplateElement::execute(executionContext, sourceTree, sourceNode, mode);
  -	
  -	const XObject* const	value =
  -		m_selectPattern->execute(sourceNode,
  -								 *this,
  -								 executionContext);
  +
  +	XalanDOMString	theValue;
   
  -	if(0 != getStylesheet().getStylesheetRoot().getTraceListeners())
  +	if (m_isDot == true)
   	{
  -		getStylesheet().getStylesheetRoot().fireSelectedEvent(
  -			SelectionEvent(executionContext,
  -						   sourceNode,
  -						   *this,
  -						   XalanDOMString(XALAN_STATIC_UCODE_STRING("select")),
  -						   *m_selectPattern,
  -						   value));       
  -	}
  +		const XalanNode::NodeType	type = sourceNode->getNodeType();
  +
  +		if(type == XalanNode::COMMENT_NODE ||
  +           type == XalanNode::PROCESSING_INSTRUCTION_NODE)
  +		{
  +			theValue = sourceNode->getNodeValue();
  +		}
  +		else
  +		{
  +			theValue = executionContext.getNodeData(*sourceNode);
  +		}
   
  -	if(0 != value)
  +		if(0 != getStylesheet().getStylesheetRoot().getTraceListeners())
  +		{
  +			getStylesheet().getStylesheetRoot().fireSelectedEvent(
  +				SelectionEvent(executionContext,
  +							   sourceNode,
  +							   *this,
  +							   XalanDOMString(XALAN_STATIC_UCODE_STRING("select")),
  +							   *m_selectPattern,
  +							   executionContext.getXObjectFactory().createString(theValue)));       
  +		}
  +	}
  +	else
   	{
  -		const int	type = value->getType();
  +		const XObject* const	value =
  +			m_selectPattern->execute(sourceNode,
  +									 *this,
  +									 executionContext);
   
  -		if (XObject::eTypeNull != type)
  +		if(0 != getStylesheet().getStylesheetRoot().getTraceListeners())
   		{
  -			const XalanDOMString	s = value->str();
  +			getStylesheet().getStylesheetRoot().fireSelectedEvent(
  +				SelectionEvent(executionContext,
  +							   sourceNode,
  +							   *this,
  +							   XalanDOMString(XALAN_STATIC_UCODE_STRING("select")),
  +							   *m_selectPattern,
  +							   value));       
  +		}
   
  -			const unsigned int		len = length(s);
  +		if(0 != value)
  +		{
  +			const int	type = value->getType();
   
  -			if(len > 0)
  +			if (XObject::eTypeNull != type)
   			{
  -				if(m_disableOutputEscaping == false)
  -				{
  -					executionContext.characters(toCharArray(s), 0, len);
  -				}
  -				else
  -				{
  -					executionContext.charactersRaw(toCharArray(s), 0, len);
  -				}
  +				theValue = value->str();
   			}
  +		}
  +	}
  +
  +	const unsigned int		len = length(theValue);
  +
  +	if(len > 0)
  +	{
  +		if(m_disableOutputEscaping == false)
  +		{
  +			executionContext.characters(toCharArray(theValue), 0, len);
  +		}
  +		else
  +		{
  +			executionContext.charactersRaw(toCharArray(theValue), 0, len);
   		}
   	}
   }