以文本方式查看主题 - 中文XML论坛 - 专业的XML技术讨论区 (http://bbs.xml.org.cn/index.asp) -- 『 XSL/XSLT/XSL-FO/CSS 』 (http://bbs.xml.org.cn/list.asp?boardid=8) ---- [求助]关于XSL的大家帮帮忙呀!!!!!!1谢谢!!!!! (http://bbs.xml.org.cn/dispbbs.asp?boardid=8&rootid=&id=49684) |
-- 作者:haitian8080 -- 发布时间:7/11/2007 9:23:00 AM -- [求助]关于XSL的大家帮帮忙呀!!!!!!1谢谢!!!!! 我的xml: <?xml version="1.0" encoding="iso-8859-1"?> <?xml-stylesheet type="text/xsl" href="hello.xsl"?> <Bonus> <Dept> <DeptId>999901</DeptId> <Emplid>000001</Emplid> <DayBonus>100</DayBonus> <MonthBonus>1000</MonthBonus> </Dept> <Dept> <DeptId>999901</DeptId> <Emplid>000002</Emplid> <DayBonus>100</DayBonus> <MonthBonus>1000</MonthBonus> </Dept> <Dept> <DeptId>999901</DeptId> <Emplid>000003</Emplid> <DayBonus>100</DayBonus> <MonthBonus>1000</MonthBonus> </Dept> <Dept> <DeptId>999902</DeptId> <Emplid>000001</Emplid> <DayBonus>100</DayBonus> <MonthBonus>1000</MonthBonus> </Dept> <Dept> <DeptId>999902</DeptId> <Emplid>000002</Emplid> <DayBonus>100</DayBonus> <MonthBonus>1000</MonthBonus> </Dept> <Dept> <DeptId>999902</DeptId> <Emplid>000002</Emplid> <DayBonus>100</DayBonus> <MonthBonus>1000</MonthBonus> </Dept> </Bonus> 我的xsl: <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" encoding="utf-8"/> <xsl:template match="/"> <html> <body> <table cellpadding="0" cellspacing="0" border="1" style="border-collapse:collapse;font-size:14px;"> <tr> <th>DeptId</th> <th>Emplid</th> <th>DayBonus</th> <th>MonthBonus</th> </tr> <xsl:for-each-group select="//Bonus/Dept" group-by="DeptId"> <tr> <td> <xsl:value-of select="DeptId"></xsl:value-of> </td> <td> <xsl:value-of select="Emplid"></xsl:value-of> </td> <td> <xsl:value-of select="DayBonus"></xsl:value-of> </td> <td> <xsl:value-of select="MonthBonus"></xsl:value-of> </td> </tr> <tr> <td></td> <td></td> <td><xsl:value-of select="sum(current-group()/DayBonus)"/> </td> <td><xsl:value-of select="sum(current-group()/MonthBonus)"/> </td></tr> </xsl:for-each-group> </table> </body> </html> </xsl:template> </xsl:stylesheet> 上面输出的结果是: DeptId Emplid DayBonus MonthBonus 999901 000001 100 1000 300 3000 999902 000001 100 1000 300 3000 但是我的效果是要 999902 000001 100 1000 |
-- 作者:haitian8080 -- 发布时间:7/11/2007 10:29:00 AM -- <xsl:for-each-group select="//Bonus/Dept" group-by="DeptId"> 在原来的基础上加了一句这个就可以了:<xsl:for-each-group select="current-group()" group-by="Emplid"> 与大家分享一下:结果就是这样了,如果谁还有更好的方法发上来看看 999902 000001 100 1000 |
W 3 C h i n a ( since 2003 ) 旗 下 站 点 苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》 |
46.875ms |