<GetPolicyStatus>
<policyResult xmlns="" xmlns:ns2="http://ws.faithlife.com/resonant">
<PolicyNumber>445</PolicyNumber>
<AnnualPremium>12000.0</AnnualPremium>
<AgentNumber>1</AgentNumber>
<ProductType>1</ProductType>
<PendingIssues>yes</PendingIssues>
</policyResult>
<policyResult xmlns="" xmlns:ns2="http://ws.faithlife.com/resonant">
<PolicyNumber>555</PolicyNumber>
<AnnualPremium>12000.0</AnnualPremium>
<AgentNumber>2</AgentNumber>
<ProductType>1</ProductType>
<AfterBusinessIssues>yes</AfterBusinessIssues>
</policyResult>
<policyResult xmlns="" xmlns:ns2="http://ws.faithlife.com/resonant">
<PolicyNumber>446</PolicyNumber>
<AnnualPremium>12000.0</AnnualPremium>
<AgentNumber>1</AgentNumber>
<ProductType>1</ProductType>
<PendingIssues>yes</PendingIssues>
</policyResult>
<policyResult xmlns="" xmlns:ns2="http://ws.faithlife.com/resonant">
<PolicyNumber>556</PolicyNumber>
<AnnualPremium>12000.0</AnnualPremium>
<AgentNumber>2</AgentNumber>
<ProductType>1</ProductType>
<AfterBusinessIssues>yes</AfterBusinessIssues>
</policyResult>
<policyResult xmlns="" xmlns:ns2="http://ws.faithlife.com/resonant">
<PolicyNumber>447</PolicyNumber>
<AnnualPremium>12000.0</AnnualPremium>
<AgentNumber>1</AgentNumber>
<ProductType>1</ProductType>
<PendingIssues>yes</PendingIssues>
</policyResult>
<policyResult xmlns="" xmlns:ns2="http://ws.faithlife.com/resonant">
<PolicyNumber>557</PolicyNumber>
<AnnualPremium>12000.0</AnnualPremium>
<AgentNumber>2</AgentNumber>
<ProductType>1</ProductType>
<AfterBusinessIssues>yes</AfterBusinessIssues>
</policyResult>
<policyResult xmlns="" xmlns:ns2="http://ws.faithlife.com/resonant">
<PolicyNumber>448</PolicyNumber>
<AnnualPremium>12000.0</AnnualPremium>
<AgentNumber>1</AgentNumber>
<ProductType>1</ProductType>
<PendingIssues>yes</PendingIssues>
</policyResult>
<policyResult xmlns="" xmlns:ns2="http://ws.faithlife.com/resonant">
<PolicyNumber>558</PolicyNumber>
<AnnualPremium>12000.0</AnnualPremium>
<AgentNumber>2</AgentNumber>
<ProductType>1</ProductType>
<AfterBusinessIssues>yes</AfterBusinessIssues>
</policyResult>
</GetPolicyStatus>
这是我的输入 xml 并期望输出如下所示。
agent number :1 (sorted order)
PendingIssues:yes(if yes)
product type: 1
policy number:445(sorted order)
annual premium:12000.0
policy number:446
annual premium:12000.0
sub total pending:24000(12000+12000)
PendingIssues:yes(if yes)
product type: 2
policy number:555
annual premium:12000.0
policy number:556
annual premium:12000.0
sub total pending:24000(12000+12000)
AfterBusinessIssues:yes(if yes)
product type: 1
policy number:445
annual premium:12000.0
policy number:446
annual premium:12000.0
sub total after business:24000(12000+12000)
AfterBusinessIssuess:yes(if yes)
product type: 2
policy number:445
annual premium:12000.0
policy number:446
annual premium:12000.0
sub total after business:24000(12000+12000).
应为所有代理编号重复此操作。
grand total :sub total pending(all)+sub total after business(all)=24000(12000+12000)+24000(12000+12000)=48000
此处代理编号和保单编号应按排序顺序排列。之前我发布了相同类型的 xml。我得到了答案,但现在这对我来说有些挑战,请任何人帮助我。
共享 xsl 请在我做错的地方进行更正。谢谢。
<xsl:template match="/">
<xsl:variable name="types" select="//policyResult"></xsl:variable>
<xsl:for-each select="$types">
<xsl:sort select="ProductType"/>
<xsl:if test="generate-id(.)=generate-id($types[ProductType=current()/ProductType][1])">
<xsl:value-of select="ProductType"></xsl:value-of>
<xsl:variable name="agents" select="$types[ProductType=current()/ProductType]"></xsl:variable>
<xsl:for-each select="$agents">
<xsl:sort select="PolicyNumber"/>
<xsl:if test="generate-id(.)=generate-id($agents[AgentNumber=current()/AgentNumber][1])">
<fo:table border-style="" width="100%" border-spacing="4">
<fo:table-body>
<fo:table-row border-left-style="solid" border-right-style="solid" border-after-style="solid">
<fo:table-cell>
<fo:block font-family="arial" font-size="10pt"
font-weight="normal">
<fo:inline>
FR#:<xsl:value-of select="AgentNumber"></xsl:value-of>
</fo:inline>
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
<xsl:for-each select="$agents[AgentNumber=current()/AgentNumber]">
<fo:block>
<xsl:text> </xsl:text>
</fo:block>
<fo:block>
<xsl:text> </xsl:text>
</fo:block>
<fo:table border-style="" width="100%" border-spacing="4">
<fo:table-column column-width="25%" />
<fo:table-column column-width="25%" />
<fo:table-column column-width="25%" />
<fo:table-column column-width="25%" />
<fo:table-body>
<fo:table-row border-before-style="solid" border-left-style="solid" border-right-style="solid">
<fo:table-cell>
<fo:block font-family="arial" font-size="10pt"
font-weight="normal">
<fo:inline>
Pol Number
</fo:inline>
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block font-family="arial" font-size="10pt"
font-weight="normal">
<fo:inline text-decoration="underline">
<xsl:value-of select="PolicyNumber"></xsl:value-of>---<xsl:value-of select="ProductType"></xsl:value-of>
</fo:inline>
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row border-left-style="solid" border-right-style="solid">
<fo:table-cell>
<fo:block font-family="arial" font-size="10pt"
font-weight="normal">
<fo:inline>
Annual Premium
</fo:inline>
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block font-family="arial" font-size="10pt"
font-weight="normal">
<fo:inline>
$<xsl:value-of select="AnnualPremium"></xsl:value-of>
</fo:inline>
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</xsl:for-each>
<fo:table border-style="solid" width="100%" border-spacing="4">
<fo:table-body>
<fo:table-row border-after-style="solid">
<fo:table-cell text-align="right">
<fo:block font-family="arial" font-size="10pt"
font-weight="normal">
<fo:inline>
Annual Premium SubTotal
</fo:inline>
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell border-right-style="solid">
<fo:block font-family="arial" font-size="10pt"
font-weight="normal">
<fo:inline>
Pending Business
</fo:inline>
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block font-family="arial" font-size="10pt" text-align="center"
font-weight="normal">
<fo:inline><!--
$<xsl:value-of select="sum(//policyResult[AgentNumber=$agentNum]/AnnualPremium)"></xsl:value-o
-->
$<xsl:value-of select="sum($agents[AgentNumber=current()/AgentNumber]/AnnualPremium)"></xsl:value-of>
</fo:inline>
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</xsl:if>
</xsl:for-each>
</xsl:if>
</xsl:for-each>
<fo:block>
<xsl:text> </xsl:text>
</fo:block>
<fo:block id="last-page"/>
</xsl:template>