public boolean checkAssign(ItemType to, ItemType from) { TypeHierarchy th = processor.getUnderlyingConfiguration().getTypeHierarchy(); return th.isSubType(from, to); }
private void checkItemType(ItemType type, Supplier<? extends Item<?>> itemSupplier, Location locationId) throws XPathException { if (!getConfiguration().getTypeHierarchy().isSubType(type, itemType)) { throwTypeError(type, itemSupplier == null ? null : itemSupplier.get(), locationId); } }
private void checkItemType(ItemType type, Supplier<? extends Item<?>> itemSupplier, Location locationId) throws XPathException { if (!getConfiguration().getTypeHierarchy().isSubType(type, itemType)) { throwTypeError(type, itemSupplier == null ? null : itemSupplier.get(), locationId); } }
/** * Static factory method, allowing early instantiation of a subclass if the type of the step expression * is already known */ public static SlashExpression makeSlashExpression(Expression start, Expression step, TypeHierarchy th) { ItemType itemType = step.getItemType(th); if (th.isSubType(itemType, AnyNodeTest.getInstance())) { return new PathExpression(start, step); } else if (th.isSubType(itemType, BuiltInAtomicType.ANY_ATOMIC)) { return new AtomicMappingExpression(start, step); } else { return new SlashExpression(start, step); } }
/** * Determine whether this ItemType subsumes another ItemType. Specifically, * <code>A.subsumes(B) is true if every value that matches the ItemType B also matches * the ItemType A. * * @param other the other ItemType * @return true if this ItemType subsumes the other ItemType. This includes the case where A and B * represent the same ItemType. * @since 9.1 */ public boolean subsumes(ItemType other) { TypeHierarchy th = processor.getUnderlyingConfiguration().getTypeHierarchy(); return th.isSubType(other.getUnderlyingItemType(), underlyingType); }
/** * Determine whether this ItemType subsumes another ItemType. Specifically, * <code>A.subsumes(B) is true if every value that matches the ItemType B also matches * the ItemType A. * * @param other the other ItemType * @return true if this ItemType subsumes the other ItemType. This includes the case where A and B * represent the same ItemType. * @since 9.1 */ public boolean subsumes(ItemType other) { TypeHierarchy th = processor.getUnderlyingConfiguration().getTypeHierarchy(); return th.isSubType(other.getUnderlyingItemType(), underlyingType); }
/** * Ask whether values of this type are atomizable * * @return true if some or all instances of this type can be successfully atomized; false * * if no instances of this type can be atomized * @param th The type hierarchy cache */ @Override public boolean isAtomizable(TypeHierarchy th) { // An instance of a specific function type can be atomized only if it is an array, which // means there must be a single argument and it must be of type xs:integer or a supertype. if (getArity() != 1) { return false; } ItemType argType = getArgumentTypes()[0].getPrimaryType(); return th.isSubType(BuiltInAtomicType.INTEGER, argType); }
public Sequence<?> call(XPathContext context, Sequence[] arguments) throws XPathException { final TypeHierarchy th = context.getConfiguration().getTypeHierarchy(); Item value = arguments[0].head(); ItemType type = SequenceTool.getItemType(value, th); if (th.isSubType(type, AnyNodeTest.getInstance())) { return new StringValue("node-set"); } else if (th.isSubType(type, BuiltInAtomicType.STRING)) { return new StringValue("string"); } else if (th.isSubType(type, NumericType.getInstance())) { return new StringValue("number"); } else if (th.isSubType(type, BuiltInAtomicType.BOOLEAN)) { return new StringValue("boolean"); } else { return new StringValue(type.toString()); } } }
/** * Type-check the expression */ /*@NotNull*/ public Expression typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException { typeCheckChildren(visitor, contextInfo); Configuration config = visitor.getConfiguration(); final TypeHierarchy th = config.getTypeHierarchy(); Expression operand = getBaseExpression(); if (th.isSubType(operand.getItemType(), requiredItemType)) { return operand; } else { if (converter == null) { allocateConverterStatically(config, 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); // 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; }
private void checkItemType(ItemType type, long locationId) throws XPathException { if (!getConfiguration().getTypeHierarchy().isSubType(type, itemType)) { String message = role.composeErrorMessage(itemType, type, getNamePool()); String errorCode = role.getErrorCode(); XPathException err = new XPathException(message); err.setErrorCode(errorCode); if (!"XPDY0050".equals(errorCode)) { err.setIsTypeError(true); } err.setLocator(ExpressionLocation.getSourceLocator(locationId, getPipelineConfiguration().getLocationProvider())); throw err; } }
private void checkItemType(ItemType type, long locationId) throws XPathException { if (!getConfiguration().getTypeHierarchy().isSubType(type, itemType)) { String message = role.composeErrorMessage(itemType, type, getNamePool()); String errorCode = role.getErrorCode(); XPathException err = new XPathException(message); err.setErrorCode(errorCode); if (!"XPDY0050".equals(errorCode)) { err.setIsTypeError(true); } err.setLocator(ExpressionLocation.getSourceLocator(locationId, getPipelineConfiguration().getLocationProvider())); throw err; } }
public Expression processValueOf(Expression select, Configuration config) { TypeHierarchy th = config.getTypeHierarchy(); if (!select.getItemType().isPlainType()) { select = Atomizer.makeAtomizer(select, null); } if (Cardinality.allowsMany(select.getCardinality())) { select = FirstItemExpression.makeFirstItemExpression(select); } if (!th.isSubType(select.getItemType(), BuiltInAtomicType.STRING)) { select = new AtomicSequenceConverter(select, BuiltInAtomicType.STRING); ((AtomicSequenceConverter) select).allocateConverterStatically(config, false); } return select; }
public Expression processValueOf(Expression select, Configuration config) { TypeHierarchy th = config.getTypeHierarchy(); if (!select.getItemType().isPlainType()) { select = Atomizer.makeAtomizer(select); } if (Cardinality.allowsMany(select.getCardinality())) { select = FirstItemExpression.makeFirstItemExpression(select); } if (!th.isSubType(select.getItemType(), BuiltInAtomicType.STRING)) { select = new AtomicSequenceConverter(select, BuiltInAtomicType.STRING); ((AtomicSequenceConverter) select).allocateConverterStatically(config, false); } return select; }
public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) throws XPathException { optimizeChildren(visitor, contextItemType); if (getSelect().isCallOn(String_1.class)) { SystemFunctionCall sf = (SystemFunctionCall) getSelect(); TypeHierarchy th = visitor.getConfiguration().getTypeHierarchy(); if (th.isSubType(sf.getArg(0).getItemType(), BuiltInAtomicType.STRING) && !Cardinality.allowsMany(sf.getArg(0).getCardinality())) { setSelect(sf.getArg(0)); } } return this; }
/** * Make an expression that extracts the first item of a sequence, after atomization */ public static Expression makeFirstItem(Expression exp, StaticContext env) { final TypeHierarchy th = env.getConfiguration().getTypeHierarchy(); if (!exp.getItemType(th).isAtomicType()) { exp = new Atomizer(exp, env.getConfiguration()); } if (Cardinality.allowsMany(exp.getCardinality())) { exp = new FirstItemExpression(exp); } if (!th.isSubType(exp.getItemType(th), BuiltInAtomicType.STRING)) { exp = new AtomicSequenceConverter(exp, BuiltInAtomicType.STRING); } return exp; }
/** * Make an expression that extracts the first item of a sequence, after atomization */ public static Expression makeFirstItem(Expression exp, StaticContext env) { final TypeHierarchy th = env.getConfiguration().getTypeHierarchy(); if (!exp.getItemType(th).isAtomicType()) { exp = new Atomizer(exp, env.getConfiguration()); } if (Cardinality.allowsMany(exp.getCardinality())) { exp = new FirstItemExpression(exp); } if (!th.isSubType(exp.getItemType(th), BuiltInAtomicType.STRING)) { exp = new AtomicSequenceConverter(exp, BuiltInAtomicType.STRING); } return exp; }
public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) throws XPathException { optimizeChildren(visitor, contextItemType); if (getSelect().isCallOn(String_1.class)) { SystemFunctionCall sf = (SystemFunctionCall) getSelect(); TypeHierarchy th = visitor.getConfiguration().getTypeHierarchy(); if (th.isSubType(sf.getArg(0).getItemType(), BuiltInAtomicType.STRING) && !Cardinality.allowsMany(sf.getArg(0).getCardinality())) { setSelect(sf.getArg(0)); } } return this; }