W3C home > Mailing lists > Public > www-xsl-fo@w3.org > May 2008

Re: How can I not include empty elements?

From: Mark Lundquist <ml@wrinkledog.com>
Date: Wed, 14 May 2008 06:21:42 -0700
Cc: www-xsl-fo@w3.org
Message-Id: <DF76471A-1AB0-4EAB-816B-48FB7165C5DB@wrinkledog.com>
To: jlr <jean.stachler@crown.com>


On May 14, 2008, at 5:50 AM, jlr wrote:

> I have an XML document that will display the elements as shown below.
> Basically, the elements are a subset of the <row> tag.  The elements
> will always have the tag names of column1, column2, column3, and  
> column4.
> As shown in the example below, some of the tag names column1, etc. may
> have elements, and some of the tag names for column1, etc. may be  
> empty
> elements.  I have only given one listing of empty elements, but this  
> could
> be up to
> 50 empty elements.  When creating the PDF document in xslt, is there  
> a way
> of  removing
> the empty elements so that they won't display?
> I have the xslt code after the xml detail.

Okay, first of all you should be doing this, e.g.:

	<xsl:apply-templates select="column1"/>

instead of

	<xsl:value-of select="column1"/>

Once you have fixed that, then just add this template:

	<xsl:template match="row/*[not (normalize-space (.))]"/>	<!-- kill  
empty columns -->


HTH,
—ml—
Received on Wednesday, 14 May 2008 13:22:19 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 14 May 2008 13:22:19 GMT