Package xbird.xquery.dm.value

Examples of xbird.xquery.dm.value.Item


        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 ValueSequence.EMPTY_SEQUENCE;
        }
        QNameValue arg = (QNameValue) firstItem;
        QualifiedName qname = arg.getValue();
        String nsuri = qname.getNamespaceURI();
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 arg = argv.getItem(0);
        if(arg.isEmpty()) {
            return BooleanValue.FALSE;
        } else {
            return BooleanValue.TRUE;
        }
    }
View Full Code Here

        String[] errObjects = null;
        if(argv == null) {
            errorName = DEFAULT_ERR_NAME;
        } else {
            final int arglen = argv.size();
            final Item firstItem = argv.getItem(0);
            if(arglen == 1) {
                QNameValue err = (QNameValue) firstItem;
                errorName = err.getValue();
                final String trace = (new Throwable()).getStackTrace()[1].toString();
                desc = "fn:error is called at " + trace;
            } else {
                if(arglen == 3) {
                    final Item thirdItem = argv.getItem(2);
                    final List<String> errList = new LinkedList<String>();
                    final IFocus<Item> thirdItemItor = thirdItem.iterator();
                    for(Item err : thirdItemItor) {
                        errList.add(err.stringValue());
                    }
                    thirdItemItor.closeQuietly();
                    errObjects = errList.toArray(new String[errList.size()]);
                }
                if(firstItem.isEmpty()) {
                    errorName = DEFAULT_ERR_NAME;
                } else {
                    QNameValue err = (QNameValue) firstItem;
                    errorName = err.getValue();
                }
                Item secondItem = argv.getItem(1);
                assert (secondItem instanceof XString);
                desc = secondItem.stringValue();
            }
        }
        if(errObjects != null) {
            final StackTraceElement[] st = (new Throwable()).getStackTrace();
            errObjects = new String[st.length];
View Full Code Here

    }

    public XString eval(Sequence<? extends Item> contextSeq, ValueSequence argv, DynamicContext dynEnv)
            throws XQueryException {
        final int arglen = argv.size();
        Item firstItem = argv.getItem(0);
        // If $input is the empty sequence, it is interpreted as the zero-length string.
        String input = firstItem.isEmpty() ? "" : firstItem.stringValue();
        Item secondItem = argv.getItem(1);
        String pattern = secondItem.stringValue();
        Item thirdItem = argv.getItem(2);
        String replacement = thirdItem.stringValue();
        checkReplacement(replacement);
        int flags = Pattern.UNIX_LINES;
        if(arglen == 4) {
            Item forthItem = argv.getItem(3);
            String flagsStr = forthItem.stringValue();
            flags = Matches.convertFlags(flagsStr);
        }
        final Pattern compiled;
        try {
            compiled = Pattern.compile(pattern, flags);
View Full Code Here

    }

    public BooleanValue 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);
        return arg.isEmpty() ? BooleanValue.TRUE : BooleanValue.FALSE;
    }
View Full Code Here

        return s;
    }

    public Sequence eval(Sequence<? extends Item> contextSeq, ValueSequence argv, DynamicContext dynEnv)
            throws XQueryException {
        final Item arg = argv.getItem(0);
        return arg.atomize(dynEnv);
    }
View Full Code Here

        return s;
    }

    public XString eval(Sequence<? extends Item> contextSeq, ValueSequence argv, DynamicContext dynEnv)
            throws XQueryException {
        final Item firstItem = argv.getItem(0);
        if(firstItem.isEmpty()) {
            // If the value of $sourceString is the empty sequence, the zero-length string is returned.
            return XString.valueOf("");
        }
        final String sourceString = firstItem.stringValue();
        final int maxSourceLen = sourceString.length();
        final Item secItem = argv.getItem(1);
        final XNumber secNum = (XNumber) secItem;
        // first character of a string is located at position 1, not position 0.
        final int startingLoc = Math.max(0, (int) Math.round(secNum.asDouble() - 1));
        final int endingLoc;
        final int arglen = argv.size();
        if(arglen == 3) {
            final Item thirdItem = argv.getItem(2);
            final XNumber thirdNum = (XNumber) thirdItem;
            final int length = (int) Math.round(thirdNum.asDouble());
            endingLoc = Math.max(0, Math.min(maxSourceLen, length));
        } else {
            endingLoc = maxSourceLen;
View Full Code Here

    }

    public Sequence eval(Sequence<? extends Item> contextSeq, ValueSequence argv, DynamicContext dynEnv)
            throws XQueryException {
        // If $relative is the empty sequence, the empty sequence is returned.
        Item firstItem = argv.getItem(0);
        if(firstItem.isEmpty()) {
            return ValueSequence.EMPTY_SEQUENCE;
        }
        final URI relative;
        String relativeStr = firstItem.stringValue();
        try {
            if(relativeStr.length() == 0) {
                relative = null;
            } else {
                relative = new URI(relativeStr);
                if(relative.isAbsolute()) {// If $relative is an absolute URI reference, it is returned unchanged.
                    return AnyURIValue.valueOf(relative);
                }
            }
        } catch (URISyntaxException e) {
            throw new DynamicError("err:FORG0002", "Invalid URI form: " + relativeStr);
        }
        final URI baseUri;
        final int arglen = argv.size();
        if(arglen == 2) {
            Item secondItem = argv.getItem(1);
            String baseStr = secondItem.stringValue();
            baseUri = URI.create(baseStr);
        } else {
            baseUri = dynEnv.getStaticContext().getBaseURI();
            if(baseUri == null) {
                throw new DynamicError("err:FONS0005", "BaseUri is not set in the static context.");
View Full Code Here

    }

    public Sequence eval(Sequence<? extends Item> contextSeq, ValueSequence argv, DynamicContext dynEnv)
            throws XQueryException {
        assert (argv.size() == 2);
        Item firstItem = argv.getItem(0);
        Item secondItem = argv.getItem(1);
        final String qname = ((XString) secondItem).getValue();
        final String paramUri;
        if(firstItem.isEmpty()) {
            if(qname.indexOf(':') != -1) {
                throw new DynamicError("err:FOCA0002", "Invalid qname: " + qname);
View Full Code Here

            return ValueSequence.EMPTY_SEQUENCE;
        }
        // Returns the empty sequence if the node is not a document node.
        // Otherwise, returns the value of the dm:document-uri accessor of the document node.
        assert (argv.size() == 1);
        Item arg = argv.getItem(0);
        Type type = arg.getType();
        if(!TypeUtil.subtypeOf(type, DocumentTest.ANY_DOCUMENT)) {
            return ValueSequence.EMPTY_SEQUENCE;
        }
        final String docuri;
        if(arg instanceof DTMDocument) {
            docuri = ((DTMDocument) arg).documentUri();
        } else if(arg instanceof DMDocument) {
            docuri = ((DMDocument) arg).documentUri();
        } else {
            throw new IllegalStateException("Invalid document node type: "
                    + arg.getClass().getName());
        }
        if(docuri == null) {
            return ValueSequence.EMPTY_SEQUENCE;
        }
        return AnyURIValue.valueOf(docuri);
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.