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

Bug 352791

Summary: Need "xml-mixed" java attribute type in oxm file
Product: z_Archived Reporter: Paul Fullbright <paul.fullbright>
Component: EclipselinkAssignee: Project Inbox <eclipselink.oxm-inbox>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: P3 CC: blaise.doughan, rick.barkhouse
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Bug Depends on: 372545    
Bug Blocks:    
Attachments:
Description Flags
Test Case none

Description Paul Fullbright CLA 2011-07-21 14:03:14 EDT
The following example:

public class Foo {

    @XmlMixed
    public List content;
}

can not be captured as it exists in an oxm file.  It does not capture wild card (@XmlAnyElement) or other (@XmlElementRef) content, so it cannot be mapped as either xml-any-element or xml-ref(s).
Comment 1 Rick Barkhouse CLA 2011-07-22 13:26:10 EDT
Further Investigation:

From all documentation I can find, it seems that @XmlMixed is always meant to be used in conjunction with @XmlElementRef, @XmlElementRefs or @XmlAnyElement.  We're still trying to determine if @XmlMixed by itself is a valid use case.

The RI does support marshalling but does not seem to be able to unmarshal:

Marshal:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<foo>First Second Third</foo>
Unmarshal:
Exception in thread "main" javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"#document"). Expected elements are <{}foo>

EclipseLink does support marshalling and unmarshalling, but on the unmarshal we are concatenating all of the values together:

Marshal:
<?xml version="1.0" encoding="UTF-8"?>
<foo>FirstSecondThird</foo>
Unmarshal:
[FirstSecondThird]
Comment 2 Rick Barkhouse CLA 2011-07-22 13:27:53 EDT
Created attachment 200218 [details]
Test Case
Comment 3 Paul Fullbright CLA 2011-07-25 09:48:49 EDT
If it turns out to not be a valid use case (I couldn't find documentation that said either way for certain) then that's also a great resolution to this.

This was the origination of my investigation into the matter:

http://www.eclipse.org/forums/index.php?t=rview&goto=692985#msg_692985

Seemed to imply that @XmlMixed *was* valid by itself.
Comment 4 Paul Fullbright CLA 2011-07-26 15:34:05 EDT
One comment and one question:

> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <foo>First Second Third</foo>

I'd expect the above to unmarshall as one text node, since there are no intervening other nodes.  Would that make sense?


In addition, what if anything would the following mean?

@XmlMixed
List foo;

It could either:
- default to @XmlElement, and ignore the @XmlMixed annotation.
- default to @XmlAnyElement, taking the @XmlMixed annotation.
- default to nothing, or an error.
- ... ?
Comment 5 Eclipse Webmaster CLA 2022-06-09 10:04:49 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink
Comment 6 Eclipse Webmaster CLA 2022-06-09 10:08:46 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink