<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>
<Worksheet ss:Name="my first worksheet">
<Table>
<Row>
<Cell>
<Data ss:Type="String">11</Data>
</Cell>
<Cell>
<Data ss:Type="String">22</Data>
</Cell>
<Cell>
<Data ss:Type="String">33</Data>
</Cell>
<Cell>
<Data ss:Type="String">44</Data>
</Cell>
<Cell>
<Data ss:Type="String">55</Data>
</Cell>
</Row>
<xsl:call-template name="staffReport" />
</Table>
</Worksheet>
<Worksheet ss:Name="second">
<Table>
<Row>
<Cell>
<Data ss:Type="String">name</Data>
</Cell>
<Cell>
<Data ss:Type="String">age</Data>
</Cell>
</Row>
<xsl:call-template name="child" />
</Table>
</Worksheet>
</Workbook>
</xsl:template>
<xsl:template name="staffReport">
<xsl:for-each select="/records/record">
<Row>
<Cell>
<Data ss:Type="String">
<xsl:value-of select="id" />
</Data>
</Cell>
<Cell>
<Data ss:Type="String">
<xsl:value-of select="company" />
</Data>
</Cell>
<Cell>
<Data ss:Type="String">
<xsl:value-of select="price" />
</Data>
</Cell>
<Cell>
<Data ss:Type="String">
<xsl:value-of select="change" />
</Data>
</Cell>
<Cell>
<Data ss:Type="String">
<xsl:value-of select="pctChange" />
</Data>
</Cell>
</Row>
</xsl:for-each>
</xsl:template>
<xsl:template name="child">
<xsl:for-each select="/records/record/child">
<Row>
<Cell>
<Data ss:Type="String">
<xsl:value-of select="name" />
</Data>
</Cell>
<Cell>
<Data ss:Type="String">
<xsl:value-of select="age" />
</Data>
</Cell>
</Row>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
xsl实例
最新推荐文章于 2019-02-19 17:56:56 发布