As we know, most of business reports are not just based on a static SQL script, they will be varied by different situation such as field column or filter, our RDL element class model allow user to create their own data type and bind the data with our existed report element type. The following is the sample RDL script.

 <?xml version="1.0"?>
 <report name="TestDataBinding" startaction="define_data">
   <reportparameter id="sql.table.name" value="product" />
   <reportaction name="define_data" nextaction="generate_sql">
      <dataitemset id="sql.fields">
         <sqlfield id="sql.fields.1" field="category_name" alias="cat" />
         <sqlfield id="sql.fields.2" field="brand_name" alias="brand" />
         <sqlfield id="sql.fields.3" field="upc_id" alias="UPC" />
      </dataitemset>
   </reportaction>
```<reportaction name="generate_sql" nextaction="format_report"> <sqlitem root="true"> <sqlitem begin="select "> <reportparameter id="sql.comma" value="" /> <foreach item="DataItems" variable="sql.fields.counter"> <dataitems refid="sql.fields" /> <sqlitem text="${sql.comma}" /> <sqlitem> <binding sourceid="sql.fields" sourceprop="field" targetprop="text" index="${sql.fields.counter}" /> </sqlitem> <sqlitem text=" as " /> <sqlitem> <binding sourceid="sql.fields" sourceprop="alias" targetprop="text" index="${sql.fields.counter}" /> </sqlitem> <reportparameter id="sql.comma" value=", " /> </foreach> </sqlitem> <sqlitem text="from ${sql.table.name}" newline="true" /> <sqlitem text=" order by 1" /> </sqlitem> </reportaction> <reportaction name="format_report"> <reportitem label="${sql.table.name}"> <foreach item="DataItems" variable="sql.fields.counter"> <dataitems refid="sql.fields" /> <reportitem> <binding sourceid="sql.fields" sourceprop="alias" targetprop="label" index="${sql.fields.counter}" /> </reportitem> </foreach> </reportitem> </reportaction> </report> And here is log output.
SqlItem output