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].
3 posts Page 1 of 1

john_a

Posts: 9
Joined: Tue Nov 03, 2015 5:35 pm

Post by john_a » Thu Jan 21, 2016 7:59 pm
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

Posts: 9
Joined: Tue Nov 03, 2015 5:35 pm

Post by john_a » Fri Jan 22, 2016 12:21 pm
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

Posts: 9
Joined: Tue Nov 03, 2015 5:35 pm

Post by john_a » Tue Mar 22, 2016 5:23 pm
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>
3 posts Page 1 of 1