如何用xsl摸板来显示这种table

cenphoenix 2004-09-21 10:03:42
-------------------------|
|product |
|--------------|
|product2 |
|--------------|
pro1 |product3 |
|--------------|
|product4 |
-------------------------|
|product1 |
|------------ |
|product2 |
|--------------|
pro2 |product3 |
|--------------|
|product4 |
|--------------|
|product5 |
---------------------——
其中pro和product都是根据xml中有多少条记录来显示的

...全文
93 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
mastercyl 2004-09-24
  • 打赏
  • 举报
回复
跟用HTML写是一样的,
htmp画好格式,xsl向里面填数据
colee 2004-09-22
  • 打赏
  • 举报
回复
test.xml:
<?xml version="1.0" encoding='gb2312'?>
<?xml-stylesheet type="text/xsl" href='test.xslt'?>
<root>
<node>
<pro1>
<product1>product 1</product1>
<product2>product 2</product2>
</pro1>
<pro3>
<product1>product 1</product1>
</pro3>
<pro2>
<product1>product 1</product1>
<product2>product 2</product2>
<product3>product 3</product3>
</pro2>
</node>
</root>

test.xslt:
<?xml version="1.0" encoding="GB2312" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes" />
<xsl:template match="/">
<table border="2" width="200px">
<xsl:for-each select="root/node/node()">
<tr>
<td>
<xsl:attribute name="rowspan">
<xsl:value-of select="count(./node())"/>
</xsl:attribute>
<xsl:value-of select="name()"/>
</td>
<td>
<xsl:value-of select="./node()[position()=1]"/>
</td>
</tr>
<xsl:for-each select="./node()[position()>1]">
<tr><td><xsl:value-of select="."/></td></tr>
</xsl:for-each>

</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
火电 2004-09-22
  • 打赏
  • 举报
回复
把你的xml贴出来看看阿

要不怎么写xsl
blestcc 2004-09-22
  • 打赏
  • 举报
回复
又是一个连问题都不会问的,你这样问别人是没法回答的
whnnet 2004-09-22
  • 打赏
  • 举报
回复
你可以设置几个变量,先把pro包含的product的数量多少得到,这样就可以进行rowspan="$变量"了

8,906

社区成员

发帖
与我相关
我的任务
社区描述
XML/XSL相关问题讨论专区
社区管理员
  • XML/XSL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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