XSL:IF and OR

  • Thread starter =?ISO-8859-1?Q?J=F8rn_Tommy_Kinder=E5s?=
  • Start date
?

=?ISO-8859-1?Q?J=F8rn_Tommy_Kinder=E5s?=

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
 
L

Larry Marburger

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
 
?

=?ISO-8859-1?Q?J=F8rn_Tommy_Kinder=E5s?=

Larry Marburger said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
SterlingLa
Top