Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries [Thread Prev] >Thread Next - Re: xslt/ spreadsheetml loop xslt/ spreadsheetml loopTo: NULL Date: 1/3/2005 8:27:00 PM I am working on formatting xml into spreadsheets. Given this sample xml data:
<root>
<triangledata name = "triangle_1">
<summarydata title = "Average">
<_1>5.6666</_1>
<_2>1.0001</_2>
<_3>1.788</_3>
<_4>3.0266</_4>
</summarydata>
<summarydata title = "Total">
<_1>54</_1>
<_2>46</_2>
<_3>15</_3>
<_4>66</_4>
</summarydata>
</triangledata>
</root>
I want to line the data up as:
Title 1 2 3 4
Average 5.6666 1.0001 1.788 3.0266
Total 54 46 ...
the current xsl is something like (it works):
<Workbook>
<Worksheet ss:Name="Sheet1">
<Table>
<Row>
<xsl:call-template name="summarydata"/>
</Row>
</Table>
</Worksheet>
<xsl:template name="summarydata">
<xsl:for-each select="root/summarydata">
<Cell><Data><xsl:value-of select="@title"/></Data></Cell>
<Cell><Data><xsl:value-of select="_1"/></Data></Cell>
<Cell><Data><xsl:value-of select="_2"/></Data></Cell>
<Cell><Data><xsl:value-of select="_3"/></Data></Cell>
<Cell><Data><xsl:value-of select="_4"/></Data></Cell>
</xsl:for-each>
</xsl:template>
</Workbook>
The catch is the numbered elements change all the time - anywhere from _32
up to _100. Is there a way to do this in loop, rather than hardcode
everything? For instance 'for each element that starts-with "_"". Played with
these combos - but cant seem to get the syntax right. ( the underscore is
only there to comply with xml rules, the actually col names are numbers.)
also - does anyone know how to set up the worksheet name as the value of an
attribute or element? Stuck on this too
Many Thanks
Barbara
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
