使用SAP CPI作为工具并使用Groovy脚本,如果“Letter”节点的创建日期早于同一级别的其他节点,则需要删除该节点。
给定此XML:
<root>
<JobApplication>
<OfferLetter>
<Letter>
<offerLetterId>699</offerLetterId>
<createdBy>00004221</createdBy>
<createDate>2022-09-15T13:20:17.000</createDate>
</Letter>
<Letter>
<offerLetterId>724</offerLetterId>
<createdBy>00001472</createdBy>
<createDate>2022-09-26T13:27:39.000</createDate>
</Letter>
</OfferLetter>
</JobApplication>
<JobApplication>
<OfferLetter>
<Letter>
<offerLetterId>723</offerLetterId>
<createdBy>00001472</createdBy>
<createDate>2022-09-26T13:27:04.000</createDate>
</Letter>
</OfferLetter>
</JobApplication>
<JobApplication>
<OfferLetter>
<Letter>
<offerLetterId>695</offerLetterId>
<createdBy>00001472</createdBy>
<createDate>2022-09-03T14:02:37.000</createDate>
</Letter>
</OfferLetter>
</JobApplication>
</root>
在第一个JobApplication节点中,它有两个“Letter”节点,我需要保留较新的一个:**“2022-09-26T13:27:39.000”**并删除另一个节点。
结果应该是这样的:
<root>
<JobApplication>
<OfferLetter>
<Letter>
<offerLetterId>724</offerLetterId>
<createdBy>00001472</createdBy>
<createDate>2022-09-26T13:27:39.000</createDate>
</Letter>
</OfferLetter>
</JobApplication>
<JobApplication>
<OfferLetter>
<Letter>
<offerLetterId>723</offerLetterId>
<createdBy>00001472</createdBy>
<createDate>2022-09-26T13:27:04.000</createDate>
</Letter>
</OfferLetter>
</JobApplication>
<JobApplication>
<OfferLetter>
<Letter>
<offerLetterId>695</offerLetterId>
<createdBy>00001472</createdBy>
<createDate>2022-09-03T14:02:37.000</createDate>
</Letter>
</OfferLetter>
</JobApplication>
</root>
1条答案
按热度按时间lyfkaqu11#
使用XSLT 3:
在XSLT 2中,您需要删除
xsl:mode
声明并将其拼写为模板