/** * Perform optimisation of an expression and its subexpressions. * <p/> * <p>This method is called after all references to functions and variables have been resolved * to the declaration of the function or variable, and after all type checking has been done.</p> * * @param visitor an expresion visitor * @param contextItemType the static type of "." at the point where this expression is invoked. * The parameter is set to null if it is known statically that the context item will be undefined. * If the type of the context item is not known statically, the argument is set to * {@link net.sf.saxon.type.Type#ITEM_TYPE} * @return the original expression, rewritten if appropriate to optimize execution * @throws net.sf.saxon.trans.XPathException if an error is discovered during this phase * (typically a type error) */ public Expression optimize(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException { operand = visitor.optimize(operand, contextItemType); if (operand instanceof LastItemExpression || operand instanceof FirstItemExpression) { return operand; } return super.optimize(visitor, contextItemType); }
/** * Perform optimisation of an expression and its subexpressions. * <p/> * <p>This method is called after all references to functions and variables have been resolved * to the declaration of the function or variable, and after all type checking has been done.</p> * * @param visitor an expresion visitor * @param contextItemType the static type of "." at the point where this expression is invoked. * The parameter is set to null if it is known statically that the context item will be undefined. * If the type of the context item is not known statically, the argument is set to * {@link net.sf.saxon.type.Type#ITEM_TYPE} * @return the original expression, rewritten if appropriate to optimize execution * @throws XPathException if an error is discovered during this phase * (typically a type error) */ public Expression optimize(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException { operand = visitor.optimize(operand, contextItemType); // don't remove this expression just because the operand is known to be a singleton. // It might be that this expression was added to give early exit from evaluating the underlying expression // if (!Cardinality.allowsMany(operand.getCardinality())) { // ComputedExpression.setParentExpression(operand, getParentExpression()); // return operand; // } if (operand instanceof FirstItemExpression) { return operand; } return super.optimize(visitor, contextItemType); }
/** * Perform optimisation of an expression and its subexpressions. * <p/> * <p>This method is called after all references to functions and variables have been resolved * to the declaration of the function or variable, and after all type checking has been done.</p> * * @param visitor an expresion visitor * @param contextItemType the static type of "." at the point where this expression is invoked. * The parameter is set to null if it is known statically that the context item will be undefined. * If the type of the context item is not known statically, the argument is set to * {@link net.sf.saxon.type.Type#ITEM_TYPE} * @return the original expression, rewritten if appropriate to optimize execution * @throws XPathException if an error is discovered during this phase * (typically a type error) */ public Expression optimize(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException { operand = visitor.optimize(operand, contextItemType); // don't remove this expression just because the operand is known to be a singleton. // It might be that this expression was added to give early exit from evaluating the underlying expression // if (!Cardinality.allowsMany(operand.getCardinality())) { // ComputedExpression.setParentExpression(operand, getParentExpression()); // return operand; // } if (operand instanceof FirstItemExpression) { return operand; } return super.optimize(visitor, contextItemType); }
/** * Perform optimisation of an expression and its subexpressions. * <p/> * <p>This method is called after all references to functions and variables have been resolved * to the declaration of the function or variable, and after all type checking has been done.</p> * * @param visitor an expresion visitor * @param contextItemType the static type of "." at the point where this expression is invoked. * The parameter is set to null if it is known statically that the context item will be undefined. * If the type of the context item is not known statically, the argument is set to * {@link net.sf.saxon.type.Type#ITEM_TYPE} * @return the original expression, rewritten if appropriate to optimize execution * @throws XPathException if an error is discovered during this phase * (typically a type error) */ public Expression optimize(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException { operand = visitor.optimize(operand, contextItemType); // don't remove this expression just because the operand is known to be a singleton. // It might be that this expression was added to give early exit from evaluating the underlying expression // if (!Cardinality.allowsMany(operand.getCardinality())) { // ComputedExpression.setParentExpression(operand, getParentExpression()); // return operand; // } if (operand instanceof FirstItemExpression) { return operand; } return super.optimize(visitor, contextItemType); }
@Override public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException { if (getBaseExpression() instanceof HomogeneityChecker) { return getBaseExpression().optimize(visitor, contextInfo); } return super.optimize(visitor, contextInfo); }
@Override public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException { if (getBaseExpression() instanceof HomogeneityChecker) { return getBaseExpression().optimize(visitor, contextInfo); } return super.optimize(visitor, contextInfo); }
public Expression optimize(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException { Expression exp = super.optimize(visitor, contextItemType); if (exp == this) { final TypeHierarchy th = visitor.getConfiguration().getTypeHierarchy(); if (operand.getItemType(th).isAtomicType()) { return operand; } return this; } else { return exp; } }
public Expression optimize(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException { Expression exp = super.optimize(visitor, contextItemType); if (exp == this) { final TypeHierarchy th = visitor.getConfiguration().getTypeHierarchy(); if (operand.getItemType(th).isAtomicType()) { return operand; } return this; } else { return exp; } }
/** * Perform optimisation of an expression and its subexpressions. * <p>This method is called after all references to functions and variables have been resolved * to the declaration of the function or variable, and after all type checking has been done.</p> * * @param visitor an expression visitor * @param contextInfo the static type of "." at the point where this expression is invoked. * The parameter is set to null if it is known statically that the context item will be undefined. * If the type of the context item is not known statically, the argument is set to * {@link net.sf.saxon.type.Type#ITEM_TYPE} * @return the original expression, rewritten if appropriate to optimize execution * @throws net.sf.saxon.trans.XPathException * if an error is discovered during this phase * (typically a type error) */ /*@NotNull*/ public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException { Expression e2 = super.optimize(visitor, contextInfo); if (e2 != this) { return e2; } // if the operand can't be empty, then set allowEmpty to false to provide more information for analysis if (!Cardinality.allowsZero(getBaseExpression().getCardinality())) { allowEmpty = false; resetLocalStaticProperties(); } return this; }
/** * Perform optimisation of an expression and its subexpressions. * <p>This method is called after all references to functions and variables have been resolved * to the declaration of the function or variable, and after all type checking has been done.</p> * * @param visitor an expression visitor * @param contextInfo the static type of "." at the point where this expression is invoked. * The parameter is set to null if it is known statically that the context item will be undefined. * If the type of the context item is not known statically, the argument is set to * {@link net.sf.saxon.type.Type#ITEM_TYPE} * @return the original expression, rewritten if appropriate to optimize execution * @throws net.sf.saxon.trans.XPathException * if an error is discovered during this phase * (typically a type error) */ /*@NotNull*/ public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException { Expression e2 = super.optimize(visitor, contextInfo); if (e2 != this) { return e2; } // if the operand can't be empty, then set allowEmpty to false to provide more information for analysis if (!Cardinality.allowsZero(getBaseExpression().getCardinality())) { allowEmpty = false; resetLocalStaticProperties(); } return this; }
/** * Perform optimisation of an expression and its subexpressions. * <p>This method is called after all references to functions and variables have been resolved * to the declaration of the function or variable, and after all type checking has been done.</p> * * @param visitor an expresion visitor * @param contextInfo the static type of "." at the point where this expression is invoked. * The parameter is set to null if it is known statically that the context item will be undefined. * If the type of the context item is not known statically, the argument is set to * {@link net.sf.saxon.type.Type#ITEM_TYPE} * @return the original expression, rewritten if appropriate to optimize execution * @throws net.sf.saxon.trans.XPathException * if an error is discovered during this phase * (typically a type error) */ /*@NotNull*/ public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException { getOperand().optimize(visitor, contextInfo); Expression base = getBaseExpression(); if (!Cardinality.allowsMany(base.getCardinality())) { return base; } return super.optimize(visitor, contextInfo); }
/** * Perform optimisation of an expression and its subexpressions. * <p>This method is called after all references to functions and variables have been resolved * to the declaration of the function or variable, and after all type checking has been done.</p> * * @param visitor an expresion visitor * @param contextInfo the static type of "." at the point where this expression is invoked. * The parameter is set to null if it is known statically that the context item will be undefined. * If the type of the context item is not known statically, the argument is set to * {@link net.sf.saxon.type.Type#ITEM_TYPE} * @return the original expression, rewritten if appropriate to optimize execution * @throws net.sf.saxon.trans.XPathException * if an error is discovered during this phase * (typically a type error) */ /*@NotNull*/ public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException { getOperand().optimize(visitor, contextInfo); Expression base = getBaseExpression(); if (!Cardinality.allowsMany(base.getCardinality())) { return base; } return super.optimize(visitor, contextInfo); }
/** * Perform optimisation of an expression and its subexpressions. * <p/> * <p>This method is called after all references to functions and variables have been resolved * to the declaration of the function or variable, and after all type checking has been done.</p> * * @param visitor an expression visitor * @param contextItemType the static type of "." at the point where this expression is invoked. * The parameter is set to null if it is known statically that the context item will be undefined. * If the type of the context item is not known statically, the argument is set to * {@link net.sf.saxon.type.Type#ITEM_TYPE} * @return the original expression, rewritten if appropriate to optimize execution * @throws net.sf.saxon.trans.XPathException * if an error is discovered during this phase * (typically a type error) */ public Expression optimize(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException { Expression exp = super.optimize(visitor, contextItemType); if (exp == this) { final TypeHierarchy th = visitor.getConfiguration().getTypeHierarchy(); if (th.isSubType(operand.getItemType(th), BuiltInAtomicType.ANY_ATOMIC)) { return operand; } if (operand instanceof ValueOf && (((ValueOf)operand).getOptions()& ReceiverOptions.DISABLE_ESCAPING) == 0) { // XSLT users tend to use ValueOf unnecessarily return ((ValueOf)operand).convertToStringJoin(visitor.getStaticContext()); } } return exp; }
public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException { Expression exp = super.optimize(visitor, contextInfo); if (exp == this) { // Since it's an error for the result to have more than one item, there's no point sorting the input setBaseExpression(getBaseExpression().unordered(true, false)); if (getBaseExpression().getItemType().isPlainType() && !Cardinality.allowsMany(getBaseExpression().getCardinality())) { return getBaseExpression(); } return this; } else { return exp; } }
/** * Perform optimisation of an expression and its subexpressions. * <p/> * <p>This method is called after all references to functions and variables have been resolved * to the declaration of the function or variable, and after all type checking has been done.</p> * * @param visitor an expression visitor * @param contextItemType the static type of "." at the point where this expression is invoked. * The parameter is set to null if it is known statically that the context item will be undefined. * If the type of the context item is not known statically, the argument is set to * {@link net.sf.saxon.type.Type#ITEM_TYPE} * @return the original expression, rewritten if appropriate to optimize execution * @throws net.sf.saxon.trans.XPathException * if an error is discovered during this phase * (typically a type error) */ public Expression optimize(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException { Expression exp = super.optimize(visitor, contextItemType); if (exp == this) { final TypeHierarchy th = visitor.getConfiguration().getTypeHierarchy(); if (th.isSubType(operand.getItemType(th), BuiltInAtomicType.ANY_ATOMIC)) { return operand; } if (operand instanceof ValueOf && (((ValueOf)operand).getOptions()& ReceiverOptions.DISABLE_ESCAPING) == 0) { // XSLT users tend to use ValueOf unnecessarily return ((ValueOf)operand).convertToStringJoin(visitor.getStaticContext()); } } return exp; }
public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException { Expression exp = super.optimize(visitor, contextInfo); if (exp == this) { // Since it's an error for the result to have more than one item, there's no point sorting the input setBaseExpression(getBaseExpression().unordered(true, false)); if (getBaseExpression().getItemType().isPlainType() && !Cardinality.allowsMany(getBaseExpression().getCardinality())) { return getBaseExpression(); } return this; } else { return exp; } }
Expression e = super.optimize(visitor, contextItemType); if (e != this) { return e;
Expression e = super.optimize(visitor, contextItemType); if (e != this) { return e;
Expression e = super.optimize(visitor, contextInfo); if (e != this) { return e;
Expression e = super.optimize(visitor, contextInfo); if (e != this) { return e;