[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Compare 2 xml in XSL based on some condition is not w

Subject: 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
 Compare 2 xml in XSL based on some condition is not  w
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.