xstream

XStream short dynamic aliases

I want to have short names for classes, now i can do it with aliases XStream x = new XStream(); x.alias("dic", Dic.class); but i have to define alias manually for every class, is there any way to configure xstream to do it automatically? ...

XStream failing when & present in the XML document

Hi , I am using xStream for serializing and de-serializing objects. But when there is "&" present for any of the tag values , xStream is failing and throwing excpetion. for e.g. this fails.. <tag>value & value</tag> Exception :- "An entity name must immediately follow..." <tag>value value</tag> this passes Is there any way to tell...

XStream or Simple

I need to decide on which one to use. My case is pretty simple. I need to convert a simple POJO/Bean to XML, and then back. Nothing special. One thing I am looking for is it should include the parent properties as well. Best would be if it can work on super type, which can be just a marker interface. If anyone can compare these two wi...

Suitable XML Marshaller and Unmarshaller

Hi. We have an XML that needs to be converted to an object and vice versa. Something like Xstream does. Until now we were using Xstream to marshall and unmarshall the object/xml. However the problem is that an object that corresponds to XML in xstream, needs to have all the tags as attributes; else if XML contains any extra tags which ...

XStream, CircularReferenceException

Please consider this code. Is it using Circular Reference? If not why am I getting CircularReferenceException, while enabling NO_REFERENCE mode in XStream. Anyone, please clarify the thing. @XStreamAlias("BalanceEnquiry") public class BalanceEnquiry extends EAIRequest { @XStreamImplicit private List<BalanceEnquiry.Detail> detai...

XStream : node with attributes and text node?

Hi, I would like to serialize an object to an XML of this form with XStream. <node att="value">text</node> The value of the node (text) is a field on the serialized object, as well as the att attribute. Is this possible without writing a converter for this object? Thanks! ...

XStream serializing collections

I have a class structure that I would like to serialize with Xstream. The root class contains a collection of other objects (of varying types). I would like to only serialize part of the objects that are stored in the collection (primarily their IDs, and not the remaining contents of each element). Anyone have an idea of how I might go...

XStream avoid collection xml element

Given a List of POJO's, if I serialize them with XStream I get: <list> <pojo> <a>a</a> <b>b</b> </pojo> <pojo> <a>a</a> <b>b</b> </pojo> </list> How can I do the serialization and omit the <list> </list> entries? I've used addImplicitCollection for a similar purpose but that was to omit the collection inst...

Is pretty XStream serialization feasible with Scala?

I'm trying out XStream as a way to quickly serialize objects to Xml or JSON to send over the wire, and deserialize. I do want the XML/JSON to be simple/clean. It seems to work well, I've added a few aliases, but now I've hit a problem, this code: println(new XStream.toXML(List(1,2,3))) produces this XML: <scala.coloncolon serializa...

How can I get XStream to output Scala lists nicely? Can I write a custom converter?

This code: println(new XStream.toXML(List(1,2,3))) produces this XML: <scala.coloncolon serialization="custom"> <unserializable-parents/> <scala.coloncolon> <int>1</int> <int>2</int> <int>3</int> <scala.ListSerializeEnd/> </scala.coloncolon> </scala.coloncolon> Instead I'd like this: <list> <int>1</int> <...

Self closing tags with XStream?

Is there a way to get XStream to generate self closing elements? E.g. <foo/> instead of <foo></foo> ...

customising serialisation of java collections using xstream

I have an object that needs to be serialised as XML, which contains the following field: List<String> tags = new List<String>(); XStream serialises it just fine (after some aliases) like this: <tags> <string>tagOne</string> <string>tagTwo</string> <string>tagThree</string> <string>tagFour</string> </tags> That's OK as far a...

xstream > backwards compatibility when making an abstraction in the model

I have class A { @xstreamalias("obj1"); Object obj1; @xstreamalias("obj2"); Object obj2; } and I want to change to class AbstractA { @xstreamalias("obj1"); Object obj1; } class A extends AbstractA{ @xstreamalias("obj2"); Object obj2; } without loosing the contents of obj1. currently I have no trouble read...

How to use EnumSingleValueConverter with XStream?

I am trying to serialize a List which looks as follows: public class Comp { public enum TYPE { Type1, Type2, Type3 }; public Type type; So, I create a list of these like this: Comp a = new Comp(); a.type = Type.Type1; Comp b = new Comp(); b.type = Type.Type2; List<Comp> list = new List<Comp>(); li...

Best approach to serialize XML to stream with Java?

We serialize/deserialize XML using XStream... and just got an OutOfMemory exception. Firstly I don't understand why we're getting the error as we have 500MB allocated to the server. Question is - what changes should we make to stay out of trouble? We want to ensure this implementation scales. Currently we have ~60K objects, ea...

Xstream: Implicitly ignoring all fields

How do I tell Xstream to serialize only fields which are annotated explicitly and ignore the rest? I am trying to serialize a hibernate persistent object and all proxy related fields get serialized which I don’t want in my xml. e.g. <createdBy class="com..domain.Users " reference="../../values/createdBy"/> is not something I wan...

Xstream: removing class attribute

How do I remove the class=”Something ” attributes in Xstream . I use Xstream with annotations ...

MarshallingView in Spring to adjust output?

I have some POJOs which are the basis for this RESTful API I am working on. However, some of the responses I need to include some other information to make the API more complete. I really don't want to put these extra information in the POJO, but include it at the web service layer as if it were. It deals with "People" who have "Appoin...

XStream: Collapsing XML hierarchy as I parse

I have an XML document (generated by Adobe XFA forms), that contains data like the following: <Position> <PositionBorder> <Title/> <StartDate/> <EndDate/> </PositionBorder> </Position> Since this file is defined elsewhere, I am not at liberty to change the format of the XML that I get. In my Java code, I cr...

Default value from DTD in xStream.

Geven XML file <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE ExternalRequestContext [ <!ELEMENT ExternalRequestContext EMPTY> <!ATTLIST ExternalRequestContext requestType CDATA #REQUIRED deepEnrichment (true | false) "false" channelMandatory (true | false) "true"> ] > <ExternalRequestContext requestType="News" deepEnrichment="fal...