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

Bug 340671

Summary: Extraneous xsi:type written out when using inheritance / XmlSeeAlso
Product: z_Archived Reporter: Rick Barkhouse <rick.barkhouse>
Component: EclipselinkAssignee: Nobody - feel free to take it <nobody>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: blaise.doughan, denise.mahar, eclipselink.oxm-inbox
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposed changes and test
none
Updated patch none

Description Rick Barkhouse CLA 2011-03-22 11:31:57 EDT
Consider the following classes:

@XmlRootElement
@XmlSeeAlso({Dog.class, Cat.class})
public class Animal {
	public String name;
}

@XmlRootElement
public class Cat extends Animal {
	public int sleepTime;
	public Dog enemy;
}

public class Dog extends Animal {
	public String barkLevel;
}

Note that both Animal and Cat have @XmlRootElement defined.

When a new Cat is created and marshalled, an unnecessary xsi:type attribute is written out:

<?xml version="1.0" encoding="UTF-8"?>
<cat xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="cat">
   <name>Fluffy</name>
   <sleepTime>10</sleepTime>
   <enemy>
      <name>Buster</name>
      <barkLevel>LOUD</barkLevel>
   </enemy>
</cat>
Comment 1 Rick Barkhouse CLA 2011-03-22 11:39:14 EDT
This bug is captured in the following test case:

org.eclipse.persistence.testing.jaxb.javadoc.xmlseealso.XmlSeeAlsoTest

(Praba is working on these tests and they have not been checked in yet, the above test class name may change)
Comment 2 Denise Smith CLA 2011-05-12 15:51:02 EDT
Created attachment 195538 [details]
Proposed changes and test
Comment 3 Denise Smith CLA 2011-05-16 13:53:11 EDT
Created attachment 195769 [details]
Updated patch
Comment 4 Denise Smith CLA 2011-05-16 16:02:36 EDT
The xsi:type will not get marshaled out in this case anymore.  Modifications so that on an XMLDescriptor setDefaultRootElementType will be called to set the type if it is known.  This will be used for comparison during marshal to help determine if an xsi:type attribute should be added or not.
Comment 5 Eclipse Webmaster CLA 2022-06-09 10:20:39 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink