我无法为下面的问题创建XSLT。
最大数量= 100
输入:
EMP1
AMT = 10
EMP1
AMT = 20
EMP1
AMT = 90
EMP2
AMT = 50
EMP2
AMT = 60
输出
Header
EMP1
AMT = 10
EMP1
AMT = 20
EMP1
AMT = 20 --- EMP1 Amount total exceeding max amount so Total amount - Max Amount and rest of the amount will go in next batch section
Trailer
------------------------------
Header
EMP1
AMT = 70
EMP2
AMT = 50
EMP2
AMT = 10
Trailer
------------------------------
Header
EMP2
AMT = 50 and so on according to the data
Trailer
不会有批量记录包含金额总和超过最高金额的同一员工。
我尝试使用局部变量和全局变量,也尝试了XSLT中的关键概念,但似乎都不起作用。我们将非常感谢您的帮助。
尝试了使用局部和全局变量的场景和捕获金额字段,还使用了xslt的关键功能,但没有成功
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xp20="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.Xpath20"
xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="2.0">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:for-each select="/DATA_DS/G_1/G_2/FILE_FRAGMENT/TEST_DD/Rel_Action">
<xsl:variable name="Amount_MAX">100</xsl:variable>
<!-- HEADER Begin -->
<xsl:text>Header</xsl:text>
<!-- HEADER End -->
<!-- DETAIL Begin -->
<xsl:for-each select="/DATA_DS/G_1/G_2/FILE_FRAGMENT/TEST_DD/Rel_Action">
<xsl:variable name="Amount_Loop"
select="Personal_Payments_Trav/Personal_Payments/Personal_Payment_Rec/Payment_Amount"/>
<xsl:choose>
<xsl:when test="/DATA_DS/G_1/G_2/FILE_FRAGMENT/TEST_DD/Rel_Action/Personal_Payments_Trav/Personal_Payments/Personal_Payment_Rec/Payment_Amount < 100">
<xsl:value-of select="Personal_Payments_Trav/Personal_Payments/Personal_Payment_Rec/Payment_Amount"/>
</xsl:when>
<xsl:otherwise>
<Record>
<xsl:value-of select="Personal_Payments_Trav/Personal_Payments/Personal_Payment_Rec/Payment_Amount - 99"/>
</Record>
</xsl:otherwise>
</xsl:choose>
<xsl:text> </xsl:text>
<!--Single space filler-->
<xsl:text> </xsl:text>
</xsl:for-each>
<!-- DETAIL End -->
<!-- TRAILER Begin -->
<xsl:text>Trailer</xsl:text>
<!-- TRAILER End -->
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Header
EMP1
AMT = 10
EMP1
AMT = 20
EMP1
AMT = 20 --- EMP1 Amount total exceeding max amount so Total amount - Max Amount and rest of the amount will go in next batch section
Trailer
------------------------------
Header
EMP1
AMT = 70
EMP2
AMT = 50
EMP2
AMT = 10
Trailer
------------------------------
Header
发布于 2019-06-28 14:53:59
这在XSLT中是一个相当棘手的问题。如果可以在XSLT 3.0中使用xsl:iterate,那么我建议您:
(a)第一次传递:在需要开始新批处理的地方使用xsl:iterate
注入“新批处理”元素,您可以通过将当前批处理的大小作为xsl:iterate
的一个参数来实现。当您发现一个项目需要拆分成两个(或更多?)批处理,然后在此过程中进行拆分。
(b)第二遍:使用xsl:for-each-group group-starting-with="new-batch"
生成按批次分组的输出。
对不起,我没有时间为你解决细节问题。
https://stackoverflow.com/questions/56807008
复制