You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Derek Hohls <DH...@csir.co.za> on 2007/05/11 13:56:29 UTC

Re: How to replace SQL/ESQL datasource through an XML datasource

Urs
 
Your problem statement is not quite clear in this message;
perhaps you can indicate your overall program logic, showing
how data is handled and processed by the different parts of 
Cocoon.   You need to differentiate clearly between data 
retrieval ('"raw" data); data alteration (eg. calculated values);
data manipulation (e.g. sorting) and data layout (order, 
appearance etc.) This will help visualise alternatives.
 
Derek

>>> "Urs Iwert" <ur...@sysinf.ch> 2007/05/11 11:51:54 AM >>>

Hi cocooners,

I'm using cocoon to creating html,pdf,xls and rtf reports.

I started using XSP/ESQL to connect directly to the datasource (mysql)
and merged the data with the layout of the report in the xsp page.

<map:match pattern="report/*.xml">
    <map:generate src="report/{1}.xml" type="serverpages" />
    <map:transform type="i18n" />
    <map:transform src="stylesheets/doc2pdf.xsl" />
    <map:serialize type="fo2pdf" />
</map:match>

  
Now the requirements have changed and the xml data comes from an other
provider. So I don't have to deal with the sql statement anymore, but
how can I merge the xml data with the layout of the report in the xsp
page. Formatting, filtering, grouping, calculations depend on the
provided data using xsp. How can use this approach without transfering
the logic to a xsl stylesheet.

I can't see any solution. Any idea appreciated.

Urs Iwert

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org



-- 
This message is subject to the CSIR's copyright, terms and conditions and
e-mail legal notice. Views expressed herein do not necessarily represent the
views of the CSIR.
 
CSIR E-mail Legal Notice
http://mail.csir.co.za/CSIR_eMail_Legal_Notice.html 
 
CSIR Copyright, Terms and Conditions
http://mail.csir.co.za/CSIR_Copyright.html 
 
For electronic copies of the CSIR Copyright, Terms and Conditions and the CSIR
Legal Notice send a blank message with REQUEST LEGAL in the subject line to
CallCentre@csir.co.za.


This message has been scanned for viruses and dangerous content by MailScanner, 
and is believed to be clean.


AW: How to replace SQL/ESQL datasource through an XMLdatasource

Posted by Urs Iwert <ur...@sysinf.ch>.
Hi Derek 
 
Thanks for helping me.
 
The first step from the matcher gets the raw data from the database and
I can do some calculation or formatting stuff. This works great for me
because the esql-stylesheet is merging raw data and layout together.
Using XSP is very convenient to skip rows, having values formatted,
running sums, etc. Further steps are just to translate and to transform
into the requested output format.
 
So far I could access the database directly. From the new requirements I
get the raw data from an xml file. It's easy to read an xml file, but
there is where my problem starts. Merging layout and raw data can not be
done in a similar way (using ESQL/XSP). At least I have to write an xsl
stylesheet to merge raw data and layout.
 
Using an xsl-stylesheet merging raw data and layout would mean I have to
transfer all logic from the xsp page to the stylesheet and therefore
rewriting all existing reports.

Urs
 

<!-- sitemap.xmap
------------------------------------------------------->
 
Here's the matcher in the sitemap
 
<map:match pattern="report/*.pdf">
    <map:generate src="report/{1}.xsp" type="serverpages" />
    <map:transform type="i18n" />
    <map:transform src="stylesheets/doc2pdf.xsl" />
    <map:serialize type="fo2pdf" />
</map:match>
 

<!-- employee.xsp
------------------------------------------------------->
 
Following a very simple example: 
 
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsp:page 
  language="java" 
  xmlns:xsp="http://apache.org/xsp" 
  xmlns:esql="http://apache.org/cocoon/SQL/v2" 
  xmlns:i18n="http://apache.org/cocoon/i18n/2.1">
 
  <content>
 
    <page orientation="landscape" paper="A4">
 
    <title><i18n:text>Employees</i18n:text></title>
 
    <esql:connection>
      <esql:pool>mydb</esql:pool>
      
      <esql:execute-query>
        <esql:query>select firstname, lastname, age from employee order
by age asc</esql:query>
 
        <esql:results>
          <table border="0">
            <colgroup>
              <col width="4"/> <!-- firstname -->
              <col width="4"/> <!-- lastname -->
              <col width="2"/> <!-- age -->
            </colgroup>
 
            <thead>
              <tr>
                <th align="left"><i18n:text>firstname</i18n:text></th>
                <th align="left"><i18n:text>lastname</i18n:text></th>
                <th align="center"><i18n:text>age</i18n:text></th>
              </tr>
            </thead>
                            
            <tbody>
              <esql:row-results>
                <xsp:logic>
                    int age = (int) <esql:get-int column="age"/>;
                    if (age > 50) {
                </xsp:logic>
 
                <tr>
                  <td><esql:get-string column="firstname"/></td>
                  <td><esql:get-string column="lastname"/></td>
                  <td><esql:get-int    column="age"/></td>
                </tr>
                
                <xsp:logic>
                    }
                </xsp:logic>
              </esql:row-results>
            </tbody>
            
          </table>
        </esql:results>
 
      </esql:execute-query>
    </esql:connection>
  </page>
                
  </content>
</xsp:page>
 

 

________________________________

Von: Derek Hohls [mailto:DHohls@csir.co.za] 
Gesendet: Freitag, 11. Mai 2007 13:56
An: users@cocoon.apache.org
Betreff: Re: How to replace SQL/ESQL datasource through an XMLdatasource


Urs
 
Your problem statement is not quite clear in this message;
perhaps you can indicate your overall program logic, showing
how data is handled and processed by the different parts of 
Cocoon.   You need to differentiate clearly between data 
retrieval ('"raw" data); data alteration (eg. calculated values);
data manipulation (e.g. sorting) and data layout (order, 
appearance etc.) This will help visualise alternatives.
 
Derek

>>> "Urs Iwert" <ur...@sysinf.ch> 2007/05/11 11:51:54 AM >>>

Hi cocooners,

I'm using cocoon to creating html,pdf,xls and rtf reports.

I started using XSP/ESQL to connect directly to the datasource (mysql)
and merged the data with the layout of the report in the xsp page.

<map:match pattern="report/*.xml">
    <map:generate src="report/{1}.xml" type="serverpages" />
    <map:transform type="i18n" />
    <map:transform src="stylesheets/doc2pdf.xsl" />
    <map:serialize type="fo2pdf" />
</map:match>

  
Now the requirements have changed and the xml data comes from an other
provider. So I don't have to deal with the sql statement anymore, but
how can I merge the xml data with the layout of the report in the xsp
page. Formatting, filtering, grouping, calculations depend on the
provided data using xsp. How can use this approach without transfering
the! logic to a xsl stylesheet.

I can't see any solution. Any idea appreciated.

Urs Iwert

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org



-- 
This message is subject to the CSIR's copyright, terms and conditions
and e-mail legal notice. 
Views expressed herein do not necessarily represent the views of the
CSIR. 

CSIR E-mail Legal Notice
<http://mail.csir.co.za/CSIR_eMail_Legal_Notice.html>  

CSIR Copyright, Terms and Conditions
<http://mail.csir.co.za/CSIR_Copyright.html>  

For electronic copies of the CSIR Copyright, Terms and Conditions and
the CSIR Legal Notice 
send a blank message with "REQUEST LEGAL" in the subject line to CSIR
CallCentre <ma...@csir.co.za>  


This message has been scanned for viruses and dangerous content by
MailScanner <http://www.mailscanner.info/> , 
and is believed to be clean.