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 2005/08/18 07:11:25 UTC
cvs commit: xml-xalan/c/src/xalanc/XPath XPathProcessor.hpp XPathProcessorImpl.cpp XPathProcessorImpl.hpp XUnknown.cpp XUnknown.hpp
dbertoni 2005/08/17 22:11:25
Modified: c/src/xalanc/XPath XPathProcessor.hpp XPathProcessorImpl.cpp
XPathProcessorImpl.hpp XUnknown.cpp XUnknown.hpp
Log:
Fixes for Jira issue XALANC-115.
Revision Changes Path
1.5 +10 -2 xml-xalan/c/src/xalanc/XPath/XPathProcessor.hpp
Index: XPathProcessor.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/xalanc/XPath/XPathProcessor.hpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- XPathProcessor.hpp 26 Feb 2004 22:40:35 -0000 1.4
+++ XPathProcessor.hpp 18 Aug 2005 05:11:25 -0000 1.5
@@ -65,6 +65,8 @@
* @param expression expression that will be evaluated
* @param resolver prefix resolver to use
* @param locator the LocatorType to use for error report. May be null
+ * @param allowVariableReferences If true, variable references are allowed.
+ * @param allowKeyFunction If true, calls to the key() function are allowed.
*/
virtual void
initXPath(
@@ -72,7 +74,9 @@
XPathConstructionContext& constructionContext,
const XalanDOMString& expression,
const PrefixResolver& resolver,
- const LocatorType* locator = 0) = 0;
+ const LocatorType* locator = 0,
+ bool allowVariableReferences = true,
+ bool allowKeyFunction = true) = 0;
/**
* Given a string, create an XSLT Match Pattern object.
@@ -82,6 +86,8 @@
* @param expression expression that will be evaluated
* @param resolver prefix resolver to use
* @param locator the LocatorType to use for error report. May be null
+ * @param allowVariableReferences If true, variable references are allowed.
+ * @param allowKeyFunction If true, calls to the key() function are allowed.
*/
virtual void
initMatchPattern(
@@ -89,7 +95,9 @@
XPathConstructionContext& constructionContext,
const XalanDOMString& expression,
const PrefixResolver& resolver,
- const LocatorType* locator = 0) = 0;
+ const LocatorType* locator = 0,
+ bool allowVariableReferences = true,
+ bool allowKeyFunction = true) = 0;
/**
* Given a string, and a reference to a function object, install the
1.17 +35 -8 xml-xalan/c/src/xalanc/XPath/XPathProcessorImpl.cpp
Index: XPathProcessorImpl.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/xalanc/XPath/XPathProcessorImpl.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- XPathProcessorImpl.cpp 16 Aug 2005 18:52:29 -0000 1.16
+++ XPathProcessorImpl.cpp 18 Aug 2005 05:11:25 -0000 1.17
@@ -60,7 +60,9 @@
m_requireLiterals(false),
m_isMatchPattern(false),
m_positionPredicateStack(theManager),
- m_namespaces(theManager)
+ m_namespaces(theManager),
+ m_allowVariableReferences(true),
+ m_allowKeyFunction(true)
{
}
@@ -96,12 +98,18 @@
XPathConstructionContext& constructionContext,
const XalanDOMString& expression,
const PrefixResolver& resolver,
- const LocatorType* locator)
+ const LocatorType* locator,
+ bool allowVariableReferences,
+ bool allowKeyFunction)
{
m_isMatchPattern = false;
m_requireLiterals = false;
+ m_allowVariableReferences = allowVariableReferences;
+
+ m_allowKeyFunction = allowKeyFunction;
+
m_xpath = &pathObj;
m_constructionContext = &constructionContext;
@@ -144,10 +152,16 @@
XPathConstructionContext& constructionContext,
const XalanDOMString& expression,
const PrefixResolver& resolver,
- const LocatorType* locator)
+ const LocatorType* locator,
+ bool allowVariableReferences,
+ bool allowKeyFunction)
{
m_isMatchPattern = true;
+ m_allowVariableReferences = allowVariableReferences;
+
+ m_allowKeyFunction = allowKeyFunction;
+
m_xpath = &pathObj;
m_constructionContext = &constructionContext;
@@ -1479,13 +1493,20 @@
{
nextToken(); // consume '$'
- m_expression->appendOpCode(XPathExpression::eOP_VARIABLE);
+ if (m_allowVariableReferences == false)
+ {
+ error(XalanMessages::VariableReferenceNotAllowed);
+ }
+ else
+ {
+ m_expression->appendOpCode(XPathExpression::eOP_VARIABLE);
- QName();
+ QName();
- m_expression->updateOpCodeLength(
- XPathExpression::eOP_VARIABLE,
- opPos);
+ m_expression->updateOpCodeLength(
+ XPathExpression::eOP_VARIABLE,
+ opPos);
+ }
}
else if(tokenIs(XalanUnicode::charLeftParenthesis) == true)
{
@@ -1702,6 +1723,12 @@
// we've looked at a token.
assert(m_expression->getTokenPosition() > 0);
+ if (m_allowKeyFunction == false &&
+ m_token == XPathFunctionTable::s_key)
+ {
+ error(XalanMessages::KeyFunctionNotAllowed);
+ }
+
int theFunctionID =
XPath::getFunctionTable().nameToID(m_token);
1.14 +9 -2 xml-xalan/c/src/xalanc/XPath/XPathProcessorImpl.hpp
Index: XPathProcessorImpl.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/xalanc/XPath/XPathProcessorImpl.hpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- XPathProcessorImpl.hpp 29 Apr 2005 21:39:43 -0000 1.13
+++ XPathProcessorImpl.hpp 18 Aug 2005 05:11:25 -0000 1.14
@@ -86,7 +86,9 @@
XPathConstructionContext& constructionContext,
const XalanDOMString& expression,
const PrefixResolver& resolver,
- const LocatorType* locator = 0);
+ const LocatorType* locator = 0,
+ bool allowVariableReferences = true,
+ bool allowKeyFunction = true);
virtual void
initMatchPattern(
@@ -94,7 +96,9 @@
XPathConstructionContext& constructionContext,
const XalanDOMString& expression,
const PrefixResolver& resolver,
- const LocatorType* locator = 0);
+ const LocatorType* locator = 0,
+ bool allowVariableReferences = true,
+ bool allowKeyFunction = true);
private:
@@ -760,6 +764,9 @@
StringToStringMapType m_namespaces;
+ bool m_allowVariableReferences;
+
+ bool m_allowKeyFunction;
// Static stuff here...
static const XalanDOMString s_emptyString;
1.9 +2 -2 xml-xalan/c/src/xalanc/XPath/XUnknown.cpp
Index: XUnknown.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/xalanc/XPath/XUnknown.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- XUnknown.cpp 29 Apr 2005 21:39:43 -0000 1.8
+++ XUnknown.cpp 18 Aug 2005 05:11:25 -0000 1.9
@@ -58,8 +58,8 @@
m_value(theManager)
{
XalanMessageLoader::getMessage(
- const_cast<XalanDOMString&>(m_value),
- XalanMessages::UnknownVariable_1Param,
+ m_value,
+ XalanMessages::VariableIsNotDefined_1Param,
name);
}
1.7 +1 -1 xml-xalan/c/src/xalanc/XPath/XUnknown.hpp
Index: XUnknown.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/xalanc/XPath/XUnknown.hpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- XUnknown.hpp 8 Nov 2004 18:17:12 -0000 1.6
+++ XUnknown.hpp 18 Aug 2005 05:11:25 -0000 1.7
@@ -105,7 +105,7 @@
XUnknown(const XUnknown& source);
XUnknown();
- const XalanDOMString m_value;
+ XalanDOMString m_value;
static XalanDOMString s_unknownString;
};
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org