[stringtemplate-interest] xml rendering problem

Oliver Flege o.flege at market-maker.de
Wed Dec 29 23:56:21 PST 2010


Hi,

I use ST for xml rendering and run into the following problem:

ST st = ...
Boolean foo = getFoo(); // foo may be Boolean.TRUE, Boolean.FALSE, or null
st.add("foo", foo);

and the template needs to render

<foo>true</foo> or <foo>false</foo> if foo is defined, or

<foo xsi:nil="true"/> if foo is null

How can I express that in a template?

$if(foo)$
<foo>$foo$</foo>
$else$
<foo xsi:nil="true">
$endif$

does not work as false and null are both evaluated to false in the if statement.
Is there a specific test for null values?

Oliver


More information about the stringtemplate-interest mailing list