我想知道如何合并2个XML流,然后再次进行最终转换。使用关键值上的XSLT匹配合并两个XML流
两个流
输入1
<Response>
<Instrument>
<Date value="2010-09-02">
<Quantity>10</Quantity>
</Date>
<DXLID>1</DXLID>
</Instrument>
<Instrument TICKER="APPL" />
<SF></SF>
<Instrument>
<Date value="2010-09-02">
<Quantity>20</Quantity>
</Date>
<DXLID>2</DXLID>
</Instrument>
<Instrument TICKER="APPL" />
<SF></SF>
</Response>
输入2
<Response>
<IM>
<Instrument>
<Date value="2010-09-02">
<SAF>1</SAF>
<SAR>2</SAR>
</Date>
<DXLID>1</DXLID>
</Instrument>
<Instrument>
<Date value="2010-09-02">
<SAF>1</SAF>
<SAR>2</SAR>
</Date>
<DXLID>3</DXLID>
</Instrument>
</IM>
</Response>
所需的输出
<Response>
<All>
<Instrument>
<Date value="2010-09-02">
<SAF>1</SAF>
<SAR>2</SAR>
<Quantity>10</Quantity>
</Date>
<DXLID>1</DXLID>
</Instrument>
<Instrument>
<Date value="2010-09-02">
<Quantity>20</Quantity>
</Date>
<DXLID>2</DXLID>
</Instrument>
<Instrument>
<Date value="2010-09-02">
<SAF>1</SAF>
<SAR>2</SAR>
</Date>
<DXLID>3</DXLID>
</Instrument>
</All>
</Response>
合并需要基于节点DXLID
节点值与Date
节点的value
属性之间的匹配。
还要注意合并需要合并两种方式。
我已经编辑好你的输入样本了。如果有差异,则回滚。另外,在转换之前不需要合并它:'fn:document'允许多个输入源。如果你添加你的第二步转换,有人可以提供一个例子。 – 2010-09-03 15:52:12
@ Neil-Gallagher:您需要在您的问题中指定如何处理相同名称和定位的元素。例如,如果两个文档中都有'/ */*/Instrument/Date/Saf',但这两个元素的值不同,那么应该选择这两个值中的哪一个? – 2010-09-03 21:35:47
@ Neil-Gallagher:查看我的答案,找出不使用'count()'函数执行设置成员资格操作的解决方案。 – 2010-09-04 04:17:56