Package org.exist.xquery.value

Examples of org.exist.xquery.value.Sequence


            throw new IOException("QT3 junit tests folder unreadable.");
        }

        XQuery xqs = broker.getXQueryService();
       
        Sequence results = xqs.execute(tsQuery, null, AccessContext.TEST);
       
        for (NodeProxy p : results.toNodeSet()) {
          NamedNodeMap attrs = p.getNode().getAttributes();
          String name = attrs.getNamedItem("name").getNodeValue();
          String file = attrs.getNamedItem("file").getNodeValue();
         
          processSet(src, name, file);
View Full Code Here


        "declare namespace qt='http://www.w3.org/2010/09/qt-fots-catalog'; " +
        "let $catalog := xmldb:document('/db/QT3/"+file+"') " +
        "return $catalog//qt:test-case";

        XQuery xqs = broker.getXQueryService();
        Sequence results = xqs.execute(tsQuery, null, AccessContext.TEST);
       
        testCases(src, file, name, results);
  }
View Full Code Here

                "DEPENDENCIES", Dependency.getDependenciesName(this.getDependencies()));
            if (contextSequence != null)
                {context.getProfiler().message(this, Profiler.START_SEQUENCES,
                "CONTEXT SEQUENCE", contextSequence);}
        }
        Sequence result;
        if (args[0].isEmpty())
            {result = Sequence.EMPTY_SEQUENCE;}
        else if (args[1].isEmpty())
            {result =  Sequence.EMPTY_SEQUENCE;}
        else {
View Full Code Here

        }
       
  if(contextItem != null)
      {contextSequence = contextItem.toSequence();}

        Sequence result;
  final String s1 = getArgument(0).eval(contextSequence).getStringValue();
  final String s2 = getArgument(1).eval(contextSequence).getStringValue();       
  if(s1.length() == 0 || s2.length() == 0)
            {result = Sequence.EMPTY_SEQUENCE;}
        else {
View Full Code Here

        }
       
    //if (contextItem != null)
    //  contextSequence = contextItem.toSequence();
       
    Sequence result;
        final Sequence seq = getArgument(0).eval(contextSequence, contextItem);
    if (seq.isEmpty())
            {result = Sequence.EMPTY_SEQUENCE;}
        else {
          final Item item = seq.itemAt(0);
          NumericValue value;
          if (item instanceof NumericValue) {
        value = (NumericValue) item;
      } else {
        value = (NumericValue) item.convertTo(Type.NUMBER);
View Full Code Here

                throw new EXistException(treeParser.getErrorMessage());
            }
            LOG.info("query: " + ExpressionDumper.dump(expr));
            final long start = System.currentTimeMillis();
            expr.analyze(new AnalyzeContextInfo());
            final Sequence seq= expr.eval(null, null);
           
            QueryResponseCollection[] collections = null;
            if (!seq.isEmpty() && Type.subTypeOf(seq.getItemType(), Type.NODE))
                {collections = collectQueryInfo(scanResults(seq));}
            session.addQueryResult(seq);
            resp.setCollections(new QueryResponseCollections(collections));
            resp.setHits(seq.getItemCount());
            resp.setQueryTime(System.currentTimeMillis() - start);
            expr.reset();
            context.reset();
        } catch (final Exception e) {
            LOG.debug(e.getMessage(), e);
View Full Code Here

        try {
            broker = pool.get(session.getUser());
            final QueryResult queryResult = session.getQueryResult();
            if (queryResult == null)
                {throw new RemoteException("result set unknown or timed out");}
            final Sequence seq = (Sequence) queryResult.result;
            if (start < 1 || start > seq.getItemCount())
                {throw new RuntimeException(
                        "index " + start + " out of bounds (" + seq.getItemCount() + ")");}
            if (start + howmany > seq.getItemCount() || howmany == 0)
                {howmany = seq.getItemCount() - start + 1;}
           
            final String xml[] = new String[howmany];
            final Serializer serializer = broker.getSerializer();
            serializer.reset();
            serializer.setProperty(OutputKeys.INDENT, indent ? "yes" : "no");
            serializer.setProperty(EXistOutputKeys.EXPAND_XINCLUDES, xinclude ? "yes" : "no");
            serializer.setProperty(EXistOutputKeys.HIGHLIGHT_MATCHES, highlight);
           
            Item item;
            int j = 0;
            for (int i = --start; i < start + howmany; i++, j++) {
                item = seq.itemAt(i);
                if (item == null)
                    {continue;}
                if (item.getType() == Type.ELEMENT) {
                    final NodeValue node = (NodeValue) item;
                    xml[j] = serializer.serialize(node);
View Full Code Here

                    "CONTEXT SEQUENCE", contextSequence);}
            if (contextItem != null)
                {context.getProfiler().message(this, Profiler.START_SEQUENCES,
                    "CONTEXT ITEM", contextItem.toSequence());}
        }
        final Sequence arg = getArgument(0).eval(contextSequence, contextItem);
        final Sequence result =  arg.effectiveBooleanValue() ?
                BooleanValue.TRUE : BooleanValue.FALSE;
        if (context.getProfiler().isEnabled())
            {context.getProfiler().end(this, "", result);}
        return result;
    }
View Full Code Here

      Item current;
      final @SuppressWarnings("unused")
      String arg;
      NodeSet nodes;
      result = new ExtArrayNodeSet();
      Sequence temp;
      for (final SequenceIterator i = contextSequence.iterate(); i.hasNext();) {
        current = i.nextItem();
        final List<String> terms = getSearchTerms(contextSequence);
        nodes =
          path == null
View Full Code Here

    protected List<String> getSearchTerms(Sequence contextSequence) throws XPathException {
    if(getArgumentCount() < 2)
      {throw new XPathException(this, "function requires at least 2 arguments");}
    final List<String> terms = new ArrayList<String>();
    Expression next;
    Sequence seq;
    for(int i = 1; i < getLength(); i++) {
      next = getArgument(i);
      seq = next.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()));
        }
      }
    }
    return terms;
View Full Code Here

TOP

Related Classes of org.exist.xquery.value.Sequence

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.