Package org.exist.memtree

Examples of org.exist.memtree.NodeImpl$SingleNodeIterator


            throw new XPathException(this,
                "Encountered SAX exception while processing document constructor: " +
                ExpressionDumper.dump(this));
        }
        context.popDocumentContext();
        final NodeImpl node =  builder.getDocument();
        if (context.getProfiler().isEnabled())
            {context.getProfiler().end(this, "", node);}
        return node;
    }
View Full Code Here


            {context.pushDocumentContext();}
        try {
            final MemTreeBuilder builder = context.getDocumentBuilder();
            context.proceed(this, builder);
            final int nodeNr = builder.characters(text);
            final NodeImpl node = builder.getDocument().getNode(nodeNr);
            return node;
        } finally {
            if (newDocumentContext)
                {context.popDocumentContext();}
        }
View Full Code Here

            } else {
                return (DocumentImpl) adapter.getDocument();
            }
        } else {
            final MemTreeBuilder builder = theContext.getDocumentBuilder();
            final NodeImpl result = Shared.writeReport(report, builder);
            throw new XPathException(this, ErrorCodes.FODC0006, ErrorCodes.FODC0006.getDescription() + ": " + report.toString(), result);
        }
    }
View Full Code Here

    public ExtendedXMLStreamReader getXMLStreamReader( NodeValue nv ) throws XMLStreamException, IOException
    {
        ExtendedXMLStreamReader reader;

        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

        for (final SequenceIterator i = varSeq.iterate(); i.hasNext();) {
            final ElementImpl variable = (ElementImpl) i.nextItem();
            // get the QName of the variable
            final ElementImpl qname = (ElementImpl) variable.getFirstChild(new NameTest(Type.ELEMENT, new QName("qname", Namespaces.EXIST_NS)));
            String localname = null, prefix = null, uri = null;
            NodeImpl child = (NodeImpl) qname.getFirstChild();
            while (child != null) {
                if ("localname".equals(child.getLocalName())) {
                    localname = child.getStringValue();

                } else if ("namespace".equals(child.getLocalName())) {
                    uri = child.getStringValue();

                } else if ("prefix".equals(child.getLocalName())) {
                    prefix = child.getStringValue();

                }
                child = (NodeImpl) child.getNextSibling();
            }

            if (uri != null && prefix != null) {
                context.declareNamespace(prefix, uri);
            }

            if (localname == null) {
                continue;
            }

            final QName q;
            if (prefix != null && localname != null) {
                q = new QName(localname, uri, prefix);
            } else {
                q = new QName(localname, uri, XMLConstants.DEFAULT_NS_PREFIX);
            }

            // get serialized sequence
            final NodeImpl value = variable.getFirstChild(new NameTest(Type.ELEMENT, Marshaller.ROOT_ELEMENT_QNAME));
            final Sequence sequence;
            try {
                sequence = value == null ? Sequence.EMPTY_SEQUENCE : Marshaller.demarshall(value);
            } catch (final XMLStreamException xe) {
                throw new XPathException(xe.toString());
View Full Code Here

            result.add(new BooleanValue(report.isValid()));
            return result;

        } else  /* isCalledAs("validate-report") || isCalledAs("jing-report") */{
            final MemTreeBuilder builder = context.getDocumentBuilder();
            final NodeImpl result = Shared.writeReport(report, builder);
            return result;

        }
    }
View Full Code Here

            result.add(new BooleanValue(report.isValid()));
            return result;

        } else /* isCalledAs("jaxv-report") */ {
            final MemTreeBuilder builder = context.getDocumentBuilder();
            final NodeImpl result = Shared.writeReport(report, builder);
            return result;
        }
    }
View Full Code Here

       
        if (report.isValid())
          {return (DocumentImpl) adapter.getDocument();}
        else {
          final MemTreeBuilder builder = context.getDocumentBuilder();
            final NodeImpl result = Shared.writeReport(report, builder);
        throw new XPathException(this, ErrorCodes.EXXQDY0002, report.toString(), result);
        }
    }
View Full Code Here

            return result;
           
           
        } else if (isCalledAs("show-grammar-cache")){
            final MemTreeBuilder builder = context.getDocumentBuilder();
            final NodeImpl result = writeReport(grammarpool, builder);
            return result;
           
        } else if (isCalledAs("pre-parse-grammar")){
           
            if (args[0].isEmpty())
                {return Sequence.EMPTY_SEQUENCE;}
           
            // Setup for XML schema support only
            final XMLGrammarPreparser parser = new XMLGrammarPreparser();
            parser.registerPreparser(TYPE_XSD , null);
           
          
            final List<Grammar> allGrammars = new ArrayList<Grammar>();
           
             // iterate through the argument sequence and parse url
            for (final SequenceIterator i = args[0].iterate(); i.hasNext();) {
                String url = i.nextItem().getStringValue();
               
                // Fix database urls
                if(url.startsWith("/")){
                    url="xmldb:exist://"+url;
                }
              
                LOG.debug("Parsing "+url);
               
                // parse XSD grammar
                try {
                    if(url.endsWith(".xsd")){
                       
                        final InputStream is = new URL(url).openStream();
                        final XMLInputSource xis = new XMLInputSource(null, url, url, is, null);
                        final Grammar schema = parser.preparseGrammar(TYPE_XSD, xis);
                        is.close();

                        allGrammars.add(schema);

                    } else {
                        throw new XPathException(this, "Only XMLSchemas can be preparsed.");
                    }

                } catch(final IOException ex) {
                    LOG.debug(ex);
                    throw new XPathException(this, ex);
                   
                } catch(final Exception ex) {
                    LOG.debug(ex);
                    throw new XPathException(this, ex);
                }
               
               
            }

            LOG.debug("Successfully parsed "+allGrammars.size()+" grammars.");
           
            // Send all XSD grammars to grammarpool
            Grammar grammars[] = new Grammar[allGrammars.size()];
            grammars = allGrammars.toArray(grammars);
            grammarpool.cacheGrammars(TYPE_XSD, grammars);
            // Construct result to end user
            final ValueSequence result = new ValueSequence();
            for(final Grammar one : grammars){
                result.add( new StringValue(one.getGrammarDescription().getNamespace()) );
            }
           

            return result;
           
View Full Code Here

                return ((DocumentImpl) instanceBuilder.getDocument()).getNode(0);

            } else {

                final MemTreeBuilder builder = context.getDocumentBuilder();
                final NodeImpl result = Shared.writeReport(report, builder);
                return result;
            }

        }
    }
View Full Code Here

TOP

Related Classes of org.exist.memtree.NodeImpl$SingleNodeIterator

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.