XSL中实现HTML的表格自动换行
2005-10-23 15:04
639 查看
xml数据如:
<root>
<movie>1</movie>
<movie>2</movie>
<movie>3</movie>
<movie>4</movie>
<movie>5</movie>
<movie>6</movie>
<movie>7</movie>
<movie>8</movie>
<movie>9</movie>
<movie>10</movie>
<movie>11</movie>
<movie>12</movie>
</root>
要达到的效果:
1 2 3 4 5
6 7 8 9 10
11 12
XSL代码:
<?xml version="1.0" encoding="GB2312"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:variable name="Rows">5</xsl:variable>
<xsl:template match="//root">
<table>
<xsl:for-each select="movie[position() mod $Rows=1]">
<tr>
<xsl:apply-templates select=".|following-sibling::*[position()<$Rows]"/>
</tr>
</xsl:for-each>
</table>
</xsl:template>
<xsl:template match="movie">
<td>
<xsl:value-of select="."/>
</td>
</xsl:template>
</xsl:stylesheet>
<root>
<movie>1</movie>
<movie>2</movie>
<movie>3</movie>
<movie>4</movie>
<movie>5</movie>
<movie>6</movie>
<movie>7</movie>
<movie>8</movie>
<movie>9</movie>
<movie>10</movie>
<movie>11</movie>
<movie>12</movie>
</root>
要达到的效果:
1 2 3 4 5
6 7 8 9 10
11 12
XSL代码:
<?xml version="1.0" encoding="GB2312"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:variable name="Rows">5</xsl:variable>
<xsl:template match="//root">
<table>
<xsl:for-each select="movie[position() mod $Rows=1]">
<tr>
<xsl:apply-templates select=".|following-sibling::*[position()<$Rows]"/>
</tr>
</xsl:for-each>
</table>
</xsl:template>
<xsl:template match="movie">
<td>
<xsl:value-of select="."/>
</td>
</xsl:template>
</xsl:stylesheet>
相关文章推荐
- XSL中实现HTML的表格自动换行
- HTML 自动伸缩的表格Table js实现
- html表格内容自动换行,强制换行
- html 中自动换行的实现方式
- html表格自动换行
- html表格自动换行
- label自动换行代码和DataGrid中删除最后一页的记录时出错的解决办法以及HTML小TIPS:强制HTML表格断行
- html中表格自动换行
- html中表格自动换行
- OAF 中对文字实现html效果及对超级长文本实现默认换行,对只读的messageTextInput中的内容自动换行
- html表格内容自动换行
- HTML CSS 表格换行禁止 超出指定长度自动截断
- 怎样让HTML 表格中内容自动换行??
- label自动换行代码和DataGrid中删除最后一页的记录时出错的解决办法以及HTML小TIPS:强制HTML表格断行
- html中div不自动换行、强制不换行的具体实现
- 解决html表格中内容超出不强制换行和超出宽度自动隐藏并显示省略号
- 解决html表格中内容超出不强制换行和超出宽度自动隐藏并显示省略号
- html 表格自动换行问题
- 让HTML 表格中内容自动换行及顶端对齐
- 解决html表格中内容超出不强制换行和超出宽度自动隐藏并显示省略号