Package org.exist.memtree

Examples of org.exist.memtree.DocumentImpl


                        }
                        // make this document persistent: doc.makePersistent()
                        // returns a map of all root node ids mapped to the corresponding
                        // persistent node. We scan the current sequence and replace all
                        // in-memory nodes with their new persistent node objects.
                        final DocumentImpl expandedDoc = doc.expandRefs(null);
                        final org.exist.dom.DocumentImpl newDoc = expandedDoc.makePersistent();
                        if (newDoc != null) {
                            NodeId rootId = newDoc.getBrokerPool().getNodeFactory().createInstance();
                            for (int j = i; j < count; j++) {
                                v = (NodeValue) items[j].item;
                                if(v.getImplementationType() != NodeValue.PERSISTENT_NODE) {
                                    NodeImpl node = (NodeImpl) v;
                                    if (node.getDocument() == doc) {
                                        node = expandedDoc.getNode(node.getNodeNumber());
                                        NodeId nodeId = node.getNodeId();
                                        if (nodeId == null)
                                            {throw new XPathException("Internal error: nodeId == null");}
                                        if (node.getNodeType() == Node.DOCUMENT_NODE)
                                            {nodeId = rootId;}
View Full Code Here


      NodeValue v;
      for (int i = 0; i <= size; i++) {
        v = (NodeValue)values[i];
        if(v.getImplementationType() != NodeValue.PERSISTENT_NODE) {
                    // found an in-memory document
                    final DocumentImpl doc = ((NodeImpl)v).getDocument();
                    if (doc==null) {
                       continue;
                    }
                    // make this document persistent: doc.makePersistent()
                    // returns a map of all root node ids mapped to the corresponding
                    // persistent node. We scan the current sequence and replace all
                    // in-memory nodes with their new persistent node objects.
                    final DocumentImpl expandedDoc = doc.expandRefs(null);
                    final org.exist.dom.DocumentImpl newDoc = expandedDoc.makePersistent();
                    if (newDoc != null) {
                        NodeId rootId = newDoc.getBrokerPool().getNodeFactory().createInstance();
                        for (int j = i; j <= size; j++) {
                            v = (NodeValue) values[j];
                            if(v.getImplementationType() != NodeValue.PERSISTENT_NODE) {
                                NodeImpl node = (NodeImpl) v;
                                if (node.getDocument() == doc) {
                                    if (node.getNodeType() == Node.ATTRIBUTE_NODE)
                                        {node = expandedDoc.getAttribute(node.getNodeNumber());}
                                    else
                                        {node = expandedDoc.getNode(node.getNodeNumber());}
                                    NodeId nodeId = node.getNodeId();
                                    if (nodeId == null)
                                        {throw new XPathException("Internal error: nodeId == null");}
                                    if (node.getNodeType() == Node.DOCUMENT_NODE)
                                        {nodeId = rootId;}
View Full Code Here

    private void getId(Sequence result, Sequence seq, String id) throws XPathException {
        final Set<DocumentImpl> visitedDocs = new TreeSet<DocumentImpl>();
        for (final SequenceIterator i = seq.iterate(); i.hasNext();) {
            final NodeImpl v = (NodeImpl) i.nextItem();
            final DocumentImpl doc = v.getDocument();
            if (!visitedDocs.contains(doc)) {
                final NodeImpl elem = doc.selectById(id);
                if (elem != null)
                    {result.add(elem);}
                visitedDocs.add(doc);
            }
        }
View Full Code Here

                    }
                }

                if(result == null) {
                    //2) not binary, try and parse as an XML documemnt
                    final DocumentImpl doc = parseAsXml(is);
                    if(doc != null) {
                        result = new SequenceImpl<Document>(new DocumentTypedValue(doc));
                    }
                }
View Full Code Here

        return result;
    }
   
    private DocumentImpl parseAsXml(final InputStream is) {

        DocumentImpl result = null;
        XMLReader reader = null;

        try {
            //try and construct xml document from input stream, we use eXist's in-memory DOM implementation
View Full Code Here

      boolean ok = false;
      if (outputURL == null || outputURL.equals("")) {
        Assert.fail("expected error: " + expectedError);
      } else {
        //workaround
            Document doc = new DocumentImpl(context, false);
            Element outputFile = doc.createElement("outputFile");
            outputFile.setAttribute("compare", "Fragment");
            outputFile.setTextContent(outputURL);
 
        if (compareResult("", XSLTS_folder+"/ExpectedTestResults/", outputFile, result)) {
          ok = true;
View Full Code Here

    @Override
    public void add(final HttpResponse response) throws HttpClientException {
        final EXistTreeBuilder builder = new EXistTreeBuilder(context);
        response.outputResponseElement(builder);
        final DocumentImpl doc = builder.close();
        try {
            // we add the root *element* to the result sequence
            NodeTest kind = new TypeTest(Type.ELEMENT);
            // the elem must always be added at the front, so if there are
            // already other items, we create a new one, add the elem, then
            // add the original items after
            if(result.isEmpty()) {
                doc.selectChildren(kind, result);
            } else {
                final ValueSequence newResult = new ValueSequence();               
                doc.selectChildren(kind, newResult);
                newResult.addAll(result);
                result = newResult;
            }
        } catch (final XPathException xpe) {
            throw new HttpClientException("Unable to add HttpResponse to result:" + xpe.getMessage(), xpe);
View Full Code Here

            index.toSAX(adapter);
            adapter.endDocument();
        } catch (final SAXException e) {
            throw new XPathException(this, "Error caught while retrieving statistics: " + e.getMessage(), e);
        }
        final DocumentImpl doc = (DocumentImpl) adapter.getDocument();
        return (NodeImpl) doc.getFirstChild();
    }
View Full Code Here

        final XpathEngine xpathEngine = XMLUnit.newXpathEngine();
        final Map<String, String> namespaces = new HashMap<String, String>();
        namespaces.put("sm", "http://exist-db.org/xquery/securitymanager");
        xpathEngine.setNamespaceContext(new SimpleNamespaceContext(namespaces));

        final DocumentImpl resultDoc = (DocumentImpl)result.itemAt(0);

        final NodeList nlRealUsername = xpathEngine.getMatchingNodes("/sm:id/sm:real/sm:username", resultDoc);
        assertEquals(1, nlRealUsername.getLength());
        assertEquals(realUsername, nlRealUsername.item(0).getNodeValue());
View Full Code Here

        final XpathEngine xpathEngine = XMLUnit.newXpathEngine();
        final Map<String, String> namespaces = new HashMap<String, String>();
        namespaces.put("sm", "http://exist-db.org/xquery/securitymanager");
        xpathEngine.setNamespaceContext(new SimpleNamespaceContext(namespaces));

        final DocumentImpl resultDoc = (DocumentImpl)result.itemAt(0);

        final NodeList nlRealUsername = xpathEngine.getMatchingNodes("/sm:id/sm:real/sm:username", resultDoc);
        assertEquals(1, nlRealUsername.getLength());
        assertEquals(username, nlRealUsername.item(0).getNodeValue());
View Full Code Here

TOP

Related Classes of org.exist.memtree.DocumentImpl

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.