How to: conditionally display an element in XML during exec

If you have a new question you’d like our support staff to post a response to, please visit our customer community, GoAnywhere Insiders, to pose the question in our Discussion Boards. We have a thread “Ask Our Tech Experts” that our support team monitors on a regular basis, or you can start a new discussion where other GoAnywhere users and support staff can weigh in. Log in or create your new account at https://insiders.goanywhere.com.

If you need an immediate response, please create a support ticket 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