Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 368283 - Unsupported @XmlValue Use Cases
Summary: Unsupported @XmlValue Use Cases
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 367323 367795 (view as bug list)
Depends on:
Blocks: 369723
  Show dependency tree
 
Reported: 2012-01-10 13:16 EST by Blaise Doughan CLA
Modified: 2022-06-09 10:33 EDT (History)
1 user (show)

See Also:


Attachments
MOXy - Test Cases (2.3.3) (65.34 KB, patch)
2012-01-10 14:01 EST, Blaise Doughan CLA
no flags Details | Diff
Core - Fix (13.63 KB, patch)
2012-01-10 14:01 EST, Blaise Doughan CLA
no flags Details | Diff
MOXy - Test Cases (trunk) (50.17 KB, patch)
2012-01-10 16:04 EST, Blaise Doughan CLA
no flags Details | Diff
Core - Fix (Trunk) (13.15 KB, patch)
2012-01-10 16:04 EST, Blaise Doughan CLA
no flags Details | Diff
Core - Fix (2.3.3) (13.15 KB, patch)
2012-01-10 16:06 EST, Blaise Doughan CLA
no flags Details | Diff
Core - Fix (Trunk) (13.04 KB, patch)
2012-01-25 14:08 EST, Blaise Doughan CLA
no flags Details | Diff
MOXy - Test Cases (trunk) (65.61 KB, patch)
2012-01-25 14:08 EST, Blaise Doughan CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Blaise Doughan CLA 2012-01-10 13:16:03 EST
There are currently a couple of @XmlValue use cases that are not supported by MOXy:

USE CASE #1 - @XmlAttribute on POJO property

MOXy is not correctly handling @XmlValue when it is reference by a property
annotated with @XmlAttribute.

For an example see example 5 at the following link:
-
http://docs.oracle.com/javase/6/docs/api/javax/xml/bind/annotation/XmlType.html


USE CASE #2 - Changed @XmlValues

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-10 13:17:06 EST
*** Bug 367795 has been marked as a duplicate of this bug. ***
Comment 2 Blaise Doughan CLA 2012-01-10 13:17:16 EST
*** Bug 367323 has been marked as a duplicate of this bug. ***
Comment 3 Blaise Doughan CLA 2012-01-10 14:01:06 EST
Created attachment 209277 [details]
MOXy - Test Cases (2.3.3)
Comment 4 Blaise Doughan CLA 2012-01-10 14:01:37 EST
Created attachment 209278 [details]
Core - Fix
Comment 5 Blaise Doughan CLA 2012-01-10 16:04:18 EST
Created attachment 209284 [details]
MOXy - Test Cases (trunk)
Comment 6 Blaise Doughan CLA 2012-01-10 16:04:40 EST
Created attachment 209285 [details]
Core - Fix (Trunk)
Comment 7 Blaise Doughan CLA 2012-01-10 16:06:16 EST
Created attachment 209286 [details]
Core - Fix (2.3.3)
Comment 8 Blaise Doughan CLA 2012-01-11 15:17:20 EST
Fix checked into 2.3.3 at rev:  10676

Code reviewed by:  Denise Smith

Fix Details:
- Composite objects mapped with @XmlValue are now treated as self records.
- Composite objects mapped with @XmlAttribute are now handled by specialized code in XMLCompositeObjectMappingNodeValue
- Code takes into account XMLConversionManager, XmlAdapter, and @XmlInverseReference.
Comment 9 Blaise Doughan CLA 2012-01-25 14:08:07 EST
Created attachment 210073 [details]
Core - Fix (Trunk)
Comment 10 Blaise Doughan CLA 2012-01-25 14:08:40 EST
Created attachment 210074 [details]
MOXy - Test Cases (trunk)
Comment 11 Blaise Doughan CLA 2012-01-25 14:23:49 EST
Fix checked into trunk at rev:  10741

Code reviewed by:  Denise Smith

Fix Details:
- Composite objects mapped with @XmlValue are now treated as self records.
- Composite objects mapped with @XmlAttribute are now handled by specialized
code in XMLCompositeObjectMappingNodeValue
- Code takes into account XMLConversionManager, XmlAdapter, and
@XmlInverseReference.
Comment 12 Eclipse Webmaster CLA 2022-06-09 10:33:25 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink