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 / ricoSimpleGrid.xsl
1 <?xml version="1.0"?>\r
2 \r
3 <xsl:stylesheet version="1.0"\r
4   xmlns:xhtml="http://www.w3.org/1999/xhtml"\r
5   xmlns="http://www.w3.org/1999/xhtml"\r
6   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"\r
7   xmlns:xs="http://www.w3.org/2001/XMLSchema"\r
8   xmlns:fn="http://www.w3.org/2005/02/xpath-functions"\r
9   xmlns:xdt="http://www.w3.org/2005/02/xpath-datatypes"\r
10 exclude-result-prefixes="xhtml xsl fn xs xdt">\r
11 \r
12 <xsl:output\r
13 omit-xml-declaration="yes"\r
14 method="html"\r
15 doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"\r
16 doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>\r
17 \r
18 <xsl:attribute-set name="ricoTable"> \r
19   <xsl:attribute name="cellspacing">0</xsl:attribute> \r
20   <xsl:attribute name="cellpadding">0</xsl:attribute> \r
21 </xsl:attribute-set> \r
22 \r
23 <!-- the identity template -->\r
24 \r
25 <xsl:template match="*">\r
26   <xsl:copy>\r
27   <xsl:copy-of select="@*"/>\r
28   <xsl:apply-templates/>\r
29   </xsl:copy>\r
30 </xsl:template>\r
31 \r
32 \r
33 <!-- Transform head section -->\r
34 \r
35 <xsl:template match="xhtml:head">\r
36   <xsl:copy>\r
37   <xsl:apply-templates mode="head"/>\r
38 <script type="text/javascript">\r
39 //<![CDATA[\r
40 if (typeof ricoInit!='undefined') {\r
41   if (window.addEventListener)\r
42     window.addEventListener('load', ricoInit, false);\r
43   else if (window.attachEvent)\r
44     window.attachEvent('onload', ricoInit);\r
45 }\r
46 // ]]>\r
47 </script>\r
48   </xsl:copy>\r
49 </xsl:template>\r
50 \r
51 <xsl:template match="*[name()!='script']" mode="head">\r
52   <xsl:copy>\r
53   <xsl:copy-of select="@*|node()"/>\r
54   </xsl:copy>\r
55 </xsl:template>\r
56 \r
57 <xsl:template match="xhtml:script" mode="head">\r
58   <xsl:copy>\r
59   <xsl:copy-of select="@*"/>\r
60   <xsl:value-of select="." disable-output-escaping="yes"/>\r
61   </xsl:copy>\r
62 </xsl:template>\r
63 \r
64 \r
65 <!-- Transform tables with class ricoSimpleGrid -->\r
66   \r
67 <xsl:template match="xhtml:table[@class='ricoSimpleGrid']">\r
68 <xsl:choose>\r
69 \r
70 <xsl:when test="xhtml:thead">\r
71 <xsl:call-template name="processTable">\r
72 <xsl:with-param name="id" select="@id"/>\r
73 <xsl:with-param name="headRows" select="xhtml:thead/xhtml:tr"/>\r
74 <xsl:with-param name="bodyRows" select="xhtml:tbody/xhtml:tr"/>\r
75 </xsl:call-template>\r
76 </xsl:when>\r
77 \r
78 <xsl:when test="xhtml:tbody">\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:tbody/xhtml:tr[1]"/>\r
82 <xsl:with-param name="bodyRows" select="xhtml:tbody/xhtml:tr[position() &gt; 1]"/>\r
83 </xsl:call-template>\r
84 </xsl:when>\r
85 \r
86 <xsl:otherwise>\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:tr[1]"/>\r
90 <xsl:with-param name="bodyRows" select="xhtml:tr[position() &gt; 1]"/>\r
91 </xsl:call-template>\r
92 </xsl:otherwise>\r
93 \r
94 </xsl:choose>\r
95 </xsl:template>\r
96 \r
97 \r
98 <!-- Perform the actual table transformation -->\r
99   \r
100 <xsl:template name="processTable">\r
101 <xsl:param name="id" />\r
102 <xsl:param name="headRows" />\r
103 <xsl:param name="bodyRows" />\r
104 \r
105 <xsl:variable name="headIdx">\r
106 <xsl:choose>\r
107 <xsl:when test="$headRows[@class='ricoHeading']">\r
108 <xsl:value-of select="count($headRows[@class='ricoHeading']/preceding-sibling::*)+1"/>\r
109 </xsl:when>\r
110 <xsl:otherwise>\r
111 <xsl:value-of select="count($headRows)"/>\r
112 </xsl:otherwise>\r
113 </xsl:choose>\r
114 </xsl:variable>\r
115 \r
116 <xsl:variable name="headMain" select="$headRows[position()=$headIdx]"/>\r
117 <xsl:variable name="headCols" select="$headMain/xhtml:th | $headMain/xhtml:td"/>\r
118 \r
119 <!--\r
120 <p><xsl:value-of select="$id"/>\r
121 <br />headRowCnt: <xsl:value-of select="count($headRows)"/>\r
122 <br />headIdx: <xsl:value-of select="$headIdx"/>\r
123 <br />bodyRowCnt: <xsl:value-of select="count($bodyRows)"/>\r
124 </p>\r
125 -->\r
126 \r
127 <xsl:element name="div">\r
128 <xsl:attribute name="id"><xsl:value-of select="concat($id,'_outerDiv')"/></xsl:attribute>\r
129 <xsl:attribute name="class">ricoLG_outerDiv</xsl:attribute>\r
130 <xsl:attribute name="onload"></xsl:attribute>\r
131 \r
132 <!-- Create frozen (left) pane -->\r
133 \r
134 <xsl:element name="div">\r
135 <xsl:attribute name="id"><xsl:value-of select="concat($id,'_frozenTabsDiv')"/></xsl:attribute>\r
136 <xsl:attribute name="class">ricoLG_frozenTabsDiv</xsl:attribute>\r
137 \r
138 <xsl:call-template name="convertTHead">\r
139 <xsl:with-param name="rows" select="$headRows"/>\r
140 <xsl:with-param name="headIdx" select="$headIdx"/>\r
141 <xsl:with-param name="frozen" select="1"/>\r
142 <xsl:with-param name="id" select="concat($id,'_tab0h')"/>\r
143 </xsl:call-template>\r
144 \r
145 <xsl:call-template name="convertTBody">\r
146 <xsl:with-param name="rows" select="$bodyRows"/>\r
147 <xsl:with-param name="cols" select="$headCols"/>\r
148 <xsl:with-param name="id" select="concat($id,'_tab0')"/>\r
149 <xsl:with-param name="frozen" select="1"/>\r
150 </xsl:call-template>\r
151 \r
152 </xsl:element>\r
153 \r
154 <xsl:element name="div">\r
155 <xsl:attribute name="id"><xsl:value-of select="concat($id,'_innerDiv')"/></xsl:attribute>\r
156 <xsl:attribute name="class">ricoLG_innerDiv</xsl:attribute>\r
157 \r
158 <xsl:element name="div">\r
159 <xsl:attribute name="id"><xsl:value-of select="concat($id,'_scrollTabsDiv')"/></xsl:attribute>\r
160 <xsl:attribute name="class">ricoLG_scrollTabsDiv</xsl:attribute>\r
161 \r
162 <xsl:call-template name="convertTHead">\r
163 <xsl:with-param name="rows" select="$headRows"/>\r
164 <xsl:with-param name="headIdx" select="$headIdx"/>\r
165 <xsl:with-param name="frozen" select="0"/>\r
166 <xsl:with-param name="id" select="concat($id,'_tab1h')"/>\r
167 </xsl:call-template>\r
168 \r
169 </xsl:element>\r
170 </xsl:element>\r
171 \r
172 <xsl:element name="div">\r
173 <xsl:attribute name="id"><xsl:value-of select="concat($id,'_scrollDiv')"/></xsl:attribute>\r
174 <xsl:attribute name="class">ricoLG_scrollDiv</xsl:attribute>\r
175 \r
176 <xsl:call-template name="convertTBody">\r
177 <xsl:with-param name="rows" select="$bodyRows"/>\r
178 <xsl:with-param name="cols" select="$headCols"/>\r
179 <xsl:with-param name="id" select="concat($id,'_tab1')"/>\r
180 <xsl:with-param name="frozen" select="0"/>\r
181 </xsl:call-template>\r
182 </xsl:element>\r
183 \r
184 </xsl:element>\r
185 \r
186 </xsl:template>\r
187 \r
188 \r
189 <!-- Convert thead section -->\r
190 \r
191 <xsl:template name="convertTHead">\r
192 <xsl:param name = "rows" />\r
193 <xsl:param name = "headIdx" />\r
194 <xsl:param name = "frozen" />\r
195 <xsl:param name = "id" />\r
196 <xsl:element name="table" use-attribute-sets="ricoTable">\r
197 <xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute>\r
198 <xsl:attribute name="class">ricoLG_table ricoLG_top\r
199 <xsl:if test="$frozen">ricoLG_left</xsl:if>\r
200 <xsl:if test="not($frozen)">ricoLG_right</xsl:if>\r
201 </xsl:attribute>\r
202 <xsl:element name="thead">\r
203   <xsl:for-each select="$rows">\r
204     <xsl:choose>\r
205     <xsl:when test="position() = $headIdx">\r
206       <xsl:apply-templates select="." mode="convertHeadRow">\r
207       <xsl:with-param name="id" select="concat($id,'_main')"/>\r
208       <xsl:with-param name="frozen" select="$frozen"/>\r
209       </xsl:apply-templates>\r
210     </xsl:when>\r
211     <xsl:otherwise>\r
212       <xsl:apply-templates select="." mode="convertHeadRow">\r
213       <xsl:with-param name="id" select="concat($id,'_',position())"/>\r
214       <xsl:with-param name="frozen" select="$frozen"/>\r
215       </xsl:apply-templates>\r
216     </xsl:otherwise>\r
217     </xsl:choose>\r
218   </xsl:for-each>\r
219 </xsl:element>\r
220 <tbody />\r
221 </xsl:element>\r
222 </xsl:template>\r
223 \r
224 \r
225 <xsl:template match="*" mode="convertHeadRow">\r
226 <xsl:param name = "id" />\r
227 <xsl:param name = "frozen" />\r
228   <xsl:variable name="class" select="@class"/>\r
229   <xsl:variable name="cells" select="xhtml:th | xhtml:td"/>\r
230   <xsl:element name="tr">\r
231   <xsl:if test="$id">\r
232     <xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute>\r
233   </xsl:if>\r
234   <xsl:attribute name="class">ricoLG_hdg <xsl:value-of select="$class"/></xsl:attribute>\r
235   <xsl:for-each select="$cells[@class='ricoFrozen' and $frozen or not(@class='ricoFrozen') and not($frozen)]">\r
236       <xsl:copy>\r
237         <xsl:copy-of select="@*"/>\r
238         <div class='ricoLG_col' style='width:100px'>\r
239           <xsl:element name="div">\r
240           <xsl:attribute name="class">ricoLG_cell <xsl:value-of select="@class"/></xsl:attribute>\r
241             <xsl:copy-of select="* | @*[name()!='class'] | text()"/>\r
242           </xsl:element>\r
243         </div>\r
244       </xsl:copy>\r
245     </xsl:for-each>\r
246   </xsl:element>\r
247 </xsl:template>\r
248 \r
249 \r
250 <!-- Convert tbody section -->\r
251 \r
252 <xsl:template name="convertTBody">\r
253 <xsl:param name = "rows" />\r
254 <xsl:param name = "cols" />\r
255 <xsl:param name = "id" />\r
256 <xsl:param name = "frozen" />\r
257 <xsl:element name="table" use-attribute-sets="ricoTable">\r
258 <xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute>\r
259 <xsl:attribute name="class">ricoLG_table ricoLG_bottom\r
260 <xsl:if test="$frozen">ricoLG_left</xsl:if>\r
261 <xsl:if test="not($frozen)">ricoLG_right</xsl:if>\r
262 </xsl:attribute> \r
263 <xsl:element name="tbody">\r
264   <tr>\r
265   <xsl:for-each select="$cols">\r
266     <xsl:if test="@class='ricoFrozen' and $frozen or not(@class='ricoFrozen') and not($frozen)">\r
267       <xsl:variable name="colpos" select="position()"/>\r
268       <td>\r
269         <div class='ricoLG_col' style='width:100px'>\r
270           <xsl:for-each select="$rows">\r
271             <xsl:element name="div">\r
272             <xsl:attribute name="class">ricoLG_cell <xsl:value-of select="xhtml:td[$colpos]/@class"/></xsl:attribute>\r
273               <xsl:copy-of select="xhtml:td[$colpos]/* | xhtml:td[$colpos]/@*[name()!='class'] | xhtml:td[$colpos]/text()"/>\r
274             </xsl:element>\r
275           </xsl:for-each>\r
276         </div>\r
277       </td>\r
278     </xsl:if>\r
279   </xsl:for-each>\r
280   </tr>\r
281 </xsl:element>\r
282 </xsl:element>\r
283 </xsl:template>\r
284 \r
285 </xsl:stylesheet> \r