这个例子有问题吗?(关于排序,附代码)这可是微软的例子

jeskee 2003-10-24 11:26:51
Example
This example uses an XML source file and an XSLT style sheet.

XML File (sortempl.xml)

<?xml version='1.0'?>
<?xml-stylesheet type="text/xsl" href="sortempl.xsl"?>
<employees>
<employee>
<name>
<given>Loni</given>
<family>Ota</family>
</name>
</employee>
<employee>
<name>
<given>Leonard</given>
<family>Zuvela</family>
</name>
</employee>
<employee>
<name>
<given>John</given>
<family>Chen</family>
</name>
</employee>
<employee>
<name>
<given>Jay</given>
<family>Dirkson</family>
</name>
</employee>
<employee>
<name>
<given>Anthony</given>
<family>Dirkson</family>
</name>
</employee>
<employee>
<name>
<given>Tony</given>
<family>Dirkson</family>
</name>
</employee>
</employees>
XSLT File (sortempl.xsl)

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:template match="employees">
<ul>
<xsl:apply-templates select="employee">
<xsl:sort select="name/family"/>
<xsl:sort select="name/given"/>
</xsl:apply-templates>
</ul>
</xsl:template>

<xsl:template match="employee">
<li>
<xsl:value-of select="name/given"/>
<xsl:text> </xsl:text>
<xsl:value-of select="name/family"/>
</li>
</xsl:template>

</xsl:stylesheet>

期望结果:
John Chen
Anthony Dirkson
Jay Dirkson
Tony Dirkson
Loni Ota
Leonard Zuvela
实际结果就一个小圆点
...全文
39 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
jeskee 2003-10-24
  • 打赏
  • 举报
回复
我用的是IE5,是不是不支持<xsl:sort select="name/family"/>呢??
ssm1226 2003-10-24
  • 打赏
  • 举报
回复
注意你的IE版本

此效果在IE6.0下才能看到
ssm1226 2003-10-24
  • 打赏
  • 举报
回复
没问题
jeskee 2003-10-24
  • 打赏
  • 举报
回复
多谢!
ssm1226 2003-10-24
  • 打赏
  • 举报
回复
IE5不支持http://www.w3.org/1999/XSL/Transform

8,906

社区成员

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

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