/** * Get the expression's dependencies. If the target type is namespace-sensitive, then the expression * has a dependency on the namespace bindings in the static context * * @return the expression's dependencies. */ @Override public int getIntrinsicDependencies() { return getTargetType().isNamespaceSensitive() ? StaticProperty.DEPENDS_ON_STATIC_CONTEXT : 0; }
/** * Get the expression's dependencies. If the target type is namespace-sensitive, then the expression * has a dependency on the namespace bindings in the static context * * @return the expression's dependencies. */ @Override public int getIntrinsicDependencies() { return getTargetType().isNamespaceSensitive() ? StaticProperty.DEPENDS_ON_STATIC_CONTEXT : 0; }
/** * Type-check the expression */ public Expression typeCheck(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException { if (allConverted && requiredItemType.isNamespaceSensitive()) { XPathException err = new XPathException("Cannot convert untypedAtomic values to QNames or NOTATIONs"); err.setErrorCode("XPTY0004"); err.setIsTypeError(true); err.setLocator(this); throw err; } operand = visitor.typeCheck(operand, contextItemType); if (operand instanceof Literal) { return Literal.makeLiteral( ((Value)SequenceExtent.makeSequenceExtent( iterate(visitor.getStaticContext().makeEarlyEvaluationContext()))).reduce()); } final TypeHierarchy th = visitor.getConfiguration().getTypeHierarchy(); ItemType type = operand.getItemType(th); if (type instanceof NodeTest) { return this; } if (type.equals(BuiltInAtomicType.ANY_ATOMIC) || type instanceof AnyItemType || type.equals(BuiltInAtomicType.UNTYPED_ATOMIC)) { return this; } // the sequence can't contain any untyped atomic values, so there's no need for a converter return operand; }
/** * Type-check the expression */ public Expression typeCheck(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException { if (allConverted && requiredItemType.isNamespaceSensitive()) { XPathException err = new XPathException("Cannot convert untypedAtomic values to QNames or NOTATIONs"); err.setErrorCode("XPTY0004"); err.setIsTypeError(true); err.setLocator(this); throw err; } operand = visitor.typeCheck(operand, contextItemType); if (operand instanceof Literal) { return Literal.makeLiteral( ((Value)SequenceExtent.makeSequenceExtent( iterate(visitor.getStaticContext().makeEarlyEvaluationContext()))).reduce()); } final TypeHierarchy th = visitor.getConfiguration().getTypeHierarchy(); ItemType type = operand.getItemType(th); if (type instanceof NodeTest) { return this; } if (type.equals(BuiltInAtomicType.ANY_ATOMIC) || type instanceof AnyItemType || type.equals(BuiltInAtomicType.UNTYPED_ATOMIC)) { return this; } // the sequence can't contain any untyped atomic values, so there's no need for a converter return operand; }
/** * Type-check the expression */ public Expression typeCheck(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException { if (allConverted && requiredItemType.isNamespaceSensitive()) { XPathException err = new XPathException("Cannot convert untypedAtomic values to QNames or NOTATIONs"); err.setErrorCode("XPTY0004"); err.setIsTypeError(true); err.setLocator(this); throw err; } operand = visitor.typeCheck(operand, contextItemType); if (operand instanceof Literal) { return Literal.makeLiteral( ((Value)SequenceExtent.makeSequenceExtent( iterate(visitor.getStaticContext().makeEarlyEvaluationContext()))).reduce()); } final TypeHierarchy th = visitor.getConfiguration().getTypeHierarchy(); ItemType type = operand.getItemType(th); if (type instanceof NodeTest) { return this; } if (type.equals(BuiltInAtomicType.ANY_ATOMIC) || type instanceof AnyItemType || type.equals(BuiltInAtomicType.UNTYPED_ATOMIC)) { return this; } // the sequence can't contain any untyped atomic values, so there's no need for a converter return operand; }
/** * 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); }
throw new SaxonApiException("Requested type is an abstract type"); if (((AtomicType) it).isNamespaceSensitive()) { throw new SaxonApiException("Requested type is namespace-sensitive");
throw new SaxonApiException("Requested type is an abstract type"); if (((AtomicType) it).isNamespaceSensitive()) { throw new SaxonApiException("Requested type is namespace-sensitive");
Configuration config = tree.getConfiguration(); SchemaType stype = config.getSchemaType(type); if (stype instanceof AtomicType && !((AtomicType)stype).isNamespaceSensitive()) { CharSequence value = TinyParentNodeImpl.getStringValue(tree, nextNodeNr); return StringValue.convertStringToAtomicType(
Configuration config = tree.getConfiguration(); SchemaType stype = config.getSchemaType(type); if (stype instanceof AtomicType && !((AtomicType)stype).isNamespaceSensitive()) { CharSequence value = TinyParentNodeImpl.getStringValue(tree, nextNodeNr); return StringValue.convertStringToAtomicType(
nextToken(); if (at.isNamespaceSensitive()) { if (exp instanceof StringLiteral) { try {
nextToken(); if (at.isNamespaceSensitive()) { if (exp instanceof StringLiteral) { try {
nextToken(); if (at.isNamespaceSensitive() && exp instanceof StringLiteral) { try { String source = ((StringLiteral)exp).getStringValue();
nextToken(); if (at.isNamespaceSensitive() && exp instanceof StringLiteral) { try { String source = ((StringLiteral)exp).getStringValue();
if (getTargetPrimitiveType().isNamespaceSensitive()) { converter = converter.setNamespaceResolver(getRetainedStaticContext());
if (getTargetPrimitiveType().isNamespaceSensitive()) { converter = converter.setNamespaceResolver(getRetainedStaticContext());
throw e; if (getTargetType().isNamespaceSensitive()) { converter = converter.setNamespaceResolver(getRetainedStaticContext());
throw e; if (getTargetType().isNamespaceSensitive()) { converter = converter.setNamespaceResolver(getRetainedStaticContext());
throw err; } else { if (getTargetType().isNamespaceSensitive()) { converter = converter.setNamespaceResolver(getRetainedStaticContext());