jaxb - Nillable on @XmlAnyElement -
i made general class plural elements jaxb.
@xmltransient public abstract class plural<s> { @xmlanyelement(lax = true) private collection<s> singulars; }
with following classes,
@xmlrootelement public class item { //@xmlvalue // problem xsi:nill , "" @xmlelement(nillable = true) private string name; } @xmlrootelement public class items extends plural<item> { }
when declare name
@xmleement(nilalble = true)
, works fine. @xmlvalue
makes problem between xsi:nil
, ""
.
is there way set nillable = true
on @xmlanyelement
?
update ----------------------------------------------------------
when item#name
annotated @xmlelement
, following xml marshalls , unmarshalls successfully.
<items xmlns="http://jinahya.googlecode.com/xml/bind/test"> <item id="-4939700912221365683"> <name xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:nil="true"/> </item> <item> <name>name</name> </item> <item> <name xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:nil="true"/> </item> <item id="-8544902644460968391"> <name xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:nil="true"/> </item> <item id="525642804765733165"> <name xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:nil="true"/> </item> </items>
when item#name
annotated @xmlvalue
, following output xml marshalls , unmarshals failed on equality testing.
<?xml version="1.0" encoding="utf-8" standalone="yes"?> <items xmlns="http://jinahya.googlecode.com/xml/bind/test"> <item id="7812630870400466385">name</item> <item>name</item> <item id="-1067677982428177088"/> <item id="5609376399324841172">name</item> <item id="-4755856949417090129"/> </items>
which seems xsi:nil
omitted on each item
element. item#equals
failed on each items. ""
without xsi:nill
parsed empty element witch each came null
s. @xmlvalue
's problem? @blaise doughan learned @xmlanyelement(lax = true)
blog entry anyway. thanks.
Comments
Post a Comment