她想知道如何在异常低价竞标中建立多个集团。 The following XML should be grouped by memberID, Depositdate, and Deposit category. 每个成员的合计数额应按日期和交存类型汇总。 我已经提出了这一问题,答案是3.0。 我需要采用XSLT版本2.0的解决办法,因为Im系统的工作对版本3.0有限制。 谢谢。
<?xml version="1.0" encoding="UTF-8"?>
<Report>
<Deposit_Data>
<MemberID>12345</MemberID>
<MemberFirstName>Mickey</MemberFirstName>
<MemberLastName>Mouse</MemberLastName>
<DepositDate>2023-11-22</DepositDate>
<DepositInfo>
<DepositType>CHK</DepositType>
<Amount>50.00</Amount>
</DepositInfo>
<DepositInfo>
<DepositType>SAV</DepositType>
<Amount>30.00</Amount>
</DepositInfo>
</Deposit_Data>
<Deposit_Data>
<MemberID>12345</MemberID>
<MemberFirstName>Mickey</MemberFirstName>
<MemberLastName>Mouse</MemberLastName>
<DepositDate>2023-11-22</DepositDate>
<DepositInfo>
<DepositType>CHK</DepositType>
<Amount>10.00</Amount>
</DepositInfo>
<DepositInfo>
<DepositType>SAV</DepositType>
<Amount>5.00</Amount>
</DepositInfo>
</Deposit_Data>
<Deposit_Data>
<MemberID>12345</MemberID>
<MemberFirstName>Mickey</MemberFirstName>
<MemberLastName>Mouse</MemberLastName>
<DepositDate>2023-12-05</DepositDate>
<DepositInfo>
<DepositType>CHK</DepositType>
<Amount>25.00</Amount>
</DepositInfo>
<DepositInfo>
<DepositType>SAV</DepositType>
<Amount>10.00</Amount>
</DepositInfo>
</Deposit_Data>
<Deposit_Data>
<MemberID>78910</MemberID>
<MemberFirstName>Donald</MemberFirstName>
<MemberLastName>Duck</MemberLastName>
<DepositDate>2023-11-22</DepositDate>
<DepositInfo>
<DepositType>CHK</DepositType>
<Amount>10.00</Amount>
</DepositInfo>
<DepositInfo>
<DepositType>SAV</DepositType>
<Amount>30.00</Amount>
</DepositInfo>
</Deposit_Data>
<Deposit_Data>
<MemberID>78910</MemberID>
<MemberFirstName>Donald</MemberFirstName>
<MemberLastName>Duck</MemberLastName>
<DepositDate>2023-12-05</DepositDate>
<DepositInfo>
<DepositType>CHK</DepositType>
<Amount>20.00</Amount>
</DepositInfo>
<DepositInfo>
<DepositType>SAV</DepositType>
<Amount>10.00</Amount>
</DepositInfo>
</Deposit_Data>
<Deposit_Data>
<MemberID>78910</MemberID>
<MemberFirstName>Donald</MemberFirstName>
<MemberLastName>Duck</MemberLastName>
<DepositDate>2023-12-05</DepositDate>
<DepositInfo>
<DepositType>CHK</DepositType>
<Amount>5.00</Amount>
</DepositInfo>
<DepositInfo>
<DepositType>SAV</DepositType>
<Amount>10.00</Amount>
</DepositInfo>
</Deposit_Data>
</Report>
最终结果应当是:
MemberID|DepositDate|DepositType|Amount
12345|2023-11-22|CHK|60
12345|2023-11-22|SAV|35
12345|2023-12-05|CHK|25
12345|2023-12-05|SAV|10
78910|2023-11-22|CHK|10
78910|2023-11-22|SAV|30
78910|2023-12-05|CHK|25
78910|2023-12-05|SAV|20
我尝试根据打工的日期和交存类型与每个小组一起工作。 请参见下文关于《欧洲空间法中心》。
<xsl:template match="Deposit_Data">
<xsl:choose>
<xsl:when test="exists(DepositInfo)">
<xsl:for-each-group select="." group-by="DepositDate">
<xsl:variable name="DepositDateOfCurrentGroup" select="current-grouping-key()"/>
<!-- MemberID --><xsl:value-of select="MemberID"/>
<xsl:value-of select="$vPipeDelimiter"/>
<!-- DepositDate --><xsl:value-of select="format-date($DepositDateOfCurrentGroup, [Y0001][M01][D01] )"/>
<xsl:value-of select="$vPipeDelimiter"/>
<!-- DepositType -->
<xsl:choose>
<xsl:when test="DepositInfo/DepositType = CHK ">
<!-- Amount --><xsl:text>ACCT1</xsl:text>
</xsl:when>
<xsl:when test="DepositInfo/DepositType = SAV ">
<!-- Amount --><xsl:text>ACCT2</xsl:text>
</xsl:when>
<xsl:when test="DepositInfo/DepositType = CD ">
<!-- Amount --><xsl:text>ACCT3</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text/>
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="$vPipeDelimiter"/>
<xsl:choose>
<xsl:when test="exists(DepositDate = $DepositDateOfCurrentGroup and DepositInfo/DepositType = CHK )">
<xsl:value-of select="format-number(sum(DepositDate[DepositDate = $DepositDateOfCurrentGroup]/Amount), #######0.00 )"/>
</xsl:when>
<xsl:when test="exists([DepositDate = $DepositDateOfCurrentGroup and DepositInfo/DepositType = SAV ])">
<xsl:value-of select="format-number(sum(DepositDate[DepositDate = $DepositDateOfCurrentGroup]/Amount), #######0.00 )"/>
</xsl:when>
<xsl:when test="exists(DepositDate = $DepositDateOfCurrentGroup and DepositInfo/DepositType = CD )">
<xsl:value-of select="format-number(sum(DepositDate[DepositDate = $DepositDateOfCurrentGroup]/Amount), #######0.00 )"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>0.00</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="$vLineFeed"/>
</xsl:for-each-group>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
最终结果没有分类:
MemberID|DepositDate|DepositType|Amount|
12345|20231122|CHK|0.00
12345|20231122|CHK|0.00
12345|20231205|CHK|0.00
78910|20231122|CHK|0.00
78910|20231205|CHK|0.00
78910|20231205|CHK|0.00