以月和年为单位的 XSLT 顺序
我有一个问题。我有一个 XML 树,看起来与此类似:
<wd:meta>
<wd:creation time="[TIMESTAMP]" />
<wd:title><![CDATA[Nice title]]></wd:title>
</wd:meta>
并且还有更多具有相同结构的同级树。 该树进入 XSLTProcessor 并获得一个漂亮的样式表。 现在我想将其分解为几个月(在我的样式表中)。所以有这样的事情:
八月发生的一切
<块引用>标题不错1
标题不错2
九月发生的一切
<块引用>标题不错3
标题不错4
我怎样才能做这样的事情?我做了一些研究,但不是很成功。 我发现唯一可能有用的是:follow-sibling
谁能帮助我?我真的很感谢你的帮助。
谢谢。
edit://
我现在使用 http://www.jeniitennison.com 采用的 Muenchian 方法/xslt/grouping/muenchian.html 但我只能按月订购,不能按年订购。我尝试了可能重复的答案并试图理解它,但这并不那么容易。有没有人有更简单的解决方案?
I have a problem. I have an XML tree which looks similar to this:
<wd:meta>
<wd:creation time="[TIMESTAMP]" />
<wd:title><![CDATA[Nice title]]></wd:title>
</wd:meta>
And there are many more siblings with the same Structure.
This tree goes into the XSLTProcessor and gets a nice Stylesheet.
Now i want to take this apart into months (In my Stylesheet). So that there is something like that:
Everything that happed in August
Nice title 1
Nice title 2
Everything that happend in September
Nice title 3
Nice title 4
How can i do something like this? I made a little bit of research but i wasn't very successful.
The only thing i found what would be maybe useful was that: following-sibling
Can anyone help me? I really appreciate your help.
Thanks.
edit://
I now used the Muenchian method adopted from http://www.jenitennison.com/xslt/grouping/muenchian.html but i only can order it by month, NOT by year. I tried the Answer of the possible duplicate and tried to understand it, but it's not that easy. Has anyone a easier solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
第一步,我将迭代您的内容并为您的时间戳生成月份名称。然后您可以按月份名称对其进行排序。如果您有 xslt 2.0,则可以使用
group-by
按月对它们进行分组。如果没有,您可以实际迭代您的内容并检查是否存在具有当前月份名称的following-sibling
。如果是这样,请继续使用与当前元素的月份相同的月份名称。如果没有,就开始新的一个月。In a first step i would iterate your content and generate a monthname for your timestamps. Then you can sort it by the month name. If you have xslt 2.0 you can use
group-by
to group them by month. If not, you can acturlly iterate your content and check if there is afollowing-sibling
with the current month name. If so, go on with the same month name as the month of the current element. If not, start a new month.