Hi Rahul,
A couple of observations/questions:
– Assuming that you invoke the transformation with Input1.xml as the
source, how does the stylesheet ever get to know Input2.xml in order to
do any comparisons with clientdata/name? If Input1.xml is the input, I
would have expected something like <xsl:variable name="Input2"
as="document-node(element(ClientInfo))" select="doc('Input2.xml')"/> in
the stylesheet.
– What exactly should happen if clientname/Id of Input1.xml matches
clientdata/name of Input2.xml, and what should happen if it doesn’t?
In particular, the records of which file should be de-duplicated,
Input1.xml’s clientname records or Input2.xml? Your expected output
suggests that Input1.xml’s records should be de-duplicated.
What should happen if there is no match for clientdata/name in
Input2.xml? As I understood the requirement, then no de-duplication
should occur. I’m not sure whether this is your intention.
– Finally, where do the Name fields stem from in the expected output?
They are not present in any of the inputs.
These are the essential questions. In addition, a couple of other things
did not go unnoticed:
– You declare a key named 'kBymail', but you don’t use it.
– The start and end tags of the top-level elements in Input1.xml and
Input2.xml don’t match.
– You are comparing the clientname/Email element with the Email element
of all following siblings. This can become a performance issue for large
data sets. Consider using <xsl:for-each-group select="clientname"
group-by="Email"> for de-duplication.
Gerrit
On 31.08.2017 05:27, Rahul Singh rahulsinghindia15(_at_)gmail(_dot_)com wrote:
Hi,
i need data from input1.xml check first if clientname/id is matching
with clientdata/name from input2.xml otherwise delete duplication based
on clientname/Email from input1.xml, My duplication is working but i am
not geetitng first condition data:
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:key name="kBymail" match="clientname" use="Email"/>
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="clientname[Email =
following-sibling::clientname/Email]"/>
</xsl:stylesheet>
Input1.xml:
------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<ClientInfo>
<clientname>
<Id>003f40000049yJYAAY</Id>
<Email>gbc(_at_)gmail(_dot_)com
<mailto:gbc(_at_)gmail(_dot_)com></Email>
</clientname>
<clientname>
<Id>003f40000049z3iAAA</Id>
<Email>gbc(_at_)gmail(_dot_)com
<mailto:gbc(_at_)gmail(_dot_)com></Email>
</clientname>
<clientname>
<Id>003f40000049z3nAAA</Id>
<Email>gbc(_at_)gmail(_dot_)com
<mailto:gbc(_at_)gmail(_dot_)com></Email>
</clientname>
<clientname>
<Id>003f40000048uLLAAY</Id>
<Email>gar(_at_)gmail(_dot_)com
<mailto:gar(_at_)gmail(_dot_)com></Email>
</clientname>
<clientname>
<Id>003f40000049t38AAA</Id>
<Email>gad(_at_)gmail(_dot_)com
<mailto:gad(_at_)gmail(_dot_)com></Email>
</clientname>
</objects>
Input2.xml:
---------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<ClientInfo>
<clientdata>
<name>003f40000048uLLAAY</name>
<clientnameReference>
<Email>gar(_at_)gmail(_dot_)com
<mailto:gar(_at_)gmail(_dot_)com></Email>
</clientnameReference>
</clientdata>
<clientdata>
<name>003f40000049t38AAA</name>
<clientnameReference>
<Email>gad(_at_)gmail(_dot_)com
<mailto:gad(_at_)gmail(_dot_)com></Email>
</clientnameReference>
</clientdata>
<clientdata>
<name>003f40000049yJYAAY</name>
<clientnameReference>
<Email>gbc(_at_)gmail(_dot_)com
<mailto:gbc(_at_)gmail(_dot_)com></Email>
</clientnameReference>
</clientdata>
</objects>
Expectedoutput:
---------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<ClientInfo>
<clientname>
<Id>003f40000049yJYAAY</Id>
<Name>barcode11</Name>
<Email>gbc(_at_)gmail(_dot_)com
<mailto:gbc(_at_)gmail(_dot_)com></Email>
</clientname>
<clientname>
<Id>003f40000048uLLAAY</Id>
<Name>Bob Robben</Name>
<Email>gar(_at_)gmail(_dot_)com
<mailto:gar(_at_)gmail(_dot_)com></Email>
</clientname>
<clientname>
<Id>003f40000049t38AAA</Id>
<Name>ADVT4</Name>
<Email>gad(_at_)gmail(_dot_)com
<mailto:gad(_at_)gmail(_dot_)com></Email>
</clientname>
</objects>
XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
EasyUnsubscribe <-list/225679>
(by email <>)
--
Gerrit Imsieke
Geschäftsführer / Managing Director
le-tex publishing services GmbH
Weissenfelser Str. 84, 04229 Leipzig, Germany
Phone +49 341 355356 110, Fax +49 341 355356 510
gerrit(_dot_)imsieke(_at_)le-tex(_dot_)de, http://www.le-tex.de
Registergericht / Commercial Register: Amtsgericht Leipzig
Registernummer / Registration Number: HRB 24930
Geschäftsführer: Gerrit Imsieke, Svea Jelonek,
Thomas Schmidt, Dr. Reinhard Vöckler
--~----------------------------------------------------------------
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
--~--