Package org.exist.xquery.value

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


            }
        }
       
        Sequence result;
        final Sequence seq = args[0].convertTo(Type.DOUBLE);
        final NumericValue value = (NumericValue) seq.itemAt(0).convertTo(Type.DOUBLE);

        if (seq.isEmpty()) {
            result = Sequence.EMPTY_SEQUENCE;
           
        } else {         
View Full Code Here


        final Sequence querySeq = getArgument(1).eval(contextSequence);
        if (querySeq.isEmpty()) {
            return Sequence.EMPTY_SEQUENCE;
        }
        final String query = querySeq.itemAt(0).getStringValue();
       
        final String[] terms = getSearchTerms(query);
        final NodeSet hits[] = new NodeSet[terms.length];
        final NodeSet contextSet = contextSequence.toNodeSet();
        for (int k = 0; k < terms.length; k++) {
View Full Code Here

        Sequence result;
        double calcValue=0;
        final String functionName = getSignature().getName().getLocalName();
       
        final Sequence seqA = args[0].convertTo(Type.DOUBLE);
        final NumericValue valueA = (NumericValue)seqA.itemAt(0).convertTo(Type.DOUBLE);
       
        final Sequence seqB = args[1].convertTo(Type.DOUBLE);
        final NumericValue valueB = (NumericValue)seqB.itemAt(0).convertTo(Type.DOUBLE);
       
        if(ATAN2.equals(functionName)) {
View Full Code Here

       
        final Sequence seqA = args[0].convertTo(Type.DOUBLE);
        final NumericValue valueA = (NumericValue)seqA.itemAt(0).convertTo(Type.DOUBLE);
       
        final Sequence seqB = args[1].convertTo(Type.DOUBLE);
        final NumericValue valueB = (NumericValue)seqB.itemAt(0).convertTo(Type.DOUBLE);
       
        if(ATAN2.equals(functionName)) {
            calcValue = Math.atan2(valueA.getDouble(), valueB.getDouble());
           
        } else if(POW.equals(functionName)) {           
View Full Code Here

                if (parent == null)
                    {throw new XPathException(this, "The root element of a document can not be replaced with 'update replace'. " +
                            "Please consider removing the document or use 'update value' to just replace the children of the root.");}
                switch (node.getNodeType()) {
                    case Node.ELEMENT_NODE:
                        temp = contentSeq.itemAt(0);
            if (!Type.subTypeOf(temp.getType(), Type.NODE))
              {throw new XPathException(this,
                  Messages.getMessage(Error.UPDATE_REPLACE_ELEM_TYPE,
                      Type.getTypeName(temp.getType())));}
                        parent.replaceChild(transaction, ((NodeValue)temp).getNode(), node);
View Full Code Here

    protected List<String> getSearchTerms(Expression termsExpr, Sequence contextSequence) throws XPathException {
    final List<String> terms = new ArrayList<String>();
    final Sequence seq = termsExpr.eval(contextSequence);
        if(seq.hasOne())
            {terms.add(translateRegexp(seq.itemAt(0).getStringValue()));}
        else {
            for(final SequenceIterator it = seq.iterate(); it.hasNext(); ) {
                terms.add(translateRegexp(it.nextItem().getStringValue()));
            }
        }
View Full Code Here

      } catch (final SAXException saxe) {
        LOG.warn(saxe);
        throw new BadRequestException("Error while serializing XML: "
            + saxe.getMessage());
      }
      resultSequence.itemAt(0);

    } catch (final XPathException ex) {
      throw new EXistException("Cannot execute xquery "
          + entryByIdSource.getURL(), ex);
View Full Code Here

        throw new EXistException("I/O error on read of resource " + path, ex);
      } catch (final SAXException saxe) {
        LOG.warn(saxe);
        throw new BadRequestException("Error while serializing XML: " + saxe.getMessage());
      }
      resultSequence.itemAt(0);

    } catch (final XPathException ex) {
      throw new EXistException("Cannot execute xquery " + getFeedSource.getURL(), ex);

    } finally {
View Full Code Here

        final Sequence funcSeq = functionExpr.eval(contextSequence, contextItem);
        if (funcSeq.getCardinality() != Cardinality.EXACTLY_ONE)
            {throw new XPathException(this, ErrorCodes.XPTY0004,
                "Expected exactly one item for the function to be called, got " + funcSeq.getItemCount() +
                ". Expression: " + ExpressionDumper.dump(functionExpr));}
        final Item item0 = funcSeq.itemAt(0);
        if (!Type.subTypeOf(item0.getType(), Type.FUNCTION_REFERENCE))
            {throw new XPathException(this, ErrorCodes.XPTY0004,
                "Type error: expected function, got " + Type.getTypeName(item0.getType()));}
        final FunctionReference ref = (FunctionReference)item0;
        // if the call is a partial application, create a new function
View Full Code Here

            final Sequence nameSeq = name.eval(contextSequence, contextItem);
            //TODO : get rid of getLength()
            if (!nameSeq.hasOne())
                {throw new XPathException(this, ErrorCodes.XPTY0004,
                    "The name expression should evaluate to a single value");}
            final Item nameItem = nameSeq.itemAt(0);
            if (!(nameItem.getType() == Type.STRING || nameItem.getType() == Type.NCNAME ||
                    nameItem.getType() == Type.UNTYPED_ATOMIC))
                {throw new XPathException(this, ErrorCodes.XPTY0004,
                        "The name expression should evaluate to a " + Type.getTypeName(Type.STRING) +
                        " or a " + Type.getTypeName(Type.NCNAME) +
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.