RE: [xsl] Retrieving data from two XMLs and creating another XML using XSLT

Subject: RE: [xsl] Retrieving data from two XMLs and creating another XML using XSLT
From: cknell@xxxxxxxxxx
Date: Wed, 15 Feb 2006 14:03:19 -0500
I make no claims for it's elegance, but this stylesheet will do what you described if you name Input File 1 "manasi-d2.xml" and Input File 2 "manasi-d1.xml".
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="";>
  <xsl:output method="xml" indent="yes" />
  <xsl:strip-space elements="*" />

  <xsl:variable name="ddoc" select="document('manasi-d2.xml')" />

  <xsl:template match="/">
    <xsl:apply-templates />

<xsl:template match="Root">
  <xsl:apply-templates />

<xsl:template match="Form">
    <Person Name="{$ddoc/Data/Section/Specimen/@Name}">
          <Data Tag="{Section/@Name}.{Section/Set/@Name}.{Section/Set/Item/@Name}" Value="{$ddoc/Data/Section/Specimen/Test/Result/TextResult/@Value}"/>

<xsl:template match="Section" />
<xsl:template match="Set" />
<xsl:template match="Item" />


Charles Knell
cknell@xxxxxxxxxx - email

-----Original Message-----
From:     Manasi Kulkarni <Manasi.Kulkarni@xxxxxxxxxxxxxxxx>
Sent:     Wed, 15 Feb 2006 13:41:53 -0500
To:       'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'
Subject:  [xsl] Retrieving data from two XMLs and creating another XML using XSLT

I want to read data from two XML files with completely different structure
and build third XML using XSLT.

The input XML files are of the form:

Input File 1:

		<Specimen Name="John Smith"> 
            	<Test Name="Test1">
<TextResult Value="123"/>

Input File 2:
	<Form Name="Form1">
	      <Section Name="Sect1">
	            <Set Name="Set1">
	                  <Item Name="Item1"/>

Output File:
	<Person Name="John Smith">
	      <Data Tag="Sect1.Set1.Item1" Value="123"/>

The output XML contains some value from first XML and some from second XML.

My mail problem is creating 'Tag' attribute for output XML which is
concatenated string of values from second XML.

I tried using xsl:variable / param, however it gives me an error when I use
concat function with variables. 

Can this be done using XSL? Or should I write custom converter using Java /

Any help would be appreciated.



This message contains privileged and confidential information intended only
for the use of the addressee(s) named above.  If you are not the intended
recipient of this message, or the employee or agent responsible for
delivering it to the intended recipient, you are hereby notified that any
dissemination or copying of this message is strictly prohibited.  If you
have received this message in error, please immediately notify the sender by
return electronic mail and delete the original message without retaining a

Current Thread