Package org.exist.dom

Examples of org.exist.dom.NodeSet


        if (outerSequence != null && !outerSequence.isEmpty()
                && Type.subTypeOf(contextSequence.getItemType(), Type.NODE)
                && contextSequence.isPersistentSet()
                && outerSequence.isPersistentSet()) {
            final Sequence result = new NewArrayNodeSet(100);
            final NodeSet contextSet = contextSequence.toNodeSet();
            switch (mode) {
            case Constants.CHILD_AXIS:
            case Constants.ATTRIBUTE_AXIS:
            case Constants.DESCENDANT_AXIS:
            case Constants.DESCENDANT_SELF_AXIS:
            case Constants.DESCENDANT_ATTRIBUTE_AXIS: {
                final NodeSet outerNodeSet = outerSequence.toNodeSet();
                // TODO: in some cases, especially with in-memory nodes,
                // outerSequence.toNodeSet() will generate a document
                // which will be different from the one(s) in contextSet
                // ancestors will thus be empty :-(
                // A special treatment of VirtualNodeSet does not seem to be
                // required anymore
                final Sequence ancestors = outerNodeSet.selectAncestors(contextSet,
                        true, getExpressionId());
                if (contextSet.getDocumentSet().intersection(
                        outerNodeSet.getDocumentSet()).getDocumentCount() == 0)
                        {LOG.info("contextSet and outerNodeSet don't share any document");}
                final NewArrayNodeSet temp = new NewArrayNodeSet(100);
                for (final SequenceIterator i = ancestors.iterate(); i.hasNext();) {
                    NodeProxy p = (NodeProxy) i.nextItem();
                    ContextItem contextNode = p.getContext();
View Full Code Here


    public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException {
        if (args[0].isEmpty())
            {return Sequence.EMPTY_SEQUENCE;}
        final ExtArrayNodeSet inSet = (ExtArrayNodeSet) args[0].toNodeSet();
        final NodeSet filtered = new ExtArrayNodeSet();
        for (final NodeProxy p : inSet) {
            if (inSet.hasDescendantsInSet(p.getDocument(), p.getNodeId(), false, -1) == null)
                {filtered.add(p);}
        }
        return filtered;
    }
View Full Code Here

  }
 
  @Override
  public Sequence eval(Sequence[] args, Sequence contextSequence)
      throws XPathException {
    final NodeSet nodes = args[0].toNodeSet();
    if (nodes.isEmpty())
      {return Sequence.EMPTY_SEQUENCE;}
   
    final NodeSet result = new NewArrayNodeSet();
    final DateTimeValue dtv = (DateTimeValue) args[1].itemAt(0);
    final long lastModified = dtv.getDate().getTime();
   
    for (final NodeSetIterator i = nodes.iterator(); i.hasNext(); ) {
      final NodeProxy proxy = i.next();
      final DocumentImpl doc = proxy.getDocument();
      final long modified = doc.getMetadata().getLastModified();
      if (modified > lastModified)
        {result.add(proxy);}
    }
    return result;
  }
View Full Code Here

     */
    public Sequence eval(Sequence[] args, Sequence contextSequence)
            throws XPathException {
        if (args[0].isEmpty())
            {return Sequence.EMPTY_SEQUENCE;}
        NodeSet nodes = null;
        DocumentSet docs = null;
        Sequence qnames = null;
        if (isCalledAs("index-keys-by-qname")) {
            qnames = args[0];
            docs = contextSequence == null ? context.getStaticallyKnownDocuments() : contextSequence.getDocumentSet();
        } else {
            nodes = args[0].toNodeSet();
            docs = nodes.getDocumentSet();
        }
        final FunctionReference ref = (FunctionReference) args[2].itemAt(0);
        int max = -1;
        if (args[3].hasOne())
            {max = ((IntegerValue) args[3].itemAt(0)).getInt();}
View Full Code Here

            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++) {
            hits[k] =
                    context.getBroker().getTextEngine().getNodesContaining(
                            context,
                            contextSet.getDocumentSet(),
                            null, NodeSet.DESCENDANT, null,
                            terms[k],
                            DBBroker.MATCH_EXACT);
            hits[k] = getArgument(0).eval(hits[k]).toNodeSet();
        }
       
        NodeSet result = hits[0];
        for(int k = 1; k < hits.length; k++) {
            if(hits[k] != null)
                {result = result.deepIntersection(hits[k]);}
        }
      logger.debug("FOUND: " + result.getLength());
        return result;
    }
View Full Code Here

        final Expression path = getArgument(0);
        final Expression termsExpr = getArgument(1);
        final Expression flagsExpr = (getArgumentCount() == 3) ? getArgument(2) : null;
        final boolean matchAll = getMatchFlag(flagsExpr, contextSequence);

        NodeSet result;
    // if the expression does not depend on the current context item,
    // we can evaluate it in one single step
    if (path == null || !Dependency.dependsOn(path, Dependency.CONTEXT_ITEM)) {
      final boolean canCache =
                (getTermDependencies() & Dependency.CONTEXT_ITEM) == Dependency.NO_DEPENDENCY;
            ifcanCache && cached != null && cached.isValid(contextSequence, contextItem)) {
        return cached.getResult();
      }
            // do we optimize this expression?
            if (contextStep == null || preselectResult == null) {
                // no optimization: process the whole expression
                final NodeSet nodes =
                    path == null
                        ? contextSequence.toNodeSet()
                        : path.eval(contextSequence).toNodeSet();
                final List<String> terms = getSearchTerms(termsExpr, contextSequence);
                result = evalQuery(nodes, terms, matchAll).toNodeSet();
            } else {
                contextStep.setPreloadedData(contextSequence.getDocumentSet(), preselectResult);
                result = path.eval(contextSequence).toNodeSet();
            }

            if(canCache && contextSequence != null && contextSequence.isCacheable()) {
                cached = new CachedResult(contextSequence, contextItem, result);
            }

    // otherwise we have to walk through each item in the context
    } else {
      Item current;
//      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(termsExpr, contextSequence);
View Full Code Here

  public Sequence evalQuery(NodeSet nodes, List<String> terms, boolean matchAll)
    throws XPathException {
    if(terms == null || terms.size() == 0)
      {return Sequence.EMPTY_SEQUENCE;// no search terms
        final NodeSet[] hits = getMatches(nodes.getDocumentSet(), nodes, NodeSet.ANCESTOR, contextQName, terms, matchAll);
    NodeSet result = hits[0];
    if(result != null) {
      for(int k = 1; k < hits.length; k++) {
        if(hits[k] != null)
          {result = (type == Constants.FULLTEXT_AND ?
              result.deepIntersection(hits[k]) : result.union(hits[k]));}
      }
      return result;
    } else
      {return NodeSet.EMPTY_SET;}
  }
View Full Code Here

      {return NodeSet.EMPTY_SET;}
  }

    protected NodeSet[] getMatches(DocumentSet docs, NodeSet contextSet, int axis, QName qname, List<String> terms, boolean matchAll)
    throws XPathException {
        final NodeSet hits[] = new NodeSet[terms.size()];
        for (int k = 0; k < terms.size(); k++) {
            hits[k] =
                    context.getBroker().getTextEngine().getNodesContaining(
                            context,
                            docs,
View Full Code Here

        throws XPathException {
        int arg = 0;
        if (args[arg].isEmpty()) {
            return Sequence.EMPTY_SEQUENCE;
        }
        final NodeSet nodes = args[arg++].toNodeSet();
        final DocumentSet docs = nodes.getDocumentSet();
        QName[] qnames = null;
        if (args.length == 5) {
            qnames = new QName[args[arg].getItemCount()];
            int q = 0;
            for (final SequenceIterator i = args[arg].iterate(); i.hasNext(); q++) {
View Full Code Here

        Sequence result = Sequence.EMPTY_SEQUENCE;
      final Sequence set = expression.eval(contextSequence);

        if (!set.isEmpty()) {
            if (set.isPersistentSet()) {
                final NodeSet nodeSet = set.toNodeSet();
                switch(axis) {
                    case Constants.DESCENDANT_SELF_AXIS:
                        result = nodeSet.selectAncestorDescendant(contextSequence.toNodeSet(), NodeSet.DESCENDANT,
                            true, contextId, true);
                        break;
                    case Constants.CHILD_AXIS:
                        result = nodeSet.selectParentChild(contextSequence.toNodeSet(), NodeSet.DESCENDANT, contextId);
                        break;
                    default:
                        throw new XPathException(this, "Wrong axis specified");
                }
            } else {
View Full Code Here

TOP

Related Classes of org.exist.dom.NodeSet

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.