Package net.sf.saxon.value

Examples of net.sf.saxon.value.Value


    public XQResultSequence executeQuery() throws XQException {
        checkNotClosed();
        try {
            SequenceIterator iter = expression.iterator(context);
            if (scrollable) {
                Value value = Value.asValue(SequenceExtent.makeSequenceExtent(iter));
                return new SaxonXQSequence(value, connection.getConfiguration(), connection);
            } else {
                return new SaxonXQForwardSequence(iter, connection);
            }
        } catch (XPathException de) {
View Full Code Here


        }
    }

    public Expression compile(Executable exec) throws XPathException {
        if (test instanceof Literal) {
            Value testVal = ((Literal)test).getValue();
            // condition known statically, so we only need compile the code if true.
            // This can happen with expressions such as test="function-available('abc')".
            try {
                if (testVal.effectiveBooleanValue()) {
                    return compileSequenceConstructor(exec, iterateAxis(Axis.CHILD), true);
//                    Block block = new Block();
//                    block.setLocationId(allocateLocationId(getSystemId(), getLineNumber()));
//                    compileChildren(exec, block, true);
//                    return block.simplify(getStaticContext());
View Full Code Here

                        "A sequence of more than one item is not allowed as the " +
                        role.getMessage(), role.getErrorCode(), context);
                }
                result = item;
            } else {
                Value value = ((NodeInfo)item).atomize();
                found += value.getLength();
                if (found > 1) {
                     typeError(
                        "A sequence of more than one item is not allowed as the " +
                        role.getMessage(), role.getErrorCode(), context);
                }
                result = value.itemAt(0);
            }
        }
        if (found == 0 && !allowEmpty) {
            typeError("An empty sequence is not allowed as the " +
                             role.getMessage(), role.getErrorCode(), null);
View Full Code Here

            Item item = iter.next();
            if (item == null) {
                break;
            }
            if (item instanceof NodeInfo) {
                Value atomizedValue = ((NodeInfo)item).atomize();
                int length = atomizedValue.getLength();
                count += length;
                if (count > 1) {
                    return false;
                }
                if (length != 0) {
                    AtomicValue av = (AtomicValue)atomizedValue.itemAt(0);
                    if (!isCastable(av, targetType, context)) {
                        return false;
                    }
                }
            } else {
View Full Code Here

     */

    private void preEvaluateCollation(StaticContext env) throws XPathException {
        if (getNumberOfArguments() == getDetails().maxArguments) {
            final Expression collationExp = argument[getNumberOfArguments() - 1];
            final Value collationVal = (collationExp instanceof Literal ? ((Literal)collationExp).getValue() : null);
            if (collationVal instanceof AtomicValue) {
                // Collation is supplied as a constant
                String collationName = collationVal.getStringValue();
                URI collationURI;
                try {
                    collationURI = new URI(collationName);
                    if (!collationURI.isAbsolute()) {
                        saveBaseURI(env, true);
View Full Code Here

                    results = null;
                }
            }
            // Avoid calling next() to materialize the NodeInfo object
            if (base.moveNext()) {
                Value atomized = base.atomize();
                if (atomized instanceof AtomicValue) {
                    // common case (the atomized value of the node is a single atomic value)
                    results = null;
                    nextItem = (AtomicValue)atomized;
                    break;
                } else {
                    results = atomized.iterate();
                    nextItem = (AtomicValue)results.next();
                    if (nextItem == null) {
                        results = null;
                    } else {
                        break;
View Full Code Here

    */

    public SequenceIterator iterate(XPathContext context) throws XPathException {
        if (context.getController().isTracing()) {
            String label = argument[1].evaluateAsString(context).toString();
            Value value = Value.asValue(ExpressionTool.eagerEvaluate(argument[0], context));
            notifyListener(label, value, context);
            return value.iterate();
        } else {
            return new TracingIterator(argument[0].iterate(context), argument[1].evaluateAsString(context).toString());
        }
    }
View Full Code Here

    public int getWeight() {
        return 10000;
    }

    public Value transform(Object source, TransformationContext context) {
        Value result = null;
        if (source instanceof Integer) {
            result = new IntegerValue((Integer)source);
        } else if (source instanceof Long) {
            result = new IntegerValue((Long)source);
        } else if (source instanceof Short) {
View Full Code Here

    public int getWeight() {
        return 10000;
    }

    public Value transform(Object source, TransformationContext context) {
        Value result = null;
        if (source instanceof Integer) {
            result = new IntegerValue((Integer)source);
        } else if (source instanceof Long) {
            result = new IntegerValue((Long)source);
        } else if (source instanceof Short) {
View Full Code Here

      */

     public void checkPermittedContents(SchemaType parentType, StaticContext env, boolean whole) throws XPathException {
         // if the expression is a constant value, check that it is valid for the type
         if (select instanceof Literal) {
             Value selectValue = ((Literal)select).getValue();
             SimpleType stype = null;
             if (parentType instanceof SimpleType && whole) {
                 stype = (SimpleType)parentType;
             } else if (parentType instanceof ComplexType && ((ComplexType)parentType).isSimpleContent()) {
                 stype = ((ComplexType)parentType).getSimpleContentType();
             }
             if (whole && stype != null && !stype.isNamespaceSensitive()) {
                        // Can't validate namespace-sensitive content statically
                 ValidationFailure err = stype.validateContent(
                         selectValue.getStringValue(), null, env.getConfiguration().getNameChecker());
                 if (err != null) {
                     err.setLocator(this);
                     throw err.makeException();
                 }
                 return;
             }
             if (parentType instanceof ComplexType &&
                     !((ComplexType)parentType).isSimpleContent() &&
                     !((ComplexType)parentType).isMixedContent() &&
                     !Whitespace.isWhite(selectValue.getStringValue())) {
                 XPathException err = new XPathException("Complex type " + parentType.getDescription() +
                         " does not allow text content " +
                         Err.wrap(selectValue.getStringValue()));
                 err.setLocator(this);
                 err.setIsTypeError(true);
                 throw err;
             }
         }
View Full Code Here

TOP

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

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.