Solved

XSLT/XSL issue

Posted on 2012-03-22
3
366 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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

Suggested Solutions

Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

829 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