Package org.apache.cocoon.xml

Examples of org.apache.cocoon.xml.SaxBuffer$StartDocument


            }
            this.buffers.addFirst(this.buffer);
        }
        locators.addFirst(locator);
        locator = new LocatorImpl(locator);
        this.buffer = new SaxBuffer();
    }
View Full Code Here


        locator = new LocatorImpl(locator);
        this.buffer = new SaxBuffer();
    }

    protected SaxBuffer endBuffer() {
        SaxBuffer buffer = this.buffer;
        if (this.buffers != null && this.buffers.size() > 0) {
            this.buffer = (SaxBuffer) this.buffers.removeFirst();
        } else {
            this.buffer = null;
        }
View Full Code Here

                if (name.startsWith(src)) {
                    cacheFound = true;
                    break;
                }
            }
            SaxBuffer saxBuffer;
            if (cacheFound) {
                saxBuffer = (SaxBuffer)request.getAttribute(name);
            } else {
                // Generate the usePerRequestCache and store in a request attribute.
                saxBuffer = new SaxBuffer();
                generateSaxFragmentFromSrc(saxBuffer, locale);
                String cacheID = (new UID()).toString();
                request.setAttribute(src + cacheID, saxBuffer);
            }
            // Output the stored saxBuffer to the contentHandler
            saxBuffer.toSAX(contentHandler);
        } else { // We don't use usePerRequestCache => re-read from the source.
            generateSaxFragmentFromSrc(contentHandler, locale);
        }
    }
View Full Code Here

                    this.xmlConsumer.endDocument();
                    return;
                }
                try {
                    InputSource is = new InputSource(new ByteArrayInputStream(content));
                    SaxBuffer buffer = new SaxBuffer();
                    parser.parse(is, buffer);
                    streamed = true;
                    buffer.toSAX(this.xmlConsumer);
                } catch (Exception ignore) {
                    // ignore
                }
            }
            if ( !streamed ) {
View Full Code Here

     */
    public static XMLizable compileElementContent(Element element) {
        // Remove location information
        LocationAttributes.remove(element, true);

        SaxBuffer saxBuffer = new SaxBuffer();
        DOMStreamer domStreamer = new DOMStreamer();
        domStreamer.setContentHandler(saxBuffer);

        NodeList childNodes = element.getChildNodes();
        for (int i = 0; i < childNodes.getLength(); i++) {
View Full Code Here

            bool = Boolean.TRUE;
        }
       
        if ( bool != null && bool.booleanValue() ) {
            boolean read = false;
            SaxBuffer buffer = new SaxBuffer();
            Exception error = null;
            try {
               
                if ( timeout != null ) {
                    final int milli = timeout.intValue() * 1000;
                    LoaderThread loader = new LoaderThread(this, coplet, buffer);
                    final RunnableManager runnableManager = (RunnableManager)this.manager.lookup( RunnableManager.ROLE );
                    try {
                        runnableManager.execute( new CocoonRunnable(loader) );
                    } finally {
                        this.manager.release( runnableManager );
                    }
                    try {
                        read = loader.join( milli );
                    } catch (InterruptedException ignore) {
                        // ignored
                    }
                    error = loader.exception;
                    if ( error != null && this.getLogger().isWarnEnabled() ) {
                        this.getLogger().warn("Unable to get content of coplet: " + coplet.getId(), error);                       
                    }
                } else {
                    this.streamContent( coplet, buffer );
                    read = true;
                }
            } catch (Exception exception ) {
                error = exception;
                this.getLogger().warn("Unable to get content of coplet: " + coplet.getId(), exception);
            }
           
            if ( read ) {
                buffer.toSAX( contentHandler );
            } else {
                if ( !this.renderErrorContent(coplet, contentHandler, error)) {
                    // FIXME - get correct error message
                    contentHandler.startDocument();
                    XMLUtils.startElement( contentHandler, "p");
View Full Code Here

        if (this.errorPipeline != null) {
            return this.errorPipeline.process(environment, consumer);
        }

        // Have to buffer events if error handler is specified.
        SaxBuffer buffer = null;
        this.lastConsumer = this.errorHandler == null? consumer: (buffer = new SaxBuffer());
        try {
            connectPipeline(environment);
            return processXMLPipeline(environment);
        } catch (ProcessingException e) {
            buffer = null;
            return processErrorHandler(environment, e, consumer);
        } finally {
            if (buffer != null) {
                try {
                    buffer.toSAX(consumer);
                } catch (SAXException e) {
                    throw new ProcessingException("Failed to execute pipeline.", e);
                }
            }
        }
View Full Code Here

                        xmlDeserializer.setConsumer(this);

                        // BodyTag Support
                        XMLConsumer backup = this.currentConsumer;
                        if (tag instanceof BodyTag) {
                            SaxBuffer content = new SaxBuffer();
                            this.currentConsumer = content;
                            ((BodyTag)tag).setBodyContent(new BodyContent(content, backup));
                            ((BodyTag)tag).doInitBody();
                        }
View Full Code Here

        /** Load URI into the provided handlers, process fallback */
        public void process(ContentHandler contentHandler, LexicalHandler lexicalHandler)
        throws SAXException {
            if (this.fallback != null) {
                SaxBuffer buffer = new SaxBuffer();
                process(buffer);
                buffer.toSAX(contentHandler);
            } else {
                process0(contentHandler, lexicalHandler);
            }
        }
View Full Code Here

                    if (element.fallback != null) {
                        throw new SAXException("Duplicate element " + FALLBACK_ELEMENT + ".");
                    }

                    /* Buffer fallback content */
                    push(element.fallback = new SaxBuffer());

                    /* Done with this element */
                    return;
                }

View Full Code Here

TOP

Related Classes of org.apache.cocoon.xml.SaxBuffer$StartDocument

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.