【发布时间】:2013-12-23 14:52:02
【问题描述】:
您好,我是 XSL 新手,我正在尝试创建一个 XSL 样式表,以根据 XML 文档中指定的文章数量来打印最常见作者的姓名。
XML
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="busiestAuthor.xsl"?>
<latestIssue>
<issue number="357" />
<date>
<day> 4 </day>
<month> 1 </month>
<year> 2013 </year>
</date>
<stories>
<story>
<title> The earth is flat </title>
<author> Tom Friedman </author>
<url> http://www.HotStuff.ie/stories/story133456.xml </url>
</story>
<story>
<title> Films to watch out for in 2013 </title>
<author> Brated Film Critic </author>
<url> http://www.HotStuff.ie/stories/story133457.xml </url>
</story>
<story>
<title> The state of the economy </title>
<author> Tom Friedman </author>
<url> http://www.HotStuff.ie/stories/story133458.xml </url>
</story>
<story>
<title> Will an asteroid strike earth this year? </title>
<author> Stargazer </author>
<url> http://www.HotStuff.ie/stories/story133459.xml </url>
</story>
</stories>
</latestIssue>
所以我想要 busiestAuthor.xsl 打印的结果就是 Tom Friedman,因为他写了 2 篇文章,而其他人只写了一篇。我敢肯定这可能很容易,但正如我所说,我对这一切都很陌生,我似乎无法管理它。在 for-each 循环和排序和计数之间,我头晕目眩。
感谢各位,我正在上大学,我准备在期末考试中以某种形式提出这样的问题。干杯!
【问题讨论】:
-
您能否用您尝试过的方法、您使用的处理器以及您使用的 XSLT 版本来更新您的问题?否则,对于基本概念,您需要查找 XSLT 1.0 的 Muenchian 方法和 XSLT 2.0 的 for-each-group。