473,324 Members | 2,196 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

nested loops and conditional statements

Here's yet another question. Thanks for your patience/advice. I am
trying to match attributes from different paths in different files and
display an attribute of the subordinate tag in the second file when
they match. But I seem to only get the last value of that subordinate
tag attribute over and over. Any thoughts? I'm pretty sure that the
problem lies in my referencing absolouts paths from the 'when' tag.

-James

Document 1 (doc1.xml)
------------------------
<AA>
<BB author="McFly">
<CC title="Back to the Future">00-00-00-01</CC>
</BB>
<BB author="Bartakamous">
<CC title="Perfect Strangers">00-00-00-02</CC>
</BB>
</AA>

Document 2 (doc2.xml)
------------------------
<MM>
<NN author="McFly">
<OO dob="08.25.1980">
<!-- Additional Unrelated Tags -->
</OO>
</NN>
<NN author="Bartakamous">
<OO dob="02.15.1962">
<!-- Additional Unrelated Tags -->
</OO>
</NN>
<NN author="Mclain">
<OO dob="12.01.1899">
<!-- Additional Unrelated Tags -->
</OO>
</NN>
</MM>

XSL Document
------------------------
<xsl:for-each select="AA/BB">
<!-- Unrelated processing instructions -->
<xsl:for-each select"AA/BB>
<!-- Unrelated processing instructions -->
<xsl:for-each select="CC/@title">
<xsl:for-each select="document('doc2.xml')/MM">
<!-- Unrelated processing instructions -->
<xsl:choose>
<xsl:when test="document('doc1.xml')/AA/BB/@author=@author">
<xsl:value-of select="NN/OO/@dob"/>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
Result
------------------------
<!-- Irrelevant text abridged -->
12.01.1899
12.01.1899
12.01.1899

Jul 20 '05 #1
3 4423
> Here's yet another question. Thanks for your patience/advice. I am
trying to match attributes from different paths in different files and
display an attribute of the subordinate tag in the second file when
they match. But I seem to only get the last value of that subordinate
tag attribute over and over. Any thoughts? I'm pretty sure that the
problem lies in my referencing absolouts paths from the 'when' tag.


Hi,

Your xslt snippet doesn't seem to be working.

Try this:
<xsl:for-each select="AA/BB">
<xsl:variable name="author" select="@author"/>
<!-- Unrelated processing instructions -->
<xsl:for-each select="CC/@title">

<xsl:for-each select="document('doc2.xml')/MM/NN">
<!-- Unrelated processing instructions -->
<xsl:choose>
<xsl:when test="$author=@author">
<xsl:value-of select="OO/@dob"/>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>

regards,

--
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
Jul 20 '05 #2
Using variables did the trick. Thanks!

Jul 20 '05 #3
> Here's yet another question. Thanks for your patience/advice. I am
trying to match attributes from different paths in different files and
display an attribute of the subordinate tag in the second file when
they match. But I seem to only get the last value of that subordinate
tag attribute over and over. Any thoughts? I'm pretty sure that the
problem lies in my referencing absolouts paths from the 'when' tag.


Hi,

Your xslt snippet doesn't seem to be working.

Try this:
<xsl:for-each select="AA/BB">
<xsl:variable name="author" select="@author"/>
<!-- Unrelated processing instructions -->
<xsl:for-each select="CC/@title">

<xsl:for-each select="document('doc2.xml')/MM/NN">
<!-- Unrelated processing instructions -->
<xsl:choose>
<xsl:when test="$author=@author">
<xsl:value-of select="OO/@dob"/>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>

regards,

--
Joris Gillis
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
Jul 20 '05 #4

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

Similar topics

4
by: mike beck | last post by:
this is not all complex, but as a noob i'm having a hard time getting my head around it. i have a list of items. i need to print the items in batches of x, with a summary line after each...
2
by: SplaTTer | last post by:
I have a piece of code consisting of k nested for loops, for example: int k = 5; int *p = new int; double x,y; //x is read from file for(p=0;p<=6;p++) for(p=0;p<=3;p++) for(p=0;p<=3;p++)
3
by: Sergej Andrejev | last post by:
Not long ago I was asked to give PHP lections to some private IT school. I'm on second lection now, and will be teaching my :) students conditional statements (if..else and switch) and loops (while...
10
by: nimmi_srivastav | last post by:
Below you will see an example of a nested conditional expression that this colleague of mine loves. He claims that it is more efficient that a multi-level if-else-if structure. Moreover, our...
36
by: invni | last post by:
I have a nested while. How do I go from the inner while to the beginning of the outer while? Can this be done without using goto? while_1() { some codes here while_2() { if true go to the...
9
by: Javaman59 | last post by:
Using local declarations within a block often makes code more readable, but is it less efficient? eg... void P() { while (...) { int i = ...; bool b = ...; .... } }
3
by: Jake Emerson | last post by:
I'm attempting to build a process that helps me to evaluate the performance of weather stations. The script below operates on an MS Access database, brings back some data, and then loops through to...
5
by: =?Utf-8?B?QUEyZTcyRQ==?= | last post by:
Could someone give me a simple example of nested scope in C#, please? I've searched Google for this but have not come up with anything that makes it clear. I am looking at the ECMA guide and...
1
by: gaurav87 | last post by:
This is a small part the xml file that I have: <Prop Type='TEResult' Flags='0x0'> <Prop Name='Status' Type='String' Flags='0x400000'> <Value>Done</Value> </Prop> <Prop...
8
by: Nathan Sokalski | last post by:
I have several nested For loops, as follows: For a As Integer = 0 To 255 For b As Integer = 0 To 255 For c As Integer = 0 To 255 If <Boolean ExpressionThen <My CodeElse Exit For Next If Not...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.