473,408 Members | 2,477 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,408 software developers and data experts.

if conditions

I have the following loops:

<xsl:for-each
select="//node[@type='N_MICROFLOW_SD'][@display=$microflow_id]">
<xsl:variable name="sd_id" select="./@object"/>
<xsl:variable name="doc_id"
select="//link[@type='L_DC_SD'][@to=$sd_id]/@from"/>

<xsl:if test="//link[@type='L_MICROFLOW_WA_SD'][@to=$sd_id]/@from!=''">
<tr>
<td>Output:</td>
<td>
<xsl:value-of select="//object[@id=$sd_id]/property[@name='SDMSGNAM']"/>
<xsl:text>&#xa0;-&#xa0;</xsl:text>
<xsl:value-of select="//object[@id=$doc_id]/property[@name='ACNAME']"/>
</td>
</tr>
</xsl:if>

</xsl:for-each>

<xsl:for-each
select="//node[@type='N_MICROFLOW_SD'][@display=$microflow_id]">
<xsl:variable name="sd_id" select="./@object"/>
<xsl:variable name="doc_id"
select="//link[@type='L_DC_SD'][@to=$sd_id]/@from"/>

<xsl:if test="//link[@type='L_WC_SD'][@to=$sd_id]/@from!=''">
<tr>
<td>Output:</td>
<td>
<xsl:value-of select="//object[@id=$sd_id]/property[@name='SDMSGNAM']"/>
<xsl:text>&#xa0;-&#xa0;</xsl:text>
<xsl:value-of select="//object[@id=$doc_id]/property[@name='ACNAME']"/>
</td>
</tr>
</xsl:if>

</xsl:for-each>

The only difference between them is that the first one checks one type
of <link> element (row 7), and the other another type (row 26). Can I do
this with one loop and one if-condition? Basically, is there an or? I
sure can't seem to find a way, but then again it is late in the
afternoon and I'm tired...

-----------------
Eliza Zadura
Trainee-Developer

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #1
4 2134
"Eliza Zadura" <el**********@sync.se> wrote in message
news:3f***********************@news.frii.net
I have the following loops:

[...snip...]

The only difference between them is that the first one checks one type
of <link> element (row 7), and the other another type (row 26). Can I
do this with one loop and one if-condition? Basically, is there an
or?


There is no "else", but a kind of "switch":

---XSL Fragment---------------------------------------------------------
<xsl:choose>
<xsl:when
test="//link[@type='L_MICROFLOW_WA_SD'][@to=$sd_id]/@from!=''">
<!-- do one thing -->
</xsl:when>
<xsl:when test="//link[@type='L_WC_SD'][@to=$sd_id]/@from!=''">
<!-- do some other thing -->
</xsl:when>
<xsl:otherwise>
<!-- do something completely different-->
</xsl:otherwise>
</xsl:choose>
------------------------------------------------------------------------

HTH

martin
Jul 20 '05 #2
Thanks Martin. That doesn't quite do the trick though. What I'm looking
for is a construct that will allow me to do the following (in
pseudocode):

If the link of TYPE or TYPE where the attribute TO is ID exists then

do something.

The crux is that if both exist, I want it done only once.

For - if - break I suppose. Can this be done with xsl?

-----------------
Eliza Zadura
Trainee-Developer

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #3
"Eliza Zadura" <el**********@sync.se> wrote in message
news:3f***********************@news.frii.net
Thanks Martin. That doesn't quite do the trick though. What I'm
looking for is a construct that will allow me to do the following (in
pseudocode):

If the link of TYPE or TYPE where the attribute TO is ID exists then
do something.


OIC. Maybe you should post a XML fragment to work with. Because your
select="//....." is very unspecific it quite difficult to picture your
XML structure.

It could solve your problem to select the nodes in question with
someting like
select="//link[@type='TYPE_1' or @type='TYPE_2']"
and use "position() = 1" to test for the first node in the resulting
node-set.
If this set has two nodes or more, e.g. both types exist, the <!-- do
something --> part is nevertheless executed only once.

Martin
Jul 20 '05 #4
Yes, that does it! :o)

Thanks again.

-----------------
Eliza Zadura
Trainee-Developer

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #5

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

Similar topics

1
by: twins | last post by:
Hi, Iam wondering if there is any method to do the following: 1) When a file is created in a directory in local computer. 2) When the mysql date stored in the DB approaches the current date and...
5
by: GIMME | last post by:
One of my coworkers insists that one should never use static methods because race conditions exist. Thinking along the lines that all variable assignments are assignments to static variables. ...
1
by: Jo | last post by:
I am having a real problem with the Launch conditions in VS .NET and can only come to the conclusion that it is a bug. It states quite emphatically in the MSDN that Launch Conditions WILL be...
5
by: Uday Deo | last post by:
Hi everyone, I am looping through 4 nested loops and I would like to break in the inner most loop on certain condition and get the control on the 2 nd loop instead of 3rd loop. Here is briefly...
6
by: rshepard | last post by:
All my python books and references I find on the web have simplistic examples of the IF conditional. A few also provide examples of multiple conditions that are ANDed; e.g., if cond1: if cond2:...
2
by: Igor | last post by:
1. Are stored procedures WITH ENCRYPTION slower than the ones without encryption? 2. Should i put most restrictive conditions first or last in WHERE? In which order does MSSQL execute...
1
by: ajayvaram | last post by:
<?xml version="1.0" encoding="utf-8"?> <CategoryList> <Category ID="01" Title="One"> </Category> <Category ID="03" Title="Three"> </Category> <Category ID="04" Title="Four"> ...
1
by: mlgmlg | last post by:
Hello, I have a text box (on a Single Form) that I use to color code milestones based on a value. I use the “Conditional Formatting” tool to format four of the conditions, which works great! ...
12
by: =?ISO-8859-1?Q?Ren=E9?= | last post by:
Hi, is there a rule of thumb what is better/faster/more performant in SQL Server 2005? a) SELECT * FROM A INNER JOIN B ON B.ID = A.ID AND B.Cond1 = 1 AND B.Cond2 = 2 b) SELECT * FROM A INNER...
4
by: Prashanth Kumar B R | last post by:
Hi, I have situation in C++ where in I'll have to add around 20-25 conditions <compare a variable against a number> to an if statement. Is there any limit on the number of expressions/conditions...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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...

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.