[xsl] Compare 2 xml in XSL based on some condition is not working

Subject: [xsl] Compare 2 xml in XSL based on some condition is not working
From: "Rahul Singh rahulsinghindia15@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 16 Jun 2017 11:27:57 -0000
Hi,

I have written code to check if <CreatedDate> from merge1.xml is
grater-then of <Last_Alert_Import__c> from merge2.xml then i need all the
data in the case of grater-then from merge1.xml and if <CreatedDate> from
merge1.xml is less-then of <Last_Alert_Import__c> from merge2.xml then i
need all the data in the case of less-then from merge1.xml.
*XSL:*

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
    xmlns:xs="http://www.w3.org/2001/XMLSchema";
exclude-result-prefixes="xs" version="2.0">
    <xsl:output method="xml" indent="yes"/>
    <xsl:param name="XMLMerge2" select="document('merge2.xml')"/>
    <xsl:template match="objects">
        <objects>
            <xsl:for-each select="Alert__c">
                <xsl:variable name="Email_from_merge1"
select="CreatedDate"/>
                <xsl:if
                    test="$XMLMerge2/objects/Account[Last_Alert_Import__c
&lt; $Email_from_merge1]">
                    <xsl:copy>
                        <xsl:apply-templates select="@* | node()"/>
                    </xsl:copy>
                </xsl:if>
            </xsl:for-each>
        </objects>
       </xsl:template>
        <xsl:template match="@* | node()">
        <xsl:copy>
            <xsl:apply-templates select="@* | node()"/>
        </xsl:copy>
       </xsl:template>
     </xsl:stylesheet>

*Input: Merge1.xml--- in XSL, I am using <CreatedDate> from here.*

     <?xml version="1.0" encoding="UTF-8"?>
     <objects>
     <Alert__c>
      <Document_Name__c>file 1.pdf</Document_Name__c>
        <CreatedDate>2017-06-15T10:55:56.000Z</CreatedDate>
        </Alert__c>
        <Alert__c>
       <Document_Name__c>VICS_810_004010_US.pdf</Document_Name__c>
        <CreatedDate>2017-06-09T06:24:56.000Z</CreatedDate>
         </Alert__c>
       <Alert__c>
        <Document_Name__c>VICS_810_004010_US.pdf</Document_Name__c>
       <CreatedDate>2017-06-09T06:24:58.000Z</CreatedDate>
       </Alert__c>
       <Alert__c>
       <Document_Name__c>file 1.pdf</Document_Name__c>
       <CreatedDate>2017-06-15T10:55:08.000Z</CreatedDate>
       </Alert__c>
       <Alert__c>
      <Document_Name__c>aa.csv</Document_Name__c>
      <CreatedDate>2017-06-14T14:26:49.000Z</CreatedDate>
      </Alert__c>
      <Alert__c>
      <Document_Name__c>VICS_810_004010_US.pdf</Document_Name__c>
      <CreatedDate>2017-06-14T13:31:47.000Z</CreatedDate>
      </Alert__c>
      <Alert__c>
      <Document_Name__c>VICS_810_004010_US.pdf</Document_Name__c>
      <CreatedDate>2017-06-09T06:24:48.000Z</CreatedDate>
       </Alert__c>
      </objects>

*Merge2.xml--- in XSL, I am using <Last_Alert_Import__c> from here.*

    <?xml version="1.0" encoding="UTF-8"?>
     <objects>
     <Account>
     <Last_Alert_Import__c>2017-06-14T07:03:41.000Z</Last_Alert_Import__c>
     </Account>
     <Account>
    <Last_Alert_Import__c>2017-06-15T10:58:51.000Z</Last_Alert_Import__c>
     </Account>
    <Account>
    <Last_Alert_Import__c>2017-05-05T05:58:06.000Z</Last_Alert_Import__c>
    </Account>
    <Account>
      <Last_Alert_Import__c/>
    </Account>
    <Account>
     <Last_Alert_Import__c/>
    </Account>
    </objects>

Current Thread