xslt来自两个使用匹配节点值的xml文件

时间:2015-11-20 06:49:45

标签: xslt-1.0

请帮助我以下预期输出。我尝试使用for-each等,但所有RECORDS都重复使用ParentUUID1。我需要匹配File2.xml中的subscription_id键属性和MainInput.xml中的属性,并获得最终的预期输出。

MainInput.xml

<?xml version="1.0" encoding="UTF-8" ?>
<qw:ACCOUNT_CHANGES xmlns:qw="http://xmlns.dummy.com/qwSubsResponse">
  <qw:RECORD>
    <qw:SUBSCRIPTION>
      <qw:INFO key="subscriptionid_hash">abcd</qw:INFO>
      <qw:INFO key="subscription_id">140172</qw:INFO>
      <qw:INFO key="uuid">ParentUUID1</qw:INFO>
    </qw:SUBSCRIPTION>
    <qw:ALL_FO_ACCOUNTS>
      <qw:FO_ACCOUNT>
        <qw:FODATA key="subscription_id">140172</qw:FODATA>
        <qw:FODATA key="uuid">uuidfouser1</qw:FODATA>
      </qw:FO_ACCOUNT>
    <qw:FO_ACCOUNT>
        <qw:FODATA key="subscription_id">140172</qw:FODATA>
        <qw:FODATA key="uuid">uuidfouser1</qw:FODATA>
      </qw:FO_ACCOUNT>
    </qw:ALL_FO_ACCOUNTS>
    <qw:Platform>plat1</qw:Platform>
    <qw:skip_subscription>1</qw:skip_subscription>
  </qw:RECORD>
  <qw:RECORD>
    <qw:SUBSCRIPTION>
      <qw:INFO key="subscriptionid_hash">xyz</qw:INFO>
      <qw:INFO key="subscription_id">140</qw:INFO>
      <qw:INFO key="uuid">ParentUUID2</qw:INFO>
    </qw:SUBSCRIPTION>
    <qw:ALL_FO_ACCOUNTS>
      <qw:FO_ACCOUNT>
        <qw:FODATA key="subscription_id">140</qw:FODATA>
        <qw:FODATA key="uuid">uuidrcd2</qw:FODATA>
      </qw:FO_ACCOUNT>
    </qw:ALL_FO_ACCOUNTS>
    <qw:Platform>plat1</qw:Platform>
    <qw:skip_subscription>1</qw:skip_subscription>
  </qw:RECORD>
</qw:ACCOUNT_CHANGES>

File2.xml

<?xml version="1.0" encoding="UTF-8" ?>
<qw:ACCOUNT_CHANGES xmlns:qw="http://xmlns.dummy.com/qwSubsResponse">
  <qw:RECORD>
    <qw:ALL_FO_ACCOUNTS>
      <qw:FO_ACCOUNT>
        <qw:FODATA key="subscription_id">140172</qw:FODATA>
        <qw:FODATA key="uuid">uuidfouser1</qw:FODATA>
      </qw:FO_ACCOUNT>
    <qw:FO_ACCOUNT>
        <qw:FODATA key="subscription_id">140172</qw:FODATA>
        <qw:FODATA key="uuid">uuidfouser1</qw:FODATA>
      </qw:FO_ACCOUNT>      
    </qw:ALL_FO_ACCOUNTS>
    <qw:Platform>plat1</qw:Platform>
    <qw:skip_subscription>1</qw:skip_subscription>
  </qw:RECORD>
  <qw:RECORD>
    <qw:ALL_FO_ACCOUNTS>
      <qw:FO_ACCOUNT>
        <qw:FODATA key="subscription_id">140</qw:FODATA>
        <qw:FODATA key="uuid">uuidrcd2</qw:FODATA>
      </qw:FO_ACCOUNT>
    </qw:ALL_FO_ACCOUNTS>
    <qw:Platform>plat1</qw:Platform>
    <qw:skip_subscription>1</qw:skip_subscription>
  </qw:RECORD>
</qw:ACCOUNT_CHANGES>

预期输出:

<?xml version = '1.0' encoding = 'UTF-8'?>
<ns1:ACCOUNT_CHANGES xmlns:ns1="http://xmlns.dummy.com/qwSubsResponse">
   <ns1:RECORD>
      <ns1:SUBSCRIPTION>
         <ns1:INFO key="uuid">ParentUUID1</qw:INFO>
      </ns1:SUBSCRIPTION>
      <ns1:ALL_FO_ACCOUNTS>
         <ns1:FO_ACCOUNT>
            <ns1:FODATA key="subscription_id">140172</ns1:FODATA>
            <ns1:FODATA key="uuid">uuidfouser1</ns1:FODATA>
         </ns1:FO_ACCOUNT>
         <ns1:FO_ACCOUNT>
            <ns1:FODATA key="subscription_id">140172</ns1:FODATA>
            <ns1:FODATA key="uuid">uuidfouser1</ns1:FODATA>
         </ns1:FO_ACCOUNT>
      </ns1:ALL_FO_ACCOUNTS>
   </ns1:RECORD>
   <ns1:RECORD>
      <ns1:SUBSCRIPTION>
         <ns1:INFO key="uuid">ParentUUID2</qw:INFO>
      </ns1:SUBSCRIPTION>
      <ns1:ALL_FO_ACCOUNTS>
         <ns1:FO_ACCOUNT>
            <ns1:FODATA key="subscription_id">140</ns1:FODATA>
            <ns1:FODATA key="uuid">uuidrcd2</ns1:FODATA>
         </ns1:FO_ACCOUNT>
      </ns1:ALL_FO_ACCOUNTS>
   </ns1:RECORD>
</ns1:ACCOUNT_CHANGES>

0 个答案:

没有答案