cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matthew Monkan <matt...@ieee.org>
Subject RE: Database to Excel Spreadsheet
Date Mon, 02 Jun 2008 20:04:22 GMT

I'm so close! I switched to the XML serializer to see what XML was going into
the HSSFserializer. (My produced excel document would crash.)

And here is what returns:

<Workbook>
  <SheetNameIndex>
    <SheetName>Sheet1</SheetName>
  </SheetNameIndex>
  <Sheets>
    <Sheet>
      <Name>Sheet1</Name>
      <MaxCol>-1</MaxCol>
      <MaxRow>-1</MaxRow>
      <Cells>
        <Cell Col="1" Row="1" ValueType="60">
          <rowset nrofrows="1">
	    <row>
              <test_data>Puffball</test_data>
            </row>
          </rowset>
        </Cell>
      </Cells>
    </Sheet>
  </Sheets>
</Workbook>

Obviously the problem is the 

          <rowset>
	    <row>
              <test_data>Puffball</test_data>
            </row>
          </rowset>

which cannot be read by the HSSF serializer. I thought that the SQL
transformer would just return the text Puffball which would open fine. Is
this easy to fix? Or do I need to transform this XML again?

-Matt





Matthew Monkan wrote:
> 
> I am having a difficult time understanding what's going on inside my
> sitemap. I made this XML file which is what I assume I would want passed
> through the HSSF serializer:
> 
> main.xml:
> 
> <?xml version="1.0"?>
> 
> <Workbook xmlns="http://www.gnome.org/gnumeric/v7">
>   <SheetNameIndex>
>     <SheetName>Sheet1</SheetName>
>   </SheetNameIndex>
>   <Sheets>
>     <Sheet>
>       <Name>Sheet1</Name>
>       <MaxCol>-1</MaxCol>
>       <MaxRow>-1</MaxRow>
>       <Cells>
>         <Cell Col="1" Row="1" ValueType="60">
> 	    <execute-query xmlns="http://apache.org/cocoon/SQL/2.0">
>             <query>select * from test_table</query>
>           </execute-query>
>         </Cell>
>       </Cells>
>     </Sheet>
>   </Sheets>
> </Workbook>
> 
> Should that work? I simply want to make a sample excel document that has
> one cell of data queried from my database. Here is my sitemap:
> 
> <map:match pattern="*.xls">
>   <map:generate type="file" src="content/main.xml" />
>   <map:transform type="sql">
>     <map:parameter name="use-connection" value="eta" />
>   </map:transform>
>   <map:serialize type="xls" />
> </map:match>
> 
> Here is what I thought happens: When I ask for a .xls file, the file
> generator reads the main.xml file, the sqltransformer executes the queries
> in the xml and the HSSFserializer creates an excel file out of the altered
> xml document. But it's not working; I think I'm really confused. Is that
> how the pipeline works? Or is  it nonsensical? (I wouldn't know at this
> point.) :-(
> 
> - Matt
> 
> 
> 
> Jasha Joachimsthal-2 wrote:
>> 
>> Hi Matthew,
>> 
>> 
>> It looks like you're on the right track.
>> I assume 
>> <map:match pattern="*.xls">
>> Will be followed with something like
>> <map:generate type="file" src="content/{1}.xml" />
>> 
>> So the wildcard is being used.
>> I don't know what your xml file looks like, but if it's only replacing
>> one lookup value for your SQL query, try using the JX Generator [1]. 
>> 
>> Your generator may look like:
>> <map:generate type="jx" src="content/query.xml">
>> <map:parameter name="record" value="{1}" />
>> </map:generate>
>> 
>> [1] http://cocoon.apache.org/2.1/userdocs/jx-generator.html
>> 
>> Regards,
>> 
>> Jasha Joachimsthal 
>> 
>> www.onehippo.com
>> Amsterdam - Hippo B.V. Oosteinde 11 1017 WT Amsterdam +31(0)20-5224466 
>> San Francisco - Hippo USA Inc. 101 H Street, suite Q Petaluma CA
>> 94952-3329 +1 (707) 773-4646
>> 
>> 
>> 
>>> -----Original Message-----
>>> From: Matthew Monkan [mailto:matthew@ieee.org] 
>>> Sent: vrijdag 30 mei 2008 18:02
>>> To: users@cocoon.apache.org
>>> Subject: Database to Excel Spreadsheet
>>> 
>>> 
>>> Windows XP / Cocoon 2.1.11 / running inside Cocoon's 
>>> build\webapp folder
>>> 
>>> As an elementary user of Cocoon, I am still have trouble 
>>> dealing with the sitemap and being confident with it. I'm 
>>> always scared that I've messed up some syntax. My ultimate 
>>> goal is to do some simple selects to an Oracle DB and put it 
>>> on an Excel spreadsheet, which I feel should be really simple.
>>> But before I get into the XML and XSLT, I simply want to 
>>> design the most optimal sitemap, and at the same time get a 
>>> better concept of what's going on with it. From what I 
>>> understand, I need the file generator, SQLTransformer, XSLT 
>>> transformer, and HSSF Serializer. (If there is anything 
>>> easier that I do not know, feel free to let me know.)
>>> 
>>> Today I tried writing one from scratch:
>>> 
>>> <?xml version="1.0"?>
>>> <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
>>> 
>>>   <map:components>
>>> 
>>>     <map:generators default="file"/>
>>> 
>>>     <map:transformers default="xslt">
>>>       <map:transform type="sql">
>>>         <map:parameter name="use-connection" value="acuworld_test">
>>> 	  <map:parameter name="show-nr-of-rows" value="true">
>>>         <map:parameter name="clob-encoding" value="UTF-8">
>>>       </map:transform>
>>>     </map:transformers>
>>> 
>>>     <map:readers default="resource" />
>>> 
>>>     <map:serializers default="html">
>>>       <map:serializer
>>>            name="xls"
>>>            src="org.apache.cocoon.serialization.HSSFSerializer"
>>>            locale="us" />
>>>     </map:serializers>
>>> 
>>>     <map:selectors default="browser" />
>>> 
>>>     <map:matchers default="wildcard" />
>>> 
>>>   </map:components>
>>> 
>>>   <map:pipelines>
>>>     <map:pipeline>
>>> 
>>>       <map:match pattern="*.xls">
>>>         <map:generate type="file" src="content/MYCONTENT.xml" />
>>>         <map:transform type="sql">
>>>           <map:parameter name="use-connection" 
>>> value="CONNECTIONNAME" />
>>>         </map:transform>
>>>         <map:transform type="xslt" src="style/MYSTYLE.xsl" />
>>>         <map:serialize type="xls" />
>>>       </map:match>
>>> 
>>>     </map:pipeline>
>>>   </map:pipelines>
>>> 
>>> </map:sitemap>
>>> 
>>> Am I on the right track? I just want to have peace of mind 
>>> with the sitemap so I'm not going back and forth between 
>>> different files later trying to debug my little application.
>>> 
>>> Any help and recommendations are appreciated. :-)
>>> --
>>> View this message in context: 
>>> http://www.nabble.com/Database-to-Excel-Spreadsheet-tp17562564
>> p17562564.html
>>> Sent from the Cocoon - Users mailing list archive at Nabble.com.
>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>>> For additional commands, e-mail: users-help@cocoon.apache.org
>>> 
>>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>> For additional commands, e-mail: users-help@cocoon.apache.org
>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Database-to-Excel-Spreadsheet-tp17562564p17609638.html
Sent from the Cocoon - Users mailing list archive at Nabble.com.


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


Mime
View raw message