Page 1 of 1

How to: conditionally display an element in XML during exec

Posted: Thu Jan 21, 2016 7:59 pm
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?

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

Posted: Fri Jan 22, 2016 12:21 pm
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?

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

Posted: Tue Mar 22, 2016 5:23 pm
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>