[Home] [By Thread] [By Date] [Recent Entries]
Hi Chris,
Here's a stylesheet that does what you require (just run it against any conformant processor, even a browser, and you will get exactly the result you specified). It only utilizes xsl:apply-template and matching templates (note that the order is completely irrelevant). No need for any variable or any xsl:for-each. It is quite straightforward, I think. Just specify what you want to do when the processor encounters a certain node as input. Of most interest to you are, I think, the lowest level of matches, where you simply say (in procedural wording) "if you find an attribute of @ss:FontName, create a text node with 'font-family' and the name of the @ss:FontName" Please review it closely, I believe it should give you some insights in how powerful and easy XSLT can be with certain (seemingly rather complex) tasks (if you need professional services, don't hesitate! ;). Cheers, -- Abel Braaksma
<xsl:output indent="yes" /> <xsl:template match="/">
<xsl:apply-templates select="ss:Workbook/ss:Worksheet" />
</xsl:template> <xsl:template match="ss:Row">
<tr>
<xsl:apply-templates select="*" />
</tr>
</xsl:template> <xsl:template match="ss:Worksheet">
<table>
<xsl:apply-templates select="*"/>
</table>
</xsl:template><xsl:template match="ss:Cell"> <td> <xsl:attribute name="style"> <xsl:apply-templates select="/ss:Workbook/ss:Styles/ss:Style[@ss:ID = current()/@ss:StyleID]" /> </xsl:attribute> </td> </xsl:template> <xsl:template match="ss:Style">
<xsl:apply-templates select="*"/>
</xsl:template> <xsl:template match="ss:Alignment">
<!-- select attributes -->
<xsl:apply-templates select="@*" />
</xsl:template> <xsl:template match="@ss:Vertical">
<xsl:text>;vertical-align:</xsl:text>
<xsl:value-of select="."/>
</xsl:template> <xsl:template match="ss:Font">
<!-- select attributes -->
<xsl:apply-templates select="@*" />
</xsl:template><xsl:template match="@ss:FontName"> <xsl:text>;font-family:</xsl:text> <xsl:value-of select="."/> </xsl:template> <xsl:template match="@ss:Color"> <xsl:text>;color:</xsl:text> <xsl:value-of select="."/> </xsl:template> <xsl:template match="@ss:Underline">
<xsl:text>;text-decoration:</xsl:text>
<xsl:choose>
<xsl:when test=". = 'Single'">underline</xsl:when>
<xsl:otherwise>none</xsl:otherwise>
</xsl:choose>
</xsl:template></xsl:stylesheet> Chris M. wrote: Here's a bit of an example of what I'm talking about. The original XML is several thousand lines long:
|

Cart



