Re: SVGSerializer patch
On 24.11.2003 11:25, Borges Charles wrote: I think that in cocoon 2.1.3 the sitemap parameters are not available for serializers. They're always set to empty parameters when the SitemapModelComponent is a Serializer. Is that correct? It is correct that... you found a bug :-/ The sitemap engine wasn't updated to take into account the ability for serializers to implement SitemapModelComponent. I just fixed it in the CVS. Sylvain Given this bug fix, i propose a SVGSerializer patch which support sitemap parameters (see attached files). Your help is much appreciated. Please add the bug to bugzilla, so it won't get lost. Thanks. Joerg
Re: SVGSerializer patch
> >I think that in cocoon 2.1.3 the sitemap parameters > are not available for serializers. They're always > set to empty parameters when the > SitemapModelComponent is a Serializer. > >Is that correct? > > > > > > It is correct that... you found a bug :-/ > > The sitemap engine wasn't updated to take into > account the ability for > serializers to implement SitemapModelComponent. > > I just fixed it in the CVS. > > Sylvain > Given this bug fix, i propose a SVGSerializer patch which support sitemap parameters (see attached files). Thus, 1. in the serializer configuration you define the transcoding hints which can be overriden by the sitemap parameters, say: 2. Override in a serialize node: Charles ___ Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français ! Yahoo! Mail : http://fr.mail.yahoo.comIndex: SVGSerializer.java === RCS file: /home/cvspublic/cocoon-2.1/src/blocks/batik/java/org/apache/cocoon/serialization/SVGSerializer.java,v retrieving revision 1.9 diff -u -r1.9 SVGSerializer.java --- SVGSerializer.java 9 Oct 2003 15:26:54 - 1.9 +++ SVGSerializer.java 24 Nov 2003 10:17:39 - @@ -51,7 +51,13 @@ package org.apache.cocoon.serialization; import java.awt.Color; +import java.io.IOException; import java.io.OutputStream; +import java.io.Serializable; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; import org.apache.avalon.excalibur.pool.Poolable; import org.apache.avalon.framework.component.ComponentManager; @@ -62,18 +68,22 @@ import org.apache.avalon.framework.context.Context; import org.apache.avalon.framework.context.ContextException; import org.apache.avalon.framework.context.Contextualizable; +import org.apache.avalon.framework.parameters.Parameters; import org.apache.batik.transcoder.Transcoder; +import org.apache.batik.transcoder.TranscoderException; import org.apache.batik.transcoder.TranscoderInput; import org.apache.batik.transcoder.TranscoderOutput; import org.apache.batik.transcoder.TranscodingHints; -import org.apache.batik.transcoder.TranscoderException; import org.apache.batik.util.ParsedURL; import org.apache.cocoon.Constants; +import org.apache.cocoon.ProcessingException; import org.apache.cocoon.caching.CacheableProcessingComponent; import org.apache.cocoon.components.transcoder.ExtendableTranscoderFactory; import org.apache.cocoon.components.transcoder.TranscoderFactory; import org.apache.cocoon.components.url.ParsedContextURLProtocolHandler; import org.apache.cocoon.components.url.ParsedResourceURLProtocolHandler; +import org.apache.cocoon.environment.SourceResolver; +import org.apache.cocoon.sitemap.SitemapModelComponent; import org.apache.cocoon.util.ClassUtils; import org.apache.cocoon.xml.dom.SVGBuilder; import org.apache.excalibur.source.SourceValidity; @@ -89,7 +99,7 @@ * @version CVS $Id: SVGSerializer.java,v 1.9 2003/10/09 15:26:54 sylvain Exp $ */ public class SVGSerializer extends SVGBuilder -implements Composable, Serializer, Configurable, Poolable, CacheableProcessingComponent, Contextualizable { +implements Composable, Serializer, Configurable, Poolable, CacheableProcessingComponent, Contextualizable, SitemapModelComponent { /** * Get the context @@ -112,7 +122,22 @@ /** The Transcoder Factory to use */ TranscoderFactory factory = ExtendableTranscoderFactory.getTranscoderFactoryImplementation(); - + +/** The current caching key */ +private Serializable cachingKey; + +/** The default Batik TranscodingHints set up in configuration step */ +private TranscodingHints defaultTranscodingHints; + +/** The current Batik TranscodingHints can overrides the default one */ +private TranscodingHints currentTranscodingHints; + +/** The map holding information for the Batik TranscodingHints.Keys */ +private Map transcodingHintKeysInfo; + +/** Override default TranscodingHints with sitemap parameters? */ +private boolean overrideTranscodingHints = false; +private boolean _overrideTranscodingHints = false; /** * Set the OutputStream where the XML should be serialized. */ @@ -157,8 +182,10 @@ ); } -// Now run through the other parameters, using them as hints -// to the transcoder +// Now run through the other parameters, adding them to the +// default transcoding hints +defaultTranscodingHints = new TranscodingHints(); +transcodingHintKeysInfo = new HashMap(); for (int i = 0; i < parameters.length; i++ ) { String name = parameters[i].getAttribute("name"); // Skip over the parameters we've dealt with. Ensure this @@ -169,48 +196,93 @@ // Now try and get the hints out try { -// Turn it
Re: SVGSerializer patch
Borges Charles wrote: --- Vadim Gritsenko <[EMAIL PROTECTED]> a écrit : > Borges Charles wrote: Do you have an idea of how to do if you want to override parameters used to render an image like the indexed or quality parameters? Pass via sitemap parameters; passing it via request parameters does not look like a safe approach to me. Vadim I think that in cocoon 2.1.3 the sitemap parameters are not available for serializers. They're always set to empty parameters when the SitemapModelComponent is a Serializer. Is that correct? It is correct that... you found a bug :-/ The sitemap engine wasn't updated to take into account the ability for serializers to implement SitemapModelComponent. I just fixed it in the CVS. Sylvain -- Sylvain Wallez Anyware Technologies http://www.apache.org/~sylvain http://www.anyware-tech.com { XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects } Orixo, the opensource XML business alliance - http://www.orixo.com
Re: SVGSerializer patch
--- Vadim Gritsenko <[EMAIL PROTECTED]> a écrit : > Borges Charles wrote: > > >Do you have an idea of how to do if you want to > >override parameters used to render an image like > the > >indexed or quality parameters? > > > > > > Pass via sitemap parameters; passing it via request > parameters does not > look like a safe approach to me. > > Vadim > I think that in cocoon 2.1.3 the sitemap parameters are not available for serializers. They're always set to empty parameters when the SitemapModelComponent is a Serializer. Is that correct? Thanks. ___ Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français ! Yahoo! Mail : http://fr.mail.yahoo.com
Re: SVGSerializer patch
Borges Charles wrote: Do you have an idea of how to do if you want to override parameters used to render an image like the indexed or quality parameters? Pass via sitemap parameters; passing it via request parameters does not look like a safe approach to me. Vadim
Re: SVGSerializer patch
--- Tony Collen <[EMAIL PROTECTED]> a écrit : > Vadim Gritsenko wrote: > > Borges Charles wrote: > > > >> Hi, > >> > >> Here's proposed SVGSerializer patch to support > request > >> parameters. > >> > >> > > ... > > > >> or > >> > samples/batik/batikLogo.png?width=200&height=100&indexed=2 > >> ... ugly! > >> > >> > > > > Or > > samples/batik/batikLogo.png?width=1000&height=1000 > > samples/batik/batikLogo.png?width=1000&height=1001 > > samples/batik/batikLogo.png?width=1000&height=1002 > > ... > > in the loop and your server is down. > > > > No, thank you, I'll pass on this particular > parameter! > > Shouldn't this be a concern of a transformer or the > generator, anyway, and not the serializer?? > > Just pass the request parameters to an XSLT to > change the svg height or width, then output the > image. > > Tony > I think this example with height and width wasn't a good choice. I agree with you, when it comes to change such parameters which are specified in the svg (height, width, background color...) it's wiser to go for an XSLT. Do you have an idea of how to do if you want to override parameters used to render an image like the indexed or quality parameters? Thanks ___ Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français ! Yahoo! Mail : http://fr.mail.yahoo.com
Re: SVGSerializer patch
Tony Collen wrote: Vadim Gritsenko wrote: Borges Charles wrote: Hi, Here's proposed SVGSerializer patch to support request parameters. ... or samples/batik/batikLogo.png?width=200&height=100&indexed=2 ... ugly! Or samples/batik/batikLogo.png?width=1000&height=1000 samples/batik/batikLogo.png?width=1000&height=1001 samples/batik/batikLogo.png?width=1000&height=1002 ... in the loop and your server is down. No, thank you, I'll pass on this particular parameter! Shouldn't this be a concern of a transformer or the generator, anyway, and not the serializer?? Just pass the request parameters to an XSLT to change the svg height or width, then output the image. Even better: pass via sitemap parameter (I like this way more :) Vadim
Re: SVGSerializer patch
Vadim Gritsenko wrote: Borges Charles wrote: Hi, Here's proposed SVGSerializer patch to support request parameters. ... or samples/batik/batikLogo.png?width=200&height=100&indexed=2 ... ugly! Or samples/batik/batikLogo.png?width=1000&height=1000 samples/batik/batikLogo.png?width=1000&height=1001 samples/batik/batikLogo.png?width=1000&height=1002 ... in the loop and your server is down. No, thank you, I'll pass on this particular parameter! Shouldn't this be a concern of a transformer or the generator, anyway, and not the serializer?? Just pass the request parameters to an XSLT to change the svg height or width, then output the image. Tony
Re: SVGSerializer patch
Borges Charles wrote: Hi, Here's proposed SVGSerializer patch to support request parameters. ... or samples/batik/batikLogo.png?width=200&height=100&indexed=2 ... ugly! Or samples/batik/batikLogo.png?width=1000&height=1000 samples/batik/batikLogo.png?width=1000&height=1001 samples/batik/batikLogo.png?width=1000&height=1002 ... in the loop and your server is down. No, thank you, I'll pass on this particular parameter! Vadim
Re: SVGSerializer patch
Borges Charles wrote: Hi, Here's proposed SVGSerializer patch to support request parameters. Thanks, but please file it into bugzilla -- Torsten