cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "bernhard huber" <bernhard.hu...@gmx.at>
Subject Re: [HELP!] HSSFSerializer and XSLTransformer doesn't work together (2nd)
Date Sat, 21 Aug 2004 17:22:54 GMT
hi,
playing around using:

<?xml version="1.0" encoding="ISO-8859-1"?>
<search-result
  xmlns:sql="http://apache.org/cocoon/SQL/2.0"
>
   <!-- The result of the search goes here... -->
   <content>
      <sql:rowset>
         <sql:row>
            <foo>bar1</foo>
         </sql:row>
         <sql:row>
            <foo>bar2</foo>
         </sql:row>
      </sql:rowset>
   </content>
</search-result>

and xsl
<?xml version="1.0"?>

<xsl:stylesheet version="1.0" 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
  xmlns:gmr="http://www.gnome.org/gnumeric/v7" 
  xmlns:sql="http://apache.org/cocoon/SQL/2.0"
>

  <xsl:template match="search-result">
    <gmr:Workbook >
      <xsl:apply-templates/>
    </gmr:Workbook>
  </xsl:template>
  
  <xsl:template match="content">
      <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>
            <xsl:apply-templates/>
          </gmr:Cells>
        </gmr:Sheet>
      </gmr:Sheets>
  </xsl:template>
  
  <xsl:template match="sql:row">
    <xsl:variable name="rowNum" select="position()-1"/>
    <xsl:for-each select="node()">
      <xsl:variable name="colNum" select="position()-1"/>
      <gmr:Cell Row="{$rowNum}" Col="{$colNum}" ValueType="60">
        <gmr:Content><xsl:value-of select="."/></gmr:Content>
      </gmr:Cell>
    </xsl:for-each>
  </xsl:template>
</xsl:stylesheet>

there is no npe anymore,
i experienced that it is very important using
  <xsl:template match="search-result">
    <gmr:Workbook >
      <xsl:apply-templates/>
    </gmr:Workbook>
  </xsl:template>

otherwise npe are thrown
i did'nt delve into trying to understand we the npe are thrown.

but you may want to check hello-world/xsl/page2xls.xsl.
and http://127.0.0.1:8888/samples/blocks/poi/hello.xls
as in this sample the sitemap definition uses
generator-transformer-serializer, too, as in your "npe-example"

regards bernhard



> Hello,
> 
> I have a problem using XSLTTransformer and HSSFSerializer together. If I
> do
> so, I got a NullPointerException. Vladim talked to me that I have to look
> into the xalan sources and to get the original exception but I can't
> compile
> xalan (TransformerImpl) (The source version doesn't macht with the
> compiled
> one?).
> 
> NOTE: Using the XSLTTransformer together with XMLSerializer works well but
> not with HSSFSerializer.
> 
> Can somebody help me please to solve this problem because my company
> want's
> to using Cocoon but only if this basic feature does work in the next days.
> It would be great if we are able to use Cocoon in our server park.
> 
> This is the file I want to transform:
> 
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <search-result>
>    <!-- The result of the search goes here... -->
>    <content>
>       <rowset>
>          <row>
>             <foo>bar1</foo>
>          </row>
>          <row>
>             <foo>bar2</foo>
>          </row>
>       </rowset>
>    </content>
> </search-result>
> 
> This is the stylesheet to transform the file above:
> 
> <?xml version="1.0"?>
> 
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>                               xmlns:sql="http://apache.org/cocoon/SQL/2.0"
>                              
> xmlns:gmr="http://www.gnome.org/gnumeric/v7">
> 
>    <xsl:template match="sql:rowset">
>    <gmr:Workbook>
>       <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>
>          <xsl:for-each select="./sql:row">
>             <xsl:variable name="rowNum" select="position()-1"/>
>                <xsl:for-each select="node()">
>                <xsl:variable name="colNum" select="position()-1"/>
>                <gmr:Cell Row="{$rowNum}" Col="{$colNum}"
> ValueType="60"><xsl:value-of select="."/></gmr:Cell>
>                </xsl:for-each>
>             </xsl:for-each>
>          </gmr:Cells>
>          </gmr:Sheet>
>       </gmr:Sheets>
>    </gmr:Workbook>
>    </xsl:template>
> 
> </xsl:stylesheet>
> 
> This is the sitemap entry for this:
> 
>       <map:match pattern="search/*.xls">
>          <map:generate type="file" src="test.xml"/>
>          <map:transform type="xslt"
> src="stylesheets/searchResult2XLS.xsl"/>
>          <map:serialize type="xls"/>
>       </map:match>
> 
> And what I get is the following error:
> 
> Original Exception: java.lang.RuntimeException:
> java.lang.NullPointerException
> 	at
>
org.apache.xalan.transformer.TransformerImpl.run(TransformerImpl.java:3407)
> 	at
>
org.apache.xalan.transformer.TransformerHandlerImpl.endDocument(TransformerH
> andlerImpl.java:433)
> 	at
> org.apache.cocoon.xml.AbstractXMLPipe.endDocument(AbstractXMLPipe.java:56)
> 	at
>
org.apache.cocoon.transformation.TraxTransformer.endDocument(TraxTransformer
> .java:562)
> 	at org.apache.xerces.parsers.AbstractSAXParser.endDocument(Unknown
> Source)
> 	at org.apache.xerces.impl.XMLDocumentScannerImpl.endEntity(Unknown
> Source)
> 	at org.apache.xerces.impl.XMLEntityManager.endEntity(Unknown Source)
> 	at org.apache.xerces.impl.XMLEntityScanner.load(Unknown Source)
> 	at org.apache.xerces.impl.XMLEntityScanner.skipSpaces(Unknown Source)
> 	at
>
org.apache.xerces.impl.XMLDocumentScannerImpl$TrailingMiscDispatcher.dispatc
> h(Unknown Source)
> 	at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
> Source)
> 	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
> 	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
> 	at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
> 	at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
> 	at org.apache.excalibur.xml.impl.JaxpParser.parse(JaxpParser.java:296)
> .....
> 
> Thank you so much!
> 
> Regards
> Stephan
> 
> 
> 
> 

-- 
NEU: Bis zu 10 GB Speicher für e-mails & Dateien!
1 GB bereits bei GMX FreeMail http://www.gmx.net/de/go/mail


Mime
View raw message