/** * Refine the type information associated with this variable declaration. This is useful when the * type of the variable has not been explicitly declared (which is common); the variable then takes * a static type based on the type of the expression to which it is bound. The effect of this call * is to update the static expression type for all references to this variable. * @param type the inferred item type of the expression to which the variable is bound * @param cardinality the inferred cardinality of the expression to which the variable is bound * @param constantValue the constant value to which the variable is bound (null if there is no constant value) * @param properties other static properties of the expression to which the variable is bound * @param visitor an expression visitor to provide context information * @param currentExpression the expression that binds the variable */ public void refineTypeInformation(ItemType type, int cardinality, Value constantValue, int properties, ExpressionVisitor visitor, Assignation currentExpression) { List references = new ArrayList(); ExpressionTool.gatherVariableReferences(currentExpression.getAction(), this, references); for (Iterator iter=references.iterator(); iter.hasNext();) { BindingReference ref = (BindingReference)iter.next(); if (ref instanceof VariableReference) { ((VariableReference)ref).refineVariableType(type, cardinality, constantValue, properties, visitor); visitor.resetStaticProperties(); ExpressionTool.resetPropertiesWithinSubtree(currentExpression); } } }
/** * Refine the type information associated with this variable declaration. This is useful when the * type of the variable has not been explicitly declared (which is common); the variable then takes * a static type based on the type of the expression to which it is bound. The effect of this call * is to update the static expression type for all references to this variable. * @param type the inferred item type of the expression to which the variable is bound * @param cardinality the inferred cardinality of the expression to which the variable is bound * @param constantValue the constant value to which the variable is bound (null if there is no constant value) * @param properties other static properties of the expression to which the variable is bound * @param visitor an expression visitor to provide context information * @param currentExpression the expression that binds the variable */ public void refineTypeInformation(ItemType type, int cardinality, Value constantValue, int properties, ExpressionVisitor visitor, Assignation currentExpression) { List references = new ArrayList(); ExpressionTool.gatherVariableReferences(currentExpression.getAction(), this, references); for (Iterator iter=references.iterator(); iter.hasNext();) { BindingReference ref = (BindingReference)iter.next(); if (ref instanceof VariableReference) { ((VariableReference)ref).refineVariableType(type, cardinality, constantValue, properties, visitor); visitor.resetStaticProperties(); ExpressionTool.resetPropertiesWithinSubtree(currentExpression); } } }
/** * Refine the type information associated with this variable declaration. This is useful when the * type of the variable has not been explicitly declared (which is common); the variable then takes * a static type based on the type of the expression to which it is bound. The effect of this call * is to update the static expression type for all references to this variable. * @param type the inferred item type of the expression to which the variable is bound * @param cardinality the inferred cardinality of the expression to which the variable is bound * @param constantValue the constant value to which the variable is bound (null if there is no constant value) * @param properties other static properties of the expression to which the variable is bound * @param visitor an expression visitor to provide context information * @param currentExpression the expression that binds the variable */ public void refineTypeInformation(ItemType type, int cardinality, Value constantValue, int properties, ExpressionVisitor visitor, Assignation currentExpression) { List references = new ArrayList(); ExpressionTool.gatherVariableReferences(currentExpression.getAction(), this, references); for (Iterator iter=references.iterator(); iter.hasNext();) { BindingReference ref = (BindingReference)iter.next(); if (ref instanceof VariableReference) { ((VariableReference)ref).refineVariableType(type, cardinality, constantValue, properties, visitor); visitor.resetStaticProperties(); ExpressionTool.resetPropertiesWithinSubtree(currentExpression); } } }
/** * Type-check the expression */ public Expression typeCheck(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException { operand = visitor.typeCheck(operand, contextItemType); // If the configuration allows typed data, check whether the content type of these particular nodes is untyped final TypeHierarchy th = visitor.getConfiguration().getTypeHierarchy(); computeSingleValued(th); visitor.resetStaticProperties(); if (th.isSubType(operand.getItemType(th), BuiltInAtomicType.ANY_ATOMIC)) { return operand; } operand.setFlattened(true); return this; }
/** * Type-check the expression */ public Expression typeCheck(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException { operand = visitor.typeCheck(operand, contextItemType); // If the configuration allows typed data, check whether the content type of these particular nodes is untyped final TypeHierarchy th = visitor.getConfiguration().getTypeHierarchy(); computeSingleValued(th); visitor.resetStaticProperties(); if (th.isSubType(operand.getItemType(th), BuiltInAtomicType.ANY_ATOMIC)) { return operand; } operand.setFlattened(true); return this; }
/** * Type-check the expression */ public Expression typeCheck(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException { operand = visitor.typeCheck(operand, contextItemType); // If the configuration allows typed data, check whether the content type of these particular nodes is untyped final TypeHierarchy th = visitor.getConfiguration().getTypeHierarchy(); computeSingleValued(th); visitor.resetStaticProperties(); if (th.isSubType(operand.getItemType(th), BuiltInAtomicType.ANY_ATOMIC)) { return operand; } operand.setFlattened(true); return this; }
/** * Type-check the expression */ public Expression typeCheck(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException { operand = visitor.typeCheck(operand, contextItemType); visitor.resetStaticProperties(); if (Literal.isEmptySequence(operand)) { if (!allowEmpty) { typeError("An empty sequence is not allowed as the " + role.getMessage(), role.getErrorCode(), null); } return operand; } final TypeHierarchy th = visitor.getConfiguration().getTypeHierarchy(); if (operand.getItemType(th).isAtomicType()) { return operand; } return this; }
/** * If any subexpressions within the step are not dependent on the focus, * and if they are not "creative" expressions (expressions that can create new nodes), then * promote them: this causes them to be evaluated once, outside the path expression * @param visitor the expression visitor * @param contextItemType the type of the context item for evaluating the start expression * @return the rewritten expression, or the original expression if no rewrite was possible */ protected Expression promoteFocusIndependentSubexpressions( ExpressionVisitor visitor, ItemType contextItemType) throws XPathException { Optimizer opt = visitor.getConfiguration().getOptimizer(); PromotionOffer offer = new PromotionOffer(opt); offer.action = PromotionOffer.FOCUS_INDEPENDENT; offer.promoteDocumentDependent = (start.getSpecialProperties() & StaticProperty.CONTEXT_DOCUMENT_NODESET) != 0; offer.containingExpression = this; setStepExpression(doPromotion(step, offer)); visitor.resetStaticProperties(); if (offer.containingExpression != this) { offer.containingExpression = visitor.optimize(visitor.typeCheck(offer.containingExpression, contextItemType), contextItemType); return offer.containingExpression; } return this; }
/** * Type-check the expression */ public Expression typeCheck(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException { operand = visitor.typeCheck(operand, contextItemType); visitor.resetStaticProperties(); if (Literal.isEmptySequence(operand)) { if (!allowEmpty) { typeError("An empty sequence is not allowed as the " + role.getMessage(), role.getErrorCode(), null); } return operand; } final TypeHierarchy th = visitor.getConfiguration().getTypeHierarchy(); if (operand.getItemType(th).isAtomicType()) { return operand; } return this; }
visitor.resetStaticProperties(); visitor.resetStaticProperties();
visitor.resetStaticProperties(); visitor.resetStaticProperties();
visitor.resetStaticProperties(); visitor.resetStaticProperties();
visitor.resetStaticProperties(); if (offer.containingExpression != this) { offer.containingExpression =
(StaticProperty.DEPENDS_ON_CONTEXT_ITEM | StaticProperty.DEPENDS_ON_POSITION)) == 0 && !Cardinality.allowsMany(filter.getCardinality()); visitor.resetStaticProperties(); return this;
(StaticProperty.DEPENDS_ON_CONTEXT_ITEM | StaticProperty.DEPENDS_ON_POSITION)) == 0 && !Cardinality.allowsMany(filter.getCardinality()); visitor.resetStaticProperties(); return this;
(StaticProperty.DEPENDS_ON_CONTEXT_ITEM | StaticProperty.DEPENDS_ON_POSITION)) == 0 && !Cardinality.allowsMany(filter.getCardinality()); visitor.resetStaticProperties(); return this;
sequence = seq2; adoptChildExpression(sequence); visitor.resetStaticProperties(); return optimize(visitor, contextItemType); action = act2; adoptChildExpression(action); visitor.resetStaticProperties();
visitor.resetStaticProperties(); if (offer.containingExpression != this) { state = 0; // allow reanalysis (see test axes286)
visitor.resetStaticProperties(); if (offer.containingExpression != this) { state = 0; // allow reanalysis (see test axes286)
sequence = seq2; adoptChildExpression(sequence); visitor.resetStaticProperties(); return optimize(visitor, contextItemType); action = act2; adoptChildExpression(action); visitor.resetStaticProperties();