Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


xslt/ spreadsheetml loop

From: michanne@-----------.---------.---
To: 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





transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent