我有一个生成交易文件的 XML,它记录了会员卡中用于赚取积分的金额和完成日期的条目。没有我可以使用的顺序,因为相同的卡号可能会出现在 XML 中。我想要的是让 XSL 找到一个卡号(我没有用作 ID 的记录),把它放在 a 中<td></td>
并显示总共花了多少钱,赚了多少积分以及什么完成日期。
这是XML...
<Root>
<Events>
<TicketEnd Date="2012-10-21" />
</Events>
<Ticket>
<TicketStart Date="2012-10-22" />
<TicketEnd Date="2012-10-22" />
</Ticket>
<Events>
</Events>
<Ticket>
<TicketStart Date="2012-10-22" />
<Clubcard Opcode="96" Function="27" CardAcc="1" QualSpendInfo="0" SchemeNo="40" CardNo="1042540000026" PointsToDate="0" RedemptionValue="0" CustomerUpdateDate="000000" QualSpent="0" Date="2012-10-22" />
<ClubcardPoints Opcode="96" Function="28" SchemeNo="40" PromNo="0" CardNo="1042540000026" QualSpend="30005" PointSpend="0" Points="6" BonusPoints="0" PromCount="0" Date="2012-10-22" />
<Clubcard Opcode="96" Function="27" CardAcc="1" QualSpendInfo="1" SchemeNo="40" CardNo="1042540000026" PointsToDate="0" RedemptionValue="0" CustomerUpdateDate="000000" QualSpent="30005" Date="2012-10-22" />
<TicketEnd Date="2012-10-22" />
</Ticket>
<Ticket>
<TicketStart Date="2012-10-22" />
<Clubcard Opcode="96" Function="27" CardAcc="1" QualSpendInfo="0" SchemeNo="40" CardNo="1042540000019" PointsToDate="0" RedemptionValue="0" CustomerUpdateDate="000000" QualSpent="0" Date="2012-10-22" />
<ClubcardPoints Opcode="96" Function="28" SchemeNo="40" PromNo="0" CardNo="1042540000019" QualSpend="24330" PointSpend="0" Points="4" BonusPoints="0" PromCount="0" Date="2012-10-22" />
<Clubcard Opcode="96" Function="27" CardAcc="1" QualSpendInfo="1" SchemeNo="40" CardNo="1042540000019" PointsToDate="0" RedemptionValue="0" CustomerUpdateDate="000000" QualSpent="24330" Date="2012-10-22" />
<TicketEnd Date="2012-10-22" />
</Ticket>
<Ticket>
<TicketStart Date="2012-10-22" />
<Clubcard Opcode="96" Function="27" CardAcc="1" QualSpendInfo="0" SchemeNo="40" CardNo="1042540000026" PointsToDate="0" RedemptionValue="0" CustomerUpdateDate="000000" QualSpent="0" Date="2012-10-22" />
<ClubcardPoints Opcode="96" Function="28" SchemeNo="40" PromNo="0" CardNo="1042540000026" QualSpend="30005" PointSpend="0" Points="6" BonusPoints="0" PromCount="0" Date="2012-10-22" />
<Clubcard Opcode="96" Function="27" CardAcc="1" QualSpendInfo="1" SchemeNo="40" CardNo="1042540000026" PointsToDate="0" RedemptionValue="0" CustomerUpdateDate="000000" QualSpent="30005" Date="2012-10-22" />
<TicketEnd Date="2012-10-22" />
</Ticket>
</Root>
我的 XSL 只能列出条目...
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="/">
<html>
<head>
<title>Loyalty Sales</title>
</head>
<body>
<br/>
<br/>
<br/>
<h1 style="color:blue;
margin-left:20px;
font-family:verdana;
text-align:center;">
Customers Report</h1>
<br/>
<p style="color:red;
margin-left:20px;
font-family:arial;
text-align:right;
font-size:15px;">
Store Report</p>
<p style="color:green;
margin-left:20px;
font-family:arial;
text-align:right;
font-size:15px;">
for Customer ABC</p>
<br/>
<table width="100%" border="3">
<THEAD>
<TR bgcolor="RGB(0, 204, 51)">
<TD width="25%">
<font color="white"><B>Account Number</B></font>
</TD>
<TD width="25%">
<font color="white"><B>Points</B></font>
</TD>
<TD width="25%">
<font color="white"><B>Date</B></font>
</TD>
<TD width="25%">
<font color="white"><B>Qualified Spent</B></font>
</TD>
</TR>
</THEAD>
<TBODY>
<xsl:for-each select="Root/Ticket/ClubcardPoints">
<TR>
<TD width="25%"><xsl:value-of select="@CardNo" /></TD>
<TD width="25%"><xsl:value-of select="@Points" /></TD>
<TD width="25%"><xsl:value-of select="@Date" /></TD>
<TD width="25%"><xsl:value-of select="format-number(@QualSpend div 100,'R#.##')" /></TD>
</TR>
</xsl:for-each>
</TBODY>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
我已经搜索了示例,但找不到具有所有这些条件的场景,并且当放入单个 XSL 时它会失败。请帮忙。
这是我想要的输出文件...
<THEAD>
<TR bgcolor="RGB(0, 204, 51)">
<TD width="25%"><font color="white"><B>Account Number</B></font></TD>
<TD width="25%"><font color="white"><B>Total Points</B></font></TD>
<TD width="25%"><font color="white"><B>Date</B></font></TD>
<TD width="25%"><font color="white"><B>Total Qualified Spent</B></font></TD>
</TR>
</THEAD>
<TBODY>
<TR>
<TD width="25%">1042540000002</TD>
<TD width="25%">100</TD>
<TD width="25%">2012-10-22</TD>
<TD width="25%">R750.32</TD>
</TR>