XStream
  1. XStream
  2. XSTR-283

Implicite Collections lead to wrong reference in plain XML text

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.2
    • Component/s: None
    • Labels:
      None

      Description

      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>

        Issue Links

          People

          • Assignee:
            Unassigned
            Reporter:
            Jörg Schaible
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: