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

Bug 332250

Summary: Marshalling node with no namespace should clear default namespace if necessary
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: P3 CC: eclipselink.oxm-inbox
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
MOXy - Test Cases
none
Core - Fix
none
Core - Fix (to address SDO test failures) none

Description Blaise Doughan CLA 2010-12-09 16:01:56 EST
If a node value is being marshalled that is not namespace qualified, if it is being written to an XML document with a default namespace declaration then it should clear it:

If:

    <bar>Hello World</bar>

Is being marshalled into the following doc:

   <foo xmlns="urn:foo">
   </foo>

Then the result should be:

   <foo xmlns="urn:foo">
       <bar xmlns="">Hello World</bar>
   </foo>
Comment 1 Blaise Doughan CLA 2010-12-14 11:53:03 EST
Created attachment 185148 [details]
MOXy - Test Cases
Comment 2 Blaise Doughan CLA 2010-12-14 11:53:18 EST
Created attachment 185149 [details]
Core - Fix
Comment 3 Blaise Doughan CLA 2010-12-14 13:39:14 EST
DOMReader
- In getQName(Element), the handlePrefixedAttribute(Element) method is now called even if the element does not have a prefix.  This is to handle the default namespace use case

DomToXMLEventWriter
- Needed to get the default namespace before the element was created.  This is because if the element was created in the default namespace it would blow aware what the default namespace had previously been.

XMLFragmentReader
- Guard against a null NamspaceResolver being passed to the constructor
- When resolving a namespace, the default namespace on the NamespaceResolver is also checked.

NamespaceResolver
- If the prefix passed to the put operation is null/"", set the uri as the default namespace on the NamespaceResolver.

NodeRecord
- When performing startPrefixMappings recognize that you may need to declare the default namespace as no namespace "".

OutputStreamRecord/WriterRecord
- If the prefix is null/"" and there is no namespace URI then declare the "" namespace.

SAXDocumentBuilder
- If the prefix or URI are null, convert then to "".
Comment 4 Blaise Doughan CLA 2010-12-14 16:53:04 EST
Fix checked into trunk at rev: 8708

Code reviewed by:  Matt MacIvor
Comment 5 Blaise Doughan CLA 2010-12-16 11:09:39 EST
Created attachment 185343 [details]
Core - Fix (to address SDO test failures)
Comment 6 Eclipse Webmaster CLA 2022-06-09 10:22:29 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink