|
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> |