高分求助:请问如此的XSL应该如何写?

bluefish922 2004-03-19 01:11:39
XML文件格式如下:
<root>
<titledata>
<title>
<zdname>jfje0</zdname>
<lmmc>aaa</lmmc>
</title>
<title>
<zdname>jfje2</zdname>
<lmmc>bbb</lmmc>
</title>
......
</titledata>
<rowdata>
<row id=0001 name=eeee jfje0=123456.45 dfje1=123456.45 ..../>
<row id=0002 name=ffff jfje2=123456.45 ..../>
.....
</rowdata>
我现在要打表格显示row中的数据,其中一段的<td>表头要根据上面的title来循环得到(固定的),然后根据zdname去row中取数据,有该字段就显示值,没有就为空白。请问这个循环怎么写啊?
...全文
45 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
saucer 2004-03-22
  • 打赏
  • 举报
回复
http://www.topxml.com/xsl/funccurrent.asp
bluefish922 2004-03-22
  • 打赏
  • 举报
回复
大虾就是大虾,我想请问思归,你都是在哪里看的资料啊,我怎么没找到current()这个方法
saucer 2004-03-20
  • 打赏
  • 举报
回复
your xml is not valid, but try

1. TestData.xml:
<?xml-stylesheet type="text/xsl" href="TestData.xsl" ?>
<root>
<titledata>
<title>
<zdname>jfje0</zdname>
<lmmc>aaa</lmmc>
</title>
<title>
<zdname>jfje1</zdname>
<lmmc>bbb</lmmc>
</title>
<title>
<zdname>jfje2</zdname>
<lmmc>ccc</lmmc>
</title>
</titledata>
<rowdata>
<row id="0001" name="eeee" jfje0="123456.45xx" jfje1="987"/>
<row id="0002" name="ffff" jfje2="123456.45xx"/>
</rowdata>
</root>

2. TestData.xsl:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">


<xsl:template match="/">
<html>
<body>
<xsl:apply-templates select="root" />
</body>
</html>
</xsl:template>

<xsl:template match="root">
<table border="1" cellspacing="0" cellpadding="0">
<thead>
<xsl:for-each select="titledata/title">
<th><xsl:value-of select="lmmc" /></th>
</xsl:for-each>
</thead>
<tbody>
<xsl:for-each select="rowdata/row">
<xsl:variable name="row" select="." />
<tr>
<xsl:for-each select="/root/titledata/title">
<td><xsl:value-of select="$row/@*[name() = current()/zdname]" /> </td>
</xsl:for-each>
</tr>
</xsl:for-each>
</tbody>
</table>
</xsl:template>

</xsl:stylesheet>
kisslan 2004-03-19
  • 打赏
  • 举报
回复
楼主把要形成的表格大概排一下吧,那样明白一点:)
liuxianzhi 2004-03-19
  • 打赏
  • 举报
回复
关注中,我也不会!

8,909

社区成员

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

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