本文介绍了在XSLT中,如何更新循环中的多个元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 您好, 首先,感谢您抽出时间查看我的问题。 我试图想出一个循环模板的代码, 找到一个名为start_time的元素并调用该元素的值,并减去因夏令时而导致的时间变化的小时。并且有多个开始时间,这就是为什么我将不得不使用循环。 这是原始的xml。 那里是PlaylistItem中存在的其他元素,但我已将它们删除为 simple。例如,所需的输出是 2015-10-12T11:07:39.924 将是 2015-10-12T12:07:39.924 在Block内的PlaylistItem中为每个人换回一个小时。 你的非常感谢帮助。 < Block> < PlaylistItem> < StartTime> 2015-10-12T11:59:42.201< / StartTime> < / PlaylistItem> < PlaylistItem> < StartTime> 2015-10-12T11:07:39.924< / StartTime> < / PlaylistItem> < PlaylistItem> < StartTime> 2015-10-12T20:29:42.211< / StartTime> < / PlaylistItem> < PlaylistItem> < StartTime> 2015-10-12T09:39:58.901< / StartTime> < / PlaylistItem> < PlaylistItem> < StartTime> 2015-10-12T12:04:50.551< / StartTime> < / PlaylistItem> < / Block> 我对这个XSLT世界很新,我只有一个基本的逻辑来解决这个问题。所以我的逻辑是 1)遍历Block 2)访问PlaylistItem,访问StartTime 3)抓住这个字符串 4)使用子字符串并获取字符串中的小时字符 5)从中减去一个然后保存它 6)确保这适用阻止每个播放列表中的每个startTime。 我正在尝试为此搜索正确的语法然后实现它但是 目前我没有任何有效的可执行代码,我可以在这里发布。 请帮忙!当我尝试自己编写代码时,我将更新这篇文章。 再次感谢。解决方案 Hello,First, thanks for your time for having a look at my question.I am trying to come up with a code that loops through a template,finds an element called start_time and call the value of the element and subtract an hour for the time change due to daylight savings. And there are multiple start times and that's why I am going to have to use a loop.This is the original xml.There are other elements existing inside PlaylistItem, but I have removed them forsimplicity. The desired output is, for example, 2015-10-12T11:07:39.924 to be2015-10-12T12:07:39.924shifted back by an hour for every one of them inside PlaylistItem inside Block.Your help will be very much appreciated.<Block><PlaylistItem> <StartTime>2015-10-12T11:59:42.201</StartTime></PlaylistItem><PlaylistItem> <StartTime>2015-10-12T11:07:39.924</StartTime></PlaylistItem><PlaylistItem> <StartTime>2015-10-12T20:29:42.211</StartTime></PlaylistItem><PlaylistItem> <StartTime>2015-10-12T09:39:58.901</StartTime></PlaylistItem><PlaylistItem> <StartTime>2015-10-12T12:04:50.551</StartTime></PlaylistItem></Block>I am very new to this XSLT world and I only have a basic piece of logic for this problem. So my logic here is to 1)iterate through the Block2)access PlaylistItem, access StartTime3)grab this string4)use substring and grab the hour characters in the string5)subtract one from it and then save it6)make sure this applies to every startTime inside every Playlist in Block.I'm trying to search for the proper syntax for this and then implement it butright at the moment I don't have any valid executable code that I can post here.Please help! And I'll be updating this post as I try to write the code myself.Thanks again. 解决方案 这篇关于在XSLT中,如何更新循环中的多个元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-16 18:54