如何用xsl实现如下问题:

snaill 2002-04-11 01:59:16
希望能使用xsl文件,将xml文件中数据按date排序后,取出时间最新的前10项。
xml:
<root>
<data>
<date>2001.2.2</date>
<otherdata></otherdata>
<data>
<data>
<date>2001.2.5</date>
<otherdata></otherdata>
<data>
<data>
<date>2001.2.6</date>
<otherdata></otherdata>
<data>
...
</root>
...全文
54 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
wangwenyou 2002-04-12
  • 打赏
  • 举报
回复
一点补充:
date不要那样存放,否则排序会出问题,最好这样
<date>2001.02.02</date>
snaill 2002-04-12
  • 打赏
  • 举报
回复
多谢各位
chechy 2002-04-11
  • 打赏
  • 举报
回复
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:apply-templates select="root/data">
<xsl:sort order="descending" select="date"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="date">
<xsl:if test="position()<10">
<!-- do your things -->
</xsl:if>
</xsl:template>
</xsl:stylesheet>

8,906

社区成员

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

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