3 <xsl:stylesheet version="1.0"
4 xmlns:xhtml="http://www.w3.org/1999/xhtml"
5 xmlns="http://www.w3.org/1999/xhtml"
6 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
7 xmlns:xs="http://www.w3.org/2001/XMLSchema"
8 xmlns:fn="http://www.w3.org/2005/02/xpath-functions"
9 xmlns:xdt="http://www.w3.org/2005/02/xpath-datatypes"
10 exclude-result-prefixes="xhtml xsl fn xs xdt">
13 omit-xml-declaration="yes"
15 doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
16 doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
18 <xsl:attribute-set name="ricoTable">
19 <xsl:attribute name="cellspacing">0</xsl:attribute>
20 <xsl:attribute name="cellpadding">0</xsl:attribute>
23 <!-- the identity template -->
25 <xsl:template match="*">
27 <xsl:copy-of select="@*"/>
28 <xsl:apply-templates/>
33 <!-- in some cases, IE was duplicating br tags -->
35 <xsl:template match="xhtml:br">
37 <xsl:copy-of select="@*"/>
42 <!-- Transform head section -->
44 <xsl:template match="xhtml:head">
46 <xsl:apply-templates mode="head"/>
47 <script type="text/javascript">
49 if (typeof ricoInit!='undefined') {
50 if (window.addEventListener)
51 window.addEventListener('load', ricoInit, false);
52 else if (window.attachEvent)
53 window.attachEvent('onload', ricoInit);
60 <xsl:template match="*[name()!='script']" mode="head">
62 <xsl:copy-of select="@*|node()"/>
66 <xsl:template match="xhtml:script" mode="head">
68 <xsl:copy-of select="@*"/>
69 <xsl:value-of select="." disable-output-escaping="yes"/>
74 <!-- Transform tables with class ricoSimpleGrid -->
76 <xsl:template match="xhtml:table[@class='ricoSimpleGrid']">
79 <xsl:when test="xhtml:thead">
80 <xsl:call-template name="processTable">
81 <xsl:with-param name="id" select="@id"/>
82 <xsl:with-param name="headRows" select="xhtml:thead/xhtml:tr"/>
83 <xsl:with-param name="bodyRows" select="xhtml:tbody/xhtml:tr"/>
87 <xsl:when test="xhtml:tbody">
88 <xsl:call-template name="processTable">
89 <xsl:with-param name="id" select="@id"/>
90 <xsl:with-param name="headRows" select="xhtml:tbody/xhtml:tr[1]"/>
91 <xsl:with-param name="bodyRows" select="xhtml:tbody/xhtml:tr[position() > 1]"/>
96 <xsl:call-template name="processTable">
97 <xsl:with-param name="id" select="@id"/>
98 <xsl:with-param name="headRows" select="xhtml:tr[1]"/>
99 <xsl:with-param name="bodyRows" select="xhtml:tr[position() > 1]"/>
107 <!-- Perform the actual table transformation -->
109 <xsl:template name="processTable">
110 <xsl:param name="id" />
111 <xsl:param name="headRows" />
112 <xsl:param name="bodyRows" />
114 <xsl:variable name="headIdx">
116 <xsl:when test="$headRows[@class='ricoHeading']">
117 <xsl:value-of select="count($headRows[@class='ricoHeading']/preceding-sibling::*)+1"/>
120 <xsl:value-of select="count($headRows)"/>
125 <xsl:variable name="headMain" select="$headRows[position()=$headIdx]"/>
126 <xsl:variable name="headCols" select="$headMain/xhtml:th | $headMain/xhtml:td"/>
129 <p><xsl:value-of select="$id"/>
130 <br />headRowCnt: <xsl:value-of select="count($headRows)"/>
131 <br />headIdx: <xsl:value-of select="$headIdx"/>
132 <br />bodyRowCnt: <xsl:value-of select="count($bodyRows)"/>
136 <xsl:element name="div">
137 <xsl:attribute name="id"><xsl:value-of select="concat($id,'_outerDiv')"/></xsl:attribute>
138 <xsl:attribute name="class">ricoLG_outerDiv</xsl:attribute>
139 <xsl:attribute name="onload"></xsl:attribute>
141 <!-- Create frozen (left) pane -->
143 <xsl:element name="div">
144 <xsl:attribute name="id"><xsl:value-of select="concat($id,'_frozenTabsDiv')"/></xsl:attribute>
145 <xsl:attribute name="class">ricoLG_frozenTabsDiv</xsl:attribute>
147 <xsl:call-template name="convertTHead">
148 <xsl:with-param name="rows" select="$headRows"/>
149 <xsl:with-param name="headIdx" select="$headIdx"/>
150 <xsl:with-param name="frozen" select="1"/>
151 <xsl:with-param name="id" select="concat($id,'_tab0h')"/>
154 <xsl:call-template name="convertTBody">
155 <xsl:with-param name="rows" select="$bodyRows"/>
156 <xsl:with-param name="cols" select="$headCols"/>
157 <xsl:with-param name="id" select="concat($id,'_tab0')"/>
158 <xsl:with-param name="frozen" select="1"/>
163 <xsl:element name="div">
164 <xsl:attribute name="id"><xsl:value-of select="concat($id,'_innerDiv')"/></xsl:attribute>
165 <xsl:attribute name="class">ricoLG_innerDiv</xsl:attribute>
167 <xsl:element name="div">
168 <xsl:attribute name="id"><xsl:value-of select="concat($id,'_scrollTabsDiv')"/></xsl:attribute>
169 <xsl:attribute name="class">ricoLG_scrollTabsDiv</xsl:attribute>
171 <xsl:call-template name="convertTHead">
172 <xsl:with-param name="rows" select="$headRows"/>
173 <xsl:with-param name="headIdx" select="$headIdx"/>
174 <xsl:with-param name="frozen" select="0"/>
175 <xsl:with-param name="id" select="concat($id,'_tab1h')"/>
181 <xsl:element name="div">
182 <xsl:attribute name="id"><xsl:value-of select="concat($id,'_scrollDiv')"/></xsl:attribute>
183 <xsl:attribute name="class">ricoLG_scrollDiv</xsl:attribute>
185 <xsl:call-template name="convertTBody">
186 <xsl:with-param name="rows" select="$bodyRows"/>
187 <xsl:with-param name="cols" select="$headCols"/>
188 <xsl:with-param name="id" select="concat($id,'_tab1')"/>
189 <xsl:with-param name="frozen" select="0"/>
198 <!-- Convert thead section -->
200 <xsl:template name="convertTHead">
201 <xsl:param name = "rows" />
202 <xsl:param name = "headIdx" />
203 <xsl:param name = "frozen" />
204 <xsl:param name = "id" />
205 <xsl:element name="table" use-attribute-sets="ricoTable">
206 <xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute>
207 <xsl:attribute name="class">ricoLG_table ricoLG_top
208 <xsl:if test="$frozen">ricoLG_left</xsl:if>
209 <xsl:if test="not($frozen)">ricoLG_right</xsl:if>
211 <xsl:element name="thead">
212 <xsl:for-each select="$rows">
214 <xsl:when test="position() = $headIdx">
215 <xsl:apply-templates select="." mode="convertHeadRow">
216 <xsl:with-param name="id" select="concat($id,'_main')"/>
217 <xsl:with-param name="frozen" select="$frozen"/>
218 </xsl:apply-templates>
221 <xsl:apply-templates select="." mode="convertHeadRow">
222 <xsl:with-param name="id" select="concat($id,'_',position())"/>
223 <xsl:with-param name="frozen" select="$frozen"/>
224 </xsl:apply-templates>
234 <xsl:template match="*" mode="convertHeadRow">
235 <xsl:param name = "id" />
236 <xsl:param name = "frozen" />
237 <xsl:variable name="class" select="@class"/>
238 <xsl:variable name="cells" select="xhtml:th | xhtml:td"/>
239 <xsl:element name="tr">
241 <xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute>
243 <xsl:attribute name="class">ricoLG_hdg <xsl:value-of select="$class"/></xsl:attribute>
244 <xsl:for-each select="$cells[@class='ricoFrozen' and $frozen or not(@class='ricoFrozen') and not($frozen)]">
246 <xsl:copy-of select="@*"/>
247 <div class='ricoLG_col' style='width:100px'>
248 <xsl:element name="div">
249 <xsl:attribute name="class">ricoLG_cell <xsl:value-of select="@class"/></xsl:attribute>
250 <xsl:copy-of select="* | @*[name()!='class'] | text()"/>
259 <!-- Convert tbody section -->
261 <xsl:template name="convertTBody">
262 <xsl:param name = "rows" />
263 <xsl:param name = "cols" />
264 <xsl:param name = "id" />
265 <xsl:param name = "frozen" />
266 <xsl:element name="table" use-attribute-sets="ricoTable">
267 <xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute>
268 <xsl:attribute name="class">ricoLG_table ricoLG_bottom
269 <xsl:if test="$frozen">ricoLG_left</xsl:if>
270 <xsl:if test="not($frozen)">ricoLG_right</xsl:if>
272 <xsl:element name="tbody">
274 <xsl:for-each select="$cols">
275 <xsl:if test="@class='ricoFrozen' and $frozen or not(@class='ricoFrozen') and not($frozen)">
276 <xsl:variable name="colpos" select="position()"/>
278 <div class='ricoLG_col' style='width:100px'>
279 <xsl:for-each select="$rows">
280 <xsl:element name="div">
281 <xsl:attribute name="class">ricoLG_cell <xsl:value-of select="xhtml:td[$colpos]/@class"/></xsl:attribute>
282 <xsl:copy-of select="xhtml:td[$colpos]/* | xhtml:td[$colpos]/@*[name()!='class'] | xhtml:td[$colpos]/text()"/>