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

Bug 312117

Summary: Using substitution name for an element causes duplicate elements in marshalled XML
Product: z_Archived Reporter: Rick Barkhouse <rick.barkhouse>
Component: EclipselinkAssignee: Nobody - feel free to take it <nobody>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Patch none

Description Rick Barkhouse CLA 2010-05-07 15:19:07 EDT
Considering the following schema:

...
    <xs:element name="name" type="xs:string"/>
    <xs:element name="nom" substitutionGroup="myns:name"/>

    <xs:complexType name="person">
        <xs:sequence>
            <xs:element ref="myns:name"/>
        </xs:sequence>
    </xs:complexType>

    <xs:element name="person" type="myns:person"/>
    <xs:element name="personne" substitutionGroup="myns:person"/>
...

Taking this schema and generating EclipseLink mappings, if we set the JAXBElement for "name" to have a QName of "nom", then you will see duplicate elements written to XML, for both the original as well as the substituted name:

<?xml version="1.0" encoding="UTF-8"?>
<ns0:person xmlns:ns0="myNamespace">
   <ns0:name>Bob Smith</ns0:name>
   <ns0:nom>Bob Smith</ns0:nom>
</ns0:person>
Comment 1 Rick Barkhouse CLA 2010-05-07 16:56:09 EDT
Created attachment 167577 [details]
Patch

Code fix + new test case
Comment 2 Rick Barkhouse CLA 2010-05-07 17:12:55 EDT
Fixed and checked in, reviewed by bdoughan.
Comment 3 Eclipse Webmaster CLA 2022-06-09 10:20:59 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink