XStream
  1. XStream
  2. XSTR-344

Allow convert element with string body and attributes

    Details

    • Type: New Feature New Feature
    • Status: Closed Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.2.1
    • Fix Version/s: 1.4
    • Component/s: None
    • Labels:
      None
    • JDK version and platform:
      JDK 1.5_08 for Windows XP

      Description

      I found a thread about "convert element with string body and attributes" in user mail list(http://article.gmane.org/gmane.comp.java.xstream.user/2349), but it seems that no one fire an issue here.

      I have a class like this:
      class Dely {
      public String code;
      public String content;
      }

      I use it like this:
      public static void main(String ...strings) {
      XStream xstream = new XStream();
      xstream.alias("dely", Dely.class);
      xstream.useAttributeFor("code", String.class);

      //xstream.setDefaultContent("content", Dely.class);

      Dely d = new Dely();
      d.code = "abc";
      d.content = "Hello";

      System.out.println(xstream.toXML(d));
      }

      I would like the output xml as following:
      <dely code="abc">Hello</dely>

        Issue Links

          People

          • Assignee:
            Jörg Schaible
            Reporter:
            jian liao
          • Votes:
            3 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: