0
金額をグループ化する方法がわかりません。私は2つのアプローチをする必要があります。可変情報に基づいてXSLTのノードをグループ化する
-I-。最初のアプローチは、私が複数の経費を持っていない状況を指しています。 (これは完了です)。入力XML情報。私が使用している周波数について
<xsl:template match="node()" mode="Amount">
<xsl:choose>
<xsl:when test="Frequency = '4 Weekly'">
<xsl:value-of select="(Amount * 13) div 12"/>
</xsl:when>
<xsl:when test="Frequency = 'Quarterly'">
<xsl:value-of select="Amount * 4"/>
</xsl:when>
<xsl:when test="Frequency != ''">
<xsl:value-of select="Amount"/>
</xsl:when>
</xsl:choose>
</xsl:template>
:
<xsl:template match="ListOfAFGFINSApplicationIncomeandExpensesFormFill/AFGFINSApplicationIncomeandExpenses
[AFGSubCategory = ('Child Maintenance Paid', 'Rental Expense')]" mode="OtherCommitment">
<OtherCommitment
UniqueID="{fn:UniqueID(Id)}">
<xsl:attribute name="Amount">
<xsl:apply-templates select="." mode="Amount"/>
</xsl:attribute>
<xsl:attribute name="Frequency" select="fn:IncomeFrequency(Frequency)"/>
<xsl:attribute name="Category">
<xsl:choose>
<xsl:when test="AFGSubCategory = 'Child Maintenance Paid'">Child Maintenance</xsl:when>
<xsl:when test="AFGSubCategory = 'Rental Expense'">Rent</xsl:when>
</xsl:choose>
</xsl:attribute>
</OtherCommitment>
iは以下のテンプレートを使用してい金額を計算するには、次の
<ListOfAFGFINSApplicationIncomeandExpensesFormFill>
<AFGFINSApplicationIncomeandExpenses>
<AFGSubCategory>Rental Expense</AFGSubCategory>
<Amount>2000</Amount>
<Frequency>Quarterly</Frequency>
</AFGFINSApplicationIncomeandExpenses>
<AFGFINSApplicationIncomeandExpenses>
<AFGSubCategory>Child Maintenance Paid</AFGSubCategory>
<Amount>1000</Amount>
<Frequency>4 Weekly</Frequency>
</AFGFINSApplicationIncomeandExpenses>
</ListOfAFGFINSApplicationIncomeandExpensesFormFill>
私は、このXSLTコードを使用してい
<xsl:function name="fn:IncomeFrequency">
<xsl:param name="Frequency"/>
<xsl:choose>
<xsl:when test="$Frequency = '4 Weekly'">Monthly</xsl:when>
<xsl:when test="$Frequency = 'Annually'">Yearly</xsl:when>
<xsl:when test="$Frequency = 'Quarterly'">Yearly</xsl:when>
<xsl:when test="$Frequency != ''">
<xsl:value-of select="$Frequency"/>
</xsl:when>
<xsl:when test="$Frequency/../AFGAnnualAmount != ''">Yearly</xsl:when>
</xsl:choose>
</xsl:function>
これは、この状況ンは正しいです:
<OtherCommitment Amount="8000" Frequency="Yearly"
Category="Rent">
</OtherCommitment>
<OtherCommitment Amount="1083.3333333333333"
Frequency="Monthly"
Category="Child Maintenance">
</OtherCommitment>
-II-私は同じ名前を持つ以上、その後1つのサブカテゴリを持っていると私は「月刊」の値に周波数をtranformする必要がある場合に、第2の状況です。入力の
例:
<ListOfAFGFINSApplicationIncomeandExpensesFormFill>
<AFGFINSApplicationIncomeandExpenses>
<AFGSubCategory>Rental Expense</AFGSubCategory>
<Amount>2000</Amount>
<Frequency>Quarterly</Frequency>
</AFGFINSApplicationIncomeandExpenses>
<AFGFINSApplicationIncomeandExpenses>
<AFGSubCategory>Rental Expense</AFGSubCategory>
<Amount>1000</Amount>
<Frequency>Mounthly</Frequency>
</AFGFINSApplicationIncomeandExpenses>
<AFGFINSApplicationIncomeandExpenses>
<AFGSubCategory>Child Maintenance Paid</AFGSubCategory>
<Amount>1000</Amount>
<Frequency>4 Weekly</Frequency>
</AFGFINSApplicationIncomeandExpenses>
</ListOfAFGFINSApplicationIncomeandExpensesFormFill>
出力になる必要があります。
<OtherCommitment Amount="1666.6666666666667" Frequency="Monthly"
Category="Rent">
</OtherCommitment>
<!-- This will keep the first approach because is only one 'Child Maintenance'-->
<OtherCommitment Amount="1083.3333333333333"
Frequency="Monthly"
Category="Child Maintenance">
</OtherCommitment>
私はおそらく、この場合に使用する必要がある量を算出する
:
<xsl:template match="node()" mode="AmountMonthly">
<xsl:choose>
<xsl:when test="Frequency = 'Weekly'">
<xsl:value-of select="fn:remove-scientific-notation((Amount * 52) div 12)"/>
</xsl:when>
<xsl:when test="Frequency = 'Fortnightly'">
<xsl:value-of select="fn:remove-scientific-notation((Amount * 26) div 12)"/>
</xsl:when>
<xsl:when test="Frequency = '4 Weekly'">
<xsl:value-of select="fn:remove-scientific-notation((Amount * 13) div 12)"/>
</xsl:when>
<xsl:when test="Frequency = 'Monthly'">
<xsl:value-of select="Amount"/>
</xsl:when>
<xsl:when test="Frequency = 'Quarterly'">
<xsl:value-of select="fn:remove-scientific-notation((Amount * 4) div 12)"/>
</xsl:when>
<xsl:when test="Frequency = 'Annually'">
<xsl:value-of select="fn:remove-scientific-notation(Amount div 12)"/>
</xsl:when>
</xsl:choose>
</xsl:template>
しかし、私は費用を合計する方法を、考え出すことはできません。
xsl:for-each-groupグループバイと同じように問題を修正しました。ご返信ありがとうございます。 – DanielCSD