Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 367795

Summary: Chained @XmlValue properties not working correctly
Product: z_Archived Reporter: Blaise Doughan <blaise.doughan>
Component: EclipselinkAssignee: Nobody - feel free to take it <nobody>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: eclipselink.oxm-inbox
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
MOXy - Test Cases
none
Core - Fix none

Description Blaise Doughan CLA 2012-01-03 16:12:53 EST
Issue sent in via email:

In the RI, the output element has the value of the inner text.  In MOXy I get a rather strange output:

<top><middle><text()>Some Value</text()></middle></top>

When I’m expecting

<top><middle>Some Value</middle></top>

In this case I have the following three classes:

@XmlRootElement
public class Top {

  @XmlElement
  public Middle middle;

  public String toString() {
    return "Top(" + middle + ")";
  }

}

public class Middle {

  @XmlValue
  public Bottom bottom;

  public String toString() {
    return "Middle(" + bottom + ")";
  }

}

public class Bottom {

  @XmlValue
  public String value;

  public String toString() {
    return "Bottom(" + value + ")";
  }

}

And the following testing harness:

    JAXBContext c = JAXBContext.newInstance(Top.class);
    System.err.println(c.getClass());
    Marshaller m = c.createMarshaller();

    Top t = new Top();
    t.middle = new Middle();
    t.middle.bottom = new Bottom();
    t.middle.bottom.value = "Some Value";

    FileOutputStream out = new FileOutputStream("c:\\temp\\t.xml");
    m.marshal(t, out);
    out.close();

    Unmarshaller u = c.createUnmarshaller();
    Top tu = (Top) u.unmarshal(new File("c:\\temp\\t.xml"));
    System.err.println(tu);
Comment 1 Blaise Doughan CLA 2012-01-03 16:17:24 EST
Created attachment 208964 [details]
MOXy - Test Cases
Comment 2 Blaise Doughan CLA 2012-01-03 16:17:59 EST
Created attachment 208965 [details]
Core - Fix
Comment 3 Blaise Doughan CLA 2012-01-10 13:17:06 EST

*** This bug has been marked as a duplicate of bug 368283 ***
Comment 4 Eclipse Webmaster CLA 2022-06-09 10:21:27 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink