On Thu, 2002-03-28 at 09:47, Marc Johnson wrote: > >From: Rick Tessner <[EMAIL PROTECTED]> > > > >Hi all, > > > >I was just testing the refactored examples and noticed that the > >mime-type being returned on the Hello World XLS is vnd.ms-excel. > > I have no idea how the information in the sitemap would be made available to > the serializer; if anyone has a clue, I'd appreciate hearing it. In any > case, I'm not sure why the serializer would ever return anything besides > vnd.ms-excel or application/vnd.ms-excel
It seems that all that would be required would be to implement Configurable and create a configure() method. This is a guess based on how FOPSerializer and SVGSerializer do it. As to why, perhaps HSSFSerializer will be able to produce more that vnd.ms-excel in the future? I'm just basing this on what the FOP and SVG serializers do (eg. FOP produces PDF, PS, etc and SVG does JPEG and PNG). Attached is a patch for HSSFSerializer doing just that. -- Rick Tessner [EMAIL PROTECTED] "There are no bad days. Only good days and great days."
Index: src/java/org/apache/cocoon/serialization/HSSFSerializer.java =================================================================== RCS file: /home/cvspublic/xml-cocoon2/src/java/org/apache/cocoon/serialization/HSSFSerializer.java,v retrieving revision 1.3 diff -u -r1.3 HSSFSerializer.java --- src/java/org/apache/cocoon/serialization/HSSFSerializer.java 25 Mar 2002 16:44:31 -0000 1.3 +++ src/java/org/apache/cocoon/serialization/HSSFSerializer.java 28 Mar 2002 +19:39:03 -0000 @@ -53,6 +53,10 @@ import org.apache.avalon.framework.activity.Initializable; import org.apache.avalon.framework.component.ComponentSelector; +import org.apache.avalon.framework.configuration.Configurable; +import org.apache.avalon.framework.configuration.Configuration; +import org.apache.avalon.framework.configuration.ConfigurationException; + import org.apache.cocoon.components.elementprocessor.ElementProcessor; import org.apache.cocoon.components.elementprocessor.ElementProcessorFactory; import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.HSSFElementProcessorFactory; @@ -66,10 +70,10 @@ */ public class HSSFSerializer - extends POIFSSerializer implements Initializable + extends POIFSSerializer implements Configurable, Initializable { private ElementProcessorFactory _element_processor_factory; - private final static String _mime_type = "vnd.ms-excel"; + private String mimetype = "vnd.ms-excel"; /** * Constructor @@ -80,6 +84,20 @@ } /** + * Set the configurations for this serializer. + */ + public void configure(Configuration conf) throws ConfigurationException { + + // Get the mime type. + if ( conf != null ) { + this.mimetype = conf.getAttribute("mime-type"); + if ( getLogger().isDebugEnabled() ) { + getLogger().debug("HSSFSerializer mime-type:" + mimetype); + } + } + } + + /** * Initialialize the component. Initialization includes * allocating any resources required throughout the * components lifecycle. @@ -99,7 +117,7 @@ */ public String getMimeType() { - return _mime_type; + return mimetype; } /**
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]