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 26th, 2006, 11:36 PM
Authorized User
 
Join Date: Feb 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default Choosing content depending on content of other ele

Hi all,

I have the following query regarding the search for a paticular node based upon the value present in a particular nodes attribute value.

Here is the example that I am working on.

<?xml version="1.0" encoding="UTF-8"?>
<Stores>
<Product id = "1">
    <name>Vegtables</name>
    <cost>10</cost>
</Product>
<Product id = "2">
    <name>Shirts</name>
    <cost>10</cost>
</Product>
<Sales>
 <Item Prodid="1">
   <Counts>23</Counts>
 </Item>
</Sales>
</Stores>


The output that i want is like this on applying a xslt over this

<?xml version="1.0" encoding="UTF-8"?>
<Sales>
 <Item>
   <name>Vegatables</name>
   <PerItemcost>10</PerItemCost>
    <Price>230</Price>
 </Item>
</Sales>

I am not able to select the product details based upon the item's Prodid. Can any one please help me with an xslt code. I tried with large number of possible ways but I am not able to search a particular node based upon the node value of another attribute.

__________________
Regards,
dsekar_nat
 
Old February 27th, 2006, 05:58 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

If the context node is an Item, you can select the Product using

/Stores/Product[@id=current()/@Prodid]

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
changing content depending on combo box value bewise PHP How-To 1 September 13th, 2006 11:57 AM
Content management Mike707 Dreamweaver (all versions) 1 September 1st, 2006 04:43 PM
Content management?? haggis82 Dreamweaver (all versions) 1 December 9th, 2004 03:11 AM
Importing Content eschillay Dreamweaver (all versions) 1 March 1st, 2004 05:10 PM





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