XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 7th, 2004, 11:31 AM
deadc0de deadc0de is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 2 deadc0de User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 29 sec
Reputation Power: 0
I need some advice from an XSLT/XPath guru please

I need some advice on the best way to approach cross-referencing XML fields. What I'm trying to accomplish is using one element attribute as a key to find a value within a second element.

i.e.
<data>
<gizmo name="foo1" value="peanuts"/>
<gizmo name="foo2" value="walnuts"/>
</data>
<index>
<widget item="Item #1" key="foo1"/>
<widget item="Item #2" key="foo2"/>
</index>

I'd like to be able to loop through the /index/widget elements and list them in the output in a manner similar the following:

Item #1 is peanuts
Item #2 is walnuts

The methods I've tried are very clumsy and I like to see a 'proper' way if one of the guru's here could show me.

Thanks.

Reply With Quote
  #2  
Old June 7th, 2004, 06:47 PM
jharnois's Avatar
jharnois jharnois is offline
mod_dev_shed
Dev Shed God 20th Plane (14500 - 14999 posts)
 
Join Date: Sep 2002
Location: Atlanta, GA
Posts: 14,569 jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 2 Days 22 h 42 m 51 sec
Reputation Power: 835
I'm no guru ... and I haven't used XSL lately.
Code:
<xsl:for-each select "index">
<xsl:value-of select="@item" /> is <xsl:value-of select="/data/gizmo[position()]/@value" /><br />
</xsl:for-each>
__________________
# Jeremy

Explain your problem instead of asking how to do what you decided was the solution.

Reply With Quote
  #3  
Old June 7th, 2004, 08:56 PM
deadc0de deadc0de is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 2 deadc0de User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 29 sec
Reputation Power: 0
Thanks Jeremy...not quite the solution I needed but thanks for answering anyway...I found a simpler method using the <xsl:key> tag and key() call.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > I need some advice from an XSLT/XPath guru please


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT