469,140 Members | 1,164 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,140 developers. It's quick & easy.

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 2167
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Andrea Maschio | last post: by
2 posts views Thread by Jørn Tommy Kinderås | last post: by
3 posts views Thread by Eric Theil | last post: by
5 posts views Thread by Luke Vogel | last post: by
1 post views Thread by Fred | last post: by
4 posts views Thread by Doulos05 | last post: by
4 posts views Thread by grbeal | last post: by
3 posts views Thread by z1 | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Mortomer39 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.