Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 358324 - Marshall representation of XmlRootElement 'namespace' differs when using Annotations vs Bindings
Summary: Marshall representation of XmlRootElement 'namespace' differs when using Anno...
Status: RESOLVED WORKSFORME
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-20 21:45 EDT by Rick Barkhouse CLA
Modified: 2022-06-09 10:33 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rick Barkhouse CLA 2011-09-20 21:45:33 EDT
When using Annotations vs. Bindings, the way in which the XmlRootElement's namespace is declared in marshalled XML is inconsistent.

Annotations:

@XmlRootElement(namespace="ROOT")
public class Company {

	@XmlElement(name="employee")
	public List<Employee> employees = new ArrayList<Employee>();
	
}

=====

XML Bindings:

<java-type name="CompanyB">
   <xml-root-element name="company" namespace="ROOT"/>
   <java-attributes>
      <xml-element java-attribute="employees" name="employee" type="documentation.EmployeeB" container-type="java.util.ArrayList" />
   </java-attributes>
</java-type>

===== 

Marshalled XML:

Annotations: class org.eclipse.persistence.jaxb.JAXBContext
<?xml version="1.0" encoding="UTF-8"?>
<company xmlns="ROOT" xmlns:ns0="http://www.example.org/package">

Bindings: class org.eclipse.persistence.jaxb.JAXBContext
<ns0:company xmlns:ns0="ROOT" xmlns:ns1="docs">

Although functionally equivalent, the Bindings approach should look the same as when using Annotations.
Comment 1 Rick Barkhouse CLA 2011-09-20 21:49:42 EDT
* Corrected XML:

Annotations: class org.eclipse.persistence.jaxb.JAXBContext
<?xml version="1.0" encoding="UTF-8"?>
<company xmlns="ROOT">

Bindings: class org.eclipse.persistence.jaxb.JAXBContext
<ns0:company xmlns:ns0="ROOT">
Comment 2 Rick Barkhouse CLA 2012-03-21 14:02:04 EDT
Can no longer reproduce this behaviour, seems to have been fixed by a previous patch.  Annotation and Bindings now look the same:


Annotations: class org.eclipse.persistence.jaxb.JAXBContext
<?xml version="1.0" encoding="UTF-8"?>
<ns0:company xmlns:ns0="ANNO">
...
</ns0:company>
OXM: class org.eclipse.persistence.jaxb.JAXBContext
<?xml version="1.0" encoding="UTF-8"?>
<ns0:company xmlns:ns0="BIND">
...
</ns0:company>
Comment 3 Eclipse Webmaster CLA 2022-06-09 10:33:38 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink