OSDN Git Service

git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/plugin@1020 1ca29b6e-896d...
[nucleus-jp/nucleus-plugins.git] / NP_TrackBack / branches / DOM-branch / trackback / js / rico / ricoSimpleGrid2xl.xsl
1 <xsl:stylesheet version="1.0"\r
2   xmlns="urn:schemas-microsoft-com:office:spreadsheet"\r
3   xmlns:xhtml="http://www.w3.org/1999/xhtml"\r
4   xmlns:xsl="http://www.w3.org/1999/XSL/Transform" \r
5         xmlns:msxsl="urn:schemas-microsoft-com:xslt"\r
6         xmlns:o="urn:schemas-microsoft-com:office:office"\r
7         xmlns:x="urn:schemas-microsoft-com:office:excel"\r
8   xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">\r
9 \r
10 <xsl:output method="xml" indent="yes" omit-xml-declaration="no" media-type="application/xml"/>\r
11 \r
12 <xsl:template match="/">\r
13   <xsl:processing-instruction name="mso-application">\r
14   <xsl:text>progid="Excel.Sheet"</xsl:text> \r
15   </xsl:processing-instruction>\r
16 \r
17   <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"\r
18    xmlns:o="urn:schemas-microsoft-com:office:office"\r
19    xmlns:x="urn:schemas-microsoft-com:office:excel"\r
20    xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"\r
21    xmlns:html="http://www.w3.org/TR/REC-html40">\r
22 \r
23  <Styles>\r
24   <Style ss:ID="Default" ss:Name="Normal">\r
25    <Alignment ss:Vertical="Bottom"/>\r
26    <Borders/>\r
27    <Font/>\r
28    <Interior/>\r
29    <NumberFormat/>\r
30    <Protection/>\r
31   </Style>\r
32   <Style ss:ID="s21">\r
33    <Font ss:Bold="1"/>\r
34    <Alignment ss:Horizontal="Center" ss:Vertical="Bottom"/>\r
35   </Style>\r
36   <Style ss:ID="s22">\r
37    <Alignment ss:Horizontal="Left" ss:Vertical="Bottom"/>\r
38    <Font ss:Bold="1"/>\r
39    <Interior ss:Color="#99CCFF" ss:Pattern="Solid"/>\r
40   </Style>\r
41   <Style ss:ID="s23" ss:Name="Currency">\r
42    <NumberFormat\r
43     ss:Format="_(&quot;$&quot;* #,##0.00_);_(&quot;$&quot;* \(#,##0.00\);_(&quot;$&quot;* &quot;-&quot;??_);_(@_)"/>\r
44   </Style>\r
45   <Style ss:ID="s24">\r
46    <NumberFormat ss:Format="_(* #,##0.00_);_(* \(#,##0.00\);_(* &quot;-&quot;??_);_(@_)"/>\r
47   </Style>\r
48   <Style ss:ID="s25">\r
49    <Alignment ss:Horizontal="Center" ss:Vertical="Bottom"/>\r
50   </Style>\r
51  </Styles>\r
52 \r
53   <xsl:apply-templates mode="top"/> \r
54 \r
55   </Workbook>\r
56 </xsl:template>\r
57 \r
58 \r
59 <xsl:template match="*" mode="top">\r
60   <xsl:choose>\r
61 \r
62   <xsl:when test="xhtml:table[@class='ricoSimpleGrid']">\r
63   <xsl:apply-templates mode="grid"/> \r
64   </xsl:when>\r
65 \r
66   <xsl:otherwise>\r
67   <xsl:apply-templates select="*" mode="top"/> \r
68   </xsl:otherwise>\r
69   \r
70   </xsl:choose>\r
71 </xsl:template>\r
72 \r
73 \r
74 <xsl:template match="*" mode="grid">\r
75 \r
76   <xsl:choose>\r
77   \r
78   <xsl:when test="xhtml:thead">\r
79   <xsl:call-template name="processTable">\r
80   <xsl:with-param name="id" select="@id"/>\r
81   <xsl:with-param name="headRows" select="xhtml:thead/xhtml:tr"/>\r
82   <xsl:with-param name="bodyRows" select="xhtml:tbody/xhtml:tr"/>\r
83   </xsl:call-template>\r
84   </xsl:when>\r
85   \r
86   <xsl:when test="xhtml:tbody">\r
87   <xsl:call-template name="processTable">\r
88   <xsl:with-param name="id" select="@id"/>\r
89   <xsl:with-param name="headRows" select="xhtml:tbody/xhtml:tr[1]"/>\r
90   <xsl:with-param name="bodyRows" select="xhtml:tbody/xhtml:tr[position() &gt; 1]"/>\r
91   </xsl:call-template>\r
92   </xsl:when>\r
93   \r
94   <xsl:otherwise>\r
95   <xsl:call-template name="processTable">\r
96   <xsl:with-param name="id" select="@id"/>\r
97   <xsl:with-param name="headRows" select="xhtml:tr[1]"/>\r
98   <xsl:with-param name="bodyRows" select="xhtml:tr[position() &gt; 1]"/>\r
99   </xsl:call-template>\r
100   </xsl:otherwise>\r
101   \r
102   </xsl:choose>\r
103 \r
104 </xsl:template>\r
105 \r
106 \r
107 <!-- Perform the actual table transformation -->\r
108   \r
109 <xsl:template name="processTable">\r
110 <xsl:param name="id" />\r
111 <xsl:param name="headRows" />\r
112 <xsl:param name="bodyRows" />\r
113 \r
114  <Worksheet>\r
115  <xsl:attribute name="ss:Name">\r
116    <xsl:value-of select='$id'/>\r
117  </xsl:attribute>\r
118   <Table>\r
119 \r
120   <xsl:apply-templates select="$headRows" mode="convertHeadRow"/>\r
121   <xsl:apply-templates select="$bodyRows" mode="convertBodyRow"/>\r
122 \r
123   </Table>\r
124  </Worksheet>\r
125 \r
126 </xsl:template>\r
127 \r
128 \r
129 <xsl:template match="*" mode="convertHeadRow">\r
130    <Row>\r
131     <xsl:apply-templates select="xhtml:td | xhtml:th" mode="convertHeadCell"/>\r
132    </Row>\r
133 </xsl:template>\r
134 \r
135 \r
136 <xsl:template match="*" mode="convertHeadCell">\r
137   <xsl:element name="Cell">\r
138   <xsl:attribute name="ss:StyleID">s22</xsl:attribute>\r
139   <xsl:if test="@colspan">\r
140   <xsl:attribute name="ss:MergeAcross"><xsl:value-of select="number(@colspan)-1"/></xsl:attribute>\r
141   </xsl:if>\r
142     <Data ss:Type="String">\r
143     <xsl:value-of select="."/>\r
144     </Data>\r
145   </xsl:element>\r
146 </xsl:template>\r
147 \r
148 \r
149 <xsl:template match="*" mode="convertBodyRow">\r
150    <Row>\r
151     <xsl:apply-templates select="xhtml:td | xhtml:th" mode="convertBodyCell"/>\r
152    </Row>\r
153 </xsl:template>\r
154 \r
155 \r
156 <xsl:template match="*" mode="convertBodyCell">\r
157     <Cell><Data ss:Type="String"><xsl:value-of select="."/></Data></Cell>\r
158 </xsl:template>\r
159 \r
160 </xsl:stylesheet>