Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 14th, 2006, 05:10 AM
Registered User
 
Join Date: Feb 2006
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to combine two value-of selects?

Hi,
Anyone know how to do this? I have the following XML file...

<recipients>
    <item no="1">
        <phone>0046123456</phone>
    </item>
    <item no="2">
        <phone>0046987654</phone>
    </item>
</recipients>
<sendlog>
    <step no="1">
        <sent as_item="1">
            <status>STATUS 3</status>
        </sent>
        <sent as_item="2">
            <status>STATUS 1</status>
        </sent>
    </step>
</sendlog>

...and what I want to do is check if a phone number is listed, and if so, get the sendlog status of that number (a phone numbers @no is the same as the sendlogs @as_item).

I can get a phone numbers @no attribute like so:
<xsl:value-of select="//item[phone='0046123456']/./@no" />

And I can get the status of a @as_item number like so:
<xsl:value-of select="//sent[@as_item='2']/status" />

But I need to combine them. How do I use the result in the first value-of select in the second value-of select statement?

Any help on this is highly appreciated :)

Reply With Quote
  #2 (permalink)  
Old February 14th, 2006, 05:44 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Use a variable

<xsl:variable name="x" select="//item[phone='0046123456']/./@no" />
<xsl:value-of select="//sent[@as_item=$x]/status" />


Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote
  #3 (permalink)  
Old February 14th, 2006, 06:20 AM
Registered User
 
Join Date: Feb 2006
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you very much for your help.

Ps. I have your book "XSLT 2:nd Edition" on my shelf here. Perhaps I need to look into it a bit again ;)

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
listbox always selects index 0 Colonel Angus ASP.NET 2.0 Professional 5 August 18th, 2008 01:11 PM
Put together 2 selects results in a single one romulo.petri SQL Language 3 March 6th, 2008 03:43 AM
trying to get data from multiple selects ceevk1 VB Databases Basics 1 April 3rd, 2007 12:05 PM
Multiple Selects in SQL QueryStrings doonman BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 6 January 30th, 2006 07:01 AM
Two selects in one procedure Trojan_uk SQL Server 2000 2 December 17th, 2003 05:28 AM



All times are GMT -4. The time now is 04:58 AM.


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