Testing for an empty WYSIWYG field
Testing whether a WYSIWYG field is empty is tricky, because the field can contain either plain text or HTML elements. The reliable approach is to test whether the XML element's value is non-empty or the element has children, meaning HTML elements.
Velocity, with the Cascade API
Velocity
## Record the WYSIWYG field
#set ($wysiwygField = $callingPage.getStructuredDataNode("wysiwyg-field"))
## Test whether the field has a value
#if (!$_PropertyTool.isEmpty($wysiwygField.textValue))
$wysiwygField.textValue
#end
Velocity, with an Index Block
Velocity
## Record the WYSIWYG field
#set ($wysiwygField = $_XPathTool.selectSingleNode($contentRoot, "//wysiwyg-field"))
## Test whether the element has a value, or has children
#if ($wysiwygField.value != "" || $wysiwygField.getChildren().size() > 0)
$_SerializerTool.serialize($wysiwygField, true)
#end
XSLT
XML
<xsl:if test="wysiwygField/node()">
<!-- use xsl:copy-of so all child nodes and attributes are copied as well -->
<xsl:copy-of select="wysiwygField/node()"/>
</xsl:if>