This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Printing Null Values with XSLT
- To: "'xsl-list at mulberrytech dot com'" <xsl-list at mulberrytech dot com>
- Subject: RE: Printing Null Values with XSLT
- From: "Reich, Eric" <ereich at techtrader dot com>
- Date: Fri, 13 Oct 2000 09:17:32 -0400
- Reply-To: xsl-list at mulberrytech dot com
Wow!! Mike, I can't believe you responded to my question. I have your
book (just purchased two weeks ago) and to have you reply to my question
has me star struck! So, many thanks for responding!
Anyway...my problem stems from an XML document that has 3 attributes
with 3 values. My ultimate goal is to display the output in a table
using HTML. Now, at various points throughout my XML document these
same attributes and values appear; thus, my output in HTML will have
multiple tables. But, at some points in the XML document, the attributes
have no value at all (ie, Abstract=" " or Name=" "). They way I have
my HTML is like the following:
<TABLE border="1">
<TR>
<xsl:for-each select="ATTRIBUTE">
<TD>
<TABLE border="1">
<TR>
<TH>
<xsl:value-of select="NAME"/>
</TH>
</TR>
<TR>
<TD>
<xsl:value-of select="VALUE"/>
</TD>
</TR>
</TABLE>
</TD>
</xsl:for-each>
</TR>
</TABLE>
The output is as follows:
Row1: Name Default Abstract
Row2: ProductId true
Now, what I want to happen is to add some XSLT language that would
be able to not print, say, a Default column if, and only if, there
is no value associated it to it. If it does find it, then it prints
it. Does that makes sense? So, in the above scenario, the Default
column would not be seen in the browser.
I will try to test what you provided me here. I will also look in
your book for additional information.
Many thanks, Mike!!!
Eric
-----Original Message-----
From: Kay Michael [mailto:Michael.Kay@icl.com]
Sent: Friday, October 13, 2000 5:12 AM
To: 'xsl-list@mulberrytech.com'
Subject: RE: Printing Null Values with XSLT
> The Scene: On row1, I have these headers: Name,
> Default, Abstract,
> Description
> On row2, I have these datas:
> Prods, ,
> true , The Prods Number
>
> The Problem: I want to ad XSLT language to my HTMLout.xsl
> file that will query the values (shown
> as the datas above) and, if it finds
> an empty value, then the system will print nothing
> for that specific data.
>
> The Solution:
What do you want it do do if it DOESN'T find an empty value?
Normally <xsl:value-of select="Description"/> will achieve the required
effect.
Or try something like:
<xsl:choose>
<xsl:when test="Description">... do something ...</xsl:when>
<xsl:otherwise><!-- do nothing --></xsl:otherwise>
</xsl:choose>
Mike Kay
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list