Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 340671 - Extraneous xsi:type written out when using inheritance / XmlSeeAlso
Summary: Extraneous xsi:type written out when using inheritance / XmlSeeAlso
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:
Depends on:
Blocks:
 
Reported: 2011-03-22 11:31 EDT by Rick Barkhouse CLA
Modified: 2022-06-09 10:20 EDT (History)
3 users (show)

See Also:


Attachments
Proposed changes and test (15.79 KB, patch)
2011-05-12 15:51 EDT, Denise Smith CLA
no flags Details | Diff
Updated patch (16.47 KB, patch)
2011-05-16 13:53 EDT, Denise Smith CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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