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

xsl:if problems

Ok, this seems like it should be easy, but it has escaped me. Here is
my xml file:


<description>TAB DIVIDERS</description>
<note>Description of problem here</note>

<description>Diploma/Certificate Folders</description>
<note>description of problem here. </note>


Here is the stylesheet:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/
<xsl:output method="html"/>

<xsl:template match="/">
<input type="button" value="Close this window" onclick="self.close()"/

<xsl:template match="ref_sheet">
<table border="1">
<th align="center">Date</th><!--Column 1-->
<th align="center">Product ID</th><!--Column 2-->
<th align="center">Product Description</th><!--Column3-->
<th align="center">Notes</th><!--Column4-->
<th align="center">expired</th><!--Column5-->

<xsl:template match="item">
<xsl:if test="expired = false">
<td><xsl:copy-of select="date"/></td>
<td><xsl:copy-of select="product"/></td>
<td><xsl:copy-of select="description"/></td>
<td><xsl:copy-of select="note"/></td>
<td><xsl:copy-of select="expired"/></td>

This is being transformed client-side using MSXML in IE 6.x. It won't
correctly process the if statement. What I want it to do is only
display the items which are not expired (for which expired = false).
What it does is give me the table header row, but it does not return
any of the non-expired items.

May 3 '07 #1
4 2943
Doulos05 wrote:
<xsl:if test="expired = false">
<xsl:if test="expired = 'false'">


Martin Honnen
May 3 '07 #2
Doulos05 wrote:
<xsl:if test="expired = false">
So you want your XSLT processor to interpret 'expired' as a
name of an element but 'false' as a string literal? How the
hell is it supposed to know the difference?

<xsl:if test="expired='false'">

What you wrote does something else entirely.

Note that the expression given wouldn't work for


unless you use <xsl:strip-space/>.

Figuring out what

<xsl:if test="expired=false()">

would do is left as an exercise for the reader. Reading a
good XSLT/XPath tutorial is strongly recommended before you
start tinkering.
What I want it to do is only display the items which are
not expired (for which expired = false). What it does is
give me the table header row, but it does not return any
of the non-expired items.
Think before you type.

roy axenov
May 3 '07 #3
The node itsself will never equal "false", you want to see if it's
text content equals "false".

<xsl:if test="expired/.=false">

An alternate technique would be to only include the expired tag
<expired/if the item was expired, leaving it out if the item
wasn't. Then just test for the presence of the tag.

<xsl:if test="expired">

I'm no expert either, but I would give these two approaches a try.

Good luck,


May 3 '07 #4
Yeah, I figured it was something obvious. Should have caught on to
that, but I wasn't thinking enough like a programmer. I couldn't
figure it out.

On a related note, I'm still kind of new to this whole programming
thing, so if anyone has any good suggestions for tutorials or examples
for XML, I would welcome the advice. I have been using the W3C schools
tutorials (which never uses <xsl:ifto test against a string literal,
which is why it didn't cross my mind that the string needed to be in
quotes) but I'll go anywhere for good information. Thank you for the
fix and advice.

Jonathan B.

May 4 '07 #5

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

Similar topics

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...
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>...
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"/>...
by: Jørn Tommy Kinderås | last post by:
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>
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...
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...
by: mark4asp | last post by:
I'm getting a problem with this code and I think the offending linke is : <xsl:if test="$folder = 'Search'"> I want to test the value of the Folder element for a value of precisely "Search"...
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...
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...
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...
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
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...
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
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...
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: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.