/** * Determine whether a value is castable to a given type * * @param value the value to be tested * @param targetType the type to be tested against * @param context XPath dynamic context * @return true if the value is castable to the required type */ private boolean isCastable(AtomicValue value, AtomicType targetType, XPathContext context) { Converter converter = this.converter; if (converter == null) { converter = context.getConfiguration().getConversionRules().getConverter(value.getPrimitiveType(), targetType); if (converter == null) { return false; } if (converter.isAlwaysSuccessful()) { return true; } if (getTargetType().isNamespaceSensitive()) { converter = converter.setNamespaceResolver(getRetainedStaticContext()); } } return !(converter.convert(value) instanceof ValidationFailure); }
/** * Determine whether a value is castable to a given type * * @param value the value to be tested * @param targetType the type to be tested against * @param context XPath dynamic context * @return true if the value is castable to the required type */ private boolean isCastable(AtomicValue value, AtomicType targetType, XPathContext context) { Converter converter = this.converter; if (converter == null) { converter = context.getConfiguration().getConversionRules().getConverter(value.getPrimitiveType(), targetType); if (converter == null) { return false; } if (converter.isAlwaysSuccessful()) { return true; } if (getTargetType().isNamespaceSensitive()) { converter = converter.setNamespaceResolver(getRetainedStaticContext()); } } return !(converter.convert(value) instanceof ValidationFailure); }
converter = converter.setNamespaceResolver(getRetainedStaticContext()); if (converter.isAlwaysSuccessful() && !allowsEmpty() && operand.getCardinality() == StaticProperty.ALLOWS_ONE) { return Literal.makeLiteral(BooleanValue.TRUE, this);
converter = converter.setNamespaceResolver(getRetainedStaticContext()); if (converter.isAlwaysSuccessful() && !allowsEmpty() && operand.getCardinality() == StaticProperty.ALLOWS_ONE) { return Literal.makeLiteral(BooleanValue.TRUE, this);