Package org.exist.dom

Examples of org.exist.dom.DocumentSet


     */
    public Sequence eval(Sequence contextSequence, Item contextItem)
            throws XPathException {
     
        final Sequence docsArg = getArgument(0).eval(contextSequence, contextItem);
        final DocumentSet docs = docsArg.getDocumentSet();
        try {
            docs.lock(context.getBroker(), exclusive, false);
            return getArgument(1).eval(contextSequence, contextItem);
        } catch (final LockException e) {
            throw new XPathException(this, "Could not lock document set", e);
        } finally {
            docs.unlock(exclusive);
        }
    }
View Full Code Here


        // save some context properties
        evalContext.pushNamespaceContext();

        final LocalVariable mark = evalContext.markLocalVariables(false);

        final DocumentSet oldDocs = evalContext.getStaticallyKnownDocuments();
        if(exprContext != null) {
            evalContext.setStaticallyKnownDocuments(exprContext.getDocumentSet());
        }

        if(evalContext.isProfilingEnabled(2)) {
View Full Code Here

                }
            } else
                {result = evalFallback(nodes, pattern, flags, indexType);}

            if (result == null) {
                final DocumentSet docs = nodes.getDocumentSet();
                try {
                    final NativeValueIndex index = context.getBroker().getValueIndex();
                    hasUsedIndex = true;
                    //TODO : check index' case compatibility with flags' one ? -pb
                    if (context.isProfilingEnabled())
View Full Code Here

      Sequence result;
      if (args[0].isEmpty())
            {result = Sequence.EMPTY_SEQUENCE;}
      else {
          final NodeSet nodes = args[0].toNodeSet();
          final DocumentSet docs = nodes.getDocumentSet();         
          if (this.getArgumentCount() == 3) {
            final IndexWorker indexWorker = context.getBroker().getIndexController().getWorkerByIndexName(args[2].itemAt(0).getStringValue());
            //Alternate design
            //IndexWorker indexWorker = context.getBroker().getBrokerPool().getIndexManager().getIndexByName(args[2].itemAt(0).getStringValue()).getWorker();           
            if (indexWorker == null)
View Full Code Here

   * @see org.exist.xquery.Expression#eval(org.exist.dom.DocumentSet, org.exist.xquery.value.Sequence, org.exist.xquery.value.Item)
   */
    public Sequence eval(Sequence contextSequence, Item contextItem)
  throws XPathException {
 
  DocumentSet docs = null;
  Sequence result = null;
  // check if the loaded documents should remain locked
        final boolean lockOnLoad = context.lockDocumentsOnLoad();
        boolean cacheIsValid = false;
  if (getArgumentCount() == 0) {
            // 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
      //          if(cached != null) {
      //              result = cached;
      //              docs = cachedDocs;
      //          } else {
      MutableDocumentSet mdocs = new DefaultDocumentSet();
            try {
                context.getBroker().getAllXMLResources(mdocs);
            } catch(final PermissionDeniedException pde) {
                LOG.error(pde.getMessage(), pde);
                throw new XPathException(this, pde);
            }
      docs = mdocs;
      //          }
  } else {
      List<String> args = getParameterValues(contextSequence, contextItem);
      if(cachedArgs != null)
    {cacheIsValid = compareArguments(cachedArgs, args);}
      if(cacheIsValid) {
    result = cached;
    docs = cachedDocs;
      } else {
                MutableDocumentSet mdocs = new DefaultDocumentSet();
    for(int i = 0; i < args.size(); i++) {
        try {
      final String next = (String)args.get(i);
      XmldbURI nextUri = new AnyURIValue(next).toXmldbURI();
      if(nextUri.getCollectionPath().length() == 0) {
          throw new XPathException(this, "Invalid argument to " + XMLDBModule.PREFIX + ":document() function: empty string is not allowed here.");
      }
      if(nextUri.numSegments()==1) {                    
          nextUri = context.getBaseURI().toXmldbURI().resolveCollectionPath(nextUri);
      }
      final DocumentImpl doc = context.getBroker().getResource(nextUri, Permission.READ);
      if(doc == null) {
          if (context.isRaiseErrorOnFailedRetrieval()) {
        throw new XPathException(this, ErrorCodes.FODC0002, "can not access '" + nextUri + "'");
          }           
      }else {
          mdocs.add(doc);
      }
        } catch (final XPathException e) { //From AnyURIValue constructor
                        e.setLocation(line, column);
      logger.error("From AnyURIValue constructor:", e);

      throw e;
        } catch (final PermissionDeniedException e) {
      logger.error("Permission denied", e);

      throw new XPathException(this, "Permission denied: unable to load document " + (String) args.get(i));
        }
    }
                docs = mdocs;
                cachedArgs = args;
      }
  }
  try {
            if(!cacheIsValid)
                // wait for pending updates
                {docs.lock(context.getBroker(), lockOnLoad, true);}
      // wait for pending updates
      if(result == null) {
    result = new ExtArrayNodeSet(docs.getDocumentCount(), 1);
                DocumentImpl doc;
    for (final Iterator<DocumentImpl> i = docs.getDocumentIterator(); i.hasNext();) {
                    doc = i.next();
        result.add(new NodeProxy(doc)); //, -1, Node.DOCUMENT_NODE));
                    if(lockOnLoad) {
                        context.addLockedDocument(doc);
                    }
    }
      }
  } catch (final LockException e) {
      logger.error("Could not acquire lock on document set", e);

            throw new XPathException(this, "Could not acquire lock on document set.");
        } finally {
            if(!(cacheIsValid || lockOnLoad))
                // release all locks
                {docs.unlock(lockOnLoad);}
  }
  cached = result;
  cachedDocs = docs;
  registerUpdateListener();

View Full Code Here

     */
    public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException {

        // Get nodes
        final NodeSet nodes = args[0].toNodeSet();
        final DocumentSet docs = nodes.getDocumentSet();

        try {
            if (args.length > 1) {
                // Use supplied parameter
                final int splitCount = ((IntegerValue)args[1].itemAt(0)).getInt();
View Full Code Here

   */
  public Sequence eval(Sequence[] args, Sequence contextSequence)
    throws XPathException {
    if(args[0].isEmpty())
      {return Sequence.EMPTY_SEQUENCE;}
    DocumentSet docs;
    if(contextSequence instanceof NodeSet)
      {docs = contextSequence.getDocumentSet();}
    else
      {docs = context.getStaticallyKnownDocuments();}
    final String term = args[0].getStringValue();
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 {
View Full Code Here

        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

            result = Sequence.EMPTY_SEQUENCE;
        } else {
            //we will filter out nodes from the contextSequence
            result = contextSequence;
            Sequence currentContext = contextSequence;
            DocumentSet contextDocs = null;
            Expression expr = steps.get(0);
            if (expr instanceof VariableReference) {
                final Variable var = ((VariableReference) expr).getVariable();
                //TOUNDERSTAND : how null could be possible here ? -pb
                if (var != null)
View Full Code Here

TOP

Related Classes of org.exist.dom.DocumentSet

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.