Package org.exist.util.serializer

Examples of org.exist.util.serializer.Receiver


                if (v.getImplementationType() == NodeValue.IN_MEMORY_NODE) {
                    ((NodeImpl)v).copyTo(context.getBroker(), docBuilder);
                } else {
                    NodeProxy p = (NodeProxy) v;
                    MatchListener ml = index.getMatchListener(context.getBroker(), p, matchCb);
                    Receiver receiver;
                    if (ml == null)
                        receiver = docBuilder;
                    else {
                        ml.setNextInChain(docBuilder);
                        receiver = ml;
View Full Code Here


        final MemTreeBuilder builder = context.getDocumentBuilder();
        final DocumentBuilderReceiver builderReceiver = new DocumentBuilderReceiver(builder, true);
        final SAXResult result = new SAXResult(builderReceiver);
        result.setLexicalHandler(builderReceiver);    //preserve comments etc... from xslt output
        handler.setResult(result);
            final Receiver receiver = new ReceiverToSAX(handler);
            final Serializer serializer = context.getBroker().getSerializer();
            serializer.reset();
            try {
                serializer.setProperties(serializationProps);
                serializer.setReceiver(receiver, true);
                if (expandXIncludes) {
                    String xipath = serializationProps.getProperty(EXistOutputKeys.XINCLUDE_PATH);
                    if (xipath != null) {
                        final File f = new File(xipath);
                        if (!f.isAbsolute())
                            {xipath = new File(context.getModuleLoadPath(), xipath).getAbsolutePath();}
                    } else
                        {xipath = context.getModuleLoadPath();}
                    serializer.getXIncludeFilter().setModuleLoadPath(xipath);
                }
          serializer.toSAX(inputNode, 1, inputNode.getItemCount(), false, false);
        } catch (final Exception e) {
          throw new XPathException(this, "Exception while transforming node: " + e.getMessage(), e);
        }
            errorListener.checkForErrors();
        Node next = builder.getDocument().getFirstChild();
            while (next != null) {
                seq.add((NodeValue) next);
                next = next.getNextSibling();
            }
        context.popDocumentContext();
        return seq;
          }
        }
        else
        {
          //transform:stream-transform()
         
            final ResponseModule myModule = (ResponseModule)context.getModule(ResponseModule.NAMESPACE_URI);
            // response object is read from global variable $response
            final Variable respVar = myModule.resolveVariable(ResponseModule.RESPONSE_VAR);
            if(respVar == null)
                {throw new XPathException(this, "No response object found in the current XQuery context.");}
            if(respVar.getValue().getItemType() != Type.JAVA_OBJECT)
                {throw new XPathException(this, "Variable $response is not bound to an Java object.");}
            final JavaObjectValue respValue = (JavaObjectValue)
                respVar.getValue().itemAt(0);
            if (!"org.exist.http.servlets.HttpResponseWrapper".equals(respValue.getObject().getClass().getName()))
                {throw new XPathException(this, signatures[1].toString() +
                        " can only be used within the EXistServlet or XQueryServlet");}
            final ResponseWrapper response = (ResponseWrapper) respValue.getObject();
           
            //setup the response correctly
            final String mediaType = handler.getTransformer().getOutputProperty("media-type");
            final String encoding = handler.getTransformer().getOutputProperty("encoding");
            if(mediaType != null)
            {
              if(encoding == null)
              {
                response.setContentType(mediaType);
              }
              else
              {
                response.setContentType(mediaType + "; charset=" + encoding);
              }
            }
           
            //do the transformation
            try {
                final OutputStream os = new BufferedOutputStream(response.getOutputStream());
                final StreamResult result = new StreamResult(os);
                handler.setResult(result);
                final Serializer serializer = context.getBroker().getSerializer();
                serializer.reset();
                Receiver receiver = new ReceiverToSAX(handler);
                try {
                    serializer.setProperties(serializationProps);
                    if (expandXIncludes) {
                        XIncludeFilter xinclude = new XIncludeFilter(serializer, receiver);
                        String xipath = serializationProps.getProperty(EXistOutputKeys.XINCLUDE_PATH);
View Full Code Here

            handler.setResult(result);
           
            final Serializer serializer = broker.getSerializer();
            serializer.reset();
           
            Receiver receiver = new ReceiverToSAX(handler);
            try {
                XIncludeFilter xinclude = new XIncludeFilter(serializer, receiver);
                receiver = xinclude;
                String moduleLoadPath;
View Full Code Here

        return nextListener;
    }

    @Override
    public Receiver getLastInChain() {
        Receiver last = this, next = getNextInChain();
        while (next != null) {
            last = next;
            next = ((MatchListener)next).getNextInChain();
        }
        return last;
View Full Code Here

            receiver = customMatchListeners.getFirst();
        }
    }

    protected Receiver setupMatchListeners(NodeProxy p) {
        final Receiver oldReceiver = receiver;
        if (getHighlightingMode() != TAG_NONE) {
            final IndexController controller = broker.getIndexController();
            MatchListener listener = controller.getMatchListener(p);
            if (listener != null) {
                final MatchListener last = (MatchListener) listener.getLastInChain();
View Full Code Here

                factory.setURIResolver(
                        new InternalURIResolver(xsl.getCollection().getURI().toString()));
            }

            // save handlers
            Receiver oldReceiver = receiver;

            // compile stylesheet
            factory.setErrorListener(new ErrorListener());
            final TemplatesHandler handler = factory.newTemplatesHandler();
            receiver = new ReceiverToSAX(handler);
View Full Code Here

    public void toReceiver(NodeProxy p, boolean highlightMatches) throws SAXException {
        toReceiver(p, highlightMatches, true);
    }

    public void toReceiver(NodeProxy p, boolean highlightMatches, boolean checkAttributes) throws SAXException {
        Receiver oldReceiver = highlightMatches ? setupMatchListeners(p) : receiver;
        serializeToReceiver(p, false, checkAttributes);
        receiver = oldReceiver;
    }
View Full Code Here

TOP

Related Classes of org.exist.util.serializer.Receiver

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.