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

Bug 330402

Summary: @XmlNullPolicy, Collections, and Empty Nodes
Product: z_Archived Reporter: Blaise Doughan <blaise.doughan>
Component: EclipselinkAssignee: Nobody - feel free to take it <nobody>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: eclipselink.oxm-inbox
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Bug Depends on:    
Bug Blocks: 331151    
Attachments:
Description Flags
Core - Fix
none
MOXy - Test Cases
none
MOXy - Test Cases
none
Core - Fix none

Description Blaise Doughan CLA 2010-11-16 15:24:06 EST
For the following class:

import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import org.eclipse.persistence.oxm.annotations.XmlMarshalNullRepresentation;
import org.eclipse.persistence.oxm.annotations.XmlNullPolicy;

@XmlRootElement
public class Course {

    @XmlElement (name = "book")
    @XmlNullPolicy(nullRepresentationForXml = XmlMarshalNullRepresentation.EMPTY_NODE, emptyNodeRepresentsNull=true)
    List<Book> requiredBooks = new ArrayList<Book>();

}


The XML document:

<?xml version="1.0" encoding="UTF-8"?>
<course>
    <book/>
    <book>
        <title>Hello World</title>
    </book>
    <book/>
</course>

Should unmarshal to an object where the requiredBooks property contains two nulls and an instance of Book.  Currently this is not working.
Comment 1 Blaise Doughan CLA 2010-11-16 15:28:25 EST
Created attachment 183266 [details]
Core - Fix
Comment 2 Blaise Doughan CLA 2010-11-16 16:34:19 EST
Created attachment 183268 [details]
MOXy - Test Cases
Comment 3 Blaise Doughan CLA 2010-11-25 14:28:58 EST
Created attachment 183879 [details]
MOXy - Test Cases
Comment 4 Blaise Doughan CLA 2010-11-25 14:29:17 EST
Created attachment 183880 [details]
Core - Fix
Comment 5 Blaise Doughan CLA 2010-11-25 16:48:13 EST
Fix checked into trunk at rev:  8569

Code reviewed by:  Matt MacIvor

- Added CompositeCollectionMappingContentHandler
- Refactored CompositeObjectMappingContentHandler to have a super type that CompositeCollectionMappingContentHandler could leverage to share behaviour.
- Added similar support to CompositeCollectionMapping from CompositeObjectMapping to handle empty element null values.
Comment 6 Eclipse Webmaster CLA 2022-06-09 10:28:48 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink