Xpoint
   [напомнить пароль]

Помогите с XSLT преобразованием для MS excel

Метки: [без меток]
2008-03-19 15:42:56 [обр] Paul[досье]
сообщение промодерировано

Есть исходный xml файл

<?xml version="1.0"?>
<ROWSET>
<ROW>
<DAY>01/03/2008</DAY>
<IN_UKR_N>0</IN_UKR_N>
<IN_UKR_D>292764223</IN_UKR_D>
<OUT_UKR_N>0</OUT_UKR_N>
<OUT_UKR_D>302375502</OUT_UKR_D>
<OUT_SAT_N>0</OUT_SAT_N>
<OUT_SAT_D>2651765</OUT_SAT_D>
<IN_SAT_N>0</IN_SAT_N>
<IN_SAT_D>47044078</IN_SAT_D>
<OUT_VOL_N>0</OUT_VOL_N>
<OUT_VOL_D>0</OUT_VOL_D>
<IN_VOL_N>0</IN_VOL_N>
<IN_VOL_D>0</IN_VOL_D>
<IN_TOTAL>339808301</IN_TOTAL>
<OUT_TOTAL>305027267</OUT_TOTAL>
<TOTAL>644835568</TOTAL>
</ROW>
<ROW>
<DAY>02/03/2008</DAY>
<IN_UKR_N>0</IN_UKR_N>
<IN_UKR_D>56507627</IN_UKR_D>
<OUT_UKR_N>0</OUT_UKR_N>
<OUT_UKR_D>100864532</OUT_UKR_D>
<OUT_SAT_N>0</OUT_SAT_N>
<OUT_SAT_D>6489823</OUT_SAT_D>
<IN_SAT_N>0</IN_SAT_N>
<IN_SAT_D>87653153</IN_SAT_D>
<OUT_VOL_N>0</OUT_VOL_N>
<OUT_VOL_D>0</OUT_VOL_D>
<IN_VOL_N>0</IN_VOL_N>
<IN_VOL_D>0</IN_VOL_D>
<IN_TOTAL>144160780</IN_TOTAL>
<OUT_TOTAL>107354355</OUT_TOTAL>
<TOTAL>251515135</TOTAL>
</ROW>
<ROW>
<DAY>03/03/2008</DAY>
<IN_UKR_N>0</IN_UKR_N>
<IN_UKR_D>111396150</IN_UKR_D>
<OUT_UKR_N>0</OUT_UKR_N>
<OUT_UKR_D>5574435</OUT_UKR_D>
<OUT_SAT_N>0</OUT_SAT_N>
<OUT_SAT_D>20441575</OUT_SAT_D>
<IN_SAT_N>0</IN_SAT_N>
<IN_SAT_D>95616883</IN_SAT_D>
<OUT_VOL_N>0</OUT_VOL_N>
<OUT_VOL_D>0</OUT_VOL_D>
<IN_VOL_N>0</IN_VOL_N>
<IN_VOL_D>0</IN_VOL_D>
<IN_TOTAL>207013033</IN_TOTAL>
<OUT_TOTAL>26016010</OUT_TOTAL>
<TOTAL>233029043</TOTAL>
</ROW>
<ROW>
<DAY>04/03/2008</DAY>
<IN_UKR_N>0</IN_UKR_N>
<IN_UKR_D>35511652</IN_UKR_D>
<OUT_UKR_N>0</OUT_UKR_N>
<OUT_UKR_D>3087191</OUT_UKR_D>
<OUT_SAT_N>0</OUT_SAT_N>
<OUT_SAT_D>3730766</OUT_SAT_D>
<IN_SAT_N>0</IN_SAT_N>
<IN_SAT_D>42935207</IN_SAT_D>
<OUT_VOL_N>0</OUT_VOL_N>
<OUT_VOL_D>0</OUT_VOL_D>
<IN_VOL_N>0</IN_VOL_N>
<IN_VOL_D>0</IN_VOL_D>
<IN_TOTAL>78446859</IN_TOTAL>
<OUT_TOTAL>6817957</OUT_TOTAL>
<TOTAL>85264816</TOTAL>
</ROW>
</ROWSET>

Что нужно еще добавить в данный XSLT шаблон преобразования

<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><Data ss:Type="String">
<xsl:value-of select="."/>
</Data></Cell>
</xsl:template>

</xsl:stylesheet>

что бы получить

<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<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" xmlns:user="urn:my-scripts"
xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<Worksheet ss:Name="Sheet1">
<Table ss:ExpandedColumnCount="16" ss:ExpandedRowCount="3" x:FullColumns="1"
x:FullRows="1">
<Row>
<Cell><Data ss:Type="String">DAY</Data></Cell>
<Cell><Data ss:Type="String">IN_UKR_N</Data></Cell>
<Cell><Data ss:Type="String">IN_UKR_D</Data></Cell>
<Cell><Data ss:Type="String">OUT_UKR_N</Data></Cell>
<Cell><Data ss:Type="String">OUT_UKR_D</Data></Cell>
<Cell><Data ss:Type="String">OUT_SAT_N</Data></Cell>
<Cell><Data ss:Type="String">OUT_SAT_D</Data></Cell>
<Cell><Data ss:Type="String">IN_SAT_N</Data></Cell>
<Cell><Data ss:Type="String">IN_SAT_D</Data></Cell>
<Cell><Data ss:Type="String">OUT_VOL_N</Data></Cell>
<Cell><Data ss:Type="String">OUT_VOL_D</Data></Cell>
<Cell><Data ss:Type="String">IN_VOL_N</Data></Cell>
<Cell><Data ss:Type="String">IN_VOL_D</Data></Cell>
<Cell><Data ss:Type="String">IN_TOTAL</Data></Cell>
<Cell><Data ss:Type="String">OUT_TOTAL</Data></Cell>
<Cell><Data ss:Type="String">TOTAL</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="String">01/03/2008</Data></Cell>
<Cell><Data ss:Type="String">0</Data></Cell>
<Cell><Data ss:Type="String">292764223</Data></Cell>
<Cell><Data ss:Type="String">0</Data></Cell>
<Cell><Data ss:Type="String">302375502</Data></Cell>
<Cell><Data ss:Type="String">0</Data></Cell>
<Cell><Data ss:Type="String">2651765</Data></Cell>
<Cell><Data ss:Type="String">0</Data></Cell>
<Cell><Data ss:Type="String">47044078</Data></Cell>
<Cell><Data ss:Type="String">0</Data></Cell>
<Cell><Data ss:Type="String">0</Data></Cell>
<Cell><Data ss:Type="String">0</Data></Cell>
<Cell><Data ss:Type="String">0</Data></Cell>
<Cell><Data ss:Type="String">339808301</Data></Cell>
<Cell><Data ss:Type="String">305027267</Data></Cell>
<Cell><Data ss:Type="String">644835568</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="String">02/03/2008</Data></Cell>
<Cell><Data ss:Type="String">0</Data></Cell>
<Cell><Data ss:Type="String">56507627</Data></Cell>
<Cell><Data ss:Type="String">0</Data></Cell>
<Cell><Data ss:Type="String">100864532</Data></Cell>
<Cell><Data ss:Type="String">0</Data></Cell>
<Cell><Data ss:Type="String">6489823</Data></Cell>
<Cell><Data ss:Type="String">0</Data></Cell>
<Cell><Data ss:Type="String">87653153</Data></Cell>
<Cell><Data ss:Type="String">0</Data></Cell>
<Cell><Data ss:Type="String">0</Data></Cell>
<Cell><Data ss:Type="String">0</Data></Cell>
<Cell><Data ss:Type="String">0</Data></Cell>
<Cell><Data ss:Type="String">144160780</Data></Cell>
<Cell><Data ss:Type="String">107354355</Data></Cell>
<Cell><Data ss:Type="String">251515135</Data></Cell>
</Row>
</Table>
</Worksheet>
<Worksheet ss:Name="Sheet2">
<Table ss:ExpandedColumnCount="16" ss:ExpandedRowCount="3" x:FullColumns="1"
x:FullRows="1">
<Row>
<Cell><Data ss:Type="String">DAY</Data></Cell>
<Cell><Data ss:Type="String">IN_UKR_N</Data></Cell>
<Cell><Data ss:Type="String">IN_UKR_D</Data></Cell>
<Cell><Data ss:Type="String">OUT_UKR_N</Data></Cell>
<Cell><Data ss:Type="String">OUT_UKR_D</Data></Cell>
<Cell><Data ss:Type="String">OUT_SAT_N</Data></Cell>
<Cell><Data ss:Type="String">OUT_SAT_D</Data></Cell>
<Cell><Data ss:Type="String">IN_SAT_N</Data></Cell>
<Cell><Data ss:Type="String">IN_SAT_D</Data></Cell>
<Cell><Data ss:Type="String">OUT_VOL_N</Data></Cell>
<Cell><Data ss:Type="String">OUT_VOL_D</Data></Cell>
<Cell><Data ss:Type="String">IN_VOL_N</Data></Cell>
<Cell><Data ss:Type="String">IN_VOL_D</Data></Cell>
<Cell><Data ss:Type="String">IN_TOTAL</Data></Cell>
<Cell><Data ss:Type="String">OUT_TOTAL</Data></Cell>
<Cell><Data ss:Type="String">TOTAL</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="String">03/03/2008</Data></Cell>
<Cell><Data ss:Type="String">0</Data></Cell>
<Cell><Data ss:Type="String">111396150</Data></Cell>
<Cell><Data ss:Type="String">0</Data></Cell>
<Cell><Data ss:Type="String">5574435</Data></Cell>
<Cell><Data ss:Type="String">0</Data></Cell>
<Cell><Data ss:Type="String">20441575</Data></Cell>
<Cell><Data ss:Type="String">0</Data></Cell>
<Cell><Data ss:Type="String">95616883</Data></Cell>
<Cell><Data ss:Type="String">0</Data></Cell>
<Cell><Data ss:Type="String">0</Data></Cell>
<Cell><Data ss:Type="String">0</Data></Cell>
<Cell><Data ss:Type="String">0</Data></Cell>
<Cell><Data ss:Type="String">207013033</Data></Cell>
<Cell><Data ss:Type="String">26016010</Data></Cell>
<Cell><Data ss:Type="String">233029043</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="String">04/03/2008</Data></Cell>
<Cell><Data ss:Type="String">0</Data></Cell>
<Cell><Data ss:Type="String">35511652</Data></Cell>
<Cell><Data ss:Type="String">0</Data></Cell>
<Cell><Data ss:Type="String">3087191</Data></Cell>
<Cell><Data ss:Type="String">0</Data></Cell>
<Cell><Data ss:Type="String">3730766</Data></Cell>
<Cell><Data ss:Type="String">0</Data></Cell>
<Cell><Data ss:Type="String">42935207</Data></Cell>
<Cell><Data ss:Type="String">0</Data></Cell>
<Cell><Data ss:Type="String">0</Data></Cell>
<Cell><Data ss:Type="String">0</Data></Cell>
<Cell><Data ss:Type="String">0</Data></Cell>
<Cell><Data ss:Type="String">78446859</Data></Cell>
<Cell><Data ss:Type="String">6817957</Data></Cell>
<Cell><Data ss:Type="String">85264816</Data></Cell>
</Row>
</Table>
</Worksheet>
</Workbook>

т.е. добавить разбивку на листы в Excel по задаваемому количеству строк.

Powered by POEM™ Engine Copyright © 2002-2005