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

RE: Using XLS to transform/join two XML docs.

Subject: RE: Using XLS to transform/join two XML docs.
From: Kay Michael <Michael.Kay@xxxxxxx>
Date: Wed, 20 Dec 2000 09:56:52 -0000
xls transform
> Effectively, I'm trying to do a SQL join without the db.

The general case of a join of two tables having a many-to-many relationship
certainly isn't easy in XSLT (I leave it as a challenge for the reader!).
But your example is one-to-many, and that's quite straightforward.
> 
> So, I'd like to start with:
> 
> 	<one>
> 		<a b="1">First Choice</a>
> 		<a b="2">Second Choice</a>
> 		<a b="3">Third Choice</a>
> 	</one>
> 	
> 	<two>
> 		<x id="1" b="1" this="that" them="those" />
> 		<x id="2" b="3" this="that" them="those" />
> 	</two>
> 
> And wind up with:
> 
> 	<three>
> 		<x id="1" b="First Choice" this="that" them="those" />
> 		<x id="2" b="Third Choice" this="that" them="those" />
> 	</three>
> 
> 
<xsl:template match="two/x">
  <xsl:copy>
   <xsl:copy-of select="@id | @this | @that"/>
   <xsl:attribute name="id">
      <xsl:value-of select="//one/a[@b = current()/@b]"/>
   </xsl:attribute>
  </xsl:copy>
</xsl:template>

or, for efficiency with a large data set, use a key in the predicate.

Mike Kay


 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.