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

Compare 2 XML and get Id from another XML in main XML

Subject: Compare 2 XML and get Id from another XML in main XML
From: "Rahul Singh rahulsinghindia15@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 21 Sep 2016 14:28:28 -0000
 Compare 2 XML and get Id from another XML in main XML
Hi,

I have 2 XML. result.XML and name.xml. I am comparing both XML and calling
<id> from result.xml to name.xml sucess=true case.

*result.xml:*

<?xml version="1.0" encoding="UTF-8"?>
<results>
   <result>
        <id>001R0000018j3KBIAY</id>
        <success>true</success>
     </result>
   <result>
        <id>001R0000018j3KCIAY</id>
        <success>true</success>
     </result>
   <result>
        <id>001R0000018j3KDIAY</id>
        <success>true</success>
     </result>
   <result>
        <id>001R0000018j3KEIAY</id>
        <success>true</success>
     </result>
   <result>
        <id xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:nil="true"/>
        <success>false</success>
     </result>
   <result>
        <id>001R0000018j3KFIAY</id>
        <success>true</success>
     </result>
</results>

*Name.xml:*


<Names>
   <Name>
      <LAST_NAME>rtt</LAST_NAME>
      <FIRST_NAME>ds</FIRST_NAME>
   </Name>
   <Name>
      <LAST_NAME>jhj</LAST_NAME>
      <FIRST_NAME>tyt</FIRST_NAME>
   </Name>
   <Name>
      <LAST_NAME>qwqw</LAST_NAME>
      <FIRST_NAME>i</FIRST_NAME>
   </Name>
   <Name>
      <LAST_NAME>trt</LAST_NAME>
      <FIRST_NAME>ss</FIRST_NAME>
   </Name>
   <Name>
      <LAST_NAME>yt</LAST_NAME>
      <FIRST_NAME>asa</FIRST_NAME>
   </Name>
</Names>


*XSLT: *

<xsl:stylesheet version="2.0" xmlns:xsl="
http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" indent="yes" omit-xml-declaration="no"/>
    <xsl:strip-space elements="*"/>
    <xsl:param name="tranFile" select="document('Name.xml')"/>

    <xsl:template mode="insert" match="Names">
        <xsl:copy-of select="../../Name"/>
    </xsl:template>

    <xsl:template match="@* | node()">
        <xsl:copy>
            <xsl:apply-templates select="@*"/>
            <xsl:apply-templates mode="insert" select="."/>
            <xsl:apply-templates mode="inserta" select="."/>
            <xsl:apply-templates/>
        </xsl:copy>
    </xsl:template>

    <xsl:template mode="insert" match="*"/>
    <xsl:template mode="inserta" match="*"/>


    <xsl:template match="@* | node()">
        <xsl:copy>
            <xsl:apply-templates select="@* | node()"/>
        </xsl:copy>
    </xsl:template>
</xsl:stylesheet>


*Expected Output:*


<Names>
   <Name>
      <LAST_NAME>rtt</LAST_NAME>
      <FIRST_NAME>ds</FIRST_NAME>
 <id>001R0000018j3KBIAY</id>
   </Name>
....
....
</Names>

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.