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

Copy one element from one xml file to another

Subject: Copy one element from one xml file to another
From: Nishi Bhonsle <nishi.bhonsle@xxxxxxxxxx>
Date: Thu, 21 Oct 2004 14:13:30 -0700
copy xml file
Hi:

I have xml1 based on xsd1 and xml2 based on xsd2. I want to copy the value of the attribute "name" of the "transport" element from xml1 to xml2.

Consider xml1:

<?xml version = '1.0' encoding = 'UTF-8'?>

<applet locale="en" ...................>
 <transport name="jrmp"/><transport name="codebase"/>
....
...
...
</applet>
----------------------------------------
Consider xml2:

<disco:configuration xmlns:disco=......................... xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=............... >
....
....
  <plus helpSet="help">
    <transport name="jrmp"/>
    <transport name="http"/>
  </plus>
</disco:configuration>
-----------------------------------------

I noticed the following xsl would do the job in the sense, it outputs the correct value --

<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet  version="1.0"   xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:disco="http://www.oracle.com/discoverer/configuration"
xmlns:fo="http://www.w3.org/1999/XSL/Format">

  <xsl:output method="xml" encoding="ISO-8859-1" indent="yes" />

<xsl:template match="transport">
      <xsl:call-template name="copy"/>
</xsl:template>

<xsl:template name="copy">
    <xsl:copy>
        <xsl:apply-templates select="@*" mode="copy" />
        <xsl:apply-templates/>
        <xsl:value-of select="text()"/>
    </xsl:copy>
</xsl:template>
</xsl:stylesheet>
-------------------------------------------------

How can I thereafter replace the value for the transport element in xml2 with the values I have from the above transform?

Thanks, Nishi.

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.