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

Join XMLs with XLST with ralative data

Subject: Join XMLs with XLST with ralative data
From: Mangesh Kakade <wadapaav@xxxxxxxxx>
Date: Thu, 5 Jun 2003 01:34:08 -0700 (PDT)
join xslt
HI Everybody ,
I am very new to this list,
As I was going thru the archive , I found the way to
join the 2 or more XML docs  using ?copy? and ?key?
element.
I used it in my program , but it seems not working
well . I don?t know Where I went wrong . 
The two xml doc that I want to join are 

22.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="stock.xslt"?>
<STKAVAILABLE>
	<STKMAST Alias="01" STKCODE="31>
		<STKCODE IndexID="5011"/>
		<STKDESC IndexID="5017"/>
	</STKMAST>
	<STKMAST Alias="01" STKCODE="30">
		<STKCODE IndexID="5011"/>
		<STKDESC IndexID="5017"/>
	</STKMAST>
	<STKMAST Alias="01" STKCODE="32>
		<STKCODE IndexID="5011"/>
		<STKDESC IndexID="5017"/>
	</STKMAST>
</STKAVAILABLE>

buy22.xml
<?xml version="1.0" encoding="UTF-8"?>
<buyermaster>
	<name id="a001" deptid="01">
		<address/>
		<bstkcode>31</bstkcode>
	</name>
	<name id="a010">
		<address/>
		<bstkcode>31</bstkcode>
	</name>
	<name id="a003" deptid="10">
		<address/>
		<bstkcode>40</bstkcode>
		<bstkcode>20</bstkcode>
		<bstkcode>35</bstkcode>
	</name>
</buyermaster>
I am using join.xslt 
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="rows-bstkcode" match="bstkcode"
use="bstkcode" />
<xsl:variable name="x_22" select="document('22.xml')"
/>
<xsl:variable name="buy22"
select="document('buy22.xml')" />
<xsl:template match="/">
<tran>
  <xsl:for-each select="$x_22/STKAVAILABLE/STKMAST">
    <xsl:copy>
      <xsl:copy-of select="@*" />
      <xsl:variable name="STKCODE" select="@STKCODE"
/>
      <xsl:for-each select="$buy22">
        <xsl:copy-of select="key('rows-bstkcode',
$STKCODE)
        				/*[name() != 'bstkcode']" />
        				
      </xsl:for-each>
    </xsl:copy>
  </xsl:for-each>
 </tran> 
 </xsl:template>
</xsl:stylesheet>

And I want xml or HTML out put like this 
<tran>
<STKMAST STKCODE="31" >	<!?from 22.xml>
<name id="a001"/>       < !?Corresponding buyer id
from buy22.xml-->
<name id="a010"/>
</STKMAST>
</tran>
but with my join.xslt I am getting following out put (
xml)
<?xml version="1.0" encoding="UTF-8" ?> 
<tran>
 	 <STKMAST Alias="01" STKCODE="31" /> 
  	<STKMAST Alias="01" STKCODE="30" /> 
  	<STKMAST Alias="01" STKCODE="32" /> 
</tran>
Pls Help me 
TIA
Mangesh



__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.