You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Philipp Rech <re...@iuw.fh-darmstadt.de> on 2005/01/27 12:50:23 UTC

Re: transformation from XML to excel only works with one element set

jxtg? okay, but i need microsoft excel as and ouput format and 
i do't see how JXTG could help me here...
i would need one excel-row for each row element...
i was thinking that i miss a <xsl:for-each ...> instruction
but i dunno where/how to apply this...
(the transformation works fine to WML and PDF btw) 
any hints? (stylesheet > see below)

thanks a lot!
philipp



> Yep. Your guess is right! You are overwrite the first with the second. You
> need to use a variable to move to the next row. As a solution, try to use
> JXTemplate.
> 
> Best Regards,
> 
> Antonio Gallardo.
> 
> On Mie, 26 de Enero de 2005, 6:04, Philipp Rech dijo:
> > Hello Cocooners,
> >
> > [Cocoon Version 2.1.6]
> >
> > i have the following xml file (see below) which is the result of a db
> > querry
> > (from Cocoon)... when i transfrom it with the stylesheet (see below) using
> > the
> > transfomer within Cocoon an excel sheet opens but with only one row in it
> > (the
> > one with the last id) but i need all elements in diferent rows... so only
> > the
> > last <row> element with the <eventid>2</eventid> gets displayed but not
> > both of
> > them... my guess was thet the first one is processed but is overwritten by
> > the
> > last one (see my xml and xsl file below)
> >
> > thank you very much!
> > phil
> >
> > ps: i already asekd on the poi-user list but
> > got no reply...
> >
> >
> > here is my xml file:
> > --------------------------------
> > <?xml version="1.0" encoding="ISO-8859-1" ?>
> > <page>
> > <content>
> > <rowset xmlns:sql="http://apache.org/cocoon/SQL/2.0"
> > xmlns="http://apache.org/cocoon/SQL/2.0">
> >  <row>
> >   <eventid>3</eventid>
> >   <typeofcontrol>Control Type A</typeofcontrol>
> >   <trafficdirection>Entry</trafficdirection>
> >   <checkpoint>Blue Border</checkpoint>
> >   <klassification>illigal</klassification>
> >   <checklocation>black sea</checklocation>
> >   <guard_1>Philipp</guard_1>
> >   <guard_2>Peter Pan</guard_2>
> >   <objection>smug</objection>
> >   <dtg>2005-01-01</dtg>
> >   <location>black sea</location>
> >   <description></description>
> >   <numberofpersons>3</numberofpersons>
> >   <observed>Yes</observed>
> > </row>
> > <row>
> >   <eventid>2</eventid>
> >   <typeofcontrol>Control Type B</typeofcontrol>
> >   <trafficdirection>Leave/trafficdirection>
> >   <checkpoint>Airport</checkpoint>
> >   <klassification>illigal entry</klassification>
> >   <checklocation>airport hall 2</checklocation>
> >   <guard_1>Philipp</guard_1>
> >   <guard_2>Stepht</guard_2>
> >   <objection>illigal enrty</objection>
> >   <dtg>2005-01-12</dtg>
> >   <location>airport somewhere</location>
> >   <description>none</description>
> >   <numberofpersons>1</numberofpersons>
> >   <observed>No</observed>
> >   </row>
> >    </rowset>
> >   </content>
> >   </page>
> > ---------------------------------
> >
> >
> > here is my xsl file:
> >
> > -----------------------------
> >
> > <?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="/">
> >    <gmr:Workbook xmlns:gmr="http://www.gnome.org/gnumeric/v7">
> >      <gmr:Sheets>
> >          <gmr:Sheet DisplayFormulas="false" HideZero="false"
> > HideGrid="false"
> > HideColHeader="false" HideRowHeader="false" DisplayOutlines="true"
> > OutlineSymbolsBelow="true" OutlineSymbolsRight="true">
> > 	         <gmr:Name>BIHS - Event Data</gmr:Name>
> >         	 <gmr:MaxCol>2</gmr:MaxCol>
> > 	         <gmr:Cols DefaultSizePts="48">
> >                      <gmr:ColInfo No="0" Unit="48" MarginA="2" MarginB="2"
> > Count="7"/>
> >                  </gmr:Cols>
> >      		 <gmr:Rows DefaultSizePts="12.8">
> >        			<gmr:RowInfo No="0" Unit="12.8" MarginA="0" MarginB="0"
> > Count="9"/>
> >        			<gmr:RowInfo No="10" Unit="12.8" MarginA="1" MarginB="0"
> > Count="24"/>
> >      		 </gmr:Rows>
> >  		 <gmr:Cells>
> >      			<xsl:apply-templates/>
> >                  </gmr:Cells>
> >      	</gmr:Sheet>
> >      </gmr:Sheets>
> >     </gmr:Workbook>
> >   </xsl:template>
> >
> >
> >
> >   <xsl:template match="sql:eventid">
> >      <gmr:Cell Col="0" ValueType="60">
> >       <xsl:variable name="rownumber"><xsl:number level="any"
> > from="content"
> > count="row"/></xsl:variable>
> >       <xsl:attribute name="Row">
> >          <xsl:value-of select="$rownumber"/>
> >       </xsl:attribute>
> >        <gmr:Content>
> > 		<xsl:apply-templates/>
> > 	</gmr:Content>
> >      </gmr:Cell>
> >   </xsl:template>
> >
> >
> >   <xsl:template match="sql:typeofcontrol">
> >      <gmr:Cell Col="1" ValueType="60">
> >       <xsl:variable name="rownumber"><xsl:number level="any"
> > from="content"
> > count="row"/></xsl:variable>
> >       <xsl:attribute name="Row">
> >          <xsl:value-of select="$rownumber"/>
> >       </xsl:attribute>
> >        <gmr:Content>
> > 		<xsl:apply-templates/>
> > 	</gmr:Content>
> >      </gmr:Cell>
> >   </xsl:template>
> >
> >
> >   <xsl:template match="sql:trafficdirection">
> >      <gmr:Cell Col="2" ValueType="60">
> >       <xsl:variable name="rownumber"><xsl:number level="any"
> > from="content"
> > count="row"/></xsl:variable>
> >       <xsl:attribute name="Row">
> >          <xsl:value-of select="$rownumber"/>
> >       </xsl:attribute>
> >        <gmr:Content>
> > 		<xsl:apply-templates/>
> > 	</gmr:Content>
> >      </gmr:Cell>
> >   </xsl:template>
> >
> >
> >
> >   <xsl:template match="sql:checkpoint ">
> >      <gmr:Cell Col="3" ValueType="60">
> >       <xsl:variable name="rownumber"><xsl:number level="any"
> > from="content"
> > count="row"/></xsl:variable>
> >       <xsl:attribute name="Row">
> >          <xsl:value-of select="$rownumber"/>
> >       </xsl:attribute>
> >        <gmr:Content>
> > 		<xsl:apply-templates/>
> > 	</gmr:Content>
> >      </gmr:Cell>
> >   </xsl:template>
> >
> >
> >
> >
> >   <xsl:template match="sql:klassification">
> >      <gmr:Cell Col="4" ValueType="60">
> >       <xsl:variable name="rownumber"><xsl:number level="any"
> > from="content"
> > count="row"/></xsl:variable>
> >       <xsl:attribute name="Row">
> >          <xsl:value-of select="$rownumber"/>
> >       </xsl:attribute>
> >        <gmr:Content>
> > 		<xsl:apply-templates/>
> > 	</gmr:Content>
> >      </gmr:Cell>
> >   </xsl:template>
> >
> >
> >
> >   <xsl:template match="sql:guard_1">
> >      <gmr:Cell Col="5" ValueType="60">
> >       <xsl:variable name="rownumber"><xsl:number level="any"
> > from="content"
> > count="row"/></xsl:variable>
> >       <xsl:attribute name="Row">
> >          <xsl:value-of select="$rownumber"/>
> >       </xsl:attribute>
> >        <gmr:Content>
> > 		<xsl:apply-templates/>
> > 	</gmr:Content>
> >      </gmr:Cell>
> >   </xsl:template>
> >
> >   <xsl:template match="sql:guard_2">
> >      <gmr:Cell Col="6" ValueType="60">
> >       <xsl:variable name="rownumber"><xsl:number level="any"
> > from="content"
> > count="row"/></xsl:variable>
> >       <xsl:attribute name="Row">
> >          <xsl:value-of select="$rownumber"/>
> >       </xsl:attribute>
> >        <gmr:Content>
> > 		<xsl:apply-templates/>
> > 	</gmr:Content>
> >      </gmr:Cell>
> >   </xsl:template>
> >
> >   <xsl:template match="sql:objection">
> >      <gmr:Cell Col="7" ValueType="60">
> >       <xsl:variable name="rownumber"><xsl:number level="any"
> > from="content"
> > count="row"/></xsl:variable>
> >       <xsl:attribute name="Row">
> >          <xsl:value-of select="$rownumber"/>
> >       </xsl:attribute>
> >        <gmr:Content>
> > 		<xsl:apply-templates/>
> > 	</gmr:Content>
> >      </gmr:Cell>
> >   </xsl:template>
> >   <xsl:template match="sql:dtg">
> >      <gmr:Cell Col="8" ValueType="60">
> >       <xsl:variable name="rownumber"><xsl:number level="any"
> > from="content"
> > count="row"/></xsl:variable>
> >       <xsl:attribute name="Row">
> >          <xsl:value-of select="$rownumber"/>
> >       </xsl:attribute>
> >        <gmr:Content>
> > 		<xsl:apply-templates/>
> > 	</gmr:Content>
> >      </gmr:Cell>
> >   </xsl:template>
> >   <xsl:template match="sql:location">
> >      <gmr:Cell Col="9" ValueType="60">
> >       <xsl:variable name="rownumber"><xsl:number level="any"
> > from="content"
> > count="row"/></xsl:variable>
> >       <xsl:attribute name="Row">
> >          <xsl:value-of select="$rownumber"/>
> >       </xsl:attribute>
> >        <gmr:Content>
> > 		<xsl:apply-templates/>
> > 	</gmr:Content>
> >      </gmr:Cell>
> >   </xsl:template>
> >   <xsl:template match="sql:description">
> >      <gmr:Cell Col="10" ValueType="60">
> >       <xsl:variable name="rownumber"><xsl:number level="any"
> > from="content"
> > count="row"/></xsl:variable>
> >       <xsl:attribute name="Row">
> >          <xsl:value-of select="$rownumber"/>
> >       </xsl:attribute>
> >        <gmr:Content>
> > 		<xsl:apply-templates/>
> > 	</gmr:Content>
> >      </gmr:Cell>
> >   </xsl:template>  <xsl:template match="sql:numberofpersons">
> >      <gmr:Cell Col="11" ValueType="60">
> >       <xsl:variable name="rownumber"><xsl:number level="any"
> > from="content"
> > count="row"/></xsl:variable>
> >       <xsl:attribute name="Row">
> >          <xsl:value-of select="$rownumber"/>
> >       </xsl:attribute>
> >        <gmr:Content>
> > 		<xsl:apply-templates/>
> > 	</gmr:Content>
> >      </gmr:Cell>
> >   </xsl:template>  <xsl:template match="sql:observed">
> >      <gmr:Cell Col="12" ValueType="60">
> >       <xsl:variable name="rownumber"><xsl:number level="any"
> > from="content"
> > count="row"/></xsl:variable>
> >       <xsl:attribute name="Row">
> >          <xsl:value-of select="$rownumber"/>
> >       </xsl:attribute>
> >        <gmr:Content>
> > 		<xsl:apply-templates/>
> > 	</gmr:Content>
> >      </gmr:Cell>
> >   </xsl:template>
> >
> >
> >
> > </xsl:stylesheet>
> >
> >
> > ----------------------------------
> >
   

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