Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - xslt/ spreadsheetml loop >Thread Next - Re: xslt/ spreadsheetml loop Re: xslt/ spreadsheetml loopTo: NULL Date: 1/4/2005 9:26:00 AM Hi,
> 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.)
That would be <xsl:for-each select="*[starts-with(local-name(),'_')]">, but if the cols are the only child elements, you could use "*".
> Also - does anyone know how to set up the worksheet name as the value of anattribute or element? Stuck on this too
something like <Worksheet ss:Name="{@attribute}"/>
On the whole, the following (template-oriented) stylesheet will produce the desired output:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ss="something">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="root">
<Workbook>
<xsl:apply-templates select="triangledata"/>
</Workbook>
</xsl:template>
<xsl:template match="triangledata">
<Worksheet ss:Name="{@name}">
<Table>
<xsl:apply-templates select="summarydata[1]" mode="Title"/>
<xsl:apply-templates select="summarydata"/>
</Table>
</Worksheet>
</xsl:template>
<xsl:template match="summarydata">
<Row>
<Cell><Data><xsl:value-of select="@title"/></Data></Cell>
<xsl:apply-templates select="*[starts-with(local-name(),'_')]"/>
</Row>
</xsl:template>
<xsl:template match="summarydata/*">
<Cell><Data><xsl:value-of select="."/></Data></Cell>
</xsl:template>
<xsl:template match="summarydata" mode="Title">
<Row>
<Cell><Data>Title</Data></Cell>
<xsl:apply-templates select="*[starts-with(local-name(),'_')]" mode="Title"/>
</Row>
</xsl:template>
<xsl:template match="summarydata/*" mode="Title">
<Cell><Data><xsl:value-of select="substring-after(local-name(),'_')"/></Data></Cell>
</xsl:template>
</xsl:stylesheet>
regards,
--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-view.cgi?userid=38041)
Spread the wiki (http://www.wikipedia.org)
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
