users@jaxb.java.net

Re: Empty tag for null value

From: Wolfgang Laun <wolfgang.laun_at_gmail.com>
Date: Tue, 13 Sep 2011 19:12:01 +0200

IIRC, XML defines that <firstname/> is the same as
<firstname></firstname> and this is marshalled from firstname being
equal to "", i.e., the empty string.
-W

2011/9/13 Prêtre Thierry <shiftane_at_gmail.com>:
> Hello everybody,
> i use JAXB to marshall a bean in an XML and i've a xsd to validate it.
> I've one field in my bean called for example "firstname" and in the xsd this
> field is in minoccurs=1. By this case, if a set firstname to null then i've
> have validation error.
> Y tried to modified manually the output validated and i've inserted the tag
> :
> <firstname/>
> -- without value
> and the validation pass.
> So how can i create the empty tag when i've "null" in the value ?