Package org.exist.xquery.value

Examples of org.exist.xquery.value.Sequence.itemAt()


              !Type.subTypeOf(endSeq.itemAt(0).atomize().getType(), Type.UNTYPED_ATOMIC))
          {throw new XPathException(this, ErrorCodes.FORG0006, "Required type is " +
              Type.getTypeName(Type.INTEGER) + " but got '" + Type.getTypeName(endSeq.itemAt(0).getType()) + "(" +
              endSeq.itemAt(0).getStringValue() + ")'", endSeq);}
            final IntegerValue valueStart = (IntegerValue)startSeq.itemAt(0).convertTo(Type.INTEGER);
            final IntegerValue valueEnd = (IntegerValue)endSeq.itemAt(0).convertTo(Type.INTEGER);
//             result = new ValueSequence();
//        for (long i = valueStart.getLong();  i <= valueEnd.getLong(); i++) {
//          result.add(new IntegerValue(i));
//        }
            result = new RangeSequence(valueStart, valueEnd);
View Full Code Here


        Sequence result;
        final Sequence arg = getArgument(0).eval(contextSequence, contextItem);
        if (arg.isEmpty()) {
            result = BooleanValue.FALSE;
        } else {
            final String path = arg.itemAt(0).getStringValue();
            try {
                result = BooleanValue.valueOf(DocUtils.isDocumentAvailable(this.context, path));
            } catch (final XPathException e) {
                e.prependMessage(ErrorCodes.FODC0005, "");
                throw e;
View Full Code Here

    Sequence result;
    if (args.length == 0 || args[0].isEmpty()) {
      result = Sequence.EMPTY_SEQUENCE;
    } else {
      final Sequence arg = args[0];
      final AbstractDateTimeValue date = (AbstractDateTimeValue) arg.itemAt(0);
      if (isCalledAs("day-from-dateTime") || isCalledAs("day-from-date")) {
        result = new IntegerValue(date.getPart(DateValue.DAY), Type.INTEGER);
      } else if (isCalledAs("month-from-dateTime") || isCalledAs("month-from-date")) {
        result = new IntegerValue(date.getPart(DateValue.MONTH),
            Type.INTEGER);
View Full Code Here

        Sequence result;
        final Sequence arg = getArgument(0).eval(contextSequence, contextItem);
        if (arg.isEmpty())
            {result = Sequence.EMPTY_SEQUENCE;}
        else {
            final String path = arg.itemAt(0).getStringValue();
            // TODO: disabled cache for now as it may cause concurrency issues
            // better use compile-time inspection and maybe a pragma to mark those
            // sections in the query that can be safely cached.
            // check if we can return a cached sequence
            //if (cached != null && path.equals(cachedPath)) {
View Full Code Here

                final Sequence nodes = getArgument(1).eval(contextSequence);
                if (nodes.isEmpty())
                    {throw new XPathException(this, ErrorCodes.XPDY0002,
                        "no node or context item for fn:idref");}
               
                if (!Type.subTypeOf(nodes.itemAt(0).getType(), Type.NODE))
                  {throw new XPathException(this, ErrorCodes.XPTY0004,
                      "fn:idref() argument is not a node");}
               
                NodeValue node = (NodeValue)nodes.itemAt(0);
                if (node.getImplementationType() == NodeValue.IN_MEMORY_NODE)
View Full Code Here

               
                if (!Type.subTypeOf(nodes.itemAt(0).getType(), Type.NODE))
                  {throw new XPathException(this, ErrorCodes.XPTY0004,
                      "fn:idref() argument is not a node");}
               
                NodeValue node = (NodeValue)nodes.itemAt(0);
                if (node.getImplementationType() == NodeValue.IN_MEMORY_NODE)
                  //TODO : how to enforce this ?
                  //If $node, or the context item if the second argument is omitted,
                  //is a node in a tree whose root is not a document node [err:FODC0001] is raised                    processInMem = true;
                    {processInMem = true;}
View Full Code Here

        //bind external vars?
        if(isCalledAs("eval") && getArgumentCount() == 3) {
            if(!args[2].isEmpty()) {
                final Sequence externalVars = args[2];
                for(int i = 0; i < externalVars.getItemCount(); i++) {
                    final Item varName = externalVars.itemAt(i);
                    if(varName.getType() == Type.QNAME) {
                        final Item varValue = externalVars.itemAt(++i);
                        innerContext.declareVariable(((QNameValue)varName).getQName(), varValue);
                    }
                }
View Full Code Here

            if(!args[2].isEmpty()) {
                final Sequence externalVars = args[2];
                for(int i = 0; i < externalVars.getItemCount(); i++) {
                    final Item varName = externalVars.itemAt(i);
                    if(varName.getType() == Type.QNAME) {
                        final Item varValue = externalVars.itemAt(++i);
                        innerContext.declareVariable(((QNameValue)varName).getQName(), varValue);
                    }
                }
            }
        }
View Full Code Here

            ValueSequence newSeq = new ValueSequence();
            newSeq.keepUnOrdered(unordered);
            boolean hasSupplements = false;
            for (int i = 0;  i < sequence.getItemCount(); i++) {
                //if (sequence.itemAt(i) instanceof StringValue) {
                if (Type.subTypeOf(sequence.itemAt(i).getType(),Type.STRING)) {
                    newSeq.add(new StringValue(((StringValue) sequence.itemAt(i)).getStringValue(true)));
                    hasSupplements = true;
                } else {
                    newSeq.add(sequence.itemAt(i));
                }
View Full Code Here

            newSeq.keepUnOrdered(unordered);
            boolean hasSupplements = false;
            for (int i = 0;  i < sequence.getItemCount(); i++) {
                //if (sequence.itemAt(i) instanceof StringValue) {
                if (Type.subTypeOf(sequence.itemAt(i).getType(),Type.STRING)) {
                    newSeq.add(new StringValue(((StringValue) sequence.itemAt(i)).getStringValue(true)));
                    hasSupplements = true;
                } else {
                    newSeq.add(sequence.itemAt(i));
                }
            }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.