如何使用XSLT的模板?

dazulhb 2006-04-09 11:29:10
对http://community.csdn.net/Expert/topic/4672/4672011.xml?temp=.8016321问题的答复!!但我换为使用以下模板后,又不行了,请邦我查找一下原因,先谢了!
<?xml version="1.0" encoding="GB2312"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:template match="/">
<xsl:for-each select="NewDataSet/Table">
<table border="1">
<tr>
<th>单位名称:</th>
<th colspan="2">
<xsl:value-of select="单位名称"/>
</th>
</tr>
<tr>
<td colspan="3"> 订单细目表</td>
</tr>
<tr>
<th>单位编码</th>
<th>商品代码</th>
<th>商品型号</th>
</tr>
<xsl:apply-templates select="//Table" />
</table>
<br/>
</xsl:for-each>
</xsl:template>
<xsl:template match="//Table">
<xsl:variable name="单位代码">
<xsl:value-of select="单位代码"/>
</xsl:variable>
<xsl:for-each select="/NewDataSet/订单[单位代码=$单位代码]">
<tr>
<td>
<xsl:value-of select="单位代码"/>
</td>
<td>
<xsl:value-of select="商品代码"/>
</td>
<td>
<xsl:value-of select="商品型号"/>
</td>
</tr>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
...全文
244 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
dazulhb 2006-04-11
  • 打赏
  • 举报
回复
感谢Gavin(天行健,君子以自强不息)和lihuabiao(凝聚)两位的正解
lihuabiao 2006-04-11
  • 打赏
  • 举报
回复
Gavin(天行健,君子以自强不息) 所说的应是正确的,因为"."表示当前元素.
Gavin 2006-04-11
  • 打赏
  • 举报
回复
try:

<xsl:apply-templates select="//Table" />
-->
<xsl:apply-templates select="."/>
liuph3000 2006-04-10
  • 打赏
  • 举报
回复
我这里显示很正常,没有问题啊

========================================
http://peipei3000.jishuqi.com/reg.asp
http://www.goofar.com/?ID=634664011139
========================================
dazulhb 2006-04-10
  • 打赏
  • 举报
回复
需要显示的结果为:

单位名称:炼焦厂
订单细目表
单位代码 商品代码 商品型号
510230200101892 101 010102

单位名称:镇酒厂
订单细目表
单位代码 商品代码 商品型号
510230200102222 101 010102
510230200102222 102 020102

8,906

社区成员

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

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