Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Xsl transformation to Excel
Message
From
01/05/2006 18:36:28
 
General information
Forum:
ASP.NET
Category:
XML
Miscellaneous
Thread ID:
01118212
Message ID:
01118223
Views:
10
>Please try to change your test condition to the following:
>
>
><xsl:choose>
>	<xsl:when test="string(number(.))!='NaN'">
>		<Data Type="Number">
>			<xsl:value-of select="."/>
>		</Data>	
>	</xsl:when>
>	<xsl:otherwise>
>		<Data Type="String">
>			<xsl:value-of select="."/>
>		</Data>
>	</xsl:otherwise>
></xsl:choose>
>
>
>Notice that I have also exchanged the "if" construction to "choose" but this has no influence on the solution. I did that only to keep the conditional logic in one place.

This is the Xls as I have it now but I cannot process it with that change:
<xsl:stylesheet version="1.0"
    xmlns="urn:schemas-microsoft-com:office:spreadsheet"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
 xmlns:msxsl="urn:schemas-microsoft-com:xslt"
 xmlns:user="urn:my-scripts"
 xmlns:o="urn:schemas-microsoft-com:office:office"
 xmlns:x="urn:schemas-microsoft-com:office:excel"
 xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" > 
 
<xsl:template match="/">
  <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
    xmlns:o="urn:schemas-microsoft-com:office:office"
    xmlns:x="urn:schemas-microsoft-com:office:excel"
    xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
    xmlns:html="http://www.w3.org/TR/REC-html40">
    <xsl:apply-templates/>
  </Workbook>
</xsl:template>


<xsl:template match="/*">
  <Worksheet>
  <xsl:attribute name="ss:Name">
  <xsl:value-of select="local-name(/*/*)"/>
  </xsl:attribute>
    <Table x:FullColumns="1" x:FullRows="1">
      <Row>
        <xsl:for-each select="*[position() = 1]/*">
          <Cell><Data ss:Type="String">
          <xsl:value-of select="local-name()"/>
          </Data></Cell>
        </xsl:for-each>
      </Row>
      <xsl:apply-templates/>
    </Table>
  </Worksheet>
</xsl:template>


<xsl:template match="/*/*">
  <Row>
    <xsl:apply-templates/>
  </Row>
</xsl:template>


<xsl:template match="/*/*/*">
  <Cell>
	<xsl:when test="string(number(.))!='NaN'">
		<Data Type="Number">
			<xsl:value-of select="."/>
		</Data>	
	</xsl:when>
	<xsl:otherwise>
		<Data Type="String">
			<xsl:value-of select="."/>
		</Data>
	</xsl:otherwise>
</Cell>
</xsl:template>


</xsl:stylesheet>
I also tried to insert the choose tag after the cell tag and the closing tag before the Cell closing tag but this doesn't work either.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform