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 2001/06/06 23:51:26 UTC

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

dbertoni    01/06/06 14:51:26

  Modified:    c/src/XPath XPathProcessorImpl.cpp XPathProcessorImpl.hpp
  Log:
  Arguments to id() and key() in match patterns must be literals.
  
  Revision  Changes    Path
  1.40      +49 -14    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.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- XPathProcessorImpl.cpp	2001/05/18 19:05:39	1.39
  +++ XPathProcessorImpl.cpp	2001/06/06 21:51:24	1.40
  @@ -86,7 +86,8 @@
   	m_xpath(0),
   	m_expression(0),
   	m_prefixResolver(0),
  -	m_envSupport(0)
  +	m_envSupport(0),
  +	m_requireLiterals(false)
   {
   }
   
  @@ -105,6 +106,8 @@
   			const PrefixResolver&		prefixResolver,
   			const XPathEnvSupport&		envSupport)
   {
  +	m_requireLiterals = false;
  +
   	m_xpath = &pathObj;
   	m_expression = &m_xpath->getExpression();
   
  @@ -1640,7 +1643,15 @@
   
   	m_expression->appendOpCode(XPathExpression::eOP_ARGUMENT);
   
  -	Expr();
  +	if (m_requireLiterals == false ||
  +		isCurrentLiteral() == true)
  +	{
  +		Expr();
  +	}
  +	else
  +	{
  +		error(TranscodeFromLocalCodePage("A literal argument is required!"));
  +	}
   
   	m_expression->updateOpCodeLength(XPathExpression::eOP_ARGUMENT,
   									 opPos);
  @@ -1721,8 +1732,6 @@
   				 TranscodeFromLocalCodePage("()"));
   		}
   
  -		// $$$ ToDo: I believe that this is XSLT functionality.  We
  -		// need to figure out how to do the extensions for this stuff.
   		const int funcTok = getFunctionToken(m_token);
   
   		switch(funcTok)
  @@ -2163,18 +2172,10 @@
   {
   	assert(m_xpath != 0);
   	assert(m_expression != 0);
  -
  -	const int last = length(m_token) - 1;
  -
  -	assert(last > 0);
  -
  -	const XalanDOMChar 	c0 = m_tokenChar;
  -	const XalanDOMChar 	cX = charAt(m_token, last);
   
  -	if((c0 == XalanUnicode::charQuoteMark && cX == XalanUnicode::charQuoteMark) ||
  -	   (c0 == XalanUnicode::charApostrophe && cX == XalanUnicode::charApostrophe))
  +	if(isCurrentLiteral() == true)
   	{
  -		const XalanDOMString	theArgument = substring(m_token, 1, last);
  +		const XalanDOMString	theArgument = substring(m_token, 1, length(m_token) - 1);
   
   		m_expression->pushArgumentOnOpCodeMap(theArgument);
   
  @@ -2305,7 +2306,11 @@
   void
   XPathProcessorImpl::IdKeyPattern()
   {
  +	m_requireLiterals = true;
  +
   	FunctionCall();
  +
  +	m_requireLiterals = false;
   }
   
   
  @@ -2439,6 +2444,36 @@
   	}
   
   	return fResult;
  +}
  +
  +
  +
  +bool
  +XPathProcessorImpl::isCurrentLiteral() const
  +{
  +	const int last = length(m_token) - 1;
  +
  +	if (last <= 0)
  +	{
  +		return false;
  +	}
  +	else
  +	{
  +		assert(last > 0);
  +
  +		const XalanDOMChar 	c0 = m_tokenChar;
  +		const XalanDOMChar 	cX = charAt(m_token, last);
  +
  +		if((c0 == XalanUnicode::charQuoteMark && cX == XalanUnicode::charQuoteMark) ||
  +		   (c0 == XalanUnicode::charApostrophe && cX == XalanUnicode::charApostrophe))
  +		{
  +			return true;
  +		}
  +		else
  +		{
  +			return false;
  +		}
  +	}
   }
   
   
  
  
  
  1.14      +6 -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.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- XPathProcessorImpl.hpp	2000/11/02 01:46:02	1.13
  +++ XPathProcessorImpl.hpp	2001/06/06 21:51:24	1.14
  @@ -359,7 +359,7 @@
   	getTokenRelative(int	theOffset) const;
   
   	/**
  -	 * Retrieve the next token from the command and
  +	 * Retrieve the previous token from the command and
   	 * store it in m_token string.
   	 */
   	void
  @@ -386,6 +386,9 @@
   	void
   	consumeExpected(char	expected);
   
  +	bool
  +	isCurrentLiteral() const;
  +
   	/**
   	 * Warn the user of an problem.
   	 */
  @@ -830,6 +833,8 @@
   	const PrefixResolver*			m_prefixResolver;
   
   	const XPathEnvSupport*			m_envSupport;
  +
  +	bool							m_requireLiterals;
   
   	enum eDummy
   	{
  
  
  

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