我是全新编写xslt代码的新手。我想让xsl代码查看xml文件中的每个节点/属性,并搜索'__(string)'并计算'result = success/failed'。我在这个网站上找到了一个线程来帮助我一点: How do you do wildcard matches with XSLT?
我找到了我的xsl代码来查找字符串匹配。但后来我的问题是,我不知道如何编写代码来计算成功和给定的字符串匹配失败?我希望为输出看起来是这样的:XSLT:如何计算属性,使用字符串匹配找到
**(Casename)** | **(total success)** | **(total failed)**
__(stringmatch1)| 2 | 0
__(stringmatch2)| 0 | 2
下面是XML文件的样本:
<report>
<programtest user="testuser">
<programtest software="test">
<programtest testname="SW log">
</programtest>
<programtest testname="HW log">
</programtest>
<programtest testname="loop_program_test">
<programtest casename="test" iteration="1" result="success">
<programtest casename="__temp1" type="specifictestcase" result="success" >
</programtest>
<programtest casename="__temp2" type="specifictestcase" result="failed" >
</programtest>
</programtest>
<programtest casename="test" iteration="2" result="success">
<programtest casename="__temp1" type="specifictestcase" result="success" >
</programtest>
<programtest casename="__temp2" type="specifictestcase" result="failed" >
</programtest>
</programtest>
</programtest>
</programtest>
</programtest>
</report>
任何帮助表示赞赏! :-)
这听起来很不错。是的,你的权利是错误的。但尝试这样做,给我错误,我的xml编辑器不能识别“for-each-group”扩展名。我使用VS2010作为xml编辑器,并确保使用XSLT v 2.0即时消息。 – Joks
噢,好的。它有助于使用氧气xml编辑器。 :) – Joks
如果您使用Visual Studio,那么您可能需要XSLT v1.0解决方案,因为Microsoft的XML处理器不支持2.0。 –