У меня есть требование, чтобы получить результаты в цель на основе двух XML источников. В двух источниках XML person_number уникален, мне нужно сравнить номер человека в запросе source1, присутствует в запросе source2 или нет, если нет, то нужно только сопоставить детали source1 с целью. Ниже приведены два запроса XML.
**Source1-**
<?xml version="1.0" encoding="UTF-8" ?>
<ReadResponse xmlns="http://xmlns.oracle.com/cloud/adapter/stagefile/readPersonAccrualData_REQUEST/types">
<myRewardHoliday xmlns="http://org.com/inbound/org1">
<myRewardHoliday>
<Person_Number>1234</Person_Number>
<Assignment_Number>1111</Assignment_Number>
</myRewardHoliday>
<myRewardHoliday>
<Person_Number>1245</Person_Number>
<Assignment_Number>2222</Assignment_Number>
</myRewardHoliday>
<myRewardHoliday>
<Person_Number>1256</Person_Number>
<Assignment_Number>3333</Assignment_Number>
</myRewardHoliday>
</myRewardHoliday>
</ReadResponse>
**Source2-**
<?xml version="1.0" encoding="UTF-8" ?>
<SyncReadFileResponse xmlns="http://xmlns.oracle.com/cloud/adapter/ftp/readHDLErrorReport_REQUEST/types">
<FileReadResponse xmlns="http://xmlns.oracle.com/cloud/adapter/ftp/readHDLErrorReport_REQUEST/types/dynamicftp">
<Recordset xmlns="http://org.com/inbound/org">
<Record>
<PERSON_NUMBER>1234-ABCD</PERSON_NUMBER>
<ERROR_MESSAGE></ERROR_MESSAGE>
</Record>
<Record>
<PERSON_NUMBER>7777-ABCD</PERSON_NUMBER>
<ERROR_MESSAGE></ERROR_MESSAGE>
</Record>
</Recordset>
</FileReadResponse>
</SyncReadFileResponse>
**Source code:**
<xsl:param name="readHDLErrorReport" xml:id="id_115"/>
<xsl:param name="readPersonAccrualData" xml:id="id_117"/>
<xsl:template match="/" xml:id="id_11">
<nstrgmpr:Write xml:id="id_12">
<tns:ElementEntryFileData xml:id="id_127">
<xsl:variable name="details" select="."/>
<xsl:for-each xml:id="id_147"
select="$readPersonAccrualData/nsmpr7:ReadResponse/ns51:details/ns51:details">
<xsl:for-each select="$readHDLErrorReport/nsmpr6:SyncReadFileResponse/ns50:FileReadResponse/ns47:Recordset/ns47:Record">
<xsl:variable name="errorRecord" select="."/>
<xsl:if test="$details/ns51:Person_Number != (substring-before($errorRecord/ns47:PERSON_NUMBER,'-'))">
<tns:HolidayEEParent xml:id="id_150">
<tns:AssignmentNumber xml:id="id_151">
<xsl:value-of xml:id="id_152" select="$details/ns51:Assignment_Number"/>
</tns:AssignmentNumber>
</tns:HolidayEEParent>
</xsl:if>
</xsl:for-each>
<xsl:copy-of select="$output"/>
</xsl:for-each>
</tns:ElementEntryFileData>
**Result:**
<tns:ElementEntryFileData>
<tns:HolidayEEParent>
<tns:AssignmentNumber>1111</tns:AssignmentNumber>
</tns:HolidayEEParent>
<tns:HolidayEEParent>
<tns:AssignmentNumber>2222</tns:AssignmentNumber>
</tns:HolidayEEParent>
<tns:HolidayEEParent>
<tns:AssignmentNumber>3333</tns:AssignmentNumber>
</tns:HolidayEEParent>
</tns:ElementEntryFileData>
As per the code, it has to map to target only two records however it is writing three records, please give me suggestions and I am not getting where I made the mistakes?
Thanks,
Lakshman.