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]>

Reply via email to