[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[Recent Entries]
[Reply To This Message]
Re: XSL matching and duplication!
Hi Rahul,
A couple of observations/questions:
b 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.
b What exactly should happen if clientname/Id of Input1.xml matches
clientdata/name of Input2.xml, and what should happen if it doesnbt?
In particular, the records of which file should be de-duplicated,
Input1.xmlbs clientname records or Input2.xml? Your expected output
suggests that Input1.xmlbs 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. Ibm not sure whether this is your intention.
b 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:
b You declare a key named 'kBymail', but you donbt use it.
b The start and end tags of the top-level elements in Input1.xml and
Input2.xml donbt match.
b 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@xxxxxxxxx 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>
B B <clientname>
B B B B <Id>003f40000049yJYAAY</Id>
B B B B <Email>gbc@xxxxxxxxx <mailto:gbc@xxxxxxxxx></Email>
B B B </clientname>
B B <clientname>
B B B B <Id>003f40000049z3iAAA</Id>
B B B B <Email>gbc@xxxxxxxxx <mailto:gbc@xxxxxxxxx></Email>
B B B </clientname>
B B <clientname>
B B B B <Id>003f40000049z3nAAA</Id>
B B B B <Email>gbc@xxxxxxxxx <mailto:gbc@xxxxxxxxx></Email>
B B B </clientname>
B B <clientname>
B B B B <Id>003f40000048uLLAAY</Id>
B B B B <Email>gar@xxxxxxxxx <mailto:gar@xxxxxxxxx></Email>
B B B </clientname>
B B <clientname>
B B B B <Id>003f40000049t38AAA</Id>
B B B B <Email>gad@xxxxxxxxx <mailto:gad@xxxxxxxxx></Email>
B B B </clientname>
B </objects>
Input2.xml:
---------------------------------------
B <?xml version="1.0" encoding="UTF-8"?>
<ClientInfo>
B B <clientdata>
B B B B <name>003f40000048uLLAAY</name>
B B B <clientnameReference>
B B B B B B <Email>gar@xxxxxxxxx <mailto:gar@xxxxxxxxx></Email>
B B B B </clientnameReference>
B B B </clientdata>
B B <clientdata>
B B B B <name>003f40000049t38AAA</name>
B B B <clientnameReference>
B B B B B B <Email>gad@xxxxxxxxx <mailto:gad@xxxxxxxxx></Email>
B B B B </clientnameReference>
B B B </clientdata>
B B <clientdata>
B B B B <name>003f40000049yJYAAY</name>
B B B <clientnameReference>
B B B B B B <Email>gbc@xxxxxxxxx <mailto:gbc@xxxxxxxxx></Email>
B B B B </clientnameReference>
B B B </clientdata>
B </objects>
Expectedoutput:
---------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<ClientInfo>
B B <clientname>
B B B B <Id>003f40000049yJYAAY</Id>
B B B B <Name>barcode11</Name>
B B B B <Email>gbc@xxxxxxxxx <mailto:gbc@xxxxxxxxx></Email>
B B B </clientname>
B B <clientname>
B B B B <Id>003f40000048uLLAAY</Id>
B B B B <Name>Bob Robben</Name>
B B B B <Email>gar@xxxxxxxxx <mailto:gar@xxxxxxxxx></Email>
B B B </clientname>
B B <clientname>
B B B B <Id>003f40000049t38AAA</Id>
B B B B <Name>ADVT4</Name>
B B B B <Email>gad@xxxxxxxxx <mailto:gad@xxxxxxxxx></Email>
B B B </clientname>
B </objects>
XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
EasyUnsubscribe <-list/225679>
(by email <>)
--
Gerrit Imsieke
GeschC$ftsfC<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.imsieke@xxxxxxxxx, http://www.le-tex.de
Registergericht / Commercial Register: Amtsgericht Leipzig
Registernummer / Registration Number: HRB 24930
GeschC$ftsfC<hrer: Gerrit Imsieke, Svea Jelonek,
Thomas Schmidt, Dr. Reinhard VC6ckler
|
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format
RSS 2.0 |
|
Atom 0.3 |
|
|