History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: XSTR-283
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Assignee: Unassigned
Reporter: Joerg Schaible
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
XStream

Implicite Collections lead to wrong reference in plain XML text

Created: 07/Mar/06 04:02 PM   Updated: 31/Jul/06 05:29 PM
Component/s: None
Affects Version/s: None
Fix Version/s: 1.2

Issue Links:
Related
 


 Description  « Hide
If the implicit collection should be referenced, XStream cannot build a valid reference:

    static class WithNamedList extends WithList {
        private final String name;

        public WithNamedList(final String name) {
            this.name = name;
        }
    }

    public void testReferenceByXPathWorksWithReferencedImplicitCollection() {
        xstream.alias("strings", WithNamedList.class);
        xstream.addImplicitCollection(WithNamedList.class, "things");
        WithNamedList[] wls = new WithNamedList[]{new WithNamedList("foo"), new WithNamedList("bar")};
        wls[0].things.add("Hello");
        wls[0].things.add("Daniel");
        wls[1].things = wls[0].things;
        String xml = xstream.toXml(wls);
        System.out.println(xml);
    }


<strings-array>
  <strings>
    <name>foo</name>
    <string>Hello</string>
    <string>Daniel</string>
  </strings>
  <strings>
    <name>bar</name> reference="../strings"
  </strings>
</strings-array>


 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Joerg Schaible - 07/Mar/06 04:05 PM
A HierarchicalStreamWriter cannot reference a non-existing element. Both issues lack of this (obvious) incapability. We must find a general workaround for referenced implicit collections.

Joerg Schaible - 15/Mar/06 03:13 PM
Any attempt to reference an implicit element results now in a ConverterException.

Guilherme Silveira - 31/Jul/06 05:23 PM
moving to 1.2