Missing borders on an empty cell

Here should go questions about transforming XML with XSLT and FOP.
ajtruckle
Posts: 1
Joined: Wed Nov 04, 2015 6:31 pm

Missing borders on an empty cell

Post by ajtruckle »

Code: Select all

<td class="borderDotName">
<xsl:value-of select="Label1"/>
</td>
Hi
If the "Label1" value in the XML is not empty then the cell looks OK in the browser. But if it is empty and have no text, then the borders of my cell are missing. How can I handle empty cells?

Thanks.

Andrew
Radu
Posts: 9049
Joined: Fri Jul 09, 2004 5:18 pm

Re: Missing borders on an empty cell

Post by Radu »

Hi Andrew,

It probably depends on how the final HTML content looks like in the case of the missing value.
If the final HTML has the table cell looking like this: <td/> web browsers might have problems with it.
Ideally you could set <xsl:output method="html"/> in your XSLT stylesheet or add an XML comment inside the XSLT like:

Code: Select all

                <td class="borderDotName">
<xsl:choose>
<xsl:when test="$Label1">
<xsl:value-of select="$Label1"/>
</xsl:when>
<xsl:otherwise>
<xsl:comment>Empty CEll</xsl:comment>
</xsl:otherwise>
</xsl:choose>
</td>
to avoid having in the final HTML the <td> serialized in the short <td/> form.

More about this here:

http://www.w3.org/TR/xhtml1/guidelines.html

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply