Skip to content

How to: conditionally display an element in XML during exec

Post any question you may have in regards to GoAnywhere MFT and let our talented support staff and other users assist you.
If you need a quicker response, please create a support ticket via the customer portal my.goanywhere.com or contact our support team by email at [email protected].
  • john_a Offline
  • Posts: 9
  • Joined: Tue Nov 03, 2015 5:35 pm

How to: conditionally display an element in XML during exec

Post by john_a »

I am generating XML from data returned from a SQL Query. Unfortunately, I see no way to not display an element that has a null value for some records and not others. I currently have a data set returned from a select statement that may or may not have nulls in some columns.

Is there anyway to conditionally display an element in XML during execute?
  • john_a Offline
  • Posts: 9
  • Joined: Tue Nov 03, 2015 5:35 pm

Re: How to: conditionally display an element in XML during

Post by john_a »

Okay, I did find a way to do this. The "Skip if Empty" drop down option on the element. However this only works if the element has no children which would be fine were it not for the fact that I need to generate an element with an attribute.

This does not work -
<element name="custom-attribute" value="${data[9]}" skipIfEmpty="true">
<attribute name="attribute-id" value="MetalType" />
</element>

How do I get this to work?
  • john_a Offline
  • Posts: 9
  • Joined: Tue Nov 03, 2015 5:35 pm

Re: How to: conditionally display an element in XML during

Post by john_a »

Please note: Neither of these will work as they both return syntax errors.

Code: Select all

        <element name="custom-attributes">
	<if test="${IsNotEmpty(data[7])}">
		<element name="custom-attribute" value="${data[7]}">
		<attribute name="attribute-id" value="accentStone" />
		</element>
	</if>
	<element name="custom-attribute" value="${data[8]}" skipIfEmpty="true">
	<attribute name="attribute-id" value="accentStoneColor" />
	</element>
Post Reply