Package xbird.xquery.dm.value

Examples of xbird.xquery.dm.value.Item


    public XInteger eval(Sequence<? extends Item> contextSeq, ValueSequence argv, DynamicContext dynEnv)
            throws XQueryException {
        if(argv == null) {
            // If no argument is supplied, $arg defaults to the string value of the context item (.).
            // If no argument is supplied and the context item is undefined an error is raised: [err:XPDY0002].
            Item contextItem = dynEnv.contextItem();
            if(contextItem == null) {
                throw new DynamicError("err:XPDY0002", "ContextItem is not set");
            }
            String sv = contextItem.stringValue();
            // If the value of $arg is the empty sequence, the xs:integer 0 is returned.
            return XInteger.valueOf(sv.length());
        }
        Item first = argv.getItem(0);
        final String argstr = first.stringValue();
        return XInteger.valueOf(argstr.length());
    }
View Full Code Here


        return s;
    }

    public Sequence eval(Sequence<? extends Item> contextSeq, ValueSequence argv, DynamicContext dynEnv) throws XQueryException {
        assert (argv != null && argv.size() == 1);
        Item firstItem = argv.getItem(0);
        if(firstItem.isEmpty()) {
            return XString.valueOf("");
        }
        QNameValue arg = (QNameValue) firstItem;
        String lpart = arg.getValue().getLocalPart();
        return new XString(lpart, NCNameType.NCNAME);
View Full Code Here

    }

    public Sequence eval(Sequence<? extends Item> contextSeq, ValueSequence argv, DynamicContext dynEnv)
            throws XQueryException {
        assert (argv != null && argv.size() == 2);
        Item value = argv.getItem(0);
        Item secondItem = argv.getItem(1);
        XString label = (XString) secondItem;
        assert (label != null);
        final String message = label.getValue() + ": { " + traceItem(value, ", ") + " }.";
        LOGGER.trace(message); // TODO create trace listener?
        return value;
View Full Code Here

    }

    public Sequence eval(final Sequence<? extends Item> contextSeq, final ValueSequence argv, final DynamicContext dynEnv)
            throws XQueryException {
        assert (argv != null && argv.size() == 1);
        final Item arg = argv.getItem(0);
        final Type argType = arg.getType();
        final Type.Occurrence quantifier = argType.quantifier();
        if(!Type.Occurrence.OCC_ZERO_OR_ONE.accepts(quantifier.getAlignment())) {
            final Iterator<? extends Item> argItor = arg.iterator();
            if(argItor.hasNext()) {
                final Item first = argItor.next();
                assert (first != null);
                if(argItor.hasNext()) {
                    // Returns $arg if it contains one or more items. Otherwise, raises an error [err:FORG0004].
                    throw new DynamicError("err:FORG0004", "Invalid result sequence type was detected, $arg contains one or more items: "
                            + arg.getType());
View Full Code Here

    public Sequence eval(Sequence<? extends Item> contextSeq, ValueSequence argv, DynamicContext dynEnv) throws XQueryException {
        assert (argv != null);
        final int arglen = argv.size();
        assert (arglen == 1 || arglen == 2);
        Item firstItem = argv.getItem(0);
        // If the value of $arg is the empty sequence, returns the zero-length string.
        if(firstItem.isEmpty()) {
            return XString.valueOf("");
        }
        String arg = firstItem.stringValue();
        // If the $normalizationForm is absent, as in the first format above,
        // it shall be assumed to be "NFC"
        String nform = "NFC";
        if(arglen == 2) {
            Item secondItem = argv.getItem(1);
            nform = secondItem.stringValue();
        }
        final String normed;
        if("NFC".equalsIgnoreCase(nform)) {
            normed = Normalizer.normalize(arg, Normalizer.NFC);
        } else if("NFD".equalsIgnoreCase(nform)) {
View Full Code Here

        }
        final boolean interveningBlanks = _interveningBlanks;
        boolean init = true;
        final IFocus<? extends Item> itor = seq.iterator();
        while(itor.hasNext()) {
            final Item it = itor.next();
            if(!init) {
                if(isSeq) {
                    if(interveningBlanks) {
                        evText(SPACE, 0, 1);
                    }
View Full Code Here

    }

    public XInteger eval(DynamicContext dynEnv, Item... args) throws XQueryException {
        assert (args.length == 2) : args;
        final XInteger result;
        final Item it1 = args[0];
        final Item it2 = args[1];
        switch(combinedArgTypes(it1, it2)) {
            case INT_INT:
                long ll1 = DivInteger.compute(it1, it2, dynEnv);
                result = new XInteger(ll1);
                break;
View Full Code Here

        }

        // The above 'for each' is equivalent to the following expression.
        IFocus focus = result.iterator(); // IFocus extends Iterable
        while(result.next(focus)) {
            Item item = focus.getContextItem();
            // ..
        }
    }
View Full Code Here

        return this;
    }

    public Sequence eval(Sequence<? extends Item> contextSeq, ValueSequence argv, DynamicContext dynEnv) throws XQueryException {
        assert (argv != null && argv.size() == 1);
        Item arg = argv.getItem(0);
        final Type.Occurrence quantifier = arg.getType().quantifier();
        if(!Type.Occurrence.OCC_ONE_OR_MORE.accepts(quantifier.getAlignment())) {
            if(arg.isEmpty()) {
                // Returns $arg if it contains one or more items. Otherwise, raises an error [err:FORG0004].
                throw new DynamicError("err:FORG0004", "Invalid result sequence type was detected: "
                        + arg.getType());
            }
        }
        return arg;
    }
View Full Code Here

    }

    public Sequence eval(Sequence<? extends Item> contextSeq, ValueSequence argv, DynamicContext dynEnv)
            throws XQueryException {
        assert (argv != null && argv.size() == 1);
        Item firstItem = argv.getItem(0);
        if(firstItem.isEmpty()) {
            return ValueSequence.EMPTY_SEQUENCE;
        }
        QNameValue arg = (QNameValue) firstItem;
        QualifiedName qname = arg.getValue();
        String prefix = qname.getPrefix();
View Full Code Here

TOP

Related Classes of xbird.xquery.dm.value.Item

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.