热心人请进 xslt能做到这样吗?非常着急

yu_shi_bin 2005-03-17 03:23:28
<?xml version="1.0" encoding="GB2312" ?>
<?xml-stylesheet type="text/xsl" href="detail_frame_custom.xsl" ?>
<Detail>
<Instance>
<Id>PO_92000</Id>
<Name>OceanDrive HD 20GB</Name>
<Location>suzhou</Location>
</Instance>
<Instance>
<Id>PO_92001</Id>
<Name>OceanDrive HD 21GB</Name>
<Location>shenzhen</Location>
</Instance>
</Detail>

这时候会显示 一个html表格 id Name location 然后下面是对应的2条数据
<?xml version="1.0" encoding="GB2312" ?>
<?xml-stylesheet type="text/xsl" href="detail_frame_custom.xsl" ?>
<Detail>
<Instance>
<Id>PO_92000</Id>
<Name>OceanDrive HD 20GB</Name>
<Location>shanghai</Location>
<qty>10</qty>
</Instance>
<Instance>
<Id>PO_92001</Id>
<Name>OceanDrive HD 40GB</Name>
<Location>beijing</Location>
<qty>10</qty>
</Instance>
</Detail>

这时候会显示 一个html表格 id Name location qty 然后下面是对应的2条数据


//
就是xslt能自动获取xml的列名
谢谢

...全文
60 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
孟子E章 2005-03-17
  • 打赏
  • 举报
回复
right!
ssm1226 2005-03-17
  • 打赏
  • 举报
回复
<?xml version="1.0" encoding="GB2312"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes"/>
<xsl:template match="/">
<table border="1">
<tr>
<xsl:for-each select="/Detail/Instance[1]/node()">
<td><xsl:value-of select="name()"/></td>
</xsl:for-each>
</tr>
<xsl:for-each select="/Detail/Instance">
<tr>
<xsl:apply-templates/>
</tr>
</xsl:for-each>
</table>
</xsl:template>
<xsl:template match="*">
<td>
<xsl:value-of select="."/>
</td>
</xsl:template>
</xsl:stylesheet>
yu_shi_bin 2005-03-17
  • 打赏
  • 举报
回复
<td><xsl:value-of select="Id"/></td>
<td><xsl:value-of select="Name"/></td>
<td><xsl:value-of select="Location"/></td> 这几项也是动态的 不一定是这几个怎么办
能不能有个
<td><xsl:value-of select="*"/></td> 之类的把所有的都列举起来
孟子E章 2005-03-17
  • 打赏
  • 举报
回复
<?xml version="1.0" encoding="GB2312"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes"/>
<xsl:template match="/">
<table border="1">
<tr>
<xsl:for-each select="/Detail/Instance[1]/node()">
<td><xsl:value-of select="name()"/></td>
</xsl:for-each>
</tr>
<xsl:for-each select="/Detail/Instance">
<tr>
<td><xsl:value-of select="Id"/></td>
<td><xsl:value-of select="Name"/></td>
<td><xsl:value-of select="Location"/></td>
</tr>
</xsl:for-each>

</table>
</xsl:template>
</xsl:stylesheet>
孟子E章 2005-03-17
  • 打赏
  • 举报
回复
<xsl:value-of select="name()"/>

or

<xsl:value-of select="local-name()"/>

8,906

社区成员

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

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