XSLT - 在这种情况下如何使用分组依据?
(此的后续 线程)
我现在实际上需要知道按天分组的访问者数量,然后按时间段分组的访问者数量。我尝试应用 Kirill Polishchuk 建议的分组依据,但我只能将其按某个特定分组元素。现在我实际上需要知道如何应用多个分组依据?例如,首先按“日”分组,然后按期间分组。
我有以下 XML:
<Cinema>
<Day date="15-09-2011" day="Thursday" week="37" in="543" out="543">
<Movie name="movie1" in="191" out="191">
<Period time="16:00:00" in="20" out="20"/>
<Period time="18:00:00" in="71" out="70"/>
<Period time="20:00:00" in="100" out="101"/>
</Movie>
<Movie name="movie2" in="105" out="105">
<Period time="16:00:00" in="13" out="13"/>
<Period time="18:00:00" in="34" out="34"/>
<Period time="20:00:00" in="58" out="58"/>
</Movie>
<Movie name="movie3" in="247" out="247">
<Period time="16:00:00" in="57" out="57"/>
<Period time="18:00:00" in="75" out="72"/>
<Period time="20:00:00" in="115" out="118"/>
</Movie>
<Day>
<Day date="16-09-2011" day="Friday" week="37" in="1151" out="1151">
<Movie name="movie1" in="364" out="364">
<Period time="16:00:00" in="106" out="106"/>
<Period time="18:00:00" in="131" out="129"/>
<Period time="20:00:00" in="127" out="129"/>
</Movie>
<Movie name="movie2" in="333" out="333">
<Period time="16:00:00" in="89" out="89"/>
<Period time="18:00:00" in="116" out="116"/>
<Period time="20:00:00" in="128" out="128"/>
</Movie>
<Movie name="movie3" in="454" out="454">
<Period time="16:00:00" in="104" out="104"/>
<Period time="18:00:00" in="150" out="150"/>
<Period time="20:00:00" in="200" out="200"/>
</Movie>
<Day>
</Cinema>
我想要获取的是每天每个电影时段的总访客数。例如:
Thursday:
16:00h - in: 90, out: 90
18:00h - in: 180, out: 176
20:00h - in: 273, out: 277
Total - in: 543, out: 543
Friday:
16:00h - in: 299, out: 299
18:00h - in: 397, out: 395
20:00h - in: 455, out: 457
Total - in: 1151, out: 1151
有人有什么建议吗?提前致谢!
(我目前使用 xslt 1.0,但如果有必要,我可以“升级”到较新的 2.0)
(A follow up of this thread)
I now actually need to know the amount of visiters grouped by Day and then by period. I tried to apply the group-by suggested by Kirill Polishchuk, but I can only get it to group by one certain element. Now I actually need to know how to apply multiple group-by's? E.g. Group by 'Day' first and then by period.
I have the following XML:
<Cinema>
<Day date="15-09-2011" day="Thursday" week="37" in="543" out="543">
<Movie name="movie1" in="191" out="191">
<Period time="16:00:00" in="20" out="20"/>
<Period time="18:00:00" in="71" out="70"/>
<Period time="20:00:00" in="100" out="101"/>
</Movie>
<Movie name="movie2" in="105" out="105">
<Period time="16:00:00" in="13" out="13"/>
<Period time="18:00:00" in="34" out="34"/>
<Period time="20:00:00" in="58" out="58"/>
</Movie>
<Movie name="movie3" in="247" out="247">
<Period time="16:00:00" in="57" out="57"/>
<Period time="18:00:00" in="75" out="72"/>
<Period time="20:00:00" in="115" out="118"/>
</Movie>
<Day>
<Day date="16-09-2011" day="Friday" week="37" in="1151" out="1151">
<Movie name="movie1" in="364" out="364">
<Period time="16:00:00" in="106" out="106"/>
<Period time="18:00:00" in="131" out="129"/>
<Period time="20:00:00" in="127" out="129"/>
</Movie>
<Movie name="movie2" in="333" out="333">
<Period time="16:00:00" in="89" out="89"/>
<Period time="18:00:00" in="116" out="116"/>
<Period time="20:00:00" in="128" out="128"/>
</Movie>
<Movie name="movie3" in="454" out="454">
<Period time="16:00:00" in="104" out="104"/>
<Period time="18:00:00" in="150" out="150"/>
<Period time="20:00:00" in="200" out="200"/>
</Movie>
<Day>
</Cinema>
What I am trying to get is the total visitors of each movie period per day. For example:
Thursday:
16:00h - in: 90, out: 90
18:00h - in: 180, out: 176
20:00h - in: 273, out: 277
Total - in: 543, out: 543
Friday:
16:00h - in: 299, out: 299
18:00h - in: 397, out: 395
20:00h - in: 455, out: 457
Total - in: 1151, out: 1151
Does anyone have any suggestions? Thanks in advance!
(I use xslt 1.0 at the moment, but it is possible for me to "upgrade" to the newer 2.0, if necessary)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
XML:
输出:
XML:
Output: