Package org.exist.dom

Examples of org.exist.dom.NodeProxy


          for (final Iterator<DocumentImpl> i = ds.getDocumentIterator(); i.hasNext();) {
              doc = i.next();
                if (context.inProtectedMode() && !context.getProtectedDocs().containsKey(doc.getDocId()))
                    {continue;}
                if(doc.getResourceType() == DocumentImpl.XML_FILE) {  // skip binary resources
                result.add(new NodeProxy(doc));
              }
            }
          cached = result;
          cachedDocs = ds;
        } catch (final LockException e) {
View Full Code Here


    public DescendantOrSelfSelector(NodeSet contextSet, int contextId) {
        super(contextSet, contextId);
    }

    public NodeProxy match(DocumentImpl doc, NodeId nodeId) {
        final NodeProxy contextNode = context.parentWithChild(doc, nodeId, false, true);
        if(contextNode == null)
            {return null;}
        final NodeProxy p = new NodeProxy(doc, nodeId);
        if (Expression.NO_CONTEXT_ID != contextId) {
            p.deepCopyContext(contextNode, contextId);
        } else
            {p.copyContext(contextNode);}
        return p;
    }
View Full Code Here

            throw new XPathException("Failed to get document for RemoteXMLResource: " + xe.getMessage());
        } catch(final PermissionDeniedException pde) {
            throw new XPathException("Failed to get document: " + pde.getMessage());
        }
        final NodeId nodeId = broker.getBrokerPool().getNodeFactory().createFromString(((RemoteXMLResource)xres).getNodeId());
        return new NodeProxy(document, nodeId);
       
    }
View Full Code Here

        Match nextMatch = this.match;
        while (nextMatch != null) {
            if (proxy.getNodeId().isDescendantOf(nextMatch.getNodeId())) {
                if (ancestors == null)
                    {ancestors = new ExtArrayNodeSet();}
                ancestors.add(new NodeProxy(proxy.getDocument(), nextMatch.getNodeId()));
            }
            nextMatch = nextMatch.getNextMatch();
        }
        if (ancestors != null && !ancestors.isEmpty()) {
            for (final Iterator<NodeProxy> i = ancestors.iterator(); i.hasNext();) {
                final NodeProxy p = i.next();
                int startOffset = 0;
                try {
                    final XMLStreamReader reader = broker.getXMLStreamReader(p, false);
                    while (reader.hasNext()) {
                        final int ev = reader.next();
                        final NodeId nodeId = (NodeId) reader.getProperty(ExtendedXMLStreamReader.PROPERTY_NODE_ID);
                        if (nodeId.equals(proxy.getNodeId()))
                            {break;}
                        if (ev == XMLStreamConstants.CHARACTERS)
                            {startOffset += reader.getText().length();}
                    }
                } catch (final IOException e) {
                    LOG.warn("Problem found while serializing XML: " + e.getMessage(), e);
                } catch (final XMLStreamException e) {
                    LOG.warn("Problem found while serializing XML: " + e.getMessage(), e);
                }
                if (offsetStack == null)
                    {offsetStack = new Stack<NodeOffset>();}
                offsetStack.push(new NodeOffset(p.getNodeId(), startOffset));
            }
        }
    }
View Full Code Here

        this.context = contextSet;
        this.contextId = contextId;
    }

    public NodeProxy match(DocumentImpl doc, NodeId nodeId) {
        final NodeProxy p = new NodeProxy(doc, nodeId);
        final NodeProxy contextNode = context.get(doc, nodeId);
        if (contextNode != null) {
            if (Expression.NO_CONTEXT_ID != contextId) {
                p.deepCopyContext(contextNode, contextId);
            } else {
              p.addContextNode(contextId, p);
View Full Code Here

      maxdepth--;
     
      int i = ( l + r ) / 2;
      int j;

      NodeProxy partionElement;
      // Arbitrarily establishing partition element as the midpoint of
      // the array.
      if (a[l].getNodeId().compareTo(a[i].getNodeId()) > 0)
        {SwapVals.swap(a, l, i);} // Tri-Median Methode!
      if (a[l].getNodeId().compareTo(a[r].getNodeId()) > 0)
        {SwapVals.swap(a, l, r);}
      if (a[i].getNodeId().compareTo(a[r].getNodeId()) > 0)
        {SwapVals.swap(a, i, r);}
      partionElement = a[i];
      // loop through the array until indices cross
      i = l+1;
      j = r-1;
      while( i <= j ) {
        // find the first element that is greater than or equal to
        // the partionElement starting from the leftIndex.
        while( ( i < r ) && ( partionElement.getNodeId().compareTo(a[i].getNodeId()) > 0))
          ++i;
        // find an element that is smaller than or equal to
        // the partionElement starting from the rightIndex.
        while( ( j > l ) && ( partionElement.getNodeId().compareTo(a[j].getNodeId()) < 0) )
          --j;
        // if the indexes have not crossed, swap
        if( i <= j ) {
          SwapVals.swap(a, i, j);
          ++i;
View Full Code Here

            RecordPos rec = null;
            if (StorageAddress.hasAddress(node.getInternalAddress()))
                {rec = db.findRecord(node.getInternalAddress());}
            if (rec == null) {
                try {
                    final long address = db.findValue(broker, new NodeProxy(node));
                    if (address == BTree.KEY_NOT_FOUND)
                        {throw new IOException("Node not found.");}
                    rec = db.findRecord(address);
                } catch (final BTreeException e) {
                    throw new IOException("Node not found: " + e.getMessage());
View Full Code Here

        if( nv.getImplementationType() == NodeValue.IN_MEMORY_NODE ) {
            final NodeImpl node = (NodeImpl)nv;
            reader = new InMemoryXMLStreamReader( node.getDocument(), node.getDocument() );
        } else {
            final NodeProxy proxy = (NodeProxy)nv;
            reader = getBroker().newXMLStreamReader( new NodeProxy( proxy.getDocument(), NodeId.DOCUMENT_NODE, proxy.getDocument().getFirstChildAddress() ), false );
        }
        return( reader );
    }
View Full Code Here

                throw new XPathException(this, "Illegal URI for resource path: " + path);
            }
        } else if(Type.subTypeOf(item.getType(), Type.NODE)) {
      final NodeValue node = (NodeValue) item;
      if(node.getImplementationType() == NodeValue.PERSISTENT_NODE) {
        final NodeProxy p = (NodeProxy) node;
        //TODO: use xmldbUri
        return new StringValue(p.getDocument().getCollection().getURI().toString())
      }
    } else
      {throw new XPathException(this, "First argument to util:collection-name should be either " +
        "a Java object of type org.xmldb.api.base.Collection or a node; got: " +
        Type.getTypeName(item.getType()));}
View Full Code Here

        final NodeValue stylesheetNode = (NodeValue)stylesheetItem;
        // if the passed node is a document node or document root element,
        // we construct an XMLDB URI and use the caching implementation.
        if(stylesheetNode.getImplementationType() == NodeValue.PERSISTENT_NODE)
        {
          final NodeProxy root = (NodeProxy) stylesheetNode;
                    if (root.getNodeId() == NodeId.DOCUMENT_NODE || root.getNodeId().getTreeLevel() == 1)
                    {
            //as this is a persistent node (e.g. a stylesheet stored in the db)
            //set the URI Resolver as a DatabaseResolver
            factory.setURIResolver(new EXistURIResolver(root.getDocument().getCollection().getURI().toString()));
         
            final String uri = XmldbURI.XMLDB_URI_PREFIX + context.getBroker().getBrokerPool().getId() + "://" + root.getDocument().getURI();
            templates = getSource(factory, uri);
          }
        }
        if(templates == null)
        {
View Full Code Here

TOP

Related Classes of org.exist.dom.NodeProxy

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.