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 2004/04/02 04:45:28 UTC

cvs commit: xml-xalan/c/src/xalanc/XPath XPath.cpp XPath.hpp XPathExecutionContext.hpp XPathExecutionContextDefault.cpp XPathExecutionContextDefault.hpp

dbertoni    2004/04/01 18:45:28

  Modified:    c/src/xalanc/XPath XPath.cpp XPath.hpp
                        XPathExecutionContext.hpp
                        XPathExecutionContextDefault.cpp
                        XPathExecutionContextDefault.hpp
  Log:
  Initial clean up of whitespace stripping.  Fixed bug with whitespace stripping and xsl:copy-of.
  
  Revision  Changes    Path
  1.13      +171 -12   xml-xalan/c/src/xalanc/XPath/XPath.cpp
  
  Index: XPath.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XPath/XPath.cpp,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- XPath.cpp	26 Feb 2004 22:40:34 -0000	1.12
  +++ XPath.cpp	2 Apr 2004 02:45:27 -0000	1.13
  @@ -4362,6 +4362,7 @@
   
   
   
  +#if !defined(NDEBUG)
   XPath::eMatchScore
   XPath::nodeTest(
   			XPathExecutionContext&	executionContext,
  @@ -4391,7 +4392,11 @@
   	case XPathExpression::eNODETYPE_TEXT:
   		if ((XalanNode::CDATA_SECTION_NODE == nodeType ||
   			 XalanNode::TEXT_NODE == nodeType) &&
  -			executionContext.shouldStripSourceNode(*context) == false)
  +#if defined(XALAN_OLD_STYLE_CASTS)
  +			executionContext.shouldStripSourceNode((const XalanText&)*context) == false)
  +#else
  +			executionContext.shouldStripSourceNode(static_cast<const XalanText&>(*context)) == false)
  +#endif			
   		{
   			  score = eMatchScoreNodeTest;
   		}
  @@ -4433,7 +4438,11 @@
   		if (nodeType == XalanNode::CDATA_SECTION_NODE ||
   			nodeType == XalanNode::TEXT_NODE)
   		{
  -			if (executionContext.shouldStripSourceNode(*context) == false)
  +#if defined(XALAN_OLD_STYLE_CASTS)
  +			if (executionContext.shouldStripSourceNode((const XalanText&)*context) == false)
  +#else
  +			if (executionContext.shouldStripSourceNode(static_cast<const XalanText&>(*context)) == false)
  +#endif
   			{
   				score = eMatchScoreNodeTest;
   			}
  @@ -4640,6 +4649,7 @@
   
   	return score;
   }
  +#endif  // !defined(NDEBUG)
   
   
   
  @@ -4764,10 +4774,11 @@
   			OpCodeMapPositionType 	opPos,
   			OpCodeMapValueType 	    argLen,
   			OpCodeMapValueType		stepType) :
  -	m_executionContext(executionContext),
  +	m_executionContext(&executionContext),
   	m_targetNamespace(0),
   	m_targetLocalName(0),
  -	m_testFunction(0)
  +	m_testFunction(0),
  +    m_testFunction2(&NodeTester::testDefault2)
   {
   	const XPathExpression&	theExpression = xpath.getExpression();
   
  @@ -4796,8 +4807,12 @@
   		}
   		else
   		{
  -
  -			executionContext.error(XalanMessageLoader::getMessage(XalanMessages::ArgLengthNodeTestIsIncorrect_1Param, "processing-instruction()"), 0, xpath.getLocator());
  +			executionContext.error(
  +                XalanMessageLoader::getMessage(
  +                    XalanMessages::ArgLengthNodeTestIsIncorrect_1Param,
  +                    "processing-instruction()"),
  +                    0,
  +                    xpath.getLocator());
   		}
   		break;
   
  @@ -4902,6 +4917,62 @@
   
   
   
  +XPath::NodeTester::NodeTester() :
  +	m_executionContext(0),
  +	m_targetNamespace(0),
  +	m_targetLocalName(0),
  +	m_testFunction(&NodeTester::testDefault),
  +    m_testFunction2(&NodeTester::testDefault2)
  +{
  +}
  +
  +
  +
  +XPath::NodeTester::NodeTester(
  +            const XalanDOMString&   theNamespaceURI,
  +            const XalanDOMString&   theLocalName,
  +            eMatchScore&            theMatchScore) :
  +	m_executionContext(0),
  +	m_targetNamespace(0),
  +	m_targetLocalName(0),
  +	m_testFunction(&NodeTester::testDefault),
  +    m_testFunction2(0)
  +{
  +    if (theNamespaceURI.empty() == false)
  +    {
  +        m_targetNamespace = &theNamespaceURI;
  +
  +        if (theLocalName.empty() == true)
  +        {
  +            m_testFunction2 = &NodeTester::testElementNamespaceOnly2;
  +
  +            theMatchScore = eMatchScoreNSWild;
  +        }
  +        else
  +        {
  +            m_testFunction2 = &NodeTester::testElementQName2;
  +
  +            theMatchScore = eMatchScoreQName;
  +        }
  +    }
  +    else if (theLocalName.empty() == false)
  +    {
  +        m_testFunction2 = &NodeTester::testElementNCName2;
  +
  +        m_targetLocalName = &theLocalName;
  +
  +        theMatchScore = eMatchScoreQName;
  +    }
  +    else
  +    {
  +        m_testFunction2 = &NodeTester::testElementTotallyWild2;
  +
  +        theMatchScore = eMatchScoreNodeTest;
  +    }
  +}
  +
  +
  +
   // MSVC generates some really horrible code for some of these very simple functions when they're inlined...
   #if defined(_MSC_VER)
   #pragma auto_inline(off)
  @@ -4930,7 +5001,11 @@
   			XalanNode::NodeType		nodeType) const
   {
   	if ((XalanNode::TEXT_NODE == nodeType || XalanNode::CDATA_SECTION_NODE == nodeType) &&
  -		 shouldStripSourceNode(context) == false)
  +#if defined(XALAN_OLD_STYLE_CASTS)
  +		shouldStripSourceNode((const XalanText&)context) == false)
  +#else
  +		shouldStripSourceNode(static_cast<const XalanText&>(context)) == false)
  +#endif
   	{
   		return eMatchScoreNodeTest;
   	}
  @@ -4985,7 +5060,11 @@
   			XalanNode::NodeType		nodeType) const
   {
   	if ((nodeType != XalanNode::TEXT_NODE && nodeType != XalanNode::CDATA_SECTION_NODE) ||
  -		shouldStripSourceNode(context) == false)
  +#if defined(XALAN_OLD_STYLE_CASTS)
  +		shouldStripSourceNode((const XalanText&)context) == false)
  +#else
  +		shouldStripSourceNode(static_cast<const XalanText&>(context)) == false)
  +#endif
   	{
   		return eMatchScoreNodeTest;
   	}
  @@ -5190,6 +5269,79 @@
   
   
   XPath::eMatchScore
  +XPath::NodeTester::testElementNCName2(const XalanNode&  context) const
  +{
  +	assert(
  +        m_targetNamespace == 0 &&
  +        m_targetLocalName != 0 &&
  +        XalanNode::ELEMENT_NODE == context.getNodeType());
  +
  +	if (matchLocalName(context) == false)
  +	{
  +		return eMatchScoreNone;
  +	}
  +	else
  +	{
  +		return eMatchScoreQName;
  +	}
  +}
  +
  +
  +
  +XPath::eMatchScore
  +XPath::NodeTester::testElementQName2(const XalanNode&   context) const
  +{
  +	assert(
  +        m_targetNamespace != 0 &&
  +        m_targetLocalName != 0 &&
  +        XalanNode::ELEMENT_NODE == context.getNodeType());
  +
  +	if (matchLocalNameAndNamespaceURI(context) == false)
  +	{
  +		return eMatchScoreNone;
  +	}
  +	else
  +	{
  +		return eMatchScoreQName;
  +	}
  +}
  +
  +
  +
  +XPath::eMatchScore
  +XPath::NodeTester::testElementNamespaceOnly2(const XalanNode&   context) const
  +{
  +	assert(
  +        m_targetNamespace != 0 &&
  +        m_targetLocalName == 0 &&
  +        XalanNode::ELEMENT_NODE == context.getNodeType());
  +
  +	if (matchNamespaceURI(context) == false)
  +	{
  +		return eMatchScoreNone;
  +	}
  +	else
  +	{
  +		return eMatchScoreNSWild;
  +	}
  +}
  +
  +
  +
  +XPath::eMatchScore
  +XPath::NodeTester::testElementTotallyWild2(const XalanNode&     context) const
  +{
  +	assert(
  +        m_targetNamespace == 0 &&
  +        m_targetLocalName == 0 &&
  +        XalanNode::ELEMENT_NODE == context.getNodeType());
  +
  +	return eMatchScoreNodeTest;
  +}
  +
  +
  +
  +XPath::eMatchScore
   XPath::NodeTester::testNamespaceNCName(
   			const XalanNode& 		context,
   			XalanNode::NodeType		nodeType) const
  @@ -5240,6 +5392,14 @@
   
   
   
  +XPath::eMatchScore
  +XPath::NodeTester::testDefault2(const XalanNode&    /* context */) const
  +{
  +	return eMatchScoreNone;
  +}
  +
  +
  +
   bool
   XPath::NodeTester::matchLocalName(const XalanNode&	context) const
   {
  @@ -5283,12 +5443,11 @@
   
   
   bool
  -XPath::NodeTester::shouldStripSourceNode(const XalanNode&	context) const
  +XPath::NodeTester::shouldStripSourceNode(const XalanText&	context) const
   {
  -	assert(context.getNodeType() == XalanNode::CDATA_SECTION_NODE ||
  -		   context.getNodeType() == XalanNode::TEXT_NODE);
  +	assert(m_executionContext != 0);
   
  -	return m_executionContext.shouldStripSourceNode(context);
  +    return m_executionContext->shouldStripSourceNode(context);
   }
   
   
  
  
  
  1.8       +169 -136  xml-xalan/c/src/xalanc/XPath/XPath.hpp
  
  Index: XPath.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XPath/XPath.hpp,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- XPath.hpp	26 Feb 2004 22:40:34 -0000	1.7
  +++ XPath.hpp	2 Apr 2004 02:45:28 -0000	1.8
  @@ -1026,6 +1026,173 @@
   		m_locator = theLocator;
   	}
   
  +	class NodeTester
  +	{
  +	public:
  +
  +		NodeTester(
  +			const XPath&			xpath,
  +			XPathExecutionContext&	executionContext,
  +			OpCodeMapPositionType 	opPos,
  +			OpCodeMapValueType 	    argLen,
  +			OpCodeMapValueType 		stepType);
  +
  +		NodeTester();
  +
  +		NodeTester(
  +            const XalanDOMString&   theNamespaceURI,
  +            const XalanDOMString&   theLocalName,
  +            eMatchScore&            theMatchScore);
  +
  +		eMatchScore
  +		operator()(
  +			const XalanNode& 		context,
  +			XalanNode::NodeType		nodeType) const
  +		{
  +			assert(context.getNodeType() == nodeType);
  +
  +			return (this->*m_testFunction)(context, nodeType);
  +		}
  +
  +		eMatchScore
  +		operator()(const XalanNode&     context) const
  +		{
  +			return (this->*m_testFunction2)(context);
  +		}
  +
  +	private:
  +
  +		typedef eMatchScore (NodeTester::*TestFunctionPtr)(const XalanNode&, XalanNode::NodeType) const;
  +		typedef eMatchScore (NodeTester::*TestFunctionPtr2)(const XalanNode&) const;
  +
  +
  +		eMatchScore
  +		testComment(
  +			const XalanNode& 		context,
  +			XalanNode::NodeType		nodeType) const;
  +
  +		eMatchScore
  +		testText(
  +			const XalanNode& 		context,
  +			XalanNode::NodeType		nodeType) const;
  +
  +		eMatchScore
  +		testPI(
  +			const XalanNode& 		context,
  +			XalanNode::NodeType		nodeType) const;
  +
  +		eMatchScore
  +		testPIName(
  +			const XalanNode& 		context,
  +			XalanNode::NodeType		nodeType) const;
  +
  +		eMatchScore
  +		testNode(
  +			const XalanNode& 		context,
  +			XalanNode::NodeType		nodeType) const;
  +
  +		eMatchScore
  +		testRoot(
  +			const XalanNode& 		context,
  +			XalanNode::NodeType		nodeType) const;
  +
  +		eMatchScore
  +		testAttributeNCName(
  +			const XalanNode& 		context,
  +			XalanNode::NodeType		nodeType) const;
  +
  +		eMatchScore
  +		testAttributeQName(
  +			const XalanNode& 		context,
  +			XalanNode::NodeType		nodeType) const;
  +
  +		eMatchScore
  +		testAttributeNamespaceOnly(
  +			const XalanNode& 		context,
  +			XalanNode::NodeType		nodeType) const;
  +
  +		eMatchScore
  +		testAttributeTotallyWild(
  +			const XalanNode& 		context,
  +			XalanNode::NodeType		nodeType) const;
  +
  +		eMatchScore
  +		testElementNCName(
  +			const XalanNode& 		context,
  +			XalanNode::NodeType		nodeType) const;
  +
  +		eMatchScore
  +		testElementQName(
  +			const XalanNode& 		context,
  +			XalanNode::NodeType		nodeType) const;
  +
  +		eMatchScore
  +		testElementNamespaceOnly(
  +			const XalanNode& 		context,
  +			XalanNode::NodeType		nodeType) const;
  +
  +		eMatchScore
  +		testElementTotallyWild(
  +			const XalanNode& 		context,
  +			XalanNode::NodeType		nodeType) const;
  +
  +		eMatchScore
  +		testElementNCName2(const XalanNode&     context) const;
  +
  +		eMatchScore
  +		testElementQName2(const XalanNode& 		context) const;
  +
  +		eMatchScore
  +		testElementNamespaceOnly2(const XalanNode&  context) const;
  +
  +		eMatchScore
  +		testElementTotallyWild2(const XalanNode&    context) const;
  +
  +		eMatchScore
  +		testNamespaceNCName(
  +			const XalanNode& 		context,
  +			XalanNode::NodeType		nodeType) const;
  +
  +		eMatchScore
  +		testNamespaceTotallyWild(
  +			const XalanNode& 		context,
  +			XalanNode::NodeType		nodeType) const;
  +
  +		eMatchScore
  +		testDefault(
  +			const XalanNode& 		context,
  +			XalanNode::NodeType		nodeType) const;
  +
  +		eMatchScore
  +		testDefault2(const XalanNode&   context) const;
  +
  +		bool
  +		matchLocalName(const XalanNode&		context) const;
  +
  +		bool
  +		matchNamespaceURI(const XalanNode&	context) const;
  +
  +		bool
  +		matchLocalNameAndNamespaceURI(const XalanNode&	context) const;
  +
  +		bool
  +		matchNamespace(const XalanNode&		context) const;
  +
  +		bool
  +		shouldStripSourceNode(const XalanText&	context) const;
  +
  +		// Data members...
  +		XPathExecutionContext*	m_executionContext;
  +
  +		const XalanDOMString*	m_targetNamespace;
  +
  +		const XalanDOMString*	m_targetLocalName;
  +
  +		TestFunctionPtr			m_testFunction;
  +
  +        TestFunctionPtr2        m_testFunction2;
  +	};
  +
   protected:
   
   	/**
  @@ -2187,142 +2354,6 @@
   			XalanNode& 				context, 
   			OpCodeMapPositionType 	opPos) const;
   
  -	class NodeTester
  -	{
  -	public:
  -
  -		NodeTester(
  -			const XPath&			xpath,
  -			XPathExecutionContext&	executionContext,
  -			OpCodeMapPositionType 	opPos,
  -			OpCodeMapValueType 	    argLen,
  -			OpCodeMapValueType 		stepType);
  -
  -		eMatchScore
  -		operator()(
  -			const XalanNode& 		context,
  -			XalanNode::NodeType		nodeType) const
  -		{
  -			assert(context.getNodeType() == nodeType);
  -
  -			return (this->*m_testFunction)(context, nodeType);
  -		}
  -
  -	private:
  -
  -		typedef eMatchScore (NodeTester::*TestFunctionPtr)(const XalanNode&, XalanNode::NodeType) const;
  -
  -
  -		eMatchScore
  -		testComment(
  -			const XalanNode& 		context,
  -			XalanNode::NodeType		nodeType) const;
  -
  -		eMatchScore
  -		testText(
  -			const XalanNode& 		context,
  -			XalanNode::NodeType		nodeType) const;
  -
  -		eMatchScore
  -		testPI(
  -			const XalanNode& 		context,
  -			XalanNode::NodeType		nodeType) const;
  -
  -		eMatchScore
  -		testPIName(
  -			const XalanNode& 		context,
  -			XalanNode::NodeType		nodeType) const;
  -
  -		eMatchScore
  -		testNode(
  -			const XalanNode& 		context,
  -			XalanNode::NodeType		nodeType) const;
  -
  -		eMatchScore
  -		testRoot(
  -			const XalanNode& 		context,
  -			XalanNode::NodeType		nodeType) const;
  -
  -		eMatchScore
  -		testAttributeNCName(
  -			const XalanNode& 		context,
  -			XalanNode::NodeType		nodeType) const;
  -
  -		eMatchScore
  -		testAttributeQName(
  -			const XalanNode& 		context,
  -			XalanNode::NodeType		nodeType) const;
  -
  -		eMatchScore
  -		testAttributeNamespaceOnly(
  -			const XalanNode& 		context,
  -			XalanNode::NodeType		nodeType) const;
  -
  -		eMatchScore
  -		testAttributeTotallyWild(
  -			const XalanNode& 		context,
  -			XalanNode::NodeType		nodeType) const;
  -
  -		eMatchScore
  -		testElementNCName(
  -			const XalanNode& 		context,
  -			XalanNode::NodeType		nodeType) const;
  -
  -		eMatchScore
  -		testElementQName(
  -			const XalanNode& 		context,
  -			XalanNode::NodeType		nodeType) const;
  -
  -		eMatchScore
  -		testElementNamespaceOnly(
  -			const XalanNode& 		context,
  -			XalanNode::NodeType		nodeType) const;
  -
  -		eMatchScore
  -		testElementTotallyWild(
  -			const XalanNode& 		context,
  -			XalanNode::NodeType		nodeType) const;
  -
  -		eMatchScore
  -		testNamespaceNCName(
  -			const XalanNode& 		context,
  -			XalanNode::NodeType		nodeType) const;
  -
  -		eMatchScore
  -		testNamespaceTotallyWild(
  -			const XalanNode& 		context,
  -			XalanNode::NodeType		nodeType) const;
  -
  -		eMatchScore
  -		testDefault(
  -			const XalanNode& 		context,
  -			XalanNode::NodeType		nodeType) const;
  -
  -		bool
  -		matchLocalName(const XalanNode&		context) const;
  -
  -		bool
  -		matchNamespaceURI(const XalanNode&	context) const;
  -
  -		bool
  -		matchLocalNameAndNamespaceURI(const XalanNode&	context) const;
  -
  -		bool
  -		matchNamespace(const XalanNode&		context) const;
  -
  -		bool
  -		shouldStripSourceNode(const XalanNode&	context) const;
  -
  -		// Data members...
  -		XPathExecutionContext&	m_executionContext;
  -
  -		const XalanDOMString*	m_targetNamespace;
  -
  -		const XalanDOMString*	m_targetLocalName;
  -
  -		TestFunctionPtr			m_testFunction;
  -	};
  -
   protected:
   
   	void
  @@ -2469,6 +2500,7 @@
   			OpCodeMapValueType 		stepType,
   			MutableNodeRefList& 	subQueryResults) const;
   
  +#if !defined(NDEBUG)
   	eMatchScore
   	nodeTest(
   			XPathExecutionContext&	executionContext,
  @@ -2477,6 +2509,7 @@
   			OpCodeMapPositionType 	opPos,
   			OpCodeMapValueType 	    argLen,
   			OpCodeMapValueType 		stepType) const;
  +#endif
   
   	OpCodeMapPositionType
   	predicates(
  
  
  
  1.9       +1 -1      xml-xalan/c/src/xalanc/XPath/XPathExecutionContext.hpp
  
  Index: XPathExecutionContext.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XPath/XPathExecutionContext.hpp,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- XPathExecutionContext.hpp	26 Feb 2004 22:40:35 -0000	1.8
  +++ XPathExecutionContext.hpp	2 Apr 2004 02:45:28 -0000	1.9
  @@ -632,7 +632,7 @@
   	 * @return true if the text node should be stripped of extra whitespace
   	 */
   	virtual bool
  -	shouldStripSourceNode(const XalanNode&	node) = 0;
  +	shouldStripSourceNode(const XalanText&	node) = 0;
   
   	/**
   	 * Get the document associated with the given URI.
  
  
  
  1.10      +1 -1      xml-xalan/c/src/xalanc/XPath/XPathExecutionContextDefault.cpp
  
  Index: XPathExecutionContextDefault.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XPath/XPathExecutionContextDefault.cpp,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- XPathExecutionContextDefault.cpp	11 Mar 2004 00:49:12 -0000	1.9
  +++ XPathExecutionContextDefault.cpp	2 Apr 2004 02:45:28 -0000	1.10
  @@ -453,7 +453,7 @@
   
   
   bool
  -XPathExecutionContextDefault::shouldStripSourceNode(const XalanNode&	/* node */)
  +XPathExecutionContextDefault::shouldStripSourceNode(const XalanText&	/* node */)
   {
   	return false;
   }
  
  
  
  1.8       +1 -1      xml-xalan/c/src/xalanc/XPath/XPathExecutionContextDefault.hpp
  
  Index: XPathExecutionContextDefault.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XPath/XPathExecutionContextDefault.hpp,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- XPathExecutionContextDefault.hpp	26 Feb 2004 22:40:35 -0000	1.7
  +++ XPathExecutionContextDefault.hpp	2 Apr 2004 02:45:28 -0000	1.8
  @@ -297,7 +297,7 @@
   			const XalanDocument&		theDocument) const;
   
   	virtual bool
  -	shouldStripSourceNode(const XalanNode&	node);
  +	shouldStripSourceNode(const XalanText&	node);
   
   	virtual XalanDocument*
   	getSourceDocument(const XalanDOMString&		theURI) const;
  
  
  

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