cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ricardo Rocha <rica...@apache.org>
Subject Re: Dom elements as function Arguments in XSP file
Date Fri, 10 Mar 2000 01:02:17 GMT
Hi guys,

On Wed, 08 Mar 2000, Guy wrote:
> How Can I pass DOM Elements to the functions in the XSP file
> I have the following files
> <xsp:page ...
>  <page>
>    <title>Report</title>
>   <util:report>
>     <report_input>
>      <input1/>
>      ..
>      <inputn/>
>    </report_input>
>   </util:report>
> </page>
> </xsp:page>
> 
> How can I  get the <report_input> tag as String or as Element in the
> Lib.xsl.xsp file?

I hope I'm understanding your requirement correctly (TM), :-)

The question could be rephrased as: "when a dynamic
XSP tag is represented in logic as a method, how can
I pass content nested inside the dynamic tag as argument(s)
to the underlying method?"

In the example above, you may want to process
<util:report> so that generated code looks like:

  {
    User user = (User)session.getValue("User");
    ReportInput[] inputs = <somehow-get-all-inputs/>; // Here's the trick
    user.execReport(inputs, request, document)
  }

Assuming you have XSL templates to transform each
<input1/> through <inputn/> to a suitable Java expression,
you could do  something like:

  <xsl:template match="util:report">
    <xsp:logic>
      User user = (User)session.getValue("User");
      ReportInput[] inputs = {
          <xsl:for-each select="report-input/*">
            <xsl:apply-templates/>,  // Note the comma
          </xsl:for-each>
       };
      user.execReport(inputs, request, document)
    </xsp:logic>
  </xsl:template>

Hope this helps,

Ricardo

Mime
View raw message