Thanks to everyone who answered and sorry for the vague question . I got it
working with the below xsl, but there is one problem. The columns get
printed from column1 instead of column0. Can someone tell me how I can print
right from column0. I tried to change to do so but it didnt work.
My input xml looks like this
<result>
<column>time</column><column>time1</column>
<row><time>1</time><time1>3</time1></row>
<row><time>001</time><time1>300</time1></row>
</result>
A snippet from my xsl.
<xsl:template match="result">
<xsl:for-each select="column">
<gmr:Cell Row="0" ValueType="60">
<xsl:variable name="colnumber"><xsl:number level="single"
from="column" count="column"/></xsl:variable>
<xsl:attribute name="Col">
<xsl:value-of select="$colnumber"/>
</xsl:attribute>
<gmr:Content>
<xsl:apply-templates select="." mode="value"/>
</gmr:Content>
</gmr:Cell>
</xsl:for-each>
<xsl:for-each select="row">
<xsl:apply-templates select=".">
<xsl:with-param name="rownumber" select="position()"/>
</xsl:apply-templates>
</xsl:for-each>
</xsl:template>
<xsl:template match="row">
<xsl:param name="rownumber" select="1"/>
<xsl:for-each select="*">
<xsl:apply-templates select=".">
<xsl:with-param name="rownumber" select="$rownumber"/>
<xsl:with-param name="colnumber" select="position()"/>
</xsl:apply-templates>
</xsl:for-each>
</xsl:template>
On Friday 05 March 2004 12:48 pm, Wendell Piez wrote:
Anna,
It's a bit hard to answer your question since we are having to guess what
you want your output to look like. (No we don't all use Excel every day.
:-)
In general, however, I can say you don't need or want to use a counter. (In
XSLT you almost never do.) Accordingly, a simple and clean stylesheet to do
what you want will look quite different from what you have so far.
If you post again with a sample of the output you want, it'll be easier for
someone to give you more concrete help.
Cheers,
Wendell
At 11:30 AM 3/5/2004, you wrote:
Can someone please answer my question below I am stuck.
On Thursday 04 March 2004 03:41 pm, Anna Bikkina wrote:
Hi,
I have a xml file that has to converted to excel. I am trying to use a
xsl s stylesheet and cocoon to do this job for me.
Below is my xml. I am able to display the column's correctly in excel
but when it comes to data . I am not able to have <Time> data in
column1, <Action> data in column. I am not able to increment the column
value from 0 to 5. The problem is the number of columns I will have is
not known prior . So I have to use the count() function to get this
done. The way it is printing row data right now is in column 5 it
prints the value of <user1> thats it. Please check the xsl below and
let me know where I am making a mistake.
<xsl:template match="result">
<xsl:for-each select="column">
<gmr:Cell Row="0" ValueType="60">
<xsl:variable name="colnumber"><xsl:number
level="any" from="result" count="column"/></xsl:variable>
<xsl:attribute name="Col">
<xsl:value-of select="$colnumber"/>
</xsl:attribute>
<gmr:Content>
<xsl:apply-templates select="."
mode="value"/>
</gmr:Content>
</gmr:Cell>
</xsl:for-each>
<xsl:for-each select="row">
<xsl:variable name="rownumber"><xsl:number level="any"
from="result" count="row"/></xsl:variable>
<xsl:variable name="cnumber"><xsl:number level="any"
from="result"
count="column"/></xsl:variable>
<xsl:for-each select="*">
<gmr:Cell ValueType="60">
<xsl:attribute name="Row">
<xsl:value-of select="$rownumber"/>
</xsl:attribute>
<xsl:attribute name="Col">
<xsl:value-of
select="$cnumber"/> <!-- cnumber is not working
properly. How can I get this working-->
</xsl:attribute>
<gmr:Content>
<xsl:apply-templates
select="." mode="value"/>
</gmr:Content>
</gmr:Cell>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
My XML FILE
<?xml version="1.0"?>
<page>
<title>Hello</title>
<content>
<result>
<column>Time</column>
<column>Action</column>
<column>Price</column>
<column>User</column>
<column>User1</br></column>
<row>
<Time>1</Time>
<Action>120000</Action>
<Price>13</Price>
<Name>12000</Name> <Name1>120000</Name1> </row>
</result>
</content>
</page>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
======================================================================
Wendell Piez
mailto:wapiez(_at_)mulberrytech(_dot_)com
Mulberry Technologies, Inc. http://www.mulberrytech.com
17 West Jefferson Street Direct Phone: 301/315-9635
Suite 207 Phone: 301/315-9631
Rockville, MD 20850 Fax: 301/315-8285
----------------------------------------------------------------------
Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list