Subject: Re: [xsl] How to find out if Xml contains two or more equal element name value with xsl? From: "Michael Müller-Hillebrand mmh@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Wed, 7 Sep 2016 09:57:19 -0000 |
Or using a key, although reducing the result to a single instance is a bit cumbersomeb& <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:output method="xml" indent="yes" omit-xml-declaration="no"/> <xsl:strip-space elements="*"/> <xsl:key name="contact-by-nid" match="Contact" use="Nid" /> <xsl:template match="Contact"> <xsl:variable name="matching-contacts" select="key('contact-by-nid', Nid)"/> <xsl:if test="count($matching-contacts) > 1 and $matching-contacts[1] is ."> <xsl:copy-of select="Nid"/> </xsl:if> </xsl:template> </xsl:stylesheet> - Michael > Am 07.09.2016 um 11:44 schrieb Rahul Singh rahulsinghindia15@xxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>: > > Hi, > > I have only one XML. and there <Nid> contains same data like 000817441. I want to throw an email for same data. > > How to find out if Xml contains two or more equal element name value with xsl? But my code is not responding > > Below is XML: > > <?xml version="1.0" encoding="UTF-8"?> > <objects> > <Contact> > <Id>003j000001Cj6l8AAB</Id> > <Nid>000817441</Nid> > </Contact> > <Contact> > <Id>007j000001Cj6l8AAB</Id> > <Nid>000817441</Nid> > </Contact> > <Contact> > <Id>003j700001Cj6l9AAB</Id> > <Nid>001191237</Nid> > </Contact> > <Contact> > <Id>003j000801Cj6lAAAR</Id> > <Nid>010978087</Nid> > </Contact> > <Contact> > <Id>003j000001Cj9l8AAB</Id> > <Nid>000817441</Nid> > </Contact> > </objects> > > > Below in XSL: > > <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform <http://www.w3.org/1999/XSL/Transform>"> > <xsl:output method="xml" indent="yes" omit-xml-declaration="no"/> > <xsl:strip-space elements="*"/> > <xsl:template match="objects"> > <xsl:if > test="boolean(//objects/Contact[./Nid > preceding-sibling::node() or ./Nid > following-sibling::Nid])"> > <Nid> > <xsl:value-of select="Nid"/> > </Nid> > </xsl:if> > </xsl:template> > </xsl:stylesheet> > > Expected output: > > <Nid>000817441</Nid> [demime 1.01d removed an attachment of type application/pgp-signature which had a name of signature.asc]
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] How to find out if Xml co, David Carlisle d.p.c | Thread | Re: [xsl] How to find out if Xml co, Flynn, Peter pflynn@ |
Re: [xsl] How to find out if Xml co, David Carlisle d.p.c | Date | Re: [xsl] How to find out if Xml co, Flynn, Peter pflynn@ |
Month |