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 February 14th, 2006, 05:10 AM
Registered User
Join Date: Feb 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to combine two value-of selects?

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

    <item no="1">
    <item no="2">
    <step no="1">
        <sent as_item="1">
            <status>STATUS 3</status>
        <sent as_item="2">
            <status>STATUS 1</status>

...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 :)

Old February 14th, 2006, 05:44 AM
mhkay's Avatar
Wrox Author
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts

Use a variable

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

Michael Kay
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Old February 14th, 2006, 06:20 AM
Registered User
Join Date: Feb 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts

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 ;)

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

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