xslt高手帮忙.

oldearth 2004-10-27 04:18:35
<?xml version="1.0" encoding="gb2312" ?>
<?xml-stylesheet type="text/xsl" href="list.xsl" ?>
<list>
<people>
<name>111</name>
</people>
<people>
<name>222</name>
</people>
<people>
<name>333</name>
</people>
<people>
<name>444</name>
</people>
<people>
<name>555</name>
</people>
<people>
<name>666</name>
</people>
<people>
<name>777</name>
</people>
<people>
<name>888</name>
</people>
<people>
<name>999</name>
</people>
<people>
<name>000</name>
</people>
</list>

<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/" >

<html>
<head>
<title>title</title>

<script language="javaScript">
function showMessage( arg )
{
alert( arg.name );
}
</script>
</head>
<body>
<table width="100%" >

<xsl:for-each select="list/people">
<td align="center" valign="top" style='cursor:hand;' onclick="showMessage( this )" >
<xsl:attribute name="name"><xsl:value-of select="name"/></xsl:attribute>
<xsl:value-of select="name"/>
</td>
</xsl:for-each>

</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>


如何输出到第5个people时换行输出.
...全文
103 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
vcvj 2004-10-28
  • 打赏
  • 举报
回复
<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/" >

<html>
<head>
<title>title</title>

<script language="javaScript">
function showMessage( arg )
{
alert( arg.name );
}
</script>
</head>
<body>

<xsl:for-each select="list/people">
<a style='cursor:hand;' onclick="showMessage( this )" >
<xsl:attribute name="name"><xsl:value-of select="name"/></xsl:attribute>
<xsl:value-of select="name"/>
</a>   
<xsl:if test="position()=5"><br/></xsl:if>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
zcjl 2004-10-28
  • 打赏
  • 举报
回复
<xsl:for-each select="list/people">
<xsl:if test="position() mod 5 = 1">
<xsl:text disable-output-escaping="yes"><tr></xsl:text>
</xsl:if>
<td align="center" valign="top" style='cursor:hand;' onclick="showMessage( this )" >
<xsl:attribute name="name"><xsl:value-of select="name"/></xsl:attribute>
<xsl:value-of select="name"/>
</td>
<xsl:if test="position() mod 5 = 0">
<xsl:text disable-output-escaping="yes"><tr></xsl:text>
</xsl:if>
</xsl:for-each>
zcjl 2004-10-28
  • 打赏
  • 举报
回复
用<xsl:if>判断people的position
如果%5的结果等于0,就显示<tr>和</tr>

67,538

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧