Issue Type: Bug Bug
Affects Versions: 1.4.4
Assignee: Jörg Schaible
Components: Converters
Created: 21/Sep/13 10:54 PM
Description:

Great product, but you already know that...

Note the 1 underscore changed to 2 underscores. I tried to use the alias to fix it but it had no effect.

class:
public class Gallery {
private String title;
private String description;
private String file_root;
private String thumb_src;
private ArrayList<GImage> images = new ArrayList();

public void Gallery () {
}

code to generate xml:
public void saveGalleryToFile(File file) {
XStream xstream = new XStream();
xstream.alias("gallery", Gallery.class);
xstream.alias("image", GImage.class);
xstream.aliasField("file_root", Gallery.class, "file__root");
xstream.aliasField("thumb_src", Gallery.class, "thumb__src");
xstream.aliasField("image_src", GImage.class, "image__src");
xstream.aliasField("thumb_src", GImage.class, "thumb__src");
xstream.omitField(GImage.class, "remove");

// Convert ObservableList to a normal ArrayList
ArrayList<Gallery> galleryList = new ArrayList<>(galleryData);

String xml = xstream.toXML(galleryList);

Sample output:
<list>
<gallery>
<title></title>
<description></description>
<file_root>C:\Simple</file_root>
<thumb_src>\thumbs\IMG_1849.jpg</thumb_src>
<images>
<image>
<title>Title #0</title>
<description>Description #0</description>
<image_src>\images\IMG_1848.jpg</image_src>
<thumb_src>\thumbs\IMG_1848.jpg</thumb_src>
</image>

Project: XStream
Priority: Minor Minor
Reporter: William Ingram
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Reply via email to