xsl-list
[Top] [All Lists]

[xsl] How to compare 2 xml based on some condition in XSL

2017-06-16 03:06:48
Hi,

I have written code to check if CreatedDate from merge1 is grater then of
Last_Alert_Import__c from merge2 then i need all data in grater case from
merge1 and if CreatedDate from merge1 is less then of Last_Alert_Import__c
from merge2 then i need less-then case data only from merge1.
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>
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--
<Prev in Thread] Current Thread [Next in Thread>
  • [xsl] How to compare 2 xml based on some condition in XSL, Rahul Singh rahulsinghindia15(_at_)gmail(_dot_)com <=