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

Need xsl help

Subject: Need xsl help
From: "Rahul Singh rahulsinghindia15@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 8 Sep 2016 18:07:55 -0000
 Need xsl help
Hi.

I have only one XML. and there <Nid> contains same data like 892828740. I
want get the Id,Updateeddate,Nid for Contact based on Updateeddate if Nid
has more then one same data. Below is my input, XSL, expected output

Below is XML:

<?xml version="1.0" encoding="UTF-8"?>
<objects>
  <Contact>
    <Id>003j000001DQMkcAAH</Id>
    <Updateeddate>2016-09-08T10:31:24.000Z</Updateeddate>
    <Nid>892828740</Nid>
  </Contact>
  <Contact>
    <Id>003j000001DQMlXAAX</Id>
    <Updateeddate>2016-09-08T10:22:47.000Z</Updateeddate>
    <Nid>879284114</Nid>
  </Contact>
  <Contact>
    <Id>003j000001DQMlYAAX</Id>
    <Updateeddate>2016-09-08T10:22:47.000Z</Updateeddate>
    <Nid>882692370</Nid>
  </Contact>
  <Contact>
    <Id>003j000001DQMlZAAX</Id>
    <Updateeddate>2016-09-08T10:22:47.000Z</Updateeddate>
    <Nid>892828740</Nid>
  </Contact>
 </objects>



Below in XSL:

<xsl:stylesheet version="2.0" xmlns:xsl="
http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
    <xsl:template match="objects">
        <xsl:if test="count(//Contact/Nid[(. =
../following-sibling::Contact/Nid)])">
            <Nids>

                <Nid>
                    <Id>
                        <xsl:value-of
                            select="//Contact/Nid[(. =
../following-sibling::Contact/Nid)]"/>
                    </Id>
                    <updateDate>
                        <xsl:value-of select="//Updateeddate"/>
                    </updateDate>
                    <Nid/>
                </Nid>

            </Nids>
        </xsl:if>
    </xsl:template>
</xsl:stylesheet>




Expected output:

<objects>
  <Contact>
    <Id>003j000001DQMkcAAH</Id>
    <Updateeddate>2016-09-08T10:31:24.000Z</Updateeddate>
    <Nid>892828740</Nid>
  </Contact>
  <Contact>
    <Id>003j000001DQMlXAAX</Id>
    <Updateeddate>2016-09-08T10:22:47.000Z</Updateeddate>
    <Nid>879284114</Nid>
  </Contact>
  <Contact>
    <Id>003j000001DQMlYAAX</Id>
    <Updateeddate>2016-09-08T10:22:47.000Z</Updateeddate>
    <Nid>882692370</Nid>
  </Contact>
</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.