以文本方式查看主题 - 中文XML论坛 - 专业的XML技术讨论区 (http://bbs.xml.org.cn/index.asp) -- 『 XSL/XSLT/XSL-FO/CSS 』 (http://bbs.xml.org.cn/list.asp?boardid=8) ---- [求助]关于xsl的问题,高手门帮我解决一下!!!谢谢 (http://bbs.xml.org.cn/dispbbs.asp?boardid=8&rootid=&id=49729) |
-- 作者:haitian8080 -- 发布时间:7/11/2007 9:24:00 PM -- [求助]关于xsl的问题,高手门帮我解决一下!!!谢谢 我的xml: <?xml version="1.0" encoding="utf-8"?> <Bonus> <Dept> <DeptId>99901</DeptId> <Emplid>00001</Emplid> <DayBonus>100</DayBonus> <MonthBonus>1000</MonthBonus> </Dept> <Dept> <DeptId>99901</DeptId> <Emplid>00001</Emplid> <DayBonus>100</DayBonus> <MonthBonus>1000</MonthBonus> </Dept> <Dept> <DeptId>99901</DeptId> <Emplid>00001</Emplid> <DayBonus>100</DayBonus> <MonthBonus>1000</MonthBonus> </Dept> <Dept> <DeptId>99901</DeptId> <Emplid>00001</Emplid> <DayBonus>100</DayBonus> <MonthBonus>1000</MonthBonus> </Dept> <Dept> <DeptId>99901</DeptId> <Emplid>00001</Emplid> <DayBonus>100</DayBonus> <MonthBonus>1000</MonthBonus> </Dept> <Dept> <DeptId>99901</DeptId> <Emplid>00001</Emplid> <DayBonus>100</DayBonus> <MonthBonus>1000</MonthBonus> </Dept> </Bonus> DeptId Emplid DayBonus MonthBonus 99902 00001 100 1000 需求要的结果: 99902 00001 100 1000 |
-- 作者:haitian8080 -- 发布时间:7/11/2007 9:54:00 PM -- for-each-group 是xsl 2.0 的新特性可以;但是在ERP中没发用2.0新特性 ;只能用1.0 |
-- 作者:Qr -- 发布时间:7/12/2007 9:02:00 AM -- 不知道LZ对XPath了解多少,你知道在你的代码(xsl:for-each)中 not 和 preceding::* 在此起什么作用吗? 1、去掉xsl:for-each中的过滤语句; 2、再改第2个tr,增一个xsl:if判断: <xsl:if test="not(DeptId=following::*/DeptId)"> <tr> <td></td> <td></td> <td><xsl:value-of select="sum(../Dept[DeptId=current()/DeptId]/DayBonus)"/> </td> <td><xsl:value-of select="sum(../Dept[DeptId=current()/DeptId]/MonthBonus)"/> </td> </tr> </xsl:if> 运行结果: DeptId Emplid DayBonus MonthBonus 99901 00001 100 1000 99901 00001 100 1000 99901 00001 100 1000 300 3000 99902 00001 100 1000 99902 00001 100 1000 99902 00001 100 1000 300 3000 正是你想要的。 |
-- 作者:Qr -- 发布时间:7/12/2007 9:08:00 AM -- 对了,如果DeptId次序打乱,可以先按DeptId排序。测试结果如上。 |
-- 作者:haitian8080 -- 发布时间:7/12/2007 10:48:00 AM -- 谢谢高手了!!!! |
-- 作者:haitian8080 -- 发布时间:7/12/2007 10:50:00 AM -- following代表什么意思吗???????????????? |
W 3 C h i n a ( since 2003 ) 旗 下 站 点 苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》 |
156.250ms |