Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: xslt/ spreadsheetml loop

From: michanne@-----------.---------.---
To: NULL
Date: 1/4/2005 12:59:00 PM
Just what i needed. Thank you so much!


"Joris Gillis" wrote:

> 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)
> 


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