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 Tue, 03 Jun 2008 15:52:02 GMT

Thanks Robin, I did indeed use the predicate wrong.

Alright, I'm really close to getting this application to work but am stumped
over one thing.

Here is my initial XML file:

<?xml version="1.0"?>
<execute-query xmlns="http://apache.org/cocoon/SQL/2.0">
  <query>SELECT test_data from test_table;</query>
</execute-query>

It gets passed through the SQL transformer and produces this XML:

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

Okay, so now I just need to select Puffball from test_data and wrap it with
XML that the HSSFSerializer likes. This is the XSL I use:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">

<gmr:Workbook xmlns:gmr="http://www.gnome.org/gnumeric/v7">
  <gmr:SheetNameIndex>
    <gmr:SheetName>Sheet1</gmr:SheetName>
  </gmr:SheetNameIndex>
  <gmr:Sheets>
    <gmr:Sheet>
      <gmr:Name>Sheet1</gmr:Name>
      <gmr:MaxCol>-1</gmr:MaxCol>
      <gmr:MaxRow>-1</gmr:MaxRow>
      <gmr:Cells>
        <gmr:Cell Col="1" Row="1" ValueType="60">
	    <xsl:value-of select="/rowset/row/test_data[1]" />
        </gmr:Cell>
      </gmr:Cells>
    </gmr:Sheet>
  </gmr:Sheets>
</gmr:Workbook>

</xsl:template>
</xsl:stylesheet>

However, after the transformation I get this XML:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">

<gmr:Workbook xmlns:gmr="http://www.gnome.org/gnumeric/v7">
  <gmr:SheetNameIndex>
    <gmr:SheetName>Sheet1</gmr:SheetName>
  </gmr:SheetNameIndex>
  <gmr:Sheets>
    <gmr:Sheet>
      <gmr:Name>Sheet1</gmr:Name>
      <gmr:MaxCol>-1</gmr:MaxCol>
      <gmr:MaxRow>-1</gmr:MaxRow>
      <gmr:Cells>
        <gmr:Cell Col="1" Row="1" ValueType="60">
	    <gmr:Cell ValueType="60" Row="1" Col="1"/>
        </gmr:Cell>
      </gmr:Cells>
    </gmr:Sheet>
  </gmr:Sheets>
</gmr:Workbook>

</xsl:template>
</xsl:stylesheet>

Notice that the <xsl:value-of select="/rowset/row/test_data[1]" /> statement
retrieved <gmr:Cell ValueType="60" Row="1" Col="1"/>

?!?!

Why did it return a copy of the Cell element and not Puffball? :,(


- Matt


------------------------------------------

Robin Wyles wrote:
> 
> I think there is an error in your xsl here:
> 
>   <xsl:value-of select="/Workbook/Sheets/Sheet/Cells/Cell/rowset/row/ 
> test_data/[1]" />
> 
> Should be...
> 
>   <xsl:value-of select="/Workbook/Sheets/Sheet/Cells/Cell/rowset/row/ 
> test_data[1]" />
> 
> You don't use a slash before declaring a predicate.
> 
> Cheers,
> 
> Robin
> 
-- 
View this message in context: http://www.nabble.com/Database-to-Excel-Spreadsheet-tp17562564p17626874.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