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/06/19 23:00:54 UTC

cvs commit: xml-xalan/c/src/XPath XPathProcessorImpl.cpp XPathProcessorImpl.hpp

dbertoni    2002/06/19 14:00:54

  Modified:    c/src/XPath XPathProcessorImpl.cpp XPathProcessorImpl.hpp
  Log:
  Fixed bug with child and attribute axes in match patterns.  Added better error message handling.
  
  Revision  Changes    Path
  1.55      +49 -11    xml-xalan/c/src/XPath/XPathProcessorImpl.cpp
  
  Index: XPathProcessorImpl.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathProcessorImpl.cpp,v
  retrieving revision 1.54
  retrieving revision 1.55
  diff -u -r1.54 -r1.55
  --- XPathProcessorImpl.cpp	6 May 2002 05:26:59 -0000	1.54
  +++ XPathProcessorImpl.cpp	19 Jun 2002 21:00:54 -0000	1.55
  @@ -92,6 +92,7 @@
   	m_expression(0),
   	m_prefixResolver(0),
   	m_requireLiterals(false),
  +	m_isMatchPattern(false),
   	m_positionPredicateStack()
   {
   }
  @@ -152,6 +153,8 @@
   			const PrefixResolver&	prefixResolver,
   			const Locator*			locator)
   {
  +	m_isMatchPattern = true;
  +
   	m_xpath = &pathObj;
   
   	m_expression = &m_xpath->getExpression();
  @@ -1005,7 +1008,15 @@
   
   		if (length(theCurrentPattern) != 0)
   		{
  -			thePrintWriter.print(XALAN_STATIC_UCODE_STRING("pattern = '"));
  +			if (m_isMatchPattern == true)
  +			{
  +				thePrintWriter.print(XALAN_STATIC_UCODE_STRING("pattern = '"));
  +			}
  +			else
  +			{
  +				thePrintWriter.print(XALAN_STATIC_UCODE_STRING("expression = '"));
  +			}
  +
   			thePrintWriter.print(theCurrentPattern);
   
   			thePrintWriter.print("'");
  @@ -2415,34 +2426,34 @@
   
   	const int	opPos = m_expression->opCodeMapLength();
   
  -	int			axisType = 0;
  -
   	int			matchTypePos = -1;
   
  +	XPathExpression::eOpCodes	axisType = XPathExpression::eENDOP;
  +
   	// The next blocks guarantee that a MATCH_XXX will be added.
   	if(tokenIs(XalanUnicode::charCommercialAt) == true)
   	{
   		axisType = XPathExpression::eMATCH_ATTRIBUTE;
   
  -		m_expression->appendOpCode(XPathExpression::eMATCH_ATTRIBUTE);
  +		m_expression->appendOpCode(axisType);
   
   		nextToken();
   	}
   	else if(lookahead(s_axisString, 1) == true)
   	{
  -		// $$$ To Do: Perhaps these strings should be in the
  -		// axis table?
  +		matchTypePos = m_expression->opCodeMapLength();
  +
   		if(tokenIs(s_attributeString) == true)
   		{
   			axisType = XPathExpression::eMATCH_ATTRIBUTE;
   
  -			m_expression->appendOpCode(XPathExpression::eMATCH_ATTRIBUTE);
  +			m_expression->appendOpCode(axisType);
   		}
   		else if(tokenIs(s_childString) == true)
   		{
   			axisType = XPathExpression::eMATCH_IMMEDIATE_ANCESTOR;
   
  -			m_expression->appendOpCode(XPathExpression::eMATCH_IMMEDIATE_ANCESTOR);
  +			m_expression->appendOpCode(axisType);
   		}
   		else
   		{
  @@ -2454,9 +2465,36 @@
   	}
   	else if(tokenIs(XalanUnicode::charSolidus) == true)
   	{
  -		axisType = XPathExpression::eMATCH_ANY_ANCESTOR;
  +		if(lookahead(s_axisString, 2) == false)
  +		{
  +			axisType = XPathExpression::eMATCH_ANY_ANCESTOR;
   
  -		m_expression->appendOpCode(XPathExpression::eMATCH_ANY_ANCESTOR);
  +			m_expression->appendOpCode(axisType);
  +		}
  +		else
  +		{
  +			nextToken();
  +
  +			if(tokenIs(s_attributeString) == true)
  +			{
  +				axisType = XPathExpression::eMATCH_ATTRIBUTE;
  +
  +				m_expression->appendOpCode(axisType);
  +			}
  +			else if(tokenIs(s_childString) == true)
  +			{
  +				axisType = XPathExpression::eMATCH_ANY_ANCESTOR;
  +
  +				m_expression->appendOpCode(axisType);
  +			}
  +			else
  +			{
  +				error("Only child:: and attribute:: axes are allowed in match patterns!");
  +			}
  +
  +			nextToken();
  +
  +		}
   
   		nextToken();
   	}
  @@ -2471,7 +2509,7 @@
   
   		axisType = XPathExpression::eMATCH_IMMEDIATE_ANCESTOR;
   
  -		m_expression->appendOpCode(XPathExpression::eMATCH_IMMEDIATE_ANCESTOR);
  +		m_expression->appendOpCode(axisType);
   	}
   
       // Make room for telling how long the step is without the predicate.
  
  
  
  1.20      +3 -1      xml-xalan/c/src/XPath/XPathProcessorImpl.hpp
  
  Index: XPathProcessorImpl.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathProcessorImpl.hpp,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- XPathProcessorImpl.hpp	3 Apr 2002 05:13:10 -0000	1.19
  +++ XPathProcessorImpl.hpp	19 Jun 2002 21:00:54 -0000	1.20
  @@ -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
  @@ -820,6 +820,8 @@
   	const PrefixResolver*			m_prefixResolver;
   
   	bool							m_requireLiterals;
  +
  +	bool							m_isMatchPattern;
   
   	const Locator*					m_locator;
   
  
  
  

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