xsl xml 批处理
我需要在 xsl 映射中实现某种批处理。 示例:
输入:
<FinTrans_Dinas_FF xmlns="http://MH.ESB.Dinas.Schemas.FinTrans_FF.FinTrans_FF">
<Line xmlns="">
<Header>
<DocumentDate>03022011</DocumentDate>
<Reference>71013849</Reference>
</Header>
<Item>
<PostingKey>01</PostingKey>
<AccountNumber>0000560141</AccountNumber>
<AmountInDocumentCurrency>/</AmountInDocumentCurrency>
<AmountInLocalCurrency>21,42</AmountInLocalCurrency>
</Item>
</Line>
<Line xmlns="">
<Header>
<DocumentDate>03022011</DocumentDate>
<Reference>71013849</Reference>
</Header>
<Item>
<PostingKey>01</PostingKey>
<AccountNumber>0000560141</AccountNumber>
<AmountInDocumentCurrency>/</AmountInDocumentCurrency>
<AmountInLocalCurrency>21,42</AmountInLocalCurrency>
</Item>
</Line>
<Line xmlns="">
<Header>
<DocumentDate>03022011</DocumentDate>
<Reference>77777777</Reference>
</Header>
<Item>
<PostingKey>02</PostingKey>
<AccountNumber>0000560141</AccountNumber>
<AmountInDocumentCurrency>/</AmountInDocumentCurrency>
<AmountInLocalCurrency>21,42</AmountInLocalCurrency>
</Item>
</Line>
</FinTrans_Dinas_FF>
现在我需要为每个唯一行创建一条记录(键 = 参考)。 因此,在我的输入消息中,我有 2 个唯一的记录:
Reference = 71013849
Reference = 77777777
因此,我的输出文件需要如下所示(稍微简化一下):
<Trans>
<Record>
<Lines>
<Line>
<Reference>71013849</Reference>
<Account>Account1</Account>
</Line>
<Line>
<Reference>71013849</Reference>
<Account>Account2</Account>
</Line>
</Lines>
</Record>
<Record>
<Lines>
<Line>
<Reference>77777777</Reference>
<Account>Account3</Account>
</Line>
</Lines>
</Record>
</Trans>
因此,如您所见,我的输入文件包含 3 个“行”项目,我的输出包含 2 个“记录”项目(在记录节点内有行)。显然,“Lines/Line”项中应该有更多数据,但我在本示例中对其进行了简化。
有人知道解决这个问题的最佳方法吗? (在 XSLT 1.0 中)
非常感谢!
I need to implement some kind of batching in an xsl mapping.
Example:
Input:
<FinTrans_Dinas_FF xmlns="http://MH.ESB.Dinas.Schemas.FinTrans_FF.FinTrans_FF">
<Line xmlns="">
<Header>
<DocumentDate>03022011</DocumentDate>
<Reference>71013849</Reference>
</Header>
<Item>
<PostingKey>01</PostingKey>
<AccountNumber>0000560141</AccountNumber>
<AmountInDocumentCurrency>/</AmountInDocumentCurrency>
<AmountInLocalCurrency>21,42</AmountInLocalCurrency>
</Item>
</Line>
<Line xmlns="">
<Header>
<DocumentDate>03022011</DocumentDate>
<Reference>71013849</Reference>
</Header>
<Item>
<PostingKey>01</PostingKey>
<AccountNumber>0000560141</AccountNumber>
<AmountInDocumentCurrency>/</AmountInDocumentCurrency>
<AmountInLocalCurrency>21,42</AmountInLocalCurrency>
</Item>
</Line>
<Line xmlns="">
<Header>
<DocumentDate>03022011</DocumentDate>
<Reference>77777777</Reference>
</Header>
<Item>
<PostingKey>02</PostingKey>
<AccountNumber>0000560141</AccountNumber>
<AmountInDocumentCurrency>/</AmountInDocumentCurrency>
<AmountInLocalCurrency>21,42</AmountInLocalCurrency>
</Item>
</Line>
</FinTrans_Dinas_FF>
Now I need to create a record foreach unique line (key = Reference).
So in my input message I have 2 unique records:
Reference = 71013849
Reference = 77777777
So my output file needs to look like this (simplified it a bit):
<Trans>
<Record>
<Lines>
<Line>
<Reference>71013849</Reference>
<Account>Account1</Account>
</Line>
<Line>
<Reference>71013849</Reference>
<Account>Account2</Account>
</Line>
</Lines>
</Record>
<Record>
<Lines>
<Line>
<Reference>77777777</Reference>
<Account>Account3</Account>
</Line>
</Lines>
</Record>
</Trans>
So as you can see my input file contains 3 'Line' items, my output contains 2 'Record' items (with inside the Record node the lines). Obviously inside the 'Lines/Line' item there should be more data, but I simplified it for this example.
Anyone knows the best way to solve this? (In XSLT 1.0)
Thx very much!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此转换:
应用于提供的 XML 文档时:
产生所需的正确结果:
说明:慕尼黑分组方法。
当记录和不同键值的数量很大时,这是已知的最有效的分组方法。
This transformation:
when applied to the provided XML document:
produces the wanted, correct result:
Explanation: Muenchian method for grouping.
When the number of records and different key values is significant, this is the most efficient known grouping method.