Package org.apache.cocoon.components.sax

Examples of org.apache.cocoon.components.sax.XMLDeserializer


    }

    public void generateSAXFragment(Object fragment, boolean embed) throws SAXException {

        if (fragment!=null) {
            XMLDeserializer deserializer = null;

            try {
                deserializer = (XMLDeserializer) this.manager.lookup(XMLDeserializer.ROLE);
                if (embed)
                    deserializer.setConsumer(new IncludeXMLConsumer(this.xmlConsumer));
                else
                    deserializer.setConsumer(this.xmlConsumer);
                deserializer.deserialize(fragment);
            } catch (ServiceException ce) {
                getLogger().debug("Could not retrieve XMLDeserializer component",
                                  ce);
                throw new SAXException("Could not retrieve XMLDeserializer component",
                                       ce);
View Full Code Here


            } finally {
                this.manager.release( serializer );
            }
           
            if ( read ) {
                XMLDeserializer deserializer = null;
                try {
                    deserializer = (XMLDeserializer)this.manager.lookup(XMLDeserializer.ROLE);
                    if ( contentHandler instanceof XMLConsumer ) {
                        deserializer.setConsumer( (XMLConsumer)contentHandler );
                    } else {
                        LexicalHandler lh = (contentHandler instanceof LexicalHandler ? (LexicalHandler)contentHandler : null);
                        deserializer.setConsumernew ContentHandlerWrapper(contentHandler, lh));
                    }
                    deserializer.deserialize( data );
                } catch (ComponentException ce) {
                    throw new SAXException("Unable to lookup xml deserializer.", ce);
                } finally {
                    this.manager.release( deserializer );
                }
View Full Code Here

            ComponentSelector tagSelector = (ComponentSelector) tagSelectorStack.pop();
            try {
                if (saxFragment != null) {
                    //start Iteration
                    IterationTag iterTag = (IterationTag) tag;
                    XMLDeserializer xmlDeserializer = null;
                    try {
                        xmlDeserializer = (XMLDeserializer) manager.lookup(XMLDeserializer.ROLE);
                        xmlDeserializer.setConsumer(this);
                        do {
                            xmlDeserializer.deserialize(saxFragment);
                        } while (iterTag.doAfterBody() != Tag.SKIP_BODY);

                    } catch (ComponentException e) {
                        throw new SAXException("lookup XMLDeserializer failed", e);
                    }
View Full Code Here

    /* (non-Javadoc)
     * @see org.apache.excalibur.xml.sax.XMLizable#toSAX(org.xml.sax.ContentHandler)
     */
    public void toSAX(ContentHandler contentHandler) throws SAXException {
       XMLDeserializer deserializer = null;
       try {
           deserializer = (XMLDeserializer) this.manager.lookup(XMLDeserializer.ROLE);
           if ( contentHandler instanceof XMLConsumer) {
               deserializer.setConsumer((XMLConsumer)contentHandler);
           } else {
               deserializer.setConsumer(new ContentHandlerWrapper(contentHandler));
           }
           deserializer.deserialize( this.cachedResponse.getAlternativeResponse() );
       } catch (ComponentException ce ) {
           throw new SAXException("Unable to lookup xml deserializer.", ce);
       } finally {
           this.manager.release(deserializer);
       }
View Full Code Here

    public void generate() throws SAXException {
        // Obtain the fragmentID  (which is simply the filename portion of the source)
        getLogger().debug("FragmentExtractorGenerator retrieving document " + source + ".");

        Store store = null;
        XMLDeserializer deserializer = null;
        Object fragment = null;
        try {
            store = (Store) this.manager.lookup(Store.TRANSIENT_STORE);
            fragment = store.get(source);

            if (fragment==null)
              throw new SAXException("Could not find frament with id " + source + " in store");

            deserializer = (XMLDeserializer) this.manager.lookup(XMLDeserializer.ROLE);
            deserializer.setConsumer(this.xmlConsumer);
            deserializer.deserialize(fragment);

        } catch (ServiceException ce) {
            getLogger().error("Could not lookup for component.", ce);
            throw new SAXException("Could not lookup for component.", ce);
        } finally
View Full Code Here

                                              this.configurationParameters,
                                              this.resourceParameters,
                                              this.resolver);
                                             
                XMLSerializer serializer = null;
                XMLDeserializer deserializer = null;
                try {
                    if ( ignoreErrors ) {
                        serializer = (XMLSerializer) this.manager.lookup(XMLSerializer.ROLE);
                        deserializer = (XMLDeserializer)this.manager.lookup(XMLDeserializer.ROLE);
                        SourceUtil.toSAX(source, serializer, this.configurationParameters, true);
                        deserializer.setConsumer( this.xmlConsumer );
                        deserializer.deserialize( serializer.getSAXFragment() );
                    } else {
                        SourceUtil.toSAX(source, this.xmlConsumer, this.configurationParameters, true);
                    }
                } catch (ProcessingException pe) {
                    if (!ignoreErrors) throw pe;
View Full Code Here

     * @see org.xml.sax.ContentHandler#endDocument()
     */
    public void endDocument() throws SAXException {
        if ( this.compiling ) {
            Object compiledXML = this.endCompiledXMLRecording();
            XMLDeserializer deserializer = null;
            try {
                deserializer = (XMLDeserializer)this.manager.lookup(XMLDeserializer.ROLE);
                deserializer.setConsumer(this.filter);
                deserializer.deserialize(compiledXML);
            } catch (ComponentException ce) {
                throw new SAXException("Unable to lookup xml deserializer.", ce);
            } finally {
                this.manager.release( deserializer );
            }
View Full Code Here

                    fragment = xmls.getSAXFragment();
                } finally {
                    this.manager.release(xmls);
                    CocoonComponentManager.leaveEnvironment();
                }
                XMLDeserializer xmld = (XMLDeserializer) this.manager.lookup(XMLDeserializer.ROLE);
                try {
                    xmld.setConsumer(consumer);
                    xmld.deserialize(fragment);
                } finally {
                    this.manager.release(xmld);
                }
            }
        } catch (SAXException e) {
View Full Code Here

TOP

Related Classes of org.apache.cocoon.components.sax.XMLDeserializer

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.