XSL转换-从第一个xml到第二个xml的键
从2个xml文件中,我希望生成一个新的xml文件。请注意4103700和4103701是来自第一个xml的键。基于此,我需要从第二个xml中选取值 第一个XML文件:XSL转换-从第一个xml到第二个xml的键,xml,xslt,transformation,Xml,Xslt,Transformation,从2个xml文件中,我希望生成一个新的xml文件。请注意4103700和4103701是来自第一个xml的键。基于此,我需要从第二个xml中选取值 第一个XML文件: <B2BXo856ShipmentCollection xmlns="http://xmlns.oracle.com/pcbpel/adapter/db/top/dbService"> <B2BXo856Shipment> <shipPk>3165760&
<B2BXo856ShipmentCollection xmlns="http://xmlns.oracle.com/pcbpel/adapter/db/top/dbService">
<B2BXo856Shipment>
<shipPk>3165760</shipPk>
<customerNumber>250117</customerNumber>
<shipperNumber>188884001</shipperNumber>
<b2BXo856CartonCollection>
<B2BXo856Carton>
<cartonPk>4103700</cartonPk>
<numberOfBoxes>6</numberOfBoxes>
<cartonWeight>4</cartonWeight>
</B2BXo856Carton>
<B2BXo856Carton>
<cartonPk>4103701</cartonPk>
<numberOfBoxes>6</numberOfBoxes>
<cartonWeight>4</cartonWeight>
</B2BXo856Carton>
</b2BXo856CartonCollection>
</B2BXo856Shipment>
</B2BXo856ShipmentCollection>
<dbReferenceOutputCollection xmlns="http://xmlns.oracle.com/pcbpel/adapter/db/dbReference">
<dbReferenceOutput>
<carton_fk>4103700</carton_fk>
<date_code>1701</date_code>
<SUM_NUMBER_PARTS_PER_BOX_>100</SUM_NUMBER_PARTS_PER_BOX_>
</dbReferenceOutput>
<dbReferenceOutput>
<carton_fk>4103700</carton_fk>
<date_code>1705</date_code>
<SUM_NUMBER_PARTS_PER_BOX_>800</SUM_NUMBER_PARTS_PER_BOX_>
</dbReferenceOutput>
<dbReferenceOutput>
<carton_fk>4103701</carton_fk>
<date_code>1703</date_code>
<SUM_NUMBER_PARTS_PER_BOX_>130</SUM_NUMBER_PARTS_PER_BOX_>
</dbReferenceOutput>
<dbReferenceOutput>
<carton_fk>4103701</carton_fk>
<date_code>1707</date_code>
<SUM_NUMBER_PARTS_PER_BOX_>500</SUM_NUMBER_PARTS_PER_BOX_>
</dbReferenceOutput>
<dbReferenceOutput>
<carton_fk>4103701</carton_fk>
<date_code>1710</date_code>
<SUM_NUMBER_PARTS_PER_BOX_>500</SUM_NUMBER_PARTS_PER_BOX_>
</dbReferenceOutput>
</dbReferenceOutputCollection>
3165760
250117
188884001
4103700
6.
4.
4103701
6.
4.
第二个XML文件:
<B2BXo856ShipmentCollection xmlns="http://xmlns.oracle.com/pcbpel/adapter/db/top/dbService">
<B2BXo856Shipment>
<shipPk>3165760</shipPk>
<customerNumber>250117</customerNumber>
<shipperNumber>188884001</shipperNumber>
<b2BXo856CartonCollection>
<B2BXo856Carton>
<cartonPk>4103700</cartonPk>
<numberOfBoxes>6</numberOfBoxes>
<cartonWeight>4</cartonWeight>
</B2BXo856Carton>
<B2BXo856Carton>
<cartonPk>4103701</cartonPk>
<numberOfBoxes>6</numberOfBoxes>
<cartonWeight>4</cartonWeight>
</B2BXo856Carton>
</b2BXo856CartonCollection>
</B2BXo856Shipment>
</B2BXo856ShipmentCollection>
<dbReferenceOutputCollection xmlns="http://xmlns.oracle.com/pcbpel/adapter/db/dbReference">
<dbReferenceOutput>
<carton_fk>4103700</carton_fk>
<date_code>1701</date_code>
<SUM_NUMBER_PARTS_PER_BOX_>100</SUM_NUMBER_PARTS_PER_BOX_>
</dbReferenceOutput>
<dbReferenceOutput>
<carton_fk>4103700</carton_fk>
<date_code>1705</date_code>
<SUM_NUMBER_PARTS_PER_BOX_>800</SUM_NUMBER_PARTS_PER_BOX_>
</dbReferenceOutput>
<dbReferenceOutput>
<carton_fk>4103701</carton_fk>
<date_code>1703</date_code>
<SUM_NUMBER_PARTS_PER_BOX_>130</SUM_NUMBER_PARTS_PER_BOX_>
</dbReferenceOutput>
<dbReferenceOutput>
<carton_fk>4103701</carton_fk>
<date_code>1707</date_code>
<SUM_NUMBER_PARTS_PER_BOX_>500</SUM_NUMBER_PARTS_PER_BOX_>
</dbReferenceOutput>
<dbReferenceOutput>
<carton_fk>4103701</carton_fk>
<date_code>1710</date_code>
<SUM_NUMBER_PARTS_PER_BOX_>500</SUM_NUMBER_PARTS_PER_BOX_>
</dbReferenceOutput>
</dbReferenceOutputCollection>
4103700
1701
100
4103700
1705
800
4103701
1703
130
4103701
1707
500
4103701
1710
500
预期结果:
<?xml version = '1.0' encoding = 'UTF-8'?>
<tns:Pip3B2AdvanceShipmentNotification xmlns:tns="http://www.edifecs.com/RosettaNet/100">
<tns:AdvancedShipmentNotification>
<tns:Shipment>
<tns:ShippingContainer>
<tns:LinearPhysicalDimension>
<tns:GlobalPhysicalUnitOfMeasureCode>4103700</tns:GlobalPhysicalUnitOfMeasureCode>
</tns:LinearPhysicalDimension>
<tns:ShippingContainerItem>
<tns:DocumentSubLineLotShipReference>
<tns:GlobalDocumentReferenceTypeCode>1701</tns:GlobalDocumentReferenceTypeCode>
</tns:DocumentSubLineLotShipReference>
<tns:DocumentSubLineLotShipReference>
<tns:GlobalDocumentReferenceTypeCode>1705</tns:GlobalDocumentReferenceTypeCode>
</tns:DocumentSubLineLotShipReference>
</tns:ShippingContainerItem>
</tns:ShippingContainer>
<tns:ShippingContainer>
<tns:LinearPhysicalDimension>
<tns:GlobalPhysicalUnitOfMeasureCode>4103701</tns:GlobalPhysicalUnitOfMeasureCode>
</tns:LinearPhysicalDimension>
<tns:ShippingContainerItem>
<tns:DocumentSubLineLotShipReference>
<tns:GlobalDocumentReferenceTypeCode>1703</tns:GlobalDocumentReferenceTypeCode>
</tns:DocumentSubLineLotShipReference>
<tns:DocumentSubLineLotShipReference>
<tns:GlobalDocumentReferenceTypeCode>1707</tns:GlobalDocumentReferenceTypeCode>
</tns:DocumentSubLineLotShipReference>
<tns:DocumentSubLineLotShipReference>
<tns:GlobalDocumentReferenceTypeCode>1710</tns:GlobalDocumentReferenceTypeCode>
</tns:DocumentSubLineLotShipReference>
</tns:ShippingContainerItem>
</tns:ShippingContainer>
</tns:Shipment>
</tns:AdvancedShipmentNotification>
</tns:Pip3B2AdvanceShipmentNotification>
4103700
1701
1705
4103701
1703
1707
1710
对于第一个键,第二个xml中有2个值,对于第二个键,有3个值
感谢您的帮助或指点。谢谢这里有一个提示:使用编程语言解决您的问题。这通常会产生有用的结果。当你有一个关于你的解决方案的某个方面的问题时,欢迎你在这里提问。然而,“我有X,我需要Y”不是一个问题。这个答案包含了一些关于处理多个文件的信息。XSLT 1.0和XSLT 2.0在键跨文档工作的方式上有很大的不同。请澄清您将使用哪个XSLT处理器。同时发布预期输出。嗨,Michael,我正在寻找一个解决方案,最好先在1.0版本中发布。我使用的工具支持1.0。使用2.0的方法有很多种。我已将预期结果粘贴到问题中。请看第三个xml。@Gerriet-谢谢你的指针,但这对我没有帮助。