0
<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>&#160;</xsl:text>
                    </fo:block> 

                    <fo:block>
                        <xsl:text>&#160;</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>&#160;</xsl:text>
                    </fo:block>
                <fo:block id="last-page"/>                                  


    </xsl:template>
4

0 に答える 0