/** * Static analysis: prevent sorting of the argument */ public void checkArguments(ExpressionVisitor visitor) throws XPathException { super.checkArguments(visitor); if (operation==BOOLEAN || operation==NOT) { XPathException err = TypeChecker.ebvError(argument[0], visitor.getConfiguration().getTypeHierarchy()); if (err != null) { err.setLocator(this); throw err; } Optimizer opt = visitor.getConfiguration().getOptimizer(); argument[0] = ExpressionTool.unsortedIfHomogeneous(opt, argument[0]); } }
/** * Static type checking for let expressions is delegated to the expression itself, * and is performed on the "action" expression, to allow further delegation to the branches * of a conditional * @param req the required type * @param backwardsCompatible true if backwards compatibility mode applies * @param role the role of the expression in relation to the required type * @param visitor an expression visitor * @return the expression after type checking (perhaps augmented with dynamic type checking code) * @throws XPathException if failures occur, for example if the static type of one branch of the conditional * is incompatible with the required type */ public Expression staticTypeCheck(SequenceType req, boolean backwardsCompatible, RoleLocator role, ExpressionVisitor visitor) throws XPathException { action = TypeChecker.staticTypeCheck(action, req, backwardsCompatible, role, visitor); return this; }
ExternalObjectModel model = (ExternalObjectModel)externalObjectModels.get(m); Value val = model.convertObjectToXPathValue(object, config); if (val != null && TypeChecker.testConformance(val, requiredType, context) == null) { return val;
RoleLocator role = new RoleLocator(RoleLocator.VARIABLE, getVariableQName(), 0); sequence = TypeChecker.strictTypeCheck( sequence, sequenceType, role, visitor.getStaticContext()); ItemType actualItemType = sequence.getItemType(th); XPathException err = TypeChecker.ebvError(action, visitor.getConfiguration().getTypeHierarchy()); if (err != null) { err.setLocator(this);
/** * Type-check the expression */ public Expression typeCheck(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException { // The order of events is critical here. First we ensure that the type of the // sequence expression is established. This is used to establish the type of the variable, // which in turn is required when type-checking the action part. sequence = visitor.typeCheck(sequence, contextItemType); RoleLocator role = new RoleLocator(RoleLocator.VARIABLE, getVariableQName(), 0); //role.setSourceLocator(this); sequence = TypeChecker.strictTypeCheck( sequence, requiredType, role, visitor.getStaticContext()); final TypeHierarchy th = visitor.getConfiguration().getTypeHierarchy(); final ItemType actualItemType = sequence.getItemType(th); refineTypeInformation(actualItemType, sequence.getCardinality(), (sequence instanceof Literal ? ((Literal) sequence).getValue() : null), sequence.getSpecialProperties(), visitor, this); action = visitor.typeCheck(action, contextItemType); return this; }
visitor.getConfiguration().getNamePool()); role.setSourceLocator(this); sequence = TypeChecker.strictTypeCheck( sequence, sequenceType, role, visitor.getStaticContext()); ItemType actualItemType = sequence.getItemType(th); XPathException err = TypeChecker.ebvError(action, visitor.getConfiguration().getTypeHierarchy()); if (err != null) { err.setLocator(this);
); sequence = TypeChecker.strictTypeCheck( sequence, sequenceType, role, visitor.getStaticContext()); ItemType actualItemType = sequence.getItemType(th);
/** * Static type checking for let expressions is delegated to the expression itself, * and is performed on the "action" expression, to allow further delegation to the branches * of a conditional * @param req the required type * @param backwardsCompatible true if backwards compatibility mode applies * @param role the role of the expression in relation to the required type * @param visitor an expression visitor * @return the expression after type checking (perhaps augmented with dynamic type checking code) * @throws XPathException if failures occur, for example if the static type of one branch of the conditional * is incompatible with the required type */ public Expression staticTypeCheck(SequenceType req, boolean backwardsCompatible, RoleLocator role, ExpressionVisitor visitor) throws XPathException { action = TypeChecker.staticTypeCheck(action, req, backwardsCompatible, role, visitor); return this; }
visitor.getConfiguration().getNamePool()); role.setSourceLocator(this); sequence = TypeChecker.strictTypeCheck( sequence, sequenceType, role, visitor.getStaticContext()); ItemType actualItemType = sequence.getItemType(th); XPathException err = TypeChecker.ebvError(action, visitor.getConfiguration().getTypeHierarchy()); if (err != null) { err.setLocator(this);
/** * Static analysis: prevent sorting of the argument */ public void checkArguments(ExpressionVisitor visitor) throws XPathException { super.checkArguments(visitor); if (operation==BOOLEAN || operation==NOT) { XPathException err = TypeChecker.ebvError(argument[0], visitor.getConfiguration().getTypeHierarchy()); if (err != null) { err.setLocator(this); throw err; } Optimizer opt = visitor.getConfiguration().getOptimizer(); argument[0] = ExpressionTool.unsortedIfHomogeneous(opt, argument[0], false); } }
/** * Type-check the expression */ public Expression typeCheck(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException { // TODO: avoid repeated work if done again // The order of events is critical here. First we ensure that the type of the // sequence expression is established. This is used to establish the type of the variable, // which in turn is required when type-checking the action part. sequence = visitor.typeCheck(sequence, contextItemType); RoleLocator role = new RoleLocator(RoleLocator.VARIABLE, getVariableQName(), 0, visitor.getConfiguration().getNamePool()); role.setSourceLocator(this); sequence = TypeChecker.strictTypeCheck( sequence, requiredType, role, visitor.getStaticContext()); final TypeHierarchy th = visitor.getConfiguration().getTypeHierarchy(); final ItemType actualItemType = sequence.getItemType(th); refineTypeInformation(actualItemType, sequence.getCardinality(), (sequence instanceof Literal ? ((Literal) sequence).getValue() : null), sequence.getSpecialProperties(), visitor, this); action = visitor.typeCheck(action, contextItemType); return this; }
ExternalObjectModel model = (ExternalObjectModel)externalObjectModels.get(m); Value val = model.convertObjectToXPathValue(object, config); if (val != null && TypeChecker.testConformance(val, requiredType, context) == null) { return val;
/** * Static type checking for let expressions is delegated to the expression itself, * and is performed on the "action" expression, to allow further delegation to the branches * of a conditional * @param req the required type * @param backwardsCompatible true if backwards compatibility mode applies * @param role the role of the expression in relation to the required type * @param visitor an expression visitor * @return the expression after type checking (perhaps augmented with dynamic type checking code) * @throws XPathException if failures occur, for example if the static type of one branch of the conditional * is incompatible with the required type */ public Expression staticTypeCheck(SequenceType req, boolean backwardsCompatible, RoleLocator role, ExpressionVisitor visitor) throws XPathException { action = TypeChecker.staticTypeCheck(action, req, backwardsCompatible, role, visitor); return this; }
/** * Static analysis: prevent sorting of the argument */ public void checkArguments(ExpressionVisitor visitor) throws XPathException { super.checkArguments(visitor); if (operation==BOOLEAN || operation==NOT) { XPathException err = TypeChecker.ebvError(argument[0], visitor.getConfiguration().getTypeHierarchy()); if (err != null) { err.setLocator(this); throw err; } Optimizer opt = visitor.getConfiguration().getOptimizer(); argument[0] = ExpressionTool.unsortedIfHomogeneous(opt, argument[0], false); } }
/** * Type-check the expression */ public Expression typeCheck(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException { // TODO: avoid repeated work if done again // The order of events is critical here. First we ensure that the type of the // sequence expression is established. This is used to establish the type of the variable, // which in turn is required when type-checking the action part. sequence = visitor.typeCheck(sequence, contextItemType); RoleLocator role = new RoleLocator(RoleLocator.VARIABLE, getVariableQName(), 0, visitor.getConfiguration().getNamePool()); role.setSourceLocator(this); sequence = TypeChecker.strictTypeCheck( sequence, requiredType, role, visitor.getStaticContext()); final TypeHierarchy th = visitor.getConfiguration().getTypeHierarchy(); final ItemType actualItemType = sequence.getItemType(th); refineTypeInformation(actualItemType, sequence.getCardinality(), (sequence instanceof Literal ? ((Literal) sequence).getValue() : null), sequence.getSpecialProperties(), visitor, this); action = visitor.typeCheck(action, contextItemType); return this; }
XPathException err = TypeChecker.testConformance(val, requiredType, context); if (err != null) { throw err;
/** * Check the select expression against the required type. * @param visitor an expression visitor * @throws XPathException */ private void checkAgainstRequiredType(ExpressionVisitor visitor) throws XPathException { // Note, in some cases we are doing this twice. RoleLocator role = new RoleLocator(RoleLocator.VARIABLE, variableQName, 0); //role.setSourceLocator(this); SequenceType r = requiredType; if (r != null && select != null) { // check that the expression is consistent with the required type select = TypeChecker.staticTypeCheck(select, requiredType, false, role, visitor); } }
public Expression typeCheck(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException { Expression e = super.typeCheck(visitor, contextItemType); if (e == this) { XPathException err0 = TypeChecker.ebvError(operand0, visitor.getConfiguration().getTypeHierarchy()); if (err0 != null) { err0.setLocator(this); throw err0; } XPathException err1 = TypeChecker.ebvError(operand1, visitor.getConfiguration().getTypeHierarchy()); if (err1 != null) { err1.setLocator(this); throw err1; } // Precompute the EBV of any constant operand if (operand0 instanceof Literal && !(((Literal)operand0).getValue() instanceof BooleanValue)) { operand0 = Literal.makeLiteral(BooleanValue.get(operand0.effectiveBooleanValue(null))); } if (operand1 instanceof Literal && !(((Literal)operand1).getValue() instanceof BooleanValue)) { operand1 = Literal.makeLiteral(BooleanValue.get(operand1.effectiveBooleanValue(null))); } } return e; }
RoleLocator role = new RoleLocator( RoleLocator.VARIABLE, var.getVariableQName(), 0, null); Expression value2 = TypeChecker.strictTypeCheck( visitor.typeCheck(visitor.simplify(value), AnyItemType.getInstance()), var.getRequiredType(), role, visitor.getStaticContext());
XPathException err = TypeChecker.testConformance(val, requiredType, context); if (err != null) { throw err;