我正在尝试使用 XSLT 合并两个 XML 文件。我需要匹配tradeId
两个文件中必须存在的节点值,并将所有内容复制到file1
.
欢迎任何帮助。所有类似的示例都基于属性和相同的 XML,这对我不起作用。
文件1.xml
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<trade>
<tradeId>1</tradeId>
<createdBy>1</createdBy>
<createdOnDate>2</createdOnDate>
<Payment>
<indicator>3</indicator>
<updateBy>4</updateBy>
</Payment>
<Parties>
<partyId>5</partyId>
<partyRoleTypeCode>6</partyRoleTypeCode>
</Parties>
<Product>
<term>7</term>
<shortDescription>8</shortDescription>
</Product>
</trade>
<trade>
<tradeId>2</tradeId>
<createdBy>10</createdBy>
<createdOnDate>20</createdOnDate>
<Payment>
<indicator>30</indicator>
<updateBy>40</updateBy>
</Payment>
<Parties>
<partyId>50</partyId>
<partyRoleTypeCode>60</partyRoleTypeCode>
</Parties>
<Product>
<term>70</term>
<shortDescription>80</shortDescription>
</Product>
</trade>
</S:Body>
</S:Envelope>
文件2.xml
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<financialexpectation>
<tradeId>1</tradeId>
<stateCode>TBD</stateCode>
<methodCode>TBD</methodCode>
<TypeCode>NONE</TypeCode>
</financialexpectation>
<financialexpectation>
<tradeId>2</tradeId>
<stateCode>TBD</stateCode>
<methodCode>TBD</methodCode>
<TypeCode>NONE</TypeCode>
</financialexpectation>
<financialexpectation>
<tradeId>3</tradeId>
<stateCode>TBD</stateCode>
<methodCode>TBD</methodCode>
<TypeCode>NONE</TypeCode>
</financialexpectation>
</S:Body>
</S:Envelope>
预期产出
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<trade>
<tradeId>1</tradeId>
<createdBy>1</createdBy>
<createdOnDate>2</createdOnDate>
<Payment>
<indicator>3</indicator>
<updateBy>4</updateBy>
</Payment>
<Parties>
<partyId>5</partyId>
<partyRoleTypeCode>6</partyRoleTypeCode>
</Parties>
<Product>
<term>7</term>
<shortDescription>8</shortDescription>
</Product>
<financialexpectation>
<tradeId>1</tradeId>
<stateCode>TBD</stateCode>
<methodCode>TBD</methodCode>
<TypeCode>NONE</TypeCode>
</financialexpectation>
</trade>
<trade>
<tradeId>2</tradeId>
<createdBy>10</createdBy>
<createdOnDate>20</createdOnDate>
<Payment>
<indicator>30</indicator>
<updateBy>40</updateBy>
</Payment>
<Parties>
<partyId>50</partyId>
<partyRoleTypeCode>60</partyRoleTypeCode>
</Parties>
<Product>
<term>70</term>
<shortDescription>80</shortDescription>
</Product>
<financialexpectation>
<tradeId>2</tradeId>
<stateCode>TBD</stateCode>
<methodCode>TBD</methodCode>
<TypeCode>NONE</TypeCode>
</financialexpectation>
</trade>
</S:Body>
</S:Envelope>