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

Bug 365457

Summary: Default namespace not used for @XmlNs(prefix="", namespaceURI="urn:foo")
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: P2 CC: david.twelves, rick.barkhouse, skrap
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
URL: http://blog.bdoughan.com/2011/11/jaxb-and-namespace-prefixes.html?showComment=1322840794931#c2137192234870679088
Whiteboard:
Attachments:
Description Flags
Patch - Code changes (2.3)
none
Patch - new test case
none
Patch - test case
none
MOXy - Test Cases
none
MOXy - Fix
none
MOXy - Test Cases (2.3.3)
none
MOXy - Fix (2.3.3) none

Description Blaise Doughan CLA 2011-12-02 11:34:32 EST
When an @XmlNs annotation is provided with prefix="", MOXy should use the default namespace for this, but is not currently doing so.

Example:

@XmlSchema(
    elementFormDefault=XmlNsForm.QUALIFIED,
    namespace="http://www.example.com/FOO",
    xmlns={
        //@XmlNs(prefix="", namespaceURI="http://www.example.com/FOO"),
        @XmlNs(prefix="bar", namespaceURI="http://www.example.com/BAR")
    }
)
package blog.prefix;

import javax.xml.bind.annotation.XmlNs;
import javax.xml.bind.annotation.XmlNsForm;
import javax.xml.bind.annotation.XmlSchema;
Comment 1 Rick Barkhouse CLA 2012-03-23 14:10:53 EDT
Created attachment 213120 [details]
Patch - Code changes (2.3)
Comment 2 Rick Barkhouse CLA 2012-03-26 16:05:00 EDT
Created attachment 213194 [details]
Patch - new test case
Comment 3 Rick Barkhouse CLA 2012-04-12 09:57:19 EDT
Created attachment 213897 [details]
Patch - test case
Comment 4 Blaise Doughan CLA 2012-04-30 13:21:18 EDT
Created attachment 214813 [details]
MOXy - Test Cases
Comment 5 Blaise Doughan CLA 2012-04-30 13:21:36 EDT
Created attachment 214814 [details]
MOXy - Fix
Comment 6 Blaise Doughan CLA 2012-04-30 13:54:31 EDT
Created attachment 214817 [details]
MOXy - Test Cases (2.3.3)
Comment 7 Blaise Doughan CLA 2012-04-30 13:54:48 EDT
Created attachment 214818 [details]
MOXy - Fix (2.3.3)
Comment 8 Blaise Doughan CLA 2012-05-01 09:26:48 EDT
Fix checked into 2.3.3 at rev:  11246
Fix checked into trunk at rev:  11247

Code reviewed by:  Rick Barkhouse

Fix Details
- AnnotationsProcessor:  Now declaring a prefix for the target namespace does not eliminate the possibility of having a default namespace.
- NamespaceInfo:  When creating a NamespaceResolver for the descriptor copy in the default namespace.
Comment 9 Jens Li CLA 2016-08-07 14:59:15 EDT
I think this but has re-emerged in 2.6.3.

I tried to marshal a simple example using the package-info.java file from the description of this bug report (with the commented line uncommented).

The output contained attributes with a "ns0" prefix, instead of a without a prefix.

Like this:

     xmlns:ns0="http://www.example.com/FOO"

Instead of like this:

     xmlns="http://www.example.com/FOO"
Comment 10 Eclipse Webmaster CLA 2022-06-09 10:25:07 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink