Hi Geoffrey, Geoffrey De Smet wrote:
> I am using Xstream instance with ID_REFERENCES (because need those > further down the xml file). > > I read an XML format like this: > > <benchmark> > <solver> > <entityClass>org.foo.Bar</entityclass> > </solver> > <solver> > <entityClass>org.foo.Bar</entityclass> > </solver> > <benchmark> > > When I try to write it, I get different output: > > <benchmark> > <solver> > <entityClass id="7">org.foo.Bar</entityclass> > </solver> > <solver> > <entityClass ref="7"/> > </solver> > <benchmark> > > My model looks like this: > > @XstreamAlias("solver") > class Solver { > > @XstreamAlias("entityClass") > Class<?> entityClass; > > } > > How do I make my write format the same as my read format? XStream adds the id attribute to any element in this mode, unless the instance's type has been declared as immutable. Actually this is possible for type "Class", maybe XStream should do it for Class by default anyway: xstream.addImmutableType(Class.class); > ========== > Second question (more advanced form) > ========== > > Actually, my entity model looks like this: > > @XstreamAlias("solver") > class Solver { > > @XStreamImplicit(itemFieldName = "entityClass") > protected List<Class<?>> entityClassList; > > } > > The XML input is the same. > During XML output it throws "ReferencedImplicitElementException: Cannot > reference implicit element" > because it uses refs for the Class fields. No, it is thrown because something references the entire list, which has no representation in XML. > I 'd like it not to use id-references for those fields to avoid that > exception. Will not make a difference. Cheers, Jörg --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email