473,221 Members | 1,992 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,221 software developers and data experts.

XSL:IF and OR

I need to get nodes in a xml file that match one out of two
parameters...but how can I create a or statemement with <xsl:if>?

E.G
---xml--
...
<movie>
<title>T2</title>
</movie>
<movie>
<title>Bone Collector</title>
</movie>
...
---xslt---
<xsl:parameter name="myPar1"/>
<xsl:parameter name="myPar2"/>
.....
<xsl:for-each select="topnode/movie">
<xsl:if test="(title = $myPar1) OR (title = $myPar2)"> <---------
--do something
</xsl:if>
</xsl:for-each>
------------------------------
I want something like the above, but it has to check ALL of the
parameters for every title in the xml file.

Any ideas?

Jørn T
Jul 20 '05 #1
2 10765
Jørn,

I have the following test XML and XSLT documents:

*<xml>*
<root>
<node id="1">text 1</node>
<node id="2">text 2</node>
<node id="3">text 3</node>
</root>
*</xml>*

*<xslt>*
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/root">
<xsl:for-each select="node">
-<xsl:value-of select="@id" />-<br/>
<xsl:if test="@id = '1' or @id = '2'">
###<xsl:value-of select="." />###<br/><br/>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
*</xslt>*
When transformed, it produces the following results:

*<results>*
-1-
###text 1###

-2-
###text 2###

-3-
*</results>*
Is this what you're looking for?
- Larry
Jørn Tommy Kinderås wrote:
I need to get nodes in a xml file that match one out of two
parameters...but how can I create a or statemement with <xsl:if>?

E.G
---xml--
..
<movie>
<title>T2</title>
</movie>
<movie>
<title>Bone Collector</title>
</movie>
..
---xslt---
<xsl:parameter name="myPar1"/>
<xsl:parameter name="myPar2"/>
....
<xsl:for-each select="topnode/movie">
<xsl:if test="(title = $myPar1) OR (title = $myPar2)"> <---------
--do something
</xsl:if>
</xsl:for-each>
------------------------------
I want something like the above, but it has to check ALL of the
parameters for every title in the xml file.

Any ideas?

Jørn T


Jul 20 '05 #2
Larry Marburger <no@spam.com> wrote:
Jørn,
<*snip*>
Is this what you're looking for?

Yea, looks like it's the newline char that gets passed with the
parameters that makes the xsl:if stop working. I guess that "Test" is
not the same as "Test\n".

Jørn T
Jul 20 '05 #3

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

Similar topics

1
by: LisaDi | last post by:
Hi, In my XML file, I have multiple 'Job' nodes. Within that node, there is an 'Award' item. Not every job has an 'Award' populated. :-( When I output this in XSL, I would like to use an IF...
3
by: Lizard | last post by:
OK, total newbie here, so this may be a mind-numbingly dumb question AND I may be phrasing it badly. I have an xsl:template which looks like this: <xsl:template match="LoanRecord"> <hr>...
9
by: Andrea Maschio | last post by:
Hi, i have a terrible noobie frustration formatting an XML file like this: <Dipendente Id="1" Anno="2003" Nome="pippo" Cognome="pippi" Nato_il="10/03" Email="pippo@emailprovider.it" Esito="ok"/>...
3
by: Eric Theil | last post by:
I'm at my wit's end with this one. Within an xsl:if test, I'm not able to get 2 variables to properly evaluate if one of them is wrapped within a string function. <!-- This works --> <xsl:if...
5
by: Luke Vogel | last post by:
Hi all, Probably a really basic question, but I cant find an answer ... I have an xml file of books something like: <product> <isbn>0-735-61374-5</isbn> <title>Microsoft Visual Basic Step By...
1
by: Fred | last post by:
Hi, I am using XSL if to look and see if a node exists and if so display it with a header (see below). Some of the xml I transforming has nodes like this <Test /and it shows up in my html...
4
by: Doulos05 | last post by:
Ok, this seems like it should be easy, but it has escaped me. Here is my xml file: <ref_sheet> <item> <date>2007/04/06</date> <product>124567</product> <description>TAB...
4
by: grbeal | last post by:
How do I test for a child element with xsl if condition? We have a vendor application that outputs an XML file containing records of School Closings due to inclement weather. That XML file gets...
3
by: z1 | last post by:
hi- i am fooling around with soap and weather templates. for some reason either this if or select is failing. i am very new to xml and found this code at another site. i can show you the xml...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.