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

XSL:IF

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 statement to
only print the Award row if it's not blank. (I'd like to format this
with a list item, and not have a list item display w/o any data by
it.)

Can someone please point me in the direction of some tutorials/syntax
help for this? I've seen a few snippets of code for checking for the
position of an item, but not for if > 0.

Thanks!
Lisa

==== XML ====

<Job>
<Date_Worked>a</Date_Worked>
<Position_Title>b</Position_Title>
<Comp>
<Comp_Name>
<Comp_1>c</Comp_1>
<Comp_2>e</Comp_2>
</Comp_Name>
<Comp_City>Chicago</Comp_City>
<Comp_St>IL</Comp_St>
</Comp>
<Award>Employee of the Month</Award>
<Job_Desc>blah</Job_Desc>
</Job>

==== XSLT ====
<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="Work_History">...
....
....
....
<xsl:for-each select="Work_Exp/Job">
<tr>
<td width="23%" colspan="2" valign="top" align="left">
<b><xsl:value-of select="Position_Title"/></b><br/>
<xsl:value-of select="Date_Worked"/>
</td>
....
....
....

<!-- NEED IF HERE -->
<tr><td width="100%" colspan="6" valign="top" align="left">
<xsl:value-of select="Award"/>
</td>
</tr>

</xsl:for-each>
Jul 20 '05 #1
1 2325
If I understand you correctly, it should be as simple as

<xsl:if test="Award">

Andy

"LisaDi" <li********@hotmail.com> wrote in message
news:17**************************@posting.google.c om...
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 statement to
only print the Award row if it's not blank. (I'd like to format this
with a list item, and not have a list item display w/o any data by
it.)

Can someone please point me in the direction of some tutorials/syntax
help for this? I've seen a few snippets of code for checking for the
position of an item, but not for if > 0.

Thanks!
Lisa

==== XML ====

<Job>
<Date_Worked>a</Date_Worked>
<Position_Title>b</Position_Title>
<Comp>
<Comp_Name>
<Comp_1>c</Comp_1>
<Comp_2>e</Comp_2>
</Comp_Name>
<Comp_City>Chicago</Comp_City>
<Comp_St>IL</Comp_St>
</Comp>
<Award>Employee of the Month</Award>
<Job_Desc>blah</Job_Desc>
</Job>

==== XSLT ====
<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="Work_History">...
...
...
...
<xsl:for-each select="Work_Exp/Job">
<tr>
<td width="23%" colspan="2" valign="top" align="left">
<b><xsl:value-of select="Position_Title"/></b><br/>
<xsl:value-of select="Date_Worked"/>
</td>
...
...
...

<!-- NEED IF HERE -->
<tr><td width="100%" colspan="6" valign="top" align="left">
<xsl:value-of select="Award"/>
</td>
</tr>

</xsl:for-each>

Jul 20 '05 #2

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

Similar topics

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"/>...
2
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>
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.