0

下面是我的输入 XML。这里每个 X_DLV_TAB_ITEM 都有多个 RL_DETAILS,而这些 RL_DETAILS 又有多个 RL_DETAILS_ITEM。每个 RL_DETAILS_ITEM 包含 SOURCE_HEADER_NUMBER。

我的要求是,如果两个或多个 X_DLV_TAB_ITEM 的 SOURCE_HEADER_NUMBER 相同,则只应创建 X_DLV_TAB_ITEM ,它将包含第一个 X_DLV_TAB_ITEM 以及其他的所有 RL_DETAILS_ITEM。

<X_DLV_TAB>
      <X_DLV_TAB_ITEM>
         <TRANSACTION_CODE>RC</TRANSACTION_CODE>
         <DELIVERY_ID>46689763</DELIVERY_ID>
         <NAME>46689763</NAME>
         <FREIGHT_TERMS xsi:nil="true"></FREIGHT_TERMS>
         <FOB_CODE xsi:nil="true"></FOB_CODE>
         <CARRIER_ID xsi:nil="true"></CARRIER_ID>
         <SERVICE_LEVEL xsi:nil="true"></SERVICE_LEVEL>
         <MODE_OF_TRANSPORT xsi:nil="true"></MODE_OF_TRANSPORT>
         <INITIAL_PICKUP_LOCATION_ID>ORG-142-197</INITIAL_PICKUP_LOCATION_ID>
         <ULTIMATE_DROPOFF_LOCATION_ID>CUS-44964-757828</ULTIMATE_DROPOFF_LOCATION_ID>
         <EARLIEST_PICKUP_DATE>2013-07-07T00:01:00.000-04:00</EARLIEST_PICKUP_DATE>
         <LATEST_PICKUP_DATE>2013-07-07T03:40:20.000-04:00</LATEST_PICKUP_DATE>
         <EARLIEST_DROPOFF_DATE xsi:nil="true"></EARLIEST_DROPOFF_DATE>
         <LATEST_DROPOFF_DATE xsi:nil="true"></LATEST_DROPOFF_DATE>
         <GROSS_WEIGHT>16.28333</GROSS_WEIGHT>
         <WEIGHT_UOM_CODE>LB</WEIGHT_UOM_CODE>
         <VOLUME>0.32</VOLUME>
         <VOLUME_UOM_CODE>CF</VOLUME_UOM_CODE>
         <NET_WEIGHT>16.28333</NET_WEIGHT>
         <REVISION>2</REVISION>
         <REASON_OF_TRANSPORT xsi:nil="true"></REASON_OF_TRANSPORT>
         <DESCRIPTION xsi:nil="true"></DESCRIPTION>
         <ADDITIONAL_SHIPMENT_INFO xsi:nil="true"></ADDITIONAL_SHIPMENT_INFO>
         <ROUTING_INSTRUCTIONS xsi:nil="true"></ROUTING_INSTRUCTIONS>
         <TOTAL_ITEM_COUNT>8</TOTAL_ITEM_COUNT>
         <REVISION_QLFR>REVNUM</REVISION_QLFR>
         <REASON_OF_TRANSPORT_QLFR>TRSP_REASON</REASON_OF_TRANSPORT_QLFR>
         <DESCRIPTION_QLFR>DEL_DESCRIPTION</DESCRIPTION_QLFR>
         <ADDITIONAL_SHIPMENT_INFO_QLFR>ADD_INFOS</ADDITIONAL_SHIPMENT_INFO_QLFR>
         <ROUTING_INSTRUCTIONS_QLFR>ROUTING_INSTR</ROUTING_INSTRUCTIONS_QLFR>
         <RL_DETAILS>
            <RL_DETAILS_ITEM>
               <DELIVERY_DETAIL_ID>14460996</DELIVERY_DETAIL_ID>
               <LOT_NUMBER xsi:nil="true"></LOT_NUMBER>
               <SERIAL_NUMBER xsi:nil="true"></SERIAL_NUMBER>
               <TO_SERIAL_NUMBER xsi:nil="true"></TO_SERIAL_NUMBER>
               <GROSS_WEIGHT>11</GROSS_WEIGHT>
               <WEIGHT_UOM_CODE>LB</WEIGHT_UOM_CODE>
               <VOLUME>0.2</VOLUME>
               <VOLUME_UOM_CODE>CF</VOLUME_UOM_CODE>
               <REQUESTED_QUANTITY>5</REQUESTED_QUANTITY>
               <SHIPPED_QUANTITY xsi:nil="true"></SHIPPED_QUANTITY>
               <INVENTORY_ITEM_ID>142-12386</INVENTORY_ITEM_ID>
               <CONTAINER_FLAG>N</CONTAINER_FLAG>
               <PARENT_DELIVERY_DETAIL_ID xsi:nil="true"></PARENT_DELIVERY_DETAIL_ID>
               <CUST_PO_NUMBER>Elwood.Retail.VJ04</CUST_PO_NUMBER>
               <SOURCE_HEADER_NUMBER>5405823</SOURCE_HEADER_NUMBER>
               <CUST_PO_NUMBER_QLFR>CUST_PO</CUST_PO_NUMBER_QLFR>
               <SOURCE_HEADER_NUMBER_QLFR>SO_NUM</SOURCE_HEADER_NUMBER_QLFR>
               <DELIVERY_ID>46689763</DELIVERY_ID>
               <NET_WEIGHT>11</NET_WEIGHT>
            </RL_DETAILS_ITEM>
            <RL_DETAILS_ITEM>
               <DELIVERY_DETAIL_ID>14460997</DELIVERY_DETAIL_ID>
               <LOT_NUMBER xsi:nil="true"></LOT_NUMBER>
               <SERIAL_NUMBER xsi:nil="true"></SERIAL_NUMBER>
               <TO_SERIAL_NUMBER xsi:nil="true"></TO_SERIAL_NUMBER>
               <GROSS_WEIGHT>5.28333</GROSS_WEIGHT>
               <WEIGHT_UOM_CODE>LB</WEIGHT_UOM_CODE>
               <VOLUME>0.12</VOLUME>
               <VOLUME_UOM_CODE>CF</VOLUME_UOM_CODE>
               <REQUESTED_QUANTITY>3</REQUESTED_QUANTITY>
               <SHIPPED_QUANTITY xsi:nil="true"></SHIPPED_QUANTITY>
               <INVENTORY_ITEM_ID>142-12383</INVENTORY_ITEM_ID>
               <CONTAINER_FLAG>N</CONTAINER_FLAG>
               <PARENT_DELIVERY_DETAIL_ID xsi:nil="true"></PARENT_DELIVERY_DETAIL_ID>
               <CUST_PO_NUMBER>Elwood.Retail.VJ04</CUST_PO_NUMBER>
               <SOURCE_HEADER_NUMBER>4</SOURCE_HEADER_NUMBER>
               <CUST_PO_NUMBER_QLFR>CUST_PO</CUST_PO_NUMBER_QLFR>
               <SOURCE_HEADER_NUMBER_QLFR>SO_NUM</SOURCE_HEADER_NUMBER_QLFR>
               <DELIVERY_ID>46689763</DELIVERY_ID>
               <NET_WEIGHT>5.28333</NET_WEIGHT>
            </RL_DETAILS_ITEM>
         </RL_DETAILS>
         <LPN>
            <LPN_ITEM>
               <LPN_ID>14460996</LPN_ID>
               <LPN_TYPE xsi:nil="true"></LPN_TYPE>
               <GROSS_WEIGHT>11</GROSS_WEIGHT>
               <NET_WEIGHT>11</NET_WEIGHT>
               <WEIGHT_UOM_CODE>LB</WEIGHT_UOM_CODE>
               <VOLUME_UOM_CODE>CF</VOLUME_UOM_CODE>
               <SEAL_CODE xsi:nil="true"></SEAL_CODE>
               <PACKED_ITEMS>
                  <PACKED_ITEMS_ITEM>
                     <CONTENT_ID>14460996</CONTENT_ID>
                     <LINE_NUMBER>1</LINE_NUMBER>
                     <ITEM_REF>142-12386</ITEM_REF>
                     <ITEM_QUANTITY>5</ITEM_QUANTITY>
                     <SHIP_UNIT_GID>14460996</SHIP_UNIT_GID>
                     <DELIVERY_ID>46689763</DELIVERY_ID>
                     <GROSS_WEIGHT>11</GROSS_WEIGHT>
                     <NET_WEIGHT>11</NET_WEIGHT>
                     <WEIGHT_UOM_CODE>LB</WEIGHT_UOM_CODE>
                     <VOLUME>0.2</VOLUME>
                     <VOLUME_UOM_CODE>CF</VOLUME_UOM_CODE>
                  </PACKED_ITEMS_ITEM>
               </PACKED_ITEMS>
               <PARENT_DELIVERY_DETAIL_ID xsi:nil="true"></PARENT_DELIVERY_DETAIL_ID>
               <CONTAINER_TYPE_CODE xsi:nil="true"></CONTAINER_TYPE_CODE>
               <UNIT_LENGTH>2.75</UNIT_LENGTH>
               <UNIT_HEIGHT>9.9</UNIT_HEIGHT>
               <UNIT_WIDTH>2.75</UNIT_WIDTH>
               <DIMENSION_UM_CODE>IN</DIMENSION_UM_CODE>
               <VOLUME>0.2</VOLUME>
               <EQUIPMENT_XID xsi:nil="true"></EQUIPMENT_XID>
            </LPN_ITEM>
            <LPN_ITEM>
               <LPN_ID>14460997</LPN_ID>
               <LPN_TYPE xsi:nil="true"></LPN_TYPE>
               <GROSS_WEIGHT>5.28333</GROSS_WEIGHT>
               <NET_WEIGHT>5.28333</NET_WEIGHT>
               <WEIGHT_UOM_CODE>LB</WEIGHT_UOM_CODE>
               <VOLUME_UOM_CODE>CF</VOLUME_UOM_CODE>
               <SEAL_CODE xsi:nil="true"></SEAL_CODE>
               <PACKED_ITEMS>
                  <PACKED_ITEMS_ITEM>
                     <CONTENT_ID>14460997</CONTENT_ID>
                     <LINE_NUMBER>1</LINE_NUMBER>
                     <ITEM_REF>142-12383</ITEM_REF>
                     <ITEM_QUANTITY>3</ITEM_QUANTITY>
                     <SHIP_UNIT_GID>14460997</SHIP_UNIT_GID>
                     <DELIVERY_ID>46689763</DELIVERY_ID>
                     <GROSS_WEIGHT>5.28333</GROSS_WEIGHT>
                     <NET_WEIGHT>5.28333</NET_WEIGHT>
                     <WEIGHT_UOM_CODE>LB</WEIGHT_UOM_CODE>
                     <VOLUME>0.12</VOLUME>
                     <VOLUME_UOM_CODE>CF</VOLUME_UOM_CODE>
                  </PACKED_ITEMS_ITEM>
               </PACKED_ITEMS>
               <PARENT_DELIVERY_DETAIL_ID xsi:nil="true"></PARENT_DELIVERY_DETAIL_ID>
               <CONTAINER_TYPE_CODE xsi:nil="true"></CONTAINER_TYPE_CODE>
               <UNIT_LENGTH>2.75</UNIT_LENGTH>
               <UNIT_HEIGHT>9.9</UNIT_HEIGHT>
               <UNIT_WIDTH>2.75</UNIT_WIDTH>
               <DIMENSION_UM_CODE>IN</DIMENSION_UM_CODE>
               <VOLUME>0.12</VOLUME>
               <EQUIPMENT_XID xsi:nil="true"></EQUIPMENT_XID>
            </LPN_ITEM>
         </LPN>
      </X_DLV_TAB_ITEM>
      <X_DLV_TAB_ITEM>
         <TRANSACTION_CODE>RC</TRANSACTION_CODE>
         <DELIVERY_ID>46689764</DELIVERY_ID>
         <NAME>46689764</NAME>
         <FREIGHT_TERMS xsi:nil="true"></FREIGHT_TERMS>
         <FOB_CODE xsi:nil="true"></FOB_CODE>
         <CARRIER_ID xsi:nil="true"></CARRIER_ID>
         <SERVICE_LEVEL xsi:nil="true"></SERVICE_LEVEL>
         <MODE_OF_TRANSPORT xsi:nil="true"></MODE_OF_TRANSPORT>
         <INITIAL_PICKUP_LOCATION_ID>ORG-143-192</INITIAL_PICKUP_LOCATION_ID>
         <ULTIMATE_DROPOFF_LOCATION_ID>CUS-44964-757828</ULTIMATE_DROPOFF_LOCATION_ID>
         <EARLIEST_PICKUP_DATE>2013-07-07T00:01:00.000-04:00</EARLIEST_PICKUP_DATE>
         <LATEST_PICKUP_DATE>2013-07-07T00:01:00.000-04:00</LATEST_PICKUP_DATE>
         <EARLIEST_DROPOFF_DATE xsi:nil="true"></EARLIEST_DROPOFF_DATE>
         <LATEST_DROPOFF_DATE xsi:nil="true"></LATEST_DROPOFF_DATE>
         <GROSS_WEIGHT>77.0111</GROSS_WEIGHT>
         <WEIGHT_UOM_CODE>LB</WEIGHT_UOM_CODE>
         <VOLUME>1.48</VOLUME>
         <VOLUME_UOM_CODE>CF</VOLUME_UOM_CODE>
         <NET_WEIGHT>77.0111</NET_WEIGHT>
         <REVISION>2</REVISION>
         <REASON_OF_TRANSPORT xsi:nil="true"></REASON_OF_TRANSPORT>
         <DESCRIPTION xsi:nil="true"></DESCRIPTION>
         <ADDITIONAL_SHIPMENT_INFO xsi:nil="true"></ADDITIONAL_SHIPMENT_INFO>
         <ROUTING_INSTRUCTIONS xsi:nil="true"></ROUTING_INSTRUCTIONS>
         <TOTAL_ITEM_COUNT>37</TOTAL_ITEM_COUNT>
         <REVISION_QLFR>REVNUM</REVISION_QLFR>
         <REASON_OF_TRANSPORT_QLFR>TRSP_REASON</REASON_OF_TRANSPORT_QLFR>
         <DESCRIPTION_QLFR>DEL_DESCRIPTION</DESCRIPTION_QLFR>
         <ADDITIONAL_SHIPMENT_INFO_QLFR>ADD_INFOS</ADDITIONAL_SHIPMENT_INFO_QLFR>
         <ROUTING_INSTRUCTIONS_QLFR>ROUTING_INSTR</ROUTING_INSTRUCTIONS_QLFR>
         <RL_DETAILS>
            <RL_DETAILS_ITEM>
               <DELIVERY_DETAIL_ID>14460993</DELIVERY_DETAIL_ID>
               <LOT_NUMBER xsi:nil="true"></LOT_NUMBER>
               <SERIAL_NUMBER xsi:nil="true"></SERIAL_NUMBER>
               <TO_SERIAL_NUMBER xsi:nil="true"></TO_SERIAL_NUMBER>
               <GROSS_WEIGHT>17.6111</GROSS_WEIGHT>
               <WEIGHT_UOM_CODE>LB</WEIGHT_UOM_CODE>
               <VOLUME>0.4</VOLUME>
               <VOLUME_UOM_CODE>CF</VOLUME_UOM_CODE>
               <REQUESTED_QUANTITY>10</REQUESTED_QUANTITY>
               <SHIPPED_QUANTITY xsi:nil="true"></SHIPPED_QUANTITY>
               <INVENTORY_ITEM_ID>143-12383</INVENTORY_ITEM_ID>
               <CONTAINER_FLAG>N</CONTAINER_FLAG>
               <PARENT_DELIVERY_DETAIL_ID xsi:nil="true"></PARENT_DELIVERY_DETAIL_ID>
               <CUST_PO_NUMBER>VJ04</CUST_PO_NUMBER>
               <SOURCE_HEADER_NUMBER>5405823</SOURCE_HEADER_NUMBER>
               <CUST_PO_NUMBER_QLFR>CUST_PO</CUST_PO_NUMBER_QLFR>
               <SOURCE_HEADER_NUMBER_QLFR>SO_NUM</SOURCE_HEADER_NUMBER_QLFR>
               <DELIVERY_ID>46689764</DELIVERY_ID>
               <NET_WEIGHT>17.6111</NET_WEIGHT>
            </RL_DETAILS_ITEM>
            <RL_DETAILS_ITEM>
               <DELIVERY_DETAIL_ID>14460994</DELIVERY_DETAIL_ID>
               <LOT_NUMBER xsi:nil="true"></LOT_NUMBER>
               <SERIAL_NUMBER xsi:nil="true"></SERIAL_NUMBER>
               <TO_SERIAL_NUMBER xsi:nil="true"></TO_SERIAL_NUMBER>
               <GROSS_WEIGHT>33</GROSS_WEIGHT>
               <WEIGHT_UOM_CODE>LB</WEIGHT_UOM_CODE>
               <VOLUME>0.6</VOLUME>
               <VOLUME_UOM_CODE>CF</VOLUME_UOM_CODE>
               <REQUESTED_QUANTITY>15</REQUESTED_QUANTITY>
               <SHIPPED_QUANTITY xsi:nil="true"></SHIPPED_QUANTITY>
               <INVENTORY_ITEM_ID>143-12384</INVENTORY_ITEM_ID>
               <CONTAINER_FLAG>N</CONTAINER_FLAG>
               <PARENT_DELIVERY_DETAIL_ID xsi:nil="true"></PARENT_DELIVERY_DETAIL_ID>
               <CUST_PO_NUMBER>Elwood.Retail.VJ04</CUST_PO_NUMBER>
               <SOURCE_HEADER_NUMBER>5405823</SOURCE_HEADER_NUMBER>
               <CUST_PO_NUMBER_QLFR>CUST_PO</CUST_PO_NUMBER_QLFR>
               <SOURCE_HEADER_NUMBER_QLFR>SO_NUM</SOURCE_HEADER_NUMBER_QLFR>
               <DELIVERY_ID>46689764</DELIVERY_ID>
               <NET_WEIGHT>33</NET_WEIGHT>
            </RL_DETAILS_ITEM>
            <RL_DETAILS_ITEM>
               <DELIVERY_DETAIL_ID>14460995</DELIVERY_DETAIL_ID>
               <LOT_NUMBER xsi:nil="true"></LOT_NUMBER>
               <SERIAL_NUMBER xsi:nil="true"></SERIAL_NUMBER>
               <TO_SERIAL_NUMBER xsi:nil="true"></TO_SERIAL_NUMBER>
               <GROSS_WEIGHT>26.4</GROSS_WEIGHT>
               <WEIGHT_UOM_CODE>LB</WEIGHT_UOM_CODE>
               <VOLUME>0.48</VOLUME>
               <VOLUME_UOM_CODE>CF</VOLUME_UOM_CODE>
               <REQUESTED_QUANTITY>12</REQUESTED_QUANTITY>
               <SHIPPED_QUANTITY xsi:nil="true"></SHIPPED_QUANTITY>
               <INVENTORY_ITEM_ID>143-12386</INVENTORY_ITEM_ID>
               <CONTAINER_FLAG>N</CONTAINER_FLAG>
               <PARENT_DELIVERY_DETAIL_ID xsi:nil="true"></PARENT_DELIVERY_DETAIL_ID>
               <CUST_PO_NUMBER>Elwood.Retail.VJ04</CUST_PO_NUMBER>
               <SOURCE_HEADER_NUMBER>5405823</SOURCE_HEADER_NUMBER>
               <CUST_PO_NUMBER_QLFR>CUST_PO</CUST_PO_NUMBER_QLFR>
               <SOURCE_HEADER_NUMBER_QLFR>SO_NUM</SOURCE_HEADER_NUMBER_QLFR>
               <DELIVERY_ID>46689764</DELIVERY_ID>
               <NET_WEIGHT>26.4</NET_WEIGHT>
            </RL_DETAILS_ITEM>
         </RL_DETAILS>
         <LPN>
            <LPN_ITEM>
               <LPN_ID>14460993</LPN_ID>
               <LPN_TYPE xsi:nil="true"></LPN_TYPE>
               <GROSS_WEIGHT>17.6111</GROSS_WEIGHT>
               <NET_WEIGHT>17.6111</NET_WEIGHT>
               <WEIGHT_UOM_CODE>LB</WEIGHT_UOM_CODE>
               <VOLUME_UOM_CODE>CF</VOLUME_UOM_CODE>
               <SEAL_CODE xsi:nil="true"></SEAL_CODE>
               <PACKED_ITEMS>
                  <PACKED_ITEMS_ITEM>
                     <CONTENT_ID>14460993</CONTENT_ID>
                     <LINE_NUMBER>1</LINE_NUMBER>
                     <ITEM_REF>143-12383</ITEM_REF>
                     <ITEM_QUANTITY>10</ITEM_QUANTITY>
                     <SHIP_UNIT_GID>14460993</SHIP_UNIT_GID>
                     <DELIVERY_ID>46689764</DELIVERY_ID>
                     <GROSS_WEIGHT>17.6111</GROSS_WEIGHT>
                     <NET_WEIGHT>17.6111</NET_WEIGHT>
                     <WEIGHT_UOM_CODE>LB</WEIGHT_UOM_CODE>
                     <VOLUME>0.4</VOLUME>
                     <VOLUME_UOM_CODE>CF</VOLUME_UOM_CODE>
                  </PACKED_ITEMS_ITEM>
               </PACKED_ITEMS>
               <PARENT_DELIVERY_DETAIL_ID xsi:nil="true"></PARENT_DELIVERY_DETAIL_ID>
               <CONTAINER_TYPE_CODE xsi:nil="true"></CONTAINER_TYPE_CODE>
               <UNIT_LENGTH>2.75</UNIT_LENGTH>
               <UNIT_HEIGHT>9.9</UNIT_HEIGHT>
               <UNIT_WIDTH>2.75</UNIT_WIDTH>
               <DIMENSION_UM_CODE>IN</DIMENSION_UM_CODE>
               <VOLUME>0.4</VOLUME>
               <EQUIPMENT_XID xsi:nil="true"></EQUIPMENT_XID>
            </LPN_ITEM>
            <LPN_ITEM>
               <LPN_ID>14460994</LPN_ID>
               <LPN_TYPE xsi:nil="true"></LPN_TYPE>
               <GROSS_WEIGHT>33</GROSS_WEIGHT>
               <NET_WEIGHT>33</NET_WEIGHT>
               <WEIGHT_UOM_CODE>LB</WEIGHT_UOM_CODE>
               <VOLUME_UOM_CODE>CF</VOLUME_UOM_CODE>
               <SEAL_CODE xsi:nil="true"></SEAL_CODE>
               <PACKED_ITEMS>
                  <PACKED_ITEMS_ITEM>
                     <CONTENT_ID>14460994</CONTENT_ID>
                     <LINE_NUMBER>1</LINE_NUMBER>
                     <ITEM_REF>143-12384</ITEM_REF>
                     <ITEM_QUANTITY>15</ITEM_QUANTITY>
                     <SHIP_UNIT_GID>14460994</SHIP_UNIT_GID>
                     <DELIVERY_ID>46689764</DELIVERY_ID>
                     <GROSS_WEIGHT>33</GROSS_WEIGHT>
                     <NET_WEIGHT>33</NET_WEIGHT>
                     <WEIGHT_UOM_CODE>LB</WEIGHT_UOM_CODE>
                     <VOLUME>0.6</VOLUME>
                     <VOLUME_UOM_CODE>CF</VOLUME_UOM_CODE>
                  </PACKED_ITEMS_ITEM>
               </PACKED_ITEMS>
               <PARENT_DELIVERY_DETAIL_ID xsi:nil="true"></PARENT_DELIVERY_DETAIL_ID>
               <CONTAINER_TYPE_CODE xsi:nil="true"></CONTAINER_TYPE_CODE>
               <UNIT_LENGTH>2.75</UNIT_LENGTH>
               <UNIT_HEIGHT>9.9</UNIT_HEIGHT>
               <UNIT_WIDTH>2.75</UNIT_WIDTH>
               <DIMENSION_UM_CODE>IN</DIMENSION_UM_CODE>
               <VOLUME>0.6</VOLUME>
               <EQUIPMENT_XID xsi:nil="true"></EQUIPMENT_XID>
            </LPN_ITEM>
            <LPN_ITEM>
               <LPN_ID>14460995</LPN_ID>
               <LPN_TYPE xsi:nil="true"></LPN_TYPE>
               <GROSS_WEIGHT>26.4</GROSS_WEIGHT>
               <NET_WEIGHT>26.4</NET_WEIGHT>
               <WEIGHT_UOM_CODE>LB</WEIGHT_UOM_CODE>
               <VOLUME_UOM_CODE>CF</VOLUME_UOM_CODE>
               <SEAL_CODE xsi:nil="true"></SEAL_CODE>
               <PACKED_ITEMS>
                  <PACKED_ITEMS_ITEM>
                     <CONTENT_ID>14460995</CONTENT_ID>
                     <LINE_NUMBER>1</LINE_NUMBER>
                     <ITEM_REF>143-12386</ITEM_REF>
                     <ITEM_QUANTITY>12</ITEM_QUANTITY>
                     <SHIP_UNIT_GID>14460995</SHIP_UNIT_GID>
                     <DELIVERY_ID>46689764</DELIVERY_ID>
                     <GROSS_WEIGHT>26.4</GROSS_WEIGHT>
                     <NET_WEIGHT>26.4</NET_WEIGHT>
                     <WEIGHT_UOM_CODE>LB</WEIGHT_UOM_CODE>
                     <VOLUME>0.48</VOLUME>
                     <VOLUME_UOM_CODE>CF</VOLUME_UOM_CODE>
                  </PACKED_ITEMS_ITEM>
               </PACKED_ITEMS>
               <PARENT_DELIVERY_DETAIL_ID xsi:nil="true"></PARENT_DELIVERY_DETAIL_ID>
               <CONTAINER_TYPE_CODE xsi:nil="true"></CONTAINER_TYPE_CODE>
               <UNIT_LENGTH>2.75</UNIT_LENGTH>
               <UNIT_HEIGHT>9.9</UNIT_HEIGHT>
               <UNIT_WIDTH>2.75</UNIT_WIDTH>
               <DIMENSION_UM_CODE>IN</DIMENSION_UM_CODE>
               <VOLUME>0.48</VOLUME>
               <EQUIPMENT_XID xsi:nil="true"></EQUIPMENT_XID>
            </LPN_ITEM>
         </LPN>
      </X_DLV_TAB_ITEM>
   </X_DLV_TAB>

请帮帮我,我一直在努力解决这个问题。PS:我使用的是 XSLT 1.0

谢谢阿杰

4

1 回答 1

0

钥匙是你强大的朋友:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <!-- key over all first X_DLV_TAB_ITEM by source -->
    <xsl:key name="first_of_source" match="X_DLV_TAB/X_DLV_TAB_ITEM[not(preceding-sibling::X_DLV_TAB_ITEM/RL_DETAILS/RL_DETAILS_ITEM/SOURCE_HEADER_NUMBER = RL_DETAILS/RL_DETAILS_ITEM/SOURCE_HEADER_NUMBER)]" use="RL_DETAILS/RL_DETAILS_ITEM/SOURCE_HEADER_NUMBER"/>
    <!-- key over all RL_DETAILS by source -->
    <xsl:key name="same_source" match="X_DLV_TAB/X_DLV_TAB_ITEM/RL_DETAILS" use="RL_DETAILS_ITEM/SOURCE_HEADER_NUMBER"/>


    <!-- just copy all nodes by default -->
    <xsl:template match="@* | node()">
        <xsl:copy>
            <xsl:apply-templates select="@* | node()"/>
        </xsl:copy>
    </xsl:template>

    <!-- process only the first tab item with a specific source -->
    <xsl:template match="X_DLV_TAB">
        <xsl:copy>
            <xsl:apply-templates select="key('first_of_source', X_DLV_TAB_ITEM/RL_DETAILS/RL_DETAILS_ITEM/SOURCE_HEADER_NUMBER)"/>
        </xsl:copy>
    </xsl:template>

    <!-- process details with all detail items having the same source -->
    <xsl:template match="RL_DETAILS">
        <xsl:copy>
            <xsl:apply-templates select="key('same_source', RL_DETAILS_ITEM/SOURCE_HEADER_NUMBER)/RL_DETAILS_ITEM"/>
        </xsl:copy>
    </xsl:template>
</xsl:stylesheet>
于 2014-01-15T20:52:51.240 回答