I've been having problems with setting <null> values in XML.
Here is an example:
<map>
<entry key="1" value-ref="ref1" />
<entry key="2"><null /></entry>
<entry key="3" value-ref="ref2" />
<entry key="4" value-ref="ref3" />
</map>
At the moment, the BeanFactory generated will set the <null /> value
as the empty String ("").
I've hacked at two classes to 'fix' this, but not sure if this is the
correct way:
public interface LiteralSource extends Source {
// NEW
boolean isNull();
}
public class MutableStringValueSource extends AbstractTyped implements
LiteralSource, MutableSource {
// NEW
public boolean isNull() {
return null == value;
}
}
And now the context.stg template looks like this:
sourceStringRepresentation(type,source) ::= <<
<if (!source.null)>
<(stringConversion.(type))(source=source)>
<else>
null
<endif>
>>
Does anyone have any comments on this approach? Cheers.
Paul.