Hi,

thanks to you guys I got my action running finally.
Now I have another question.

For example: I have 1 xml file that could be displayed in 15
xsl-Stylesheets (in various formats: html, pdf, xls).

Currently in my first action I choose the corresponding file.

package test.acting;

import java.util.Map;
import java.util.HashMap;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.cocoon.acting.AbstractAction;
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.environment.SourceResolver;
import org.apache.cocoon.environment.Redirector;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.xml.sax.EntityResolver;


public class XslSelection extends AbstractAction {

  public Map act(Redirector redirector, SourceResolver resolver, Map
objectModel,
  String source, Parameters parameters){

    Map results = new HashMap();
    Request request = ObjectModelHelper.getRequest(objectModel);

    String report_id = request.getParameter("report_id");
    String service_id = request.getParameter("service_id");
    String output_id = request.getParameter("output_id");

    // Now choose the suitable XSL for the output
    if(report_id.equals("16") && output_id.equals("html"))
      results.put("xsl-choice","report_16_html");
    else if(report_id.equals("16") && output_id.equals("pdf"))
      results.put("xsl-choice","report_16_pdf");
    ...
    else if(report_id.equals("17") && service_id.equals("GSM") &&
output_id.equals("html"))
      results.put("xsl-choice","report_17GSM_html");
    else if(report_id.equals("17") && !service_id.equals("GSM") &&
output_id.equals("pdf"))
      results.put("xsl-choice","report_17_pdf");
    ...
    else
      results.put("xsl-choice","error");
   ...
    return results;
  }
}

In the other action I choose the output format.
package test.acting;

import java.util.Map;
import java.util.HashMap;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.cocoon.acting.AbstractAction;
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.environment.SourceResolver;
import org.apache.cocoon.environment.Redirector;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.xml.sax.EntityResolver;


public class OutputSelection extends AbstractAction {

  public Map act(Redirector redirector, SourceResolver resolver, Map
objectModel,
  String source, Parameters parameters){

    Map results = new HashMap();
    Request request = ObjectModelHelper.getRequest(objectModel);

    String output_id = request.getParameter("output_id");

    // Now choose the suitable XSL for the output
    if(output_id.equals("html"))
      results.put("output-choice","html");
    else if(routput_id.equals("pdf"))
      results.put("output-choice","pdf");
    ...
    else
      results.put("output-choice","html");
   ...
    return results;
  }
}

Thats how I use it in the sitemap:
...
<map:match pattern="blabla">
            <map:generate src="sampleoutput.xml"/>
            <map:act type="xslSelect">
                   <map:transform src="stylesheets/{results}.xsl"/>
            </map:act>
            <map:act type="outputSelect">
                 <map:serialize type="{output-choice}"/>
             </map:act>
 </map:match>
...

My question:
Can I handle this somehow in one action (something like "2 return values")?
Or do it somehow else?

Jonny
----------------------------------------------------------------------------------------------------

This electronic message contains information from the mmo2 plc Group which
may be
privileged or confidential. The information is intended to be for the use
of the
individual(s) or entity named above. If you are not the intended recipient
be aware
that any disclosure, copying, distribution or use of the contents of this
information
is prohibited. If you have received this electronic message in error,
please notify
us by telephone or email (to the numbers or address above) immediately.




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