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

Bug 358324

Summary: Marshall representation of XmlRootElement 'namespace' differs when using Annotations vs Bindings
Product: z_Archived Reporter: Rick Barkhouse <rick.barkhouse>
Component: EclipselinkAssignee: Nobody - feel free to take it <nobody>
Status: RESOLVED WORKSFORME QA Contact:
Severity: normal    
Priority: P3 CC: blaise.doughan
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

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