You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by sb...@locus.apache.org on 2000/12/27 23:26:07 UTC
cvs commit: xml-xalan/java/src/org/apache/xpath/patterns StepPattern.java UnionPattern.java
sboag 00/12/27 14:26:07
Modified: java/src/org/apache/xpath/functions Function2Args.java
Function3Args.java FunctionDef1Arg.java
FunctionMultiArgs.java FunctionOneArg.java
java/src/org/apache/xpath/operations Operation.java
UnaryOperation.java
java/src/org/apache/xpath/patterns StepPattern.java
UnionPattern.java
Log:
Support for canTraverseOutsideSubtree.
Revision Changes Path
1.4 +13 -0 xml-xalan/java/src/org/apache/xpath/functions/Function2Args.java
Index: Function2Args.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/functions/Function2Args.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Function2Args.java 2000/12/16 20:01:55 1.3
+++ Function2Args.java 2000/12/27 22:26:01 1.4
@@ -114,4 +114,17 @@
if (argNum != 2)
throw new WrongNumberArgsException("2");
}
+
+ /**
+ * Tell if this expression or it's subexpressions can traverse outside
+ * the current subtree.
+ *
+ * @return true if traversal outside the context node's subtree can occur.
+ */
+ public boolean canTraverseOutsideSubtree()
+ {
+ return super.canTraverseOutsideSubtree()
+ ? true : m_arg1.canTraverseOutsideSubtree();
+ }
+
}
1.5 +13 -0 xml-xalan/java/src/org/apache/xpath/functions/Function3Args.java
Index: Function3Args.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/functions/Function3Args.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Function3Args.java 2000/12/16 20:01:55 1.4
+++ Function3Args.java 2000/12/27 22:26:01 1.5
@@ -113,4 +113,17 @@
if (argNum != 3)
throw new WrongNumberArgsException("3");
}
+
+ /**
+ * Tell if this expression or it's subexpressions can traverse outside
+ * the current subtree.
+ *
+ * @return true if traversal outside the context node's subtree can occur.
+ */
+ public boolean canTraverseOutsideSubtree()
+ {
+ return super.canTraverseOutsideSubtree()
+ ? true : m_arg2.canTraverseOutsideSubtree();
+ }
+
}
1.5 +24 -13 xml-xalan/java/src/org/apache/xpath/functions/FunctionDef1Arg.java
Index: FunctionDef1Arg.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/functions/FunctionDef1Arg.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- FunctionDef1Arg.java 2000/12/16 20:01:55 1.4
+++ FunctionDef1Arg.java 2000/12/27 22:26:01 1.5
@@ -64,22 +64,22 @@
/**
* <meta name="usage" content="advanced"/>
- * Base class for functions that accept one argument that can be defaulted if
+ * Base class for functions that accept one argument that can be defaulted if
* not specified.
*/
public class FunctionDef1Arg extends FunctionOneArg
{
/**
- * Execute the first argument expression that is expected to return a
+ * Execute the first argument expression that is expected to return a
* nodeset. If the argument is null, then return the current context node.
*
* @param xctxt Runtime XPath context.
*
- * @return The first node of the executed nodeset, or the current context
+ * @return The first node of the executed nodeset, or the current context
* node if the first argument is null.
*
- * @throws javax.xml.transform.TransformerException if an error occurs while
+ * @throws javax.xml.transform.TransformerException if an error occurs while
* executing the argument expression.
*/
protected Node getArg0AsNode(XPathContext xctxt)
@@ -92,16 +92,16 @@
}
/**
- * Execute the first argument expression that is expected to return a
- * string. If the argument is null, then get the string value from the
+ * Execute the first argument expression that is expected to return a
+ * string. If the argument is null, then get the string value from the
* current context node.
*
* @param xctxt Runtime XPath context.
*
- * @return The string value of the first argument, or the string value of the
+ * @return The string value of the first argument, or the string value of the
* current context node if the first argument is null.
*
- * @throws javax.xml.transform.TransformerException if an error occurs while
+ * @throws javax.xml.transform.TransformerException if an error occurs while
* executing the argument expression.
*/
protected String getArg0AsString(XPathContext xctxt)
@@ -114,16 +114,16 @@
}
/**
- * Execute the first argument expression that is expected to return a
- * number. If the argument is null, then get the number value from the
+ * Execute the first argument expression that is expected to return a
+ * number. If the argument is null, then get the number value from the
* current context node.
*
* @param xctxt Runtime XPath context.
*
- * @return The number value of the first argument, or the number value of the
+ * @return The number value of the first argument, or the number value of the
* current context node if the first argument is null.
*
- * @throws javax.xml.transform.TransformerException if an error occurs while
+ * @throws javax.xml.transform.TransformerException if an error occurs while
* executing the argument expression.
*/
protected double getArg0AsNumber(XPathContext xctxt)
@@ -136,7 +136,7 @@
}
/**
- * Check that the number of arguments passed to this function is correct.
+ * Check that the number of arguments passed to this function is correct.
*
* @param argNum The number of arguments that is being passed to the function.
*
@@ -146,5 +146,16 @@
{
if (argNum > 1)
throw new WrongNumberArgsException("0 or 1");
+ }
+
+ /**
+ * Tell if this expression or it's subexpressions can traverse outside
+ * the current subtree.
+ *
+ * @return true if traversal outside the context node's subtree can occur.
+ */
+ public boolean canTraverseOutsideSubtree()
+ {
+ return (null == m_arg0) ? false : super.canTraverseOutsideSubtree();
}
}
1.5 +30 -5 xml-xalan/java/src/org/apache/xpath/functions/FunctionMultiArgs.java
Index: FunctionMultiArgs.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/functions/FunctionMultiArgs.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- FunctionMultiArgs.java 2000/12/16 20:01:55 1.4
+++ FunctionMultiArgs.java 2000/12/27 22:26:01 1.5
@@ -60,23 +60,23 @@
/**
* <meta name="usage" content="advanced"/>
- * Base class for functions that accept an undetermined number of multiple
+ * Base class for functions that accept an undetermined number of multiple
* arguments.
*/
public class FunctionMultiArgs extends Function3Args
{
- /** Argument expressions that are at index 3 or greater. */
+ /** Argument expressions that are at index 3 or greater. */
Expression[] m_args;
/**
- * Set an argument expression for a function. This method is called by the
+ * Set an argument expression for a function. This method is called by the
* XPath compiler.
*
* @param arg non-null expression that represents the argument.
* @param argNum The argument number index.
*
- * @throws WrongNumberArgsException If a derived class determines that the
+ * @throws WrongNumberArgsException If a derived class determines that the
* number of arguments is incorrect.
*/
public void setArg(Expression arg, int argNum)
@@ -107,7 +107,7 @@
}
/**
- * Check that the number of arguments passed to this function is correct.
+ * Check that the number of arguments passed to this function is correct.
*
*
* @param argNum The number of arguments that is being passed to the function.
@@ -115,4 +115,29 @@
* @throws WrongNumberArgsException
*/
public void checkNumberArgs(int argNum) throws WrongNumberArgsException{}
+
+ /**
+ * Tell if this expression or it's subexpressions can traverse outside
+ * the current subtree.
+ *
+ * @return true if traversal outside the context node's subtree can occur.
+ */
+ public boolean canTraverseOutsideSubtree()
+ {
+
+ if (super.canTraverseOutsideSubtree())
+ return true;
+ else
+ {
+ int n = m_args.length;
+
+ for (int i = 0; i < n; i++)
+ {
+ if (m_args[i].canTraverseOutsideSubtree())
+ return true;
+ }
+
+ return false;
+ }
+ }
}
1.4 +12 -0 xml-xalan/java/src/org/apache/xpath/functions/FunctionOneArg.java
Index: FunctionOneArg.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/functions/FunctionOneArg.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- FunctionOneArg.java 2000/12/16 20:01:55 1.3
+++ FunctionOneArg.java 2000/12/27 22:26:01 1.4
@@ -111,4 +111,16 @@
if (argNum != 1)
throw new WrongNumberArgsException("1");
}
+
+ /**
+ * Tell if this expression or it's subexpressions can traverse outside
+ * the current subtree.
+ *
+ * @return true if traversal outside the context node's subtree can occur.
+ */
+ public boolean canTraverseOutsideSubtree()
+ {
+ return m_arg0.canTraverseOutsideSubtree();
+ }
+
}
1.5 +23 -4 xml-xalan/java/src/org/apache/xpath/operations/Operation.java
Index: Operation.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/operations/Operation.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Operation.java 2000/12/17 05:21:17 1.4
+++ Operation.java 2000/12/27 22:26:04 1.5
@@ -69,13 +69,31 @@
public class Operation extends Expression
{
- /** The left operand expression. */
+ /** The left operand expression. */
protected Expression m_left;
- /** The right operand expression. */
+ /** The right operand expression. */
protected Expression m_right;
/**
+ * Tell if this expression or it's subexpressions can traverse outside
+ * the current subtree.
+ *
+ * @return true if traversal outside the context node's subtree can occur.
+ */
+ public boolean canTraverseOutsideSubtree()
+ {
+
+ if (null != m_left && m_left.canTraverseOutsideSubtree())
+ return true;
+
+ if (null != m_right && m_right.canTraverseOutsideSubtree())
+ return true;
+
+ return false;
+ }
+
+ /**
* Set the left and right operand expressions for this operation.
*
*
@@ -89,7 +107,7 @@
}
/**
- * Execute a binary operation by calling execute on each of the operands,
+ * Execute a binary operation by calling execute on each of the operands,
* and then calling the operate method on the derived class.
*
*
@@ -99,7 +117,8 @@
*
* @throws javax.xml.transform.TransformerException
*/
- public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
+ public XObject execute(XPathContext xctxt)
+ throws javax.xml.transform.TransformerException
{
XObject left = m_left.execute(xctxt);
1.5 +15 -0 xml-xalan/java/src/org/apache/xpath/operations/UnaryOperation.java
Index: UnaryOperation.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/operations/UnaryOperation.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- UnaryOperation.java 2000/12/17 05:21:18 1.4
+++ UnaryOperation.java 2000/12/27 22:26:04 1.5
@@ -71,6 +71,21 @@
/** The operand for the operation. */
protected Expression m_right;
+
+ /**
+ * Tell if this expression or it's subexpressions can traverse outside
+ * the current subtree.
+ *
+ * @return true if traversal outside the context node's subtree can occur.
+ */
+ public boolean canTraverseOutsideSubtree()
+ {
+
+ if (null != m_right && m_right.canTraverseOutsideSubtree())
+ return true;
+
+ return false;
+ }
/**
* Set the expression operand for the operation.
1.17 +21 -0 xml-xalan/java/src/org/apache/xpath/patterns/StepPattern.java
Index: StepPattern.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/patterns/StepPattern.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- StepPattern.java 2000/12/17 19:31:25 1.16
+++ StepPattern.java 2000/12/27 22:26:06 1.17
@@ -175,6 +175,27 @@
/** The list of predicate expressions for this pattern step. */
Expression[] m_predicates;
+
+ /**
+ * Tell if this expression or it's subexpressions can traverse outside
+ * the current subtree.
+ *
+ * NOTE: Ancestors tests with predicates are problematic, and will require
+ * special treatment.
+ *
+ * @return true if traversal outside the context node's subtree can occur.
+ */
+ public boolean canTraverseOutsideSubtree()
+ {
+ int n = getPredicateCount();
+ for (int i = 0; i < n; i++)
+ {
+ if(getPredicate(i).canTraverseOutsideSubtree())
+ return true;
+ }
+
+ return false;
+ }
/**
* Get a predicate expression.
1.6 +20 -0 xml-xalan/java/src/org/apache/xpath/patterns/UnionPattern.java
Index: UnionPattern.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/patterns/UnionPattern.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- UnionPattern.java 2000/12/17 19:31:25 1.5
+++ UnionPattern.java 2000/12/27 22:26:06 1.6
@@ -70,6 +70,26 @@
/** Array of the contained step patterns to be tested. */
private StepPattern[] m_patterns;
+
+ /**
+ * Tell if this expression or it's subexpressions can traverse outside
+ * the current subtree.
+ *
+ * @return true if traversal outside the context node's subtree can occur.
+ */
+ public boolean canTraverseOutsideSubtree()
+ {
+ if(null != m_patterns)
+ {
+ int n = m_patterns.length;
+ for (int i = 0; i < n; i++)
+ {
+ if(m_patterns[i].canTraverseOutsideSubtree())
+ return true;
+ }
+ }
+ return false;
+ }
/**
* Set the contained step patterns to be tested.