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 6th, 2006, 07:29 AM
Authorized User
 
Join Date: Feb 2006
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default Access the values from other node

Hi,

I have the following problem
<confirmationDocument>
 <participants>
 <participant participantNr="1">
  <name>Rohner</name>
  <kind>Mrs</kind>
  <firstname>Sabina</firstname>
  </participant>
  </participants>
<services>
<service xmlns="" xsi:type="SrvcFlight" id="0">
 <segments>
 <segment id="1">
  <airline>IB</airline>
  <flightNr>IB 3475</flightNr>
  <class>L</class>
  <status>HK</status>
 <seats>
 <seat participantNr="1">
  <number>009F</number>
  <status>HK</status>
</seat>
</seats>
</segment>
</segments>
<service>
</services>
</confirmationDocument>

I have above XML data ,
Now I want to access the Kind ,name,firstname of a participant from
participants/participant tag depend on the seats/seat/@participantNr
 in a one string so as result I get Value as Mrs. Sabina Rohner.


Regards
Pravin.



 
Old March 6th, 2006, 07:42 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Assuming the context node is a service element, you can list the names of the participants like this:

<xsl:for-each select="segments/segment/seats/seat">
  <xsl:variable name="p" select="/*/participants/participant[@participantNr = current()/@participantNr]"/>
  <xsl:value-of select="$p/name"/>
   etc.

If the data file is very large, consider using keys.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
List of node values, only once for multiples mphare XSLT 4 February 1st, 2008 03:09 PM
Aggreagation of leaf node values in BSM 2005 chary SharePoint Development 0 September 19th, 2007 06:43 AM
Access Namespace Node using XPath pvasudevan XSLT 1 January 2nd, 2006 06:20 AM
Accessing values from the last sibling node graywoodhouse XSLT 3 October 29th, 2004 06:15 AM
Avoid duplicate node values nambati XSLT 1 September 8th, 2004 02:41 PM





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