Hi Gerardo, Here's a link to a previous discussion about this:
http://marc.theaimsgroup.com/?t=101542695300006&r=1&w=2 The short answer is that you can't pass a request-time parameter to a serializer; you can only pass configuration-time parameters (in the map:serializer element, when you define your serializer components), but that probably won't work for what you're trying to do. One kind-of-ugly solution mentioned in the above discussion is to have a previous component in the pipeline (such as a transformer or generator) read the parameter and stick it into the XML, which would allow your custom serializer to read it out of the XML. Not the prettiest thing, but it does work... Anyway, sorry I don't have a better answer. Harry PS There was also mention of a FileWritingTransformer, but I believe that's in the scratchpad. Might be worth checking out, though. -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 27, 2002 12:13 PM To: [EMAIL PROTECTED] Subject: Retrieving sitemap paramters in a serializer I'm sorry if this is a stupid question, but I can't seem to figure out how to get the Parameters object to a serializer. I have a pipeline that has a parameter that I am trying to access from within the serializer. The code for both is below. The serializer is just trying to write the file to disk. I'm sure that this type of serializer must have been written already, but I couldn't find it anywhere and it doesn't seem that hard. Any help would be greatly appreciated :) -gerardo <map:match pattern="test/*.html"> <map:generate type="html" src="test/{1}.html"/> <map:serialize type="file"> <map:parameter name="filename" value="{1}"/> </map:serialize> </map:match> ---------------------------------------------------------------------------- -------------------------- public class FileSerializer extends AbstractTextSerializer implements Poolable { private TransformerHandler handler; public FileSerializer() { } public void setOutputStream(OutputStream out) { try { Parameters param = ????; final String filename = param.getParameter("filename", null); if(filename != null) super.setOutputStream(new FileOutputStream("c: \\jakarta-tomcat-3.2.4\\webapps\\cocoon\\uploadDir\\"+ filename)); else super.setOutputStream(out); handler = getTransformerFactory().newTransformerHandler(); format.put(OutputKeys.METHOD,"html"); handler.setResult(new StreamResult(this.output)); handler.getTransformer().setOutputProperties(format); this.setContentHandler(handler); this.setLexicalHandler(handler); } catch (Exception e) { getLogger().error("FileSerializer.setOutputStream()", e); throw new RuntimeException(e.toString()); } } /** * Recyce the serializer. GC instance variables */ public void recycle() { super.recycle(); this.handler = null; } } +---------------------------------------------------------+ This message may contain confidential and/or privileged information. If you are not the addressee or authorized to receive this for the addressee, you must not use, copy, disclose or take any action based on this message or any information herein. If you have received this message in error, please advise the sender immediately by reply e-mail and delete this message. Thank you for your cooperation. +---------------------------------------------------------+ --------------------------------------------------------------------- Please check that your question has not already been answered in the FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html> To unsubscribe, e-mail: <[EMAIL PROTECTED]> For additional commands, e-mail: <[EMAIL PROTECTED]> --------------------------------------------------------------------- Please check that your question has not already been answered in the FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html> To unsubscribe, e-mail: <[EMAIL PROTECTED]> For additional commands, e-mail: <[EMAIL PROTECTED]>