Package net.sf.saxon.value

Examples of net.sf.saxon.value.SequenceType


    * is statically known and constant, in which case it is the actual type of the value.
    */

    public SequenceType getRequiredType() {
        // System.err.println("Get required type of $" + getVariableName());
        SequenceType defaultType = (requiredType==null ? SequenceType.ANY_SEQUENCE : requiredType);
        if (assignable) {
            return defaultType;
        } else if (requiredType != null) {
            return requiredType;
        } else if (select!=null) {
            if (select instanceof EmptySequence) {
                // returning Type.EMPTY gives problems with static type checking
                return defaultType;
            } else {
                try {
                    // try to infer the type from the select expression
                    return new SequenceType(select.getItemType(), select.getCardinality());
                } catch (Exception err) {
                    // this may fail because the select expression references a variable or function
                    // whose type is not yet known, because of forwards (perhaps recursive) references.
                    return defaultType;
                }
            }
        } else if (hasChildNodes()) {
            return new SequenceType(NodeKindTest.DOCUMENT, StaticProperty.EXACTLY_ONE);
        } else {
            // no select attribute or content: value is an empty string
            return SequenceType.SINGLE_STRING;
        }
    }
View Full Code Here


            try {
                RoleLocator role =
                    new RoleLocator(RoleLocator.INSTRUCTION, "xsl:key/use", 0);
                use = TypeChecker.staticTypeCheck(
                                use,
                                new SequenceType(Type.ANY_ATOMIC_TYPE, StaticProperty.ALLOWS_ZERO_OR_MORE),
                                false, role, getStaticContext());
            } catch (XPathException err) {
                compileError(err);
            }
        } else {
View Full Code Here

            try {
                RoleLocator role =
                    new RoleLocator(RoleLocator.INSTRUCTION, "xsl:key/use", 0);
                use = TypeChecker.staticTypeCheck(
                                use,
                                new SequenceType(Type.ANY_ATOMIC_TYPE, StaticProperty.ALLOWS_ZERO_OR_MORE),
                                false, role, getStaticContext());

            } catch (XPathException err) {
                compileError(err);
            }
View Full Code Here

                        }
                        if (param instanceof XSLParam &&
                                ((XSLParam)param).getVariableFingerprint() ==
                                    withParam.getVariableFingerprint()) {
                            ok = true;
                            SequenceType required = ((XSLParam)param).getRequiredType();
                            withParam.checkAgainstRequiredType(required);
                            break;
                        }
                    }
                    if (!ok) {
View Full Code Here

    */

    private Expression promote(Expression child) {
        RangeVariableDeclaration decl = new RangeVariableDeclaration();
        decl.setVariableName("zz:" + decl.hashCode());
        SequenceType type = new SequenceType(child.getItemType(), child.getCardinality());
        decl.setRequiredType(type);

        VariableReference var = new VariableReference(decl);
        ExpressionTool.copyLocationInfo(containingExpression, var);
        var.setParentExpression((ComputedExpression)containingExpression);
View Full Code Here

                int newcard = cardinality & ((VariableReference)ref).getCardinality();
                if (newcard==0) {
                    // this will probably lead to a type error later
                    newcard = ((VariableReference)ref).getCardinality();
                }
                SequenceType seqType =
                        new SequenceType(newItemType, newcard);

                ref.setStaticType(seqType, constantValue, properties);
            }
        }
    }
View Full Code Here

        // 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 = sequence.analyze(env, contextItemType);

        SequenceType decl = declaration.getRequiredType();
        SequenceType sequenceType =
            new SequenceType(decl.getPrimaryType(),
                             StaticProperty.ALLOWS_ZERO_OR_MORE);
        RoleLocator role = new RoleLocator(RoleLocator.VARIABLE, getVariableName(env.getNamePool()), 0);
        sequence = TypeChecker.staticTypeCheck(
                                sequence, sequenceType, false, role, env);
        ItemType actualItemType = sequence.getItemType();
View Full Code Here

        // "some" and "every" have no ordering constraints

        sequence = ExpressionTool.unsorted(sequence, false);

        SequenceType decl = declaration.getRequiredType();
        SequenceType sequenceType =
                            new SequenceType(decl.getPrimaryType(),
                                             StaticProperty.ALLOWS_ZERO_OR_MORE);
        RoleLocator role = new RoleLocator(RoleLocator.VARIABLE, getVariableName(env.getNamePool()), 0);
        sequence = TypeChecker.staticTypeCheck(
                                sequence, sequenceType, false, role, env);
        ItemType actualItemType = sequence.getItemType();
View Full Code Here

    * Type-check the expression
    */

    public Expression analyze(StaticContext env, ItemType contextItemType) throws XPathException {
        operand = operand.analyze(env, contextItemType);
        SequenceType atomicType =
                new SequenceType(Type.ANY_ATOMIC_TYPE, getCardinality());

        RoleLocator role = new RoleLocator(RoleLocator.TYPE_OP, "cast as", 0);
        operand = TypeChecker.staticTypeCheck(operand, atomicType, false, role, env);

        if (Type.isSubType(operand.getItemType(), targetType)) {
View Full Code Here

    public XQSequenceType getStaticResultType() throws XQException {
        checkNotClosed();
        Expression exp = expression.getExpression();    // unwrap two layers!
        ItemType itemType = exp.getItemType(connection.getConfiguration().getTypeHierarchy());
        int cardinality = exp.getCardinality();
        SequenceType staticType = SequenceType.makeSequenceType(itemType, cardinality);
        return new SaxonXQSequenceType(staticType, connection.getConfiguration());
    }
View Full Code Here

TOP

Related Classes of net.sf.saxon.value.SequenceType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.