cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Carsten Ziegeler" <cziege...@sundn.de>
Subject AW: cvs commit: xml-cocoon2/src/org/apache/cocoon/sitemap Manager.java
Date Wed, 05 Sep 2001 07:05:07 GMT
Thanks for this help, Vadim!

The contract of the Source (ModifiableSource) object states,
that it must be refreshed between two calls to getInputStream().
So I added a refresh() call to the xslt processor and fixed it.

Carsten

> -----Ursprungliche Nachricht-----
> Von: Vadim Gritsenko [mailto:vgritsenko@hns.com]
> Gesendet: Dienstag, 4. September 2001 18:20
> An: cocoon-dev@xml.apache.org
> Betreff: RE: cvs commit: xml-cocoon2/src/org/apache/cocoon/sitemap
> Manager.java
>
>
> Carsten,
>
> This problem happens because toSAX is called twice, from:
>
> java.lang.Exception: In toSAX
>         at
> org.apache.cocoon.components.source.SitemapSource.toSAX(SitemapSou
> rce.java:288)
>         at
> org.apache.cocoon.components.source.SitemapSource.getInputStream(S
> itemapSource.java:183)
>         at
> org.apache.cocoon.components.source.SitemapSource.getInputSource(S
> itemapSource.java:275)
>         at
> org.apache.cocoon.components.xslt.XSLTProcessorImpl.getTemplates(X
> SLTProcessorImpl.java:239)
>         at
> org.apache.cocoon.components.xslt.XSLTProcessorImpl.getTransformer
> Handler(XSLTProcessorImpl.java:118)
>         at
> org.apache.cocoon.components.xslt.XSLTProcessorImpl.getTransformer
> Handler(XSLTProcessorImpl.java:110)
>         at
> org.apache.cocoon.transformation.TraxTransformer.setConsumer(TraxT
> ransformer.java:238)
>         at
> org.apache.cocoon.components.pipeline.CachingEventPipeline.connect
> Pipeline(CachingEventPipeline.java:356)
>         at
> org.apache.cocoon.components.pipeline.CachingEventPipeline.process
> (CachingEventPipeline.java:210)
>         at
> org.apache.cocoon.components.pipeline.CachingStreamPipeline.proces
> s(CachingStreamPipeline.java:364)
>         at
> org.apache.cocoon.www.sub.sitemap_xmap.wildcardMatchN4F(sitemap_xm
> ap.java:732)
>         at
> org.apache.cocoon.www.sub.sitemap_xmap.process(sitemap_xmap.java:381)
>         at
> org.apache.cocoon.www.sub.sitemap_xmap.process(sitemap_xmap.java:323)
>         at org.apache.cocoon.sitemap.Handler.process(Handler.java:163)
>         at org.apache.cocoon.sitemap.Manager.invoke(Manager.java:115)
>         at
> org.apache.cocoon.www.sitemap_xmap.wildcardMatchN226(sitemap_xmap.
> java:2908)
>         at
> org.apache.cocoon.www.sitemap_xmap.process(sitemap_xmap.java:2283)
>         at
> org.apache.cocoon.www.sitemap_xmap.process(sitemap_xmap.java:2191)
>         at org.apache.cocoon.sitemap.Handler.process(Handler.java:163)
>         at org.apache.cocoon.sitemap.Manager.invoke(Manager.java:115)
>         at org.apache.cocoon.Cocoon.process(Cocoon.java:466)
>
> And from:
>
> java.lang.Exception: In toSAX
>         at
> org.apache.cocoon.components.source.SitemapSource.toSAX(SitemapSou
> rce.java:288)
>         at
> org.apache.cocoon.components.source.SitemapSource.getInputStream(S
> itemapSource.java:183)
>         at
> org.apache.cocoon.components.source.SitemapSource.getInputSource(S
> itemapSource.java:275)
>         at
> org.apache.cocoon.components.xslt.XSLTProcessorImpl.getTransformer
> Handler(XSLTProcessorImpl.java:120)
>         at
> org.apache.cocoon.components.xslt.XSLTProcessorImpl.getTransformer
> Handler(XSLTProcessorImpl.java:110)
>         at
> org.apache.cocoon.transformation.TraxTransformer.setConsumer(TraxT
> ransformer.java:238)
>         at
> org.apache.cocoon.components.pipeline.CachingEventPipeline.connect
> Pipeline(CachingEventPipeline.java:356)
>         at
> org.apache.cocoon.components.pipeline.CachingEventPipeline.process
> (CachingEventPipeline.java:210)
>         at
> org.apache.cocoon.components.pipeline.CachingStreamPipeline.proces
> s(CachingStreamPipeline.java:364)
>         at
> org.apache.cocoon.www.sub.sitemap_xmap.wildcardMatchN4F(sitemap_xm
> ap.java:732)
>         at
> org.apache.cocoon.www.sub.sitemap_xmap.process(sitemap_xmap.java:381)
>         at
> org.apache.cocoon.www.sub.sitemap_xmap.process(sitemap_xmap.java:323)
>         at org.apache.cocoon.sitemap.Handler.process(Handler.java:163)
>         at org.apache.cocoon.sitemap.Manager.invoke(Manager.java:115)
>         at
> org.apache.cocoon.www.sitemap_xmap.wildcardMatchN226(sitemap_xmap.
> java:2908)
>         at
> org.apache.cocoon.www.sitemap_xmap.process(sitemap_xmap.java:2283)
>         at
> org.apache.cocoon.www.sitemap_xmap.process(sitemap_xmap.java:2191)
>         at org.apache.cocoon.sitemap.Handler.process(Handler.java:163)
>         at org.apache.cocoon.sitemap.Manager.invoke(Manager.java:115)
>         at org.apache.cocoon.Cocoon.process(Cocoon.java:466)
>
> Obviously, on second invocation eventPipeline == null ->
> NullPointerException is thrown in toSAX method.
>
> Proposed solution:
> After
>         if (this.exception != null) {
>             throw this.exception;
>         }
> Add
>         if (this.eventPipeline == null) {
>                 refresh();
>                 if (this.exception != null) {
>                       throw this.exception;
>                 }
>         }
>
> What do you think?
>
> PS: Not best solution: performance will suffer because of double
> sitemap processing
>
> Vadim
>
> > -----Original Message-----
> > From: Vadim Gritsenko [mailto:vgritsenko@hns.com]
> > Sent: Tuesday, September 04, 2001 11:57 AM
> > To: cocoon-dev@xml.apache.org
> > Subject: RE: cvs commit:
> xml-cocoon2/src/org/apache/cocoon/sitemap Manager.java
> >
> >
> > That's weird :-\
> > Why HTTP works and "cocoon:" does not?
> > <map:transform src="http://localhost:8080/cocoon/sub/xsl-source"/>
> >
> >
> > Vadim
> >
> > > -----Original Message-----
> > > From: Carsten Ziegeler [mailto:cziegeler@sundn.de]
> > > Sent: Tuesday, September 04, 2001 11:43 AM
> > > To: cocoon-dev@xml.apache.org
> > > Subject: AW: cvs commit:
> xml-cocoon2/src/org/apache/cocoon/sitemap Manager.java
> > >
> > >
> > > This is actually a different problem. If you look at the sub sitemap,
> > > there is the following entry:
> > > >>>
> > >    <map:match pattern="xsl-cocoon">
> > >     <map:generate src="docs/hello-page.xml"/>
> > >     <map:transform src="cocoon:/xsl-source"/>
> > >     <map:serialize/>
> > >    </map:match>
> > > <<<<
> > >
> > > Writing a test pipeline in the sub sitemap which reads (xml generator)
> > > "cocoon:/xsl-source" works perfectly. What is not working is that
> > > the current Xalan implementation complains about the input from
> > > that source.
> > >
> > > So cocoon: urls work but not as input for Xalan.
> > >
> > > Carsten
> > >
> > > > Vadim Gritsenko wrote:
> > > >
> > > > Nope, it does not...
> > > >
> > > > http://localhost:8080/cocoon/sub/xsl-cocoon
> > > >
> > > > java.lang.NullPointerException
> > > > 	at
> > > > org.apache.cocoon.components.source.SitemapSource.toSAX(SitemapSou
> > > > rce.java:296)
> > > > 	at
> > > > org.apache.cocoon.components.source.SitemapSource.getInputStream(S
> > > > itemapSource.java:183)
> > > > 	at
> > > > org.apache.cocoon.components.source.SitemapSource.getInputSource(S
> > > > itemapSource.java:273)
> > > > 	at
> > > > org.apache.cocoon.components.xslt.XSLTProcessorImpl.getTransformer
> > > > Handler(XSLTProcessorImpl.java:120)
> > > > 	at
> > > > org.apache.cocoon.components.xslt.XSLTProcessorImpl.getTransformer
> > > > Handler(XSLTProcessorImpl.java:110)
> > > > 	at
> > > > org.apache.cocoon.transformation.TraxTransformer.setConsumer(TraxT
> > > > ransformer.java:238)
> > > > 	at
> > > > org.apache.cocoon.components.pipeline.CachingEventPipeline.connect
> > > > Pipeline(CachingEventPipeline.java:356)
> > > > 	at
> > > > org.apache.cocoon.components.pipeline.CachingEventPipeline.process
> > > > (CachingEventPipeline.java:210)
> > > > 	at
> > > > org.apache.cocoon.components.pipeline.CachingStreamPipeline.proces
> > > > s(CachingStreamPipeline.java:364)
> > > > 	at
> > > > org.apache.cocoon.www.sub.sitemap_xmap.wildcardMatchN4F(sitemap_xm
> > > > ap.java:732)
> > > > 	at
> > > >
> org.apache.cocoon.www.sub.sitemap_xmap.process(sitemap_xmap.java:381)
> > > > 	at
> > > >
> org.apache.cocoon.www.sub.sitemap_xmap.process(sitemap_xmap.java:323)
> > > > 	at
> org.apache.cocoon.sitemap.Handler.process(Handler.java:163)
> > > > 	at
> org.apache.cocoon.sitemap.Manager.invoke(Manager.java:115)
> > > > 	at
> > > > org.apache.cocoon.www.sitemap_xmap.wildcardMatchN226(sitemap_xmap.
> > > > java:2902)
> > > > 	at
> > > > org.apache.cocoon.www.sitemap_xmap.process(sitemap_xmap.java:2283)
> > > > 	at
> > > > org.apache.cocoon.www.sitemap_xmap.process(sitemap_xmap.java:2191)
> > > > 	at
> org.apache.cocoon.sitemap.Handler.process(Handler.java:163)
> > > > 	at
> org.apache.cocoon.sitemap.Manager.invoke(Manager.java:115)
> > > > 	at org.apache.cocoon.Cocoon.process(Cocoon.java:466)
> > > > 	at
> > > >
> org.apache.cocoon.servlet.CocoonServlet.service(CocoonServlet.java:532)
> > > > 	at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> > > >             ............
> > > >
> > > > Vadim
> > > >
> > > > > -----Original Message-----
> > > > > From: Davanum Srinivas [mailto:dims@yahoo.com]
> > > > > Sent: Tuesday, September 04, 2001 10:59 AM
> > > > > To: cocoon-dev@xml.apache.org
> > > > > Subject: Re: cvs commit:
> > > > xml-cocoon2/src/org/apache/cocoon/sitemap Manager.java
> > > > >
> > > > >
> > > > > Confirmed. Thanks Carsten. It works!!!
> > > > >
> > > > > -- dims
> > > > >
> > > > > --- cziegeler@apache.org wrote:
> > > > > > cziegeler    01/09/04 07:44:13
> > > > > >
> > > > > >   Modified:    src/org/apache/cocoon/components/source
> > > > SitemapSource.java
> > > > > >                src/org/apache/cocoon/environment
> > > > AbstractEnvironment.java
> > > > > >                src/org/apache/cocoon/environment/wrapper
> > > > > >                         EnvironmentWrapper.java
> > > > > >                src/org/apache/cocoon/sitemap Manager.java
> > > > > >   Log:
> > > > > >   Fixed proper handling of cocoon: urls
> > > > > >
> > > > > >   Revision  Changes    Path
> > > > > >   1.18      +5 -7
> > > >
> xml-cocoon2/src/org/apache/cocoon/components/source/SitemapSource.java
> > > > > >
> > > > > >   Index: SitemapSource.java
> > > > > >
> ===================================================================
> > > > > >   RCS file:
> > > > /home/cvs/xml-cocoon2/src/org/apache/cocoon/components/source/Site
> > > > mapSource.java,v
> > > > > >   retrieving revision 1.17
> > > > > >   retrieving revision 1.18
> > > > > >   diff -u -r1.17 -r1.18
> > > > > >   --- SitemapSource.java	2001/08/25 19:40:32	1.17
> > > > > >   +++ SitemapSource.java	2001/09/04 14:44:12	1.18
> > > > > >   @@ -3,7 +3,7 @@
> > > > > >     *
> > > > ------------------------------------------------------------------
> > > > ------- *
> > > > > >     * This software is published under the terms of the
> > > > Apache Software License *
> > > > > >     * version 1.1, a copy of which has been included  with
> > > > this distribution in *
> > > > > >   - * the LICENSE file.
> > > >                   *
> > > > > >   + * the LICENSE file.                               s
> > > >                    *
> > > > > >
> > > > ******************************************************************
> > > > ***********/
> > > > > >
> > > > > >    package org.apache.cocoon.components.source;
> > > > > >   @@ -47,7 +47,7 @@
> > > > > >     * Description of a source which is defined by a pipeline.
> > > > > >     *
> > > > > >     * @author <a href="mailto:cziegeler@apache.org">Carsten
> > > > Ziegeler</a>
> > > > > >   - * @version CVS $Revision: 1.17 $ $Date: 2001/08/25
> 19:40:32 $
> > > > > >   + * @version CVS $Revision: 1.18 $ $Date: 2001/09/04
> 14:44:12 $
> > > > > >     */
> > > > > >
> > > > > >    public final class SitemapSource
> > > > > >   @@ -98,7 +98,7 @@
> > > > > >        throws IOException, ProcessingException {
> > > > > >
> > > > > >            this.manager = manager;
> > > > > >   -
> > > > > >   +        this.setLogger(logger);
> > > > > >            // remove the protocol
> > > > > >            int protocolEnd = uri.indexOf(':');
> > > > > >            if (protocolEnd != -1) {
> > > > > >   @@ -143,7 +143,6 @@
> > > > > >                uri = uri.substring(0, queryStringPos);
> > > > > >            }
> > > > > >            this.uri = uri;
> > > > > >   -        this.environment.setURI(this.prefix, this.uri);
> > > > > >            this.refresh();
> > > > > >        }
> > > > > >
> > > > > >   @@ -234,11 +233,11 @@
> > > > > >                ((XMLProducer)eventPipeline).setConsumer(this);
> > > > > >
> > > > > >                this.environment.setURI(this.prefix, this.uri);
> > > > > >   -                this.processor.process(this.environment,
> > > > pipeline, eventPipeline);
> > > > > >   +            this.processor.process(this.environment,
> > > > pipeline, eventPipeline);
> > > > > >   +            this.environment.changeToLastContext();
> > > > > >                    String redirectURL =
> > > > this.environment.getRedirectURL();
> > > > > >                    if (redirectURL == null) {
> > > > > >                        if (this.eventPipeline instanceof
> > > > CacheableEventPipeline) {
> > > > > >   -
> this.environment.setURI(this.prefix, this.uri);
> > > > > >                            CacheableEventPipeline cep =
> > > > > > (CacheableEventPipeline)this.eventPipeline;
> > > > > >                            PipelineCacheKey pck =
> > > > cep.generateKey(this.environment);
> > > > > >                            Map validity = null;
> > > > > >   @@ -288,7 +287,6 @@
> > > > > >                if (this.redirectSource != null) {
> > > > > >                    this.redirectSource.toSAX(consumer);
> > > > > >                } else {
> > > > > >   -                this.environment.setURI(this.prefix,
> this.uri);
> > > > > >
> ((XMLProducer)eventPipeline).setConsumer(consumer);
> > > > > >                    eventPipeline.process(this.environment);
> > > > > >                }
> > > > > >
> > > > > >
> > > > > >
> > > > > >   1.19      +1 -9
> > > >
> xml-cocoon2/src/org/apache/cocoon/environment/AbstractEnvironment.java
> > > > > >
> > > > > >   Index: AbstractEnvironment.java
> > > > > >
> ===================================================================
> > > > > >   RCS file:
> > > > /home/cvs/xml-cocoon2/src/org/apache/cocoon/environment/AbstractEn
> > > > vironment.java,v
> > > > > >   retrieving revision 1.18
> > > > > >   retrieving revision 1.19
> > > > > >   diff -u -r1.18 -r1.19
> > > > > >   --- AbstractEnvironment.java	2001/08/30 15:17:03	1.18
> > > > > >   +++ AbstractEnvironment.java	2001/09/04 14:44:12	1.19
> > > > > >   @@ -24,7 +24,7 @@
> > > > > >     *
> > > > > >     * @author <a
> href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
> > > > > >     * @author <a href="mailto:cziegeler@apache.org">Carsten
> > > > Ziegeler</a>
> > > > > >   - * @version CVS $Revision: 1.18 $ $Date: 2001/08/30
> 15:17:03 $
> > > > > >   + * @version CVS $Revision: 1.19 $ $Date: 2001/09/04
> 14:44:12 $
> > > > > >     */
> > > > > >    public abstract class AbstractEnvironment extends
> > > > AbstractLoggable implements Environment {
> > > > > >
> > > > > >   @@ -118,14 +118,6 @@
> > > > > >         */
> > > > > >        public String getURI() {
> > > > > >            return this.uris;
> > > > > >   -    }
> > > > > >   -
> > > > > >   -    /**
> > > > > >   -     * Set the uri in progress. The prefix is stripped off
> > > > > >   -     */
> > > > > >   -    public void setURI(String uris) {
> > > > > >   -        getLogger().debug("Set the URIs (OLD=" + this.uris
> > > > + ", NEW=" + uris + ")");
> > > > > >   -        this.uris = uris;
> > > > > >        }
> > > > > >
> > > > > >        /**
> > > > > >
> > > > > >
> > > > > >
> > > > > >   1.9       +31 -2
> > > > > >
> > > > xml-cocoon2/src/org/apache/cocoon/environment/wrapper/EnvironmentW
> > > > rapper.java
> > > > > >
> > > > > >   Index: EnvironmentWrapper.java
> > > > > >
> ===================================================================
> > > > > >   RCS file:
> > > > > >
> > > > /home/cvs/xml-cocoon2/src/org/apache/cocoon/environment/wrapper/En
> > > > vironmentWrapper.java,v
> > > > > >   retrieving revision 1.8
> > > > > >   retrieving revision 1.9
> > > > > >   diff -u -r1.8 -r1.9
> > > > > >   --- EnvironmentWrapper.java	2001/08/30 15:17:03	1.8
> > > > > >   +++ EnvironmentWrapper.java	2001/09/04 14:44:12	1.9
> > > > > >   @@ -18,6 +18,7 @@
> > > > > >    import java.io.IOException;
> > > > > >    import java.io.OutputStream;
> > > > > >    import java.net.MalformedURLException;
> > > > > >   +import java.net.URL;
> > > > > >    import java.util.HashMap;
> > > > > >    import java.util.Iterator;
> > > > > >    import java.util.Map;
> > > > > >   @@ -29,7 +30,7 @@
> > > > > >     * contains a <code>RequestWrapper</code> object.
> > > > > >     *
> > > > > >     * @author <a href="mailto:cziegeler@apache.org">Carsten
> > > > Ziegeler</a>
> > > > > >   - * @version $Id: EnvironmentWrapper.java,v 1.8 2001/08/30
> > > > 15:17:03 dims Exp $
> > > > > >   + * @version $Id: EnvironmentWrapper.java,v 1.9 2001/09/04
> > > > 14:44:12 cziegeler Exp $
> > > > > >     */
> > > > > >    public final class EnvironmentWrapper
> > > > > >    extends AbstractEnvironment
> > > > > >   @@ -47,6 +48,13 @@
> > > > > >        /** The request object */
> > > > > >        private Request request;
> > > > > >
> > > > > >   +    /** The last context */
> > > > > >   +    private URL lastContext;
> > > > > >   +    /** The last prefix */
> > > > > >   +    private String lastPrefix;
> > > > > >   +    /** The last uri */
> > > > > >   +    private String lastURI;
> > > > > >   +
> > > > > >        /**
> > > > > >         * Constructs an EnvironmentWrapper object from a Request
> > > > > >         * and Response objects
> > > > > >   @@ -154,11 +162,32 @@
> > > > > >         * context and the prefix is set.
> > > > > >         */
> > > > > >        public void setURI(String prefix, String uris) {
> > > > > >   +        getLogger().debug("Setting uri (prefix=" + prefix
> > > > + ", uris=" + uris + ")");
> > > > > >            if (prefix != null) {
> > > > > >                setContext(getRootContext());
> > > > > >                setURIPrefix(prefix);
> > > > > >            }
> > > > > >   -        setURI(uris);
> > > > > >   +        this.uris = uris;
> > > > > >   +        this.lastURI = uris;
> > > > > >   +        this.lastContext = this.context;
> > > > > >   +        this.lastPrefix = this.prefix.toString();
> > > > > >   +    }
> > > > > >   +
> > > > > >   +    public void changeContext(String prefix, String context)
> > > > > >   +    throws MalformedURLException {
> > > > > >   +        super.changeContext(prefix, context);
> > > > > >   +        this.lastContext = this.context;
> > > > > >   +        this.lastPrefix  = this.prefix.toString();
> > > > > >   +        this.lastURI     = this.uris;
> > > > > >   +    }
> > > > > >   +
> > > > > >   +    /**
> > > > > >   +     * Change the current context to the last one set by
> > > > changeContext()
> > > > > >   +     */
> > > > > >   +    public void changeToLastContext() {
> > > > > >   +        this.setContext(this.lastContext);
> > > > > >   +        this.setURIPrefix(this.lastPrefix);
> > > > > >   +        this.uris = this.lastURI;
> > > > > >        }
> > > > > >    }
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >   1.14      +3 -3
> > > > xml-cocoon2/src/org/apache/cocoon/sitemap/Manager.java
> > > > > >
> > > > > >
> > > > > === message truncated ===
> > > > >
> > > > >
> > > > > =====
> > > > > Davanum Srinivas, JNI-FAQ Manager
> > > > > http://www.jGuru.com/faq/JNI
> > > > >
> > > > > __________________________________________________
> > > > > Do You Yahoo!?
> > > > > Get email alerts & NEW webcam video instant messaging with
> > > > Yahoo! Messenger
> > > > > http://im.yahoo.com
> > > > >
> > > > >
> ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
> > > > > For additional commands, email: cocoon-dev-help@xml.apache.org
> > > > >
> > > >
> > > >
> ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
> > > > For additional commands, email: cocoon-dev-help@xml.apache.org
> > > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
> > > For additional commands, email: cocoon-dev-help@xml.apache.org
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
> > For additional commands, email: cocoon-dev-help@xml.apache.org
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
> For additional commands, email: cocoon-dev-help@xml.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Mime
View raw message