cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Vishnev <avish...@optonline.net>
Subject RE: Cocoon2:XSP->Excel?
Date Tue, 13 Nov 2001 23:26:03 GMT
Marcelo,

What is dbprism? Is this your software? If Not, can you reply with URL to
it.  Where can I find dbprism/excel.xsl?


TIA
Alex



-----Original Message-----
From: Marcelo F. Ochoa [mailto:mochoa@ieee.org]
Sent: Monday, November 12, 2001 7:18 PM
To: cocoon-users@xml.apache.org
Subject: Re: Cocoon2:XSP->Excel?

Skladov, Victor wrote:

>Hi, people!
>
>Does anydody have expirience in creating EXCEL-Tables with XSP?
>What must I do to get a true EXCEL Table from a XSP and XSL?
>
>Thanks in advance
>Viktor
>
  To returns Excel files from Cocoon 2 there is a simple trick:
  If you returns from your XSP an XML like this:

<?xml version='1.0' encoding='iso-8859-1'?>
<ROWSET>
<ROW empno="1">
<name>Velasquez</name>
<job>President</job>
<sal>2500</sal>
</ROW>
<ROW empno="2">
<name>Ngao</name>
<job>VP, Operations</job>
<sal>1450</sal>
</ROW>
<ROW empno="3">
<name>Nagayama</name>
<job>VP, Sales</job>
<sal>1400</sal>
</ROW>
......
</ROWSET>

 And transform it with an stylesheet like this:
<?xml version="1.0"?>
<!-- Written by Marcelo F. Ochoa "mochoa@ieee.org" -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
   <html>
    <table>
       <tr><th>Emp Number</th><th>Name</th><th>Job</th><th>Sal</th></tr>
           <xsl:for-each select="ROWSET/ROW">
              <xsl:sort select="sal"
                          data-type="number"
                          order="ascending"/>
          <tr>
                <td><xsl:value-of select="@empno"/></td>
                <td><xsl:value-of select="name"/></td>
                <td><xsl:value-of select="job"/></td>
                <td><xsl:value-of select="sal"/></td>
          </tr>
           </xsl:for-each>
    </table>
   </html>
  </xsl:template>
</xsl:stylesheet>

  and finally adding this definitions into sitemap.xmap

   <map:serializer name="excel"  mime-type="application/vnd.ms-excel"
src="org.apache.cocoon.serialization.XMLSerializer">
    <encoding>iso-8859-1</encoding>
   </map:serializer>

   <map:match pattern="xmlj/DEMOj.excel">
    <map:generate type="serverpages" src="/xmlj/DEMOj.xsp"/>
    <map:transform src="stylesheets/dbprism/excel.xsl"/>
    <map:serialize type="excel"/>
   </map:match>

  and that's all.
  You could see this demo on-line at:
http://cocodrilo.exa.unicen.edu.ar:7777/dbprism/xmlj/DEMOj.excel
  Best regards, Marcelo.

--
Marcelo F. Ochoa - mochoa@ieee.org
Do you Know DB Prism? Look @ http://www.plenix.com/dbprism/
More info?
Chapter 21 of the book "Professional XML Databases" (Wrox Press
http://www.wrox.com/)
Chapter 8 of the book "Oracle & Open Source" (O'Reilly
http://www.oreilly.com/catalog/oracleopen/)
-----------------------------------------------
Lab. de Sistemas - Fac. de Cs. Exactas - UNICEN
Paraje Arroyo Seco - Campus Universitario
(7000) Tandil - Bs. AS. - Argentina
Te: +54-2293-444430 Fax: +54-2293-444431





---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

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


---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

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


Mime
View raw message