473,490 Members | 2,488 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

A little XSL help please?

[[Sorry I couldn't think of a better subject for this rookie question.]]

In my .xml I have something like:

<root>
<parent>
...
<child>
<keynode>thekey</keynode>
</child>
</parent>
...
<parent>
<keynode>thekey</keynode>
<valuenode>thevalue</valuenode>
...
</parent>
</root>

In english, what I would like to do in my .xsl is this:

When processing each /root/parent/child, use the value of keynode
('thekey') to look up a /root/parent somewhere else in the .xml with a
keynode which matches ... and retrieve the corresponding valuenode
('thevalue').

Is this possible?

P.S. I can manage the xsl:for-each part.

TIA,

--

Dennis
Jun 27 '08 #1
5 1179
Dennis wrote:
[[Sorry I couldn't think of a better subject for this rookie question.]]

In my .xml I have something like:

<root>
<parent>
...
<child>
<keynode>thekey</keynode>
</child>
</parent>
...
<parent>
<keynode>thekey</keynode>
<valuenode>thevalue</valuenode>
...
</parent>
</root>

In english, what I would like to do in my .xsl is this:

When processing each /root/parent/child, use the value of keynode
('thekey') to look up a /root/parent somewhere else in the .xml with a
keynode which matches ... and retrieve the corresponding valuenode
('thevalue').

Is this possible?
Sure
<xsl:template match="root/parent/child">
<xsl:value-of select="../parent[keynode =
current()/keynode]/valuenode"/>
</xsl:template>


--

Martin Honnen
http://JavaScript.FAQTs.com/
Jun 27 '08 #2
On Thu, 01 May 2008 18:11:55 +0200, Martin Honnen <ma*******@yahoo.de>
wrote:
>Dennis wrote:
>[[Sorry I couldn't think of a better subject for this rookie question.]]

In my .xml I have something like:

<root>
<parent>
...
<child>
<keynode>thekey</keynode>
</child>
</parent>
...
<parent>
<keynode>thekey</keynode>
<valuenode>thevalue</valuenode>
...
</parent>
</root>

In english, what I would like to do in my .xsl is this:

When processing each /root/parent/child, use the value of keynode
('thekey') to look up a /root/parent somewhere else in the .xml with a
keynode which matches ... and retrieve the corresponding valuenode
('thevalue').

Is this possible?

Sure
<xsl:template match="root/parent/child">
<xsl:value-of select="../parent[keynode =
current()/keynode]/valuenode"/>
</xsl:template>
Thanks! I'll give it a whirl...

--

Dennis
Jun 27 '08 #3
Dennis wrote:
> <xsl:template match="root/parent/child">
<xsl:value-of select="../parent[keynode =
current()/keynode]/valuenode"/>
</xsl:template>

Thanks! I'll give it a whirl...
Should be
<xsl:value-of select="../../parent[keynode = current()/keynode]/valuenode"/>
actually.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jun 27 '08 #4
On Thu, 01 May 2008 19:11:51 +0200, Martin Honnen <ma*******@yahoo.de>
wrote:
>Dennis wrote:
>> <xsl:template match="root/parent/child">
<xsl:value-of select="../parent[keynode =
current()/keynode]/valuenode"/>
</xsl:template>

Thanks! I'll give it a whirl...

Should be
<xsl:value-of select="../../parent[keynode = current()/keynode]/valuenode"/>
actually.
OK.

Can you recommend a good online resource for beginners. I have a
programming background so I pick up on things quickly. I have been using
www.w3schools.com and just googling for answers to my questions, but I
don't see anyplace that I would call a comprehensive reference site with
good examples.

Thanks,

--

Dennis
Jun 27 '08 #5
Many good tutorials/articles are available at http://www.ibm.com/xml.

For terse but enlightening examples of less-than-obvious patterns, see
the XSLT FAQ at http://www.dpawson.co.uk/xsl/sect2/sect21.html

(I've heard more complaints about the w3schools website than praise for
it. You might want to take its suggestions with a grain of salt...)
Jun 27 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2690
by: rmn | last post by:
Hi, I'm looking for the translation betwen the color spaces, but I must be mistaken with the methods to use, losing the values. Please, I need a little help of a "coloured guru"....
3
3409
by: Ron Stephens | last post by:
I posted to my web site a fun little program called merlin.py today. Please keep in mind that I am a hobbyist and this is just a little hack, if you look at the code you will see that it is still...
2
28994
by: hicham | last post by:
Hi, I am looking for help, i would like to know how can i use the endian.h and config.h to convert compiled files under solaris from BIG-ENDIAN to compiled files LITTLE-ENDIAN. I am working...
2
4853
by: Slash | last post by:
I often do a lot of text-mode programming in Linux and wanted to use colors in text mode, and found the ncurses library needlessly complex for small applications. So I wrote my own little header to...
8
27433
by: Perception | last post by:
Hello all, If I have a C-like data structure such that struct Data { int a; //16-bit value char; //3 ASCII characters int b; //32-bit value int c; //24-bit value }
2
2036
by: Daniel | last post by:
I'm new to .Net and all of its abilities so I hope this makes sense. Basically I'm confused on when is the appropriate time to use web forms controls vs. regular HTML. For example in ASP...
13
27219
by: junky_fellow | last post by:
Hi guys, I need to convert a big endian integer to little endian integer. (the integer is 4 bytes in size on my implementation). I came up with the following code. I need your comments on...
3
1614
by: ThaDoctor | last post by:
Hi. I am quite new to C++ so I think I would ask here what I am doing wrong with this code. I am writing a little game in a text console, but here is something that is in no way related to the...
23
7002
by: Niranjan | last post by:
I have this program : void main() { int i=1; if((*(char*)&i)==1) printf("The machine is little endian."); else printf("The machine is big endian."); }
3
2309
by: Ethan Furman | last post by:
len wrote: I've never had the (mis?)fortune to work with COBOL -- what are the files like? Fixed format, or something like a dBase III style? I
0
7108
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6967
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7142
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7181
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
4875
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4565
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1383
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
618
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
272
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.