Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 16th, 2005, 01:05 PM
Authorized User
 
Join Date: Mar 2005
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Default SQL Joins in XPath

I would like to calculate the sum of the prices whos attribute (idnr) can be found under params. In this sample case I want the result to be 342 + 13 + 19 + 1200 = 1574.

My problem is matching the PRICE attributes with the ID names. In SQL this would have been solved with nested queries or a JOIN.

How can I solve this problem?

_______________________________

This is how I want the XSLT code to look like:

<xsl:value-of select="sum(/PRODUCTS/*[Here I'd like to match attribute::idnr with name(/PARAMS/*)]/text())"/>

The XML data:

...

<PARAMS>
 <ID5>on</ID5>
 <NAME>Anders</NAME>
 <ID1>on</ID1>
 <ID2>on</ID2>
 <DEBUG>TRUE</DEBUG>
 <ID8>on</ID8>
</PARAMS>

...

<PRODUCTS>
 <PRICE idnr="ID1">13</PRICE>
 <PRICE idnr="ID2">19</PRICE>
 <PRICE idnr="ID3">23</PRICE>
 <PRICE idnr="ID4">54</PRICE>
 <PRICE idnr="ID5">342</PRICE>
 <PRICE idnr="ID6">756</PRICE>
 <PRICE idnr="ID7">1100</PRICE>
 <PRICE idnr="ID8">1200</PRICE>
</PRODUCTS>

...






Similar Threads
Thread Thread Starter Forum Replies Last Post
Joins in SQL Server debsoft SQL Server 2005 2 May 10th, 2007 08:23 AM
SQL - Help with Joins oldmuttonhead Classic ASP Databases 0 January 21st, 2006 05:02 PM
Union joins in SQL sellis Access 3 April 7th, 2004 12:25 AM
SQL Table Joins Dredd Classic ASP Databases 2 June 3rd, 2003 06:24 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.