Solved

XSLT/XSL issue

Posted on 2012-03-22
3
365 Views
Last Modified: 2012-03-22
I am trying to code this xsl stylesheet and not having done this before, I am lost. I do not have access to the actual xml being returned but do have access to the SQL Server procedure results that eventually ends up as the xml. The SQL Procedure returns several tables but I am really only concerned about two of them. LineItem and SubLineItem. What I need to do is filter the LineItem table down using a description.

<xsl:for-each select="//GetOrderDetailsInfoResults/LineItem[perf_desc != 'OPA Handling Fee']">

Now what I need to is to grab the value of an element (li_seq_no) out of these results. Use the returned "li_seq_no" to filter my SubLineItem and sum the due_amt element into a variable.

I have know idea how to do this. In sql server, this would be just a join such as

Select sum(sl.due_amt) from LineItem as l join SubLineItem sl on l.li_seq_no = sl.li_seq_no where l.perf_desc = 'OPA Handling Fee'

Any Ideas?
Thanks
0
Comment
Question by:DowntownIT
  • 2
3 Comments
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 500 total points
ID: 37753764
what you should do is index the source (in order for us to help you a view on the source XML would really be nice)
indexing can be done with
<xsl:key>
give the key a random name, choose what element from the source should be returned and the index is the path to the li_seq_no
then you can get the indexed node back by calling the key function

inside the for-each for the LineItem, you can get the lis_seq_no
the key is for sublineitem
so
<xsl:key name="sli" match="SubLineItem" use="li_seq_no"/>

using the function inside the for-each
key('sli', li_seq_no) will return to you tyhe sublineitem nodes that match

XML source would help to be more precise

xsl:key is an index in the document
given two tables in one XML document, xsl:key is an enabler for joins
0
 
LVL 2

Author Closing Comment

by:DowntownIT
ID: 37753886
I was able to get the xsl:key to work. Thanks for the help!
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 37754022
welcome
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Problem to Popup 2 81
XML XSLT If loop 4 25
write xml in vb.net 2 24
XSLT Display Label Name 1 22
I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn how to count occurrences of each item in an array.

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question